WSDocInfo wsDocInfo = new WSDocInfo(securityHeader.getOwnerDocument()); wsDocInfo.setCallbackLookup(callbackLookup); wsDocInfo.setCrypto(requestData.getSigCrypto()); wsDocInfo.setSecurityHeader(securityHeader);
public List<WSSecurityEngineResult> handleToken( Element elem, RequestData data, WSDocInfo wsDocInfo ) throws WSSecurityException { if (log.isDebugEnabled()) { log.debug("Found reference list element"); } List<WSDataRef> dataRefs = handleReferenceList(elem, data, wsDocInfo); WSSecurityEngineResult result = new WSSecurityEngineResult(WSConstants.ENCR, dataRefs); String tokenId = elem.getAttributeNS(null, "Id"); if (!"".equals(tokenId)) { result.put(WSSecurityEngineResult.TAG_ID, tokenId); } wsDocInfo.addTokenElement(elem); wsDocInfo.addResult(result); return java.util.Collections.singletonList(result); }
/** * Store a token element for later retrieval. Before storing the token, we check for a * previously processed token with the same (wsu/SAML) Id. * @param element is the token element to store * @param checkMultipleElements check for a previously stored element with the same Id. */ public void addTokenElement(Element element, boolean checkMultipleElements) throws WSSecurityException { if (tokenList == null) { tokenList = new ArrayList<Element>(); } if (checkMultipleElements) { for (Element elem : tokenList) { if (compareElementsById(element, elem)) { throw new WSSecurityException( WSSecurityException.INVALID_SECURITY_TOKEN, "duplicateError" ); } } } tokenList.add(element); }
List<WSDataRef> dataRefs = new ArrayList<WSDataRef>(); Element wsseHeaderElement = wsDocInfo.getSecurityHeader(); boolean asymBinding = WSSecurityUtil.getDirectChildElement( wsseHeaderElement, WSConstants.ENC_KEY_LN, WSConstants.ENC_NS) != null; if (wsDocInfo.getResultByTag(WSConstants.ENCR, dataRefURI) == null) { WSDataRef dataRef = decryptDataRefEmbedded(
java.util.Iterator<?> referenceIterator = xmlSignature.getSignedInfo().getReferences().iterator(); CallbackLookup callbackLookup = wsDocInfo.getCallbackLookup(); if (callbackLookup == null) { callbackLookup = new DOMCallbackLookup(doc); Element element = callbackLookup.getElement(uri, null, true); if (element == null) { element = wsDocInfo.getTokenElement(uri);
Element foundElement = wsDocInfo.getTokenElement(id); if (elem.equals(foundElement)) { WSSecurityEngineResult result = wsDocInfo.getResult(id); return java.util.Collections.singletonList(result); } else if (foundElement != null) { wsDocInfo.addTokenElement(elem); WSSecurityEngineResult result = null; if (samlAssertion.isSigned()) { wsDocInfo.addResult(result); return java.util.Collections.singletonList(result);
wsDocInfo = new WSDocInfo(doc); cryptoType.setAlias(issuerKeyName); certs = issuerCrypto.getX509Certificates(cryptoType); wsDocInfo.setCrypto(issuerCrypto); publicKey = samlKeyInfo.getPublicKey(); certs = samlKeyInfo.getCerts(); wsDocInfo.setCrypto(userCrypto); elem.appendChild(keyId); wsDocInfo.addTokenElement(secRefSaml.getElement(), false); ((X509Security) bstToken).setX509Certificate(certs[0]); bstToken.setID(certUri); wsDocInfo.addTokenElement(bstToken.getElement(), false); ref.setValueType(bstToken.getValueType()); secRef.setReference(ref); wsDocInfo.addTokenElement(secRef.getElement(), false); ); wsDocInfo.addTokenElement(samlToken, false);
public void prepare(Document doc, WSSecHeader secHeader) throws WSSecurityException, ConversationException { super.prepare(doc); wsDocInfo = new WSDocInfo(doc); securityHeader = secHeader.getSecurityHeader(); sig = null; wsDocInfo.addTokenElement(secRef.getElement(), false); keyInfo = keyInfoFactory.newKeyInfo(
WSSecurityEngineResult result = wsDocInfo.getResult(id); if (result != null && WSConstants.ENCR == (Integer)result.get(WSSecurityEngineResult.TAG_ACTION) wsDocInfo.addResult(result); wsDocInfo.addTokenElement(elem); return java.util.Collections.singletonList(result);
WSSecurityEngineResult result = wsDocInfo.getResult(uri); if (result != null) { processPreviousResult(result, secRef, data, parameters, wsDocInfo, bspCompliant); byte[] keyBytes = secRef.getSKIBytes(); List<WSSecurityEngineResult> resultsList = wsDocInfo.getResultsByTag(WSConstants.BST); for (WSSecurityEngineResult bstResult : resultsList) { BinarySecurity bstToken =
@Override public byte[] getAssertionKeyInfoSecret(Crypto signatureCrypto, TokenCallbackHandler tokenCallbackHandler) throws WSSecurityException { RequestData requestData = new RequestData(); requestData.setCallbackHandler(tokenCallbackHandler); requestData.setSigCrypto(signatureCrypto); WSDocInfo docInfo = new WSDocInfo(assertion.getDOM().getOwnerDocument()); // TODO Improve .. // TODO change this to use SAMLAssertion parameter once wss4j conversion is done .... SAMLKeyInfo samlKi = SAMLUtil.getCredentialFromSubject(assertion, requestData, docInfo, true); return samlKi.getSecret(); }
List<WSSecurityEngineResult> foundResults = wsDocInfo.getResultsByTag(WSConstants.TS); Timestamp timeStamp = null; if (foundResults.isEmpty()) {
String keyIdentifierValue = secRef.getKeyIdentifierValue(); String type = secRef.getKeyIdentifierValueType(); WSSecurityEngineResult result = wsDocInfo.getResult(keyIdentifierValue);
/** * Store a token element for later retrieval. Before storing the token, we check for a * previously processed token with the same (wsu/SAML) Id. * @param element is the token element to store */ public void addTokenElement(Element element) throws WSSecurityException { addTokenElement(element, true); }
callbackLookup = docInfo.getCallbackLookup();
secRef.getX509IssuerSerial(wsDocInfo.getCrypto()); if (certs == null || certs.length == 0 || certs[0] == null) { throw new WSSecurityException(WSSecurityException.FAILED_CHECK); return secRef.getTokenElement(doc, wsDocInfo, null); } else { X509Certificate[] certs = secRef.getKeyIdentifier(wsDocInfo.getCrypto()); if (certs == null || certs.length == 0 || certs[0] == null) { throw new WSSecurityException(WSSecurityException.FAILED_CHECK);
Element foundElement = wsDocInfo.getTokenElement(id); if (elem.equals(foundElement)) { WSSecurityEngineResult result = wsDocInfo.getResult(id); return java.util.Collections.singletonList(result); } else if (foundElement != null) { wsDocInfo.addTokenElement(elem); WSSecurityEngineResult result = null; if (samlAssertion.isSigned()) { wsDocInfo.addResult(result); return java.util.Collections.singletonList(result);
wsDocInfo = new WSDocInfo(doc); cryptoType.setAlias(issuerKeyName); certs = issuerCrypto.getX509Certificates(cryptoType); wsDocInfo.setCrypto(issuerCrypto); publicKey = samlKeyInfo.getPublicKey(); certs = samlKeyInfo.getCerts(); wsDocInfo.setCrypto(userCrypto); elem.appendChild(keyId); wsDocInfo.addTokenElement(secRefSaml.getElement(), false); ((X509Security) bstToken).setX509Certificate(certs[0]); bstToken.setID(certUri); wsDocInfo.addTokenElement(bstToken.getElement(), false); ref.setValueType(bstToken.getValueType()); secRef.setReference(ref); wsDocInfo.addTokenElement(secRef.getElement(), false); ); wsDocInfo.addTokenElement(samlToken, false);
public void prepare(Document doc, WSSecHeader secHeader) throws WSSecurityException, ConversationException { super.prepare(doc); wsDocInfo = new WSDocInfo(doc); securityHeader = secHeader.getSecurityHeader(); sig = null; wsDocInfo.addTokenElement(secRef.getElement(), false); keyInfo = keyInfoFactory.newKeyInfo(
WSSecurityEngineResult result = wsDocInfo.getResult(id); if (result != null && WSConstants.ENCR == (Integer)result.get(WSSecurityEngineResult.TAG_ACTION) wsDocInfo.addResult(result); wsDocInfo.addTokenElement(elem); return java.util.Collections.singletonList(result);