/** * Returns the SecurityTokenReference of the derived key token * * @return the Security Token Reference of the derived key token * @throws WSSecurityException */ public SecurityTokenReference getSecurityTokenReference() throws WSSecurityException { if (elementSecurityTokenReference != null) { return new SecurityTokenReference(elementSecurityTokenReference, bspEnforcer); } return null; }
/** * Method containsX509Data * * @return true if the <code>SecurityTokenReference</code> contains * a <code>ds:X509Data</code> element */ public boolean containsX509Data() { return containsElement(WSS4JConstants.SIG_NS, WSS4JConstants.X509_DATA_LN); }
/** * @return Returns the BinarySecurityToken element. */ public Element getBinarySecurityTokenElement() { if (bstToken != null) { return bstToken.getElement(); } return null; }
private SecurityToken createSecurityToken(BinarySecurity binarySecurityToken) { SecurityToken token = new SecurityToken(binarySecurityToken.getID()); token.setToken(binarySecurityToken.getElement()); token.setSecret(binarySecurityToken.getToken()); token.setTokenType(binarySecurityToken.getValueType()); return token; }
/** * Add a BinarySecurityToken */ private void addBST(X509Certificate cert) throws WSSecurityException { bstToken = new X509Security(getDocument()); ((X509Security) bstToken).setX509Certificate(cert); bstAddedToSecurityHeader = false; bstToken.setID(IDGenerator.generateID(null)); }
@Override public boolean equals(Object object) { if (!(object instanceof Reference)) { return false; } Reference reference = (Reference)object; if (!compare(getURI(), reference.getURI())) { return false; } if (!compare(getValueType(), reference.getValueType())) { return false; } return true; }
/** * Extracts the certificate(s) from the Binary Security token reference. * * @param token The BinarySecurity instance corresponding to either X509Security or * PKIPathSecurity * @return The X509Certificates associated with this reference * @throws WSSecurityException */ private X509Certificate[] getCertificatesTokenReference(BinarySecurity token, Crypto crypto) throws WSSecurityException { if (token instanceof PKIPathSecurity) { return ((PKIPathSecurity) token).getX509Certificates(crypto); } else if (token instanceof X509Security) { X509Certificate cert = ((X509Security) token).getX509Certificate(crypto); return new X509Certificate[]{cert}; } return null; }
public String getKeyIdentifierEncodingType() { if (containsKeyIdentifier()) { Element elem = getFirstElement(); return elem.getAttributeNS(null, "EncodingType"); } return null; }
public void setKeyIdentifier(String valueType, String keyIdVal) throws WSSecurityException { setKeyIdentifier(valueType, keyIdVal, false); }
/** * set the reference. * * @param ref */ public void setReference(Reference ref) { Element elem = getFirstElement(); if (elem != null) { element.replaceChild(ref.getElement(), elem); } else { element.appendChild(ref.getElement()); } this.reference = ref; }
/** * Get the id of the BSt generated during <code>prepare()</code>. * * @return Returns the the value of wsu:Id attribute of the * BinaruSecurityToken element. */ public String getBSTTokenId() { if (bstToken == null) { return null; } return bstToken.getID(); }
@Override public int hashCode() { int hashCode = 17; if (secretKey != null) { hashCode *= 31 + secretKey.hashCode(); } hashCode *= 31 + super.hashCode(); return hashCode; } }
/** * This constructor creates a new X509 certificate element. * * @param doc */ public X509Security(Document doc) { super(doc); setValueType(X509_V3_TYPE); }
/** * Constructor. */ public PKIPathSecurity(Document doc) { super(doc); setValueType(PKI_TYPE); }
private SecurityToken createSecurityToken(BinarySecurity binarySecurityToken) { SecurityToken token = new SecurityToken(binarySecurityToken.getID()); token.setToken(binarySecurityToken.getElement()); token.setSecret(binarySecurityToken.getToken()); token.setTokenType(binarySecurityToken.getValueType()); return token; }
public WSSecurityEngineResult(int act, BinarySecurity token, X509Certificate[] certs) { put(TAG_ACTION, act); put(TAG_BINARY_SECURITY_TOKEN, token); put(TAG_X509_CERTIFICATES, certs); if (certs != null) { put(TAG_X509_CERTIFICATE, certs[0]); } put(TAG_VALIDATED_TOKEN, Boolean.FALSE); put(TAG_TOKEN_ELEMENT, token.getElement()); }
public String getKeyIdentifierValue() { if (containsKeyIdentifier()) { return XMLUtils.getElementText(getFirstElement()); } return null; }
/** * Method containsReference * * @return true if the <code>SecurityTokenReference</code> contains * a <code>wsse:Reference</code> element */ public boolean containsReference() { return containsElement(WSS4JConstants.WSSE_NS, "Reference"); }
/** * Method containsX509IssuerSerial * * @return true if the <code>SecurityTokenReference</code> contains * a <code>ds:IssuerSerial</code> element */ public boolean containsX509IssuerSerial() { return containsElement(WSS4JConstants.SIG_NS, WSS4JConstants.X509_ISSUER_SERIAL_LN); }
/** * Method containsKeyIdentifier. * * @return true if the <code>SecurityTokenReference</code> contains * a <code>wsse:KeyIdentifier</code> element */ public boolean containsKeyIdentifier() { return containsElement(WSS4JConstants.WSSE_NS, "KeyIdentifier"); }