/** * @return Returns the BinarySecurityToken element. */ public Element getBinarySecurityTokenElement() { if (bstToken != null) { return bstToken.getElement(); } return null; }
/** * Append the BinarySecurityToken to the elements already in the Security * header. * * The method can be called any time after <code>prepare()</code>. This * allows to insert the BST element at any position in the Security header. */ public void appendBSTElementToHeader() { if (bstToken != null && !bstAddedToSecurityHeader) { Element secHeaderElement = getSecurityHeader().getSecurityHeaderElement(); secHeaderElement.appendChild(bstToken.getElement()); bstAddedToSecurityHeader = true; } }
/** * Prepend the BinarySecurityToken to the elements already in the Security * header. * * The method can be called any time after <code>prepare()</code>. This * allows to insert the BST element at any position in the Security header. */ public void prependBSTElementToHeader() { if (bstToken != null && !bstAddedToSecurityHeader) { Element secHeaderElement = getSecurityHeader().getSecurityHeaderElement(); WSSecurityUtil.prependChildElement(secHeaderElement, bstToken.getElement()); bstAddedToSecurityHeader = true; } }
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()); }
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; }
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; }
bstToken = binarySecurity.getElement(); getWsDocInfo().addTokenElement(bstToken, false);
private Element convertToDOM( BinarySecurityTokenType binarySecurityTokenType, byte[] securityTokenData ) throws WSSecurityException { Document doc = DOMUtils.getEmptyDocument(); BinarySecurity binarySecurity = null; if (WSSConstants.NS_X509_V3_TYPE.equals(binarySecurityTokenType.getValueType())) { binarySecurity = new X509Security(doc); } else if (WSSConstants.NS_X509_PKIPATH_V1.equals(binarySecurityTokenType.getValueType())) { binarySecurity = new PKIPathSecurity(doc); } else if (WSSConstants.NS_GSS_KERBEROS5_AP_REQ.equals(binarySecurityTokenType.getValueType())) { binarySecurity = new KerberosSecurity(doc); } else { throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN); } binarySecurity.addWSSENamespace(); binarySecurity.addWSUNamespace(); binarySecurity.setEncodingType(binarySecurityTokenType.getEncodingType()); binarySecurity.setValueType(binarySecurityTokenType.getValueType()); binarySecurity.setID(binarySecurityTokenType.getId()); binarySecurity.setToken(securityTokenData); return binarySecurity.getElement(); } }
private Element convertToDOM( BinarySecurityTokenType binarySecurityTokenType, byte[] securityTokenData ) throws WSSecurityException { Document doc = DOMUtils.getEmptyDocument(); BinarySecurity binarySecurity = null; if (WSSConstants.NS_X509_V3_TYPE.equals(binarySecurityTokenType.getValueType())) { binarySecurity = new X509Security(doc); } else if (WSSConstants.NS_X509_PKIPATH_V1.equals(binarySecurityTokenType.getValueType())) { binarySecurity = new PKIPathSecurity(doc); } else if (WSSConstants.NS_GSS_KERBEROS5_AP_REQ.equals(binarySecurityTokenType.getValueType())) { binarySecurity = new KerberosSecurity(doc); } else { throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN); } binarySecurity.addWSSENamespace(); binarySecurity.addWSUNamespace(); binarySecurity.setEncodingType(binarySecurityTokenType.getEncodingType()); binarySecurity.setValueType(binarySecurityTokenType.getValueType()); binarySecurity.setID(binarySecurityTokenType.getId()); binarySecurity.setToken(securityTokenData); return binarySecurity.getElement(); } }
@org.junit.Test public void testBinarySecurityToken() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = BinarySecurityTokenTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = BinarySecurityTokenTest.class.getResource("DoubleItTokens.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); // Successful invocation QName portQName = new QName(NAMESPACE, "DoubleItBinarySecurityTokenPort"); DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, PORT); // Mock up a BinarySecurityToken to add SecurityToken securityToken = new SecurityToken(); securityToken.setId("_" + UUID.randomUUID().toString()); Document doc = DOMUtils.newDocument(); BinarySecurity binarySecurity = new BinarySecurity(doc); binarySecurity.setValueType("http://custom-value-type"); binarySecurity.setToken("This is a token".getBytes()); securityToken.setToken(binarySecurity.getElement()); ((BindingProvider)port).getRequestContext().put(SecurityConstants.TOKEN, securityToken); assertEquals(50, port.doubleIt(25)); ((java.io.Closeable)port).close(); bus.shutdown(true); }
binarySecurity.getElement().appendChild(textNode); } else if (validateTarget.isDOMElement()) { try {
BinarySecurity bst = (BinarySecurity)tempTok; part = new WSEncryptionPart(bst.getID()); part.setElement(bst.getElement()); } else if (tempTok instanceof SamlAssertionWrapper) { SamlAssertionWrapper assertionWrapper = (SamlAssertionWrapper)tempTok;
((X509Security) binarySecurity).setX509Certificate(cert); binarySecurity.setID(certUri); bstToken = binarySecurity.getElement(); getWsDocInfo().addTokenElement(bstToken, false); ref.setValueType(binarySecurity.getValueType());
BinarySecurity bst = (BinarySecurity)tempTok; part = new WSEncryptionPart(bst.getID()); part.setElement(bst.getElement()); } else if (tempTok instanceof SamlAssertionWrapper) { SamlAssertionWrapper assertionWrapper = (SamlAssertionWrapper)tempTok;
binarySecurity.getElement().appendChild(textNode); } else if (validateTarget.isDOMElement()) { try {
hash = credential.getUsernametoken().hashCode(); } else if (credential.getBinarySecurityToken() != null) { tokenElement = credential.getBinarySecurityToken().getElement(); hash = credential.getBinarySecurityToken().hashCode(); } else if (credential.getSecurityContextToken() != null) {
hash = credential.getUsernametoken().hashCode(); } else if (credential.getBinarySecurityToken() != null) { tokenElement = credential.getBinarySecurityToken().getElement(); hash = credential.getBinarySecurityToken().hashCode(); } else if (credential.getSecurityContextToken() != null) {
bstToken.setID(wssConfig.getIdAllocator().createSecureId("X509-", encCert)); WSSecurityUtil.prependChildElement( secHeader.getSecurityHeaderElement(), bstToken.getElement() ); bstElement = bstToken.getElement();
bstToken.setID(wssConfig.getIdAllocator().createSecureId("X509-", encCert)); WSSecurityUtil.prependChildElement( secHeader.getSecurityHeaderElement(), bstToken.getElement() ); bstElement = bstToken.getElement();