/** * Check the issued token template against the received BinarySecurityToken */ private boolean checkIssuedTokenTemplate(Element template, BinarySecurity binarySecurityToken) { Element child = DOMUtils.getFirstElement(template); while (child != null) { if ("TokenType".equals(child.getLocalName())) { String content = child.getTextContent(); String valueType = binarySecurityToken.getValueType(); if (!content.equals(valueType)) { return false; } } child = DOMUtils.getNextElement(child); } return true; }
@Override public int hashCode() { int result = 17; byte[] token = getToken(); if (token != null) { result = 31 * result + Arrays.hashCode(token); } result = 31 * result + getValueType().hashCode(); result = 31 * result + getEncodingType().hashCode(); return result; }
/** * Check the issued token template against the received BinarySecurityToken */ private boolean checkIssuedTokenTemplate(Element template, BinarySecurity binarySecurityToken) { Element child = DOMUtils.getFirstElement(template); while (child != null) { if ("TokenType".equals(child.getLocalName())) { String content = child.getTextContent(); String valueType = binarySecurityToken.getValueType(); if (!content.equals(valueType)) { return false; } } child = DOMUtils.getNextElement(child); } return true; }
@Override public boolean equals(Object object) { if (!(object instanceof BinarySecurity)) { return false; } BinarySecurity binarySecurity = (BinarySecurity)object; byte[] token = binarySecurity.getToken(); if (!Arrays.equals(token, getToken())) { return false; } String valueType = binarySecurity.getValueType(); if (!valueType.equals(getValueType())) { return false; } String encodingType = binarySecurity.getEncodingType(); if (!encodingType.equals(getEncodingType())) { return false; } return true; }
/** * Constructor. * @param elem The BinarySecurityToken element to process * @param bspEnforcer a BSPEnforcer instance to enforce BSP rules * @throws WSSecurityException */ public BinarySecurity(Element elem, BSPEnforcer bspEnforcer) throws WSSecurityException { element = elem; QName el = new QName(element.getNamespaceURI(), element.getLocalName()); if (!(el.equals(TOKEN_BST) || el.equals(TOKEN_KI))) { throw new WSSecurityException( WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN, "unhandledToken", new Object[] {el}); } String encoding = getEncodingType(); if (encoding == null || "".equals(encoding)) { bspEnforcer.handleBSPRule(BSPRule.R3029); } if (!WSS4JConstants.BASE64_ENCODING.equals(encoding)) { bspEnforcer.handleBSPRule(BSPRule.R3030); } String valueType = getValueType(); if (valueType == null || "".equals(valueType)) { bspEnforcer.handleBSPRule(BSPRule.R3031); } }
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; }
BinarySecurity binarySecurityToken = (BinarySecurity)result.get(WSSecurityEngineResult.TAG_BINARY_SECURITY_TOKEN); if (binarySecurityToken != null && requiredType.equals(binarySecurityToken.getValueType())) { if (v3certRequired && binarySecurityToken instanceof X509Security) { try {
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; }
BinarySecurity binarySecurityToken = (BinarySecurity)result.get(WSSecurityEngineResult.TAG_BINARY_SECURITY_TOKEN); if (binarySecurityToken != null && requiredType.equals(binarySecurityToken.getValueType())) { if (v3certRequired && binarySecurityToken instanceof X509Security) { try {
((X509Security) bstToken).setX509Certificate(remoteCert); bstToken.setID(certUri); ref.setValueType(bstToken.getValueType()); secToken.setReference(ref); break;
bstToken = binarySecurity.getElement(); getWsDocInfo().addTokenElement(bstToken, false); ref.setValueType(binarySecurity.getValueType()); secRef.setReference(ref); break;