/** * Get the SignatureConfirmation element generated during * <code>prepare()</code>. * * @return Return the SignatureConfirmation element or null if <code>prepare()</code> * was not called before. */ public Element getSignatureConfirmationElement() { return (sc != null) ? sc.getElement() : null; }
/** * Get the id generated during <code>prepare()</code>. * * Returns the the value of wsu:Id attribute of this SignatureConfirmation. * * @return Return the wsu:Id of this token or null if <code>prepareToken()</code> * was not called before. */ public String getId() { if (sc == null) { return null; } return sc.getID(); }
@Override public boolean equals(Object object) { if (!(object instanceof SignatureConfirmation)) { return false; } SignatureConfirmation signatureConfirmation = (SignatureConfirmation)object; byte[] sigValue = signatureConfirmation.getSignatureValue(); if (!Arrays.equals(sigValue, getSignatureValue())) { return false; } return true; }
/** * Creates a SignatureConfimation element. * * The method prepares and initializes a WSSec SignatureConfirmation structure after * the relevant information was set. Before calling <code>prepare()</code> the * filed <code>signatureValue</code> must be set */ public void prepare() { sc = new SignatureConfirmation(getDocument(), signatureValue); sc.setID(getIdAllocator().createId("SC-", sc)); }
public List<WSSecurityEngineResult> handleToken( Element elem, RequestData data ) throws WSSecurityException { LOG.debug("Found SignatureConfirmation list element"); // // Decode SignatureConfirmation, just store in result // SignatureConfirmation sigConf = new SignatureConfirmation(elem, data.getBSPEnforcer()); WSSecurityEngineResult result = new WSSecurityEngineResult(WSConstants.SC, sigConf); String tokenId = sigConf.getID(); if (!"".equals(tokenId)) { result.put(WSSecurityEngineResult.TAG_ID, tokenId); } data.getWsDocInfo().addResult(result); data.getWsDocInfo().addTokenElement(elem); return java.util.Collections.singletonList(result); }
/** * Prepends the SignatureConfirmation element to the elements already in the * Security header. * * The method can be called any time after <code>prepare()</code>. * This allows to insert the SignatureConfirmation element at any position in the * Security header. */ public void prependToHeader() { Element securityHeaderElement = getSecurityHeader().getSecurityHeaderElement(); WSSecurityUtil.prependChildElement(securityHeaderElement, sc.getElement()); }
); if (sc != null && sc.getSignatureValue() != null) { if (savedSignatures == null || savedSignatures.isEmpty()) { if (sc.getSignatureValue().length != 0) { throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, "empty", new Object[] {"Received a SignatureConfirmation element, but there are no stored" Integer hash = Arrays.hashCode(sc.getSignatureValue()); if (savedSignatures.contains(hash)) { savedSignatures.remove(hash);
/** * Constructs a <code>SignatureConfirmation</code> object and parses the * <code>wsse11:SignatureConfirmation</code> element to initialize it. * * @param elem the <code>wsse11:SignatureCOnfirmation</code> element that * contains the confirmation data * @param bspEnforcer a BSPEnforcer instance used to enforce BSP rules */ public SignatureConfirmation(Element elem, BSPEnforcer bspEnforcer) throws WSSecurityException { element = elem; String id = getID(); if (id == null || "".equals(id)) { bspEnforcer.handleBSPRule(BSPRule.R5441); } String sv = element.getAttributeNS(null, SC_VALUE_ATTR); if (sv != null) { signatureValue = org.apache.xml.security.utils.XMLUtils.decode(sv); } }
public WSSecurityEngineResult(int act, SignatureConfirmation sc) { put(TAG_ACTION, act); put(TAG_SIGNATURE_CONFIRMATION, sc); put(TAG_VALIDATED_TOKEN, Boolean.FALSE); put(TAG_TOKEN_ELEMENT, sc.getElement()); }