new Object[] {user, "signature"}); certUri = getIdAllocator().createSecureId("X509-", certs[0]);
) { SecurityTokenReference secRefSaml = new SecurityTokenReference(doc); String secRefID = wssConfig.getIdAllocator().createSecureId("STR-", secRefSaml); secRefSaml.setID(secRefID);
if (StringUtils.isEmpty(id)) { LOG.fine("No ID extracted from token, so just making one up"); id = WSSConfig.getNewInstance().getIdAllocator().createSecureId("_", null);
if (StringUtils.isEmpty(id)) { LOG.fine("No ID extracted from token, so just making one up"); id = WSSConfig.getNewInstance().getIdAllocator().createSecureId("_", null);
) { SecurityTokenReference secRefSaml = new SecurityTokenReference(doc); String secRefID = wssConfig.getIdAllocator().createSecureId("STR-", secRefSaml); secRefSaml.setID(secRefID);
keyInfoUri = getIdAllocator().createSecureId("KI-", keyInfo); strUri = getIdAllocator().createSecureId("STR-", secRef); secRef.setID(strUri);
tokenIdToRenew, instance); sct.setID(WSSConfig.getNewInstance().getIdAllocator() .createSecureId("sctId-", sct.getElement())); } else { sct = new SecurityContextToken( NegotiationUtils.getWSCVersion(tokenType), writer.getDocument()); sct.setID(WSSConfig.getNewInstance().getIdAllocator() .createSecureId("sctId-", sct.getElement()));
String keyInfoUri = getIdAllocator().createSecureId("KI-", null); KeyInfo keyInfo = keyInfoFactory.newKeyInfo(
String strUri = getIdAllocator().createSecureId("STR-", secRef); secRef.setID(strUri);
tokenIdToRenew, instance); sct.setID(WSSConfig.getNewInstance().getIdAllocator() .createSecureId("sctId-", sct.getElement())); } else { sct = new SecurityContextToken( NegotiationUtils.getWSCVersion(tokenType), writer.getDocument()); sct.setID(WSSConfig.getNewInstance().getIdAllocator() .createSecureId("sctId-", sct.getElement()));
delegatedCredential); bst.addWSUNamespace(); bst.setID(wssConfig.getIdAllocator().createSecureId("BST-", bst));
delegatedCredential); bst.addWSUNamespace(); bst.setID(wssConfig.getIdAllocator().createSecureId("BST-", bst));
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof NameCallback) { NameCallback nameCallback = (NameCallback)callbacks[i]; nameCallback.setName("alice"); } else if (callbacks[i] instanceof PasswordCallback) { PasswordCallback passwordCallback = (PasswordCallback)callbacks[i]; passwordCallback.setPassword("alice".toCharArray()); } else if (callbacks[i] instanceof WSPasswordCallback) { WSPasswordCallback wsPasswordCallback = (WSPasswordCallback)callbacks[i]; // Get a custom (Kerberos) token directly using the WSS4J APIs if (wsPasswordCallback.getUsage() == WSPasswordCallback.CUSTOM_TOKEN) { KerberosSecurity kerberosSecurity = new KerberosSecurity(DOMUtils.getEmptyDocument()); try { kerberosSecurity.retrieveServiceTicket("alice", this, "bob@service.ws.apache.org", false, false, null); kerberosSecurity.addWSUNamespace(); WSSConfig wssConfig = WSSConfig.getNewInstance(); kerberosSecurity.setID(wssConfig.getIdAllocator().createSecureId("BST-", kerberosSecurity)); wsPasswordCallback.setCustomToken(kerberosSecurity.getElement()); } catch (WSSecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }
keyInfoUri = getIdAllocator().createSecureId("KeyId-", keyInfo); SecurityTokenReference secRef = new SecurityTokenReference(getDocument()); strUri = getIdAllocator().createSecureId("STRId-", secRef); secRef.setID(strUri); setSecurityTokenReference(secRef); certUri = getIdAllocator().createSecureId("CertId-", certs[0]); if (senderVouches) { secRefSaml = new SecurityTokenReference(getDocument()); secRefID = getIdAllocator().createSecureId("STRSAMLId-", secRefSaml); secRefSaml.setID(secRefID);
keyInfoUri = getIdAllocator().createSecureId("KI-", keyInfo); if (!useCustomSecRef && customKeyInfoElement == null) { secRef = new SecurityTokenReference(getDocument()); strUri = getIdAllocator().createSecureId("STR-", secRef); secRef.addWSSENamespace(); secRef.addWSUNamespace();
static String setupClient(STSClient client, SoapMessage message, AssertionInfoMap aim) { client.setTrust(NegotiationUtils.getTrust10(aim)); client.setTrust(NegotiationUtils.getTrust13(aim)); Policy p = new Policy(); ExactlyOne ea = new ExactlyOne(); p.addPolicyComponent(ea); All all = new All(); all.addPolicyComponent(NegotiationUtils.getAddressingPolicy(aim, false)); ea.addPolicyComponent(all); client.setPolicy(p); client.setSoap11(message.getVersion() == Soap11.getInstance()); client.setSpnego(true); WSSConfig config = WSSConfig.getNewInstance(); String context = config.getIdAllocator().createSecureId("_", null); client.setContext(context); String s = message.getContextualProperty(Message.ENDPOINT_ADDRESS).toString(); client.setLocation(s); AlgorithmSuite suite = NegotiationUtils.getAlgorithmSuite(aim); if (suite != null) { client.setAlgorithmSuite(suite); int x = suite.getAlgorithmSuiteType().getMaximumSymmetricKeyLength(); if (x < 256) { client.setKeySize(x); } } Map<String, Object> ctx = client.getRequestContext(); mapSecurityProps(message, ctx); return s; }
@Override public SecurityToken requestSecurityToken() throws Exception { KerberosSecurity bst = new KerberosSecurity(DOMUtils.createDocument()); bst.setValueType(WSConstants.WSS_GSS_KRB_V5_AP_REQ); bst.setToken(token); bst.addWSUNamespace(); bst.setID(WSSConfig.getNewInstance().getIdAllocator().createSecureId("BST-", bst)); SecurityToken securityToken = new SecurityToken(bst.getID()); securityToken.setToken(bst.getElement()); securityToken.setWsuId(bst.getID()); securityToken.setData(bst.getToken()); String sha1 = Base64.encode(KeyUtils.generateDigest(bst.getToken())); securityToken.setSHA1(sha1); securityToken.setTokenType(bst.getValueType()); return securityToken; }
static String setupClient(STSClient client, SoapMessage message, AssertionInfoMap aim) { client.setTrust(NegotiationUtils.getTrust10(aim)); client.setTrust(NegotiationUtils.getTrust13(aim)); Policy p = new Policy(); ExactlyOne ea = new ExactlyOne(); p.addPolicyComponent(ea); All all = new All(); all.addPolicyComponent(NegotiationUtils.getAddressingPolicy(aim, false)); ea.addPolicyComponent(all); client.setPolicy(p); client.setSoap11(message.getVersion() == Soap11.getInstance()); client.setSpnego(true); WSSConfig config = WSSConfig.getNewInstance(); String context = config.getIdAllocator().createSecureId("_", null); client.setContext(context); String s = message.getContextualProperty(Message.ENDPOINT_ADDRESS).toString(); client.setLocation(s); AlgorithmSuite suite = NegotiationUtils.getAlgorithmSuite(aim); if (suite != null) { client.setAlgorithmSuite(suite); int x = suite.getAlgorithmSuiteType().getMaximumSymmetricKeyLength(); if (x < 256) { client.setKeySize(x); } } Map<String, Object> ctx = client.getRequestContext(); mapSecurityProps(message, ctx); return s; }
((X509Security)bstToken).setX509Certificate(encCert); bstToken.addWSUNamespace(); bstToken.setID(wssConfig.getIdAllocator().createSecureId("X509-", encCert)); WSSecurityUtil.prependChildElement( secHeader.getSecurityHeaderElement(), bstToken.getElement()
((X509Security)bstToken).setX509Certificate(encCert); bstToken.addWSUNamespace(); bstToken.setID(wssConfig.getIdAllocator().createSecureId("X509-", encCert)); WSSecurityUtil.prependChildElement( secHeader.getSecurityHeaderElement(), bstToken.getElement()