public void prepare(Crypto crypto) throws WSSecurityException { if (sct == null) { if (identifier != null) { sct = new SecurityContextToken(wscVersion, doc, identifier); } else { sct = new SecurityContextToken(wscVersion, doc); identifier = sct.getIdentifier(); } } // The wsu:Id of the wsc:SecurityContextToken if (sctId == null) { sctId = getWsConfig().getIdAllocator().createId("sctId-", sct); } sct.setID(sctId); }
public void prependSCTElementToHeader() throws WSSecurityException { Element secHeaderElement = securityHeader.getSecurityHeaderElement(); WSSecurityUtil.prependChildElement(secHeaderElement, sct.getElement()); }
/** * @return Returns the sctId. */ public String getSctId() { if (sct != null) { return sct.getID(); } return sctId; }
@Override public boolean equals(Object object) { if (!(object instanceof SecurityContextToken)) { return false; } SecurityContextToken securityToken = (SecurityContextToken)object; if (!compare(getIdentifier(), securityToken.getIdentifier())) { return false; } return true; }
.getProperty(TokenStore.class.getName())).remove(tokenIdToRenew); String instance = IDGenerator.generateID(null); sct = new SecurityContextToken( NegotiationUtils.getWSCVersion(tokenType), writer.getDocument(), 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())); SecurityToken token = new SecurityToken(sct.getIdentifier(), created, expires); token.setToken(sct.getElement()); token.setTokenType(sct.getTokenType()); writer.getCurrentNode().appendChild(sct.getElement()); writer.writeEndElement(); writeSecurityTokenReference(writer, "#" + sct.getID(), tokenType) ); writer.writeEndElement(); writeSecurityTokenReference(writer, sct.getIdentifier(), sct.getInstance(), tokenType) ); writer.writeEndElement();
private SecurityToken findCancelOrRenewToken(Exchange exchange, Element el) throws WSSecurityException { Element childElement = DOMUtils.getFirstElement(el); String uri = ""; if ("SecurityContextToken".equals(childElement.getLocalName())) { SecurityContextToken sct = new SecurityContextToken(childElement); uri = sct.getIdentifier(); } else { SecurityTokenReference ref = new SecurityTokenReference(childElement, new BSPEnforcer()); uri = ref.getReference().getURI(); } TokenStore store = (TokenStore)exchange.getEndpoint().getEndpointInfo() .getProperty(TokenStore.class.getName()); return store.getToken(uri); }
SecurityContextToken tok = (SecurityContextToken)wser.get(WSSecurityEngineResult.TAG_SECURITY_CONTEXT_TOKEN); message.getExchange().put(SecurityConstants.TOKEN_ID, tok.getIdentifier()); SecurityToken token = TokenStoreUtils.getTokenStore(message).getToken(tok.getIdentifier()); if (token == null || token.isExpired()) { byte[] secret = (byte[])wser.get(WSSecurityEngineResult.TAG_SECRET); if (secret != null) { token = new SecurityToken(tok.getIdentifier()); token.setToken(tok.getElement()); token.setSecret(secret); token.setTokenType(tok.getTokenType()); TokenStoreUtils.getTokenStore(message).add(token);
RequestData data ) throws WSSecurityException { SecurityContextToken sct = new SecurityContextToken(elem); String tokenId = sct.getID(); if (!"".equals(tokenId)) { result.put(WSSecurityEngineResult.TAG_ID, tokenId); String id = sct.getID(); id = XMLUtils.getIDFromReference(id); secret = getSecret(data.getCallbackHandler(), sct.getIdentifier()); } catch (WSSecurityException ex) { secret = getSecret(data.getCallbackHandler(), id); secret = getSecret(data.getCallbackHandler(), id); result.put(WSSecurityEngineResult.TAG_ID, sct.getID()); result.put(WSSecurityEngineResult.TAG_SECRET, secret);
(SecurityContextToken) engineResult.get(WSSecurityEngineResult.TAG_SECURITY_CONTEXT_TOKEN); if (referenceURI.equals(sct.getIdentifier())) { return sct.getElement();
SecurityContextToken sct = new SecurityContextToken(version, doc, tokenIdentifier); return sct.getElement();
hash = credential.getBinarySecurityToken().hashCode(); } else if (credential.getSecurityContextToken() != null) { tokenElement = credential.getSecurityContextToken().getElement(); hash = credential.getSecurityContextToken().hashCode();
@Override public int hashCode() { int result = 17; String identifier = getIdentifier(); if (identifier != null) { result = 31 * result + identifier.hashCode(); } return result; }
/** * Get the identifier. * * @return the data from the identifier element. */ public String getIdentifier() { if (elementIdentifier != null) { Text text = getFirstNode(elementIdentifier); if (text != null) { return text.getData(); } } return null; }
.getProperty(TokenStore.class.getName())).remove(tokenIdToRenew); String instance = IDGenerator.generateID(null); sct = new SecurityContextToken( NegotiationUtils.getWSCVersion(tokenType), writer.getDocument(), 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())); SecurityToken token = new SecurityToken(sct.getIdentifier(), created, expires); token.setToken(sct.getElement()); token.setTokenType(sct.getTokenType()); writer.getCurrentNode().appendChild(sct.getElement()); writer.writeEndElement(); writeSecurityTokenReference(writer, "#" + sct.getID(), tokenType) ); writer.writeEndElement(); writeSecurityTokenReference(writer, sct.getIdentifier(), sct.getInstance(), tokenType) ); writer.writeEndElement();
private SecurityToken findCancelOrRenewToken(Exchange exchange, Element el) throws WSSecurityException { Element childElement = DOMUtils.getFirstElement(el); String uri = ""; if ("SecurityContextToken".equals(childElement.getLocalName())) { SecurityContextToken sct = new SecurityContextToken(childElement); uri = sct.getIdentifier(); } else { SecurityTokenReference ref = new SecurityTokenReference(childElement, new BSPEnforcer()); uri = ref.getReference().getURI(); } TokenStore store = (TokenStore)exchange.getEndpoint().getEndpointInfo() .getProperty(TokenStore.class.getName()); return store.getToken(uri); }
SecurityContextToken tok = (SecurityContextToken)wser.get(WSSecurityEngineResult.TAG_SECURITY_CONTEXT_TOKEN); message.getExchange().put(SecurityConstants.TOKEN_ID, tok.getIdentifier()); SecurityToken token = TokenStoreUtils.getTokenStore(message).getToken(tok.getIdentifier()); if (token == null || token.isExpired()) { byte[] secret = (byte[])wser.get(WSSecurityEngineResult.TAG_SECRET); if (secret != null) { token = new SecurityToken(tok.getIdentifier()); token.setToken(tok.getElement()); token.setSecret(secret); token.setTokenType(tok.getTokenType()); TokenStoreUtils.getTokenStore(message).add(token);
(SecurityContextToken) engineResult.get(WSSecurityEngineResult.TAG_SECURITY_CONTEXT_TOKEN); if (referenceURI.equals(sct.getIdentifier())) { return sct.getElement();
hash = credential.getBinarySecurityToken().hashCode(); } else if (credential.getSecurityContextToken() != null) { tokenElement = credential.getSecurityContextToken().getElement(); hash = credential.getSecurityContextToken().hashCode();
WSSecurityEngineResult.TAG_SECURITY_CONTEXT_TOKEN ); parserResult.setPrincipal(new CustomTokenPrincipal(sct.getIdentifier())); } else if (action != null && WSConstants.DKT == action.intValue()) { DerivedKeyToken dkt =
/** * Get the instance. * * @return the data from the instance element. */ public String getInstance() { if (elementInstance != null) { Text text = getFirstNode(elementInstance); if (text != null) { return text.getData(); } } return null; }