public Document build(Document doc, WSSecHeader secHeader) throws WSSecurityException, ConversationException { // // Setup the encrypted key // prepare(doc); envelope = doc.getDocumentElement(); // // prepend elements in the right order to the security header // prependDKElementToHeader(secHeader); String soapNamespace = WSSecurityUtil.getSOAPNamespace(envelope); if (parts == null) { parts = new ArrayList<WSEncryptionPart>(1); WSEncryptionPart encP = new WSEncryptionPart( WSConstants.ELEM_BODY, soapNamespace, "Content" ); parts.add(encP); } Element externRefList = encryptForExternalRef(null, parts); addExternalRefElement(externRefList, secHeader); return doc; }
keyInfo = createKeyInfo(); } catch (ConversationException ex) { throw new WSSecurityException(ex.getMessage(), ex); document, getWsConfig(), keyInfo, key, symEncAlgo, references, callbackLookup ); if (dataRef == null) {
log.debug("Use drived keys"); dkEncr = new WSSecDKEncrypt(); dkEncr.setExternalKey(tok.getSecret(), (Element) doc .importNode((Element) tok.getAttachedReference(), true)); dkEncr.setExternalKey(tok.getSecret(), (Element) doc .importNode((Element) tok.getUnattachedReference(), true)); } else { dkEncr.setExternalKey(tok.getSecret(), tok.getId()); dkEncr.setSymmetricEncAlgorithm(algorithmSuite.getEncryption()); dkEncr.setDerivedKeyLength(algorithmSuite.getEncryptionDerivedKeyLength()/8); dkEncr.prepare(doc); encrDKTokenElem = dkEncr.getdktElement(); RampartUtil.appendChildToSecHeader(rmd, encrDKTokenElem); refList = dkEncr.encryptForExternalRef(null, encrParts); secondRefList = dkEncr.encryptForExternalRef(null, secondEncrParts); RampartUtil.insertSiblingAfter(
this.setupEncryptedKey(rmd, encryptionToken); dkEncr = new WSSecDKEncrypt(); dkEncr.setParts(encrParts); dkEncr.setExternalKey(this.encryptedKeyValue, this.encryptedKeyId); dkEncr.setDerivedKeyLength(rpd.getAlgorithmSuite().getEncryptionDerivedKeyLength()/8); dkEncr.prepare(doc); this.encrDKTElement = dkEncr.getdktElement(); encrDKTokenElem = RampartUtil.appendChildToSecHeader(rmd, this.encrDKTElement); refList = dkEncr.encryptForExternalRef(null, encrParts); try { secondRefList = dkEncr.encryptForExternalRef(null, secondEncrParts); RampartUtil.insertSiblingAfter(rmd, encrDKTokenElem,
/** * Create a KeyInfo object * @throws ConversationException */ private KeyInfo createKeyInfo() throws WSSecurityException, ConversationException { KeyInfo keyInfo = new KeyInfo(document); SecurityTokenReference secToken = new SecurityTokenReference(document); secToken.addWSSENamespace(); Reference ref = new Reference(document); ref.setURI("#" + dktId); String ns = ConversationConstants.getWSCNs(getWscVersion()) + ConversationConstants.TOKEN_TYPE_DERIVED_KEY_TOKEN; ref.setValueType(ns); secToken.setReference(ref); keyInfo.addUnknownElement(secToken.getElement()); Element keyInfoElement = keyInfo.getElement(); keyInfoElement.setAttributeNS( WSConstants.XMLNS_NS, "xmlns:" + WSConstants.SIG_PREFIX, WSConstants.SIG_NS ); return keyInfo; }
WSSecDKEncrypt dkEncr = new WSSecDKEncrypt(); dkEncr.setExternalKey(this.encryptedKeyValue, this.encryptedKeyId); dkEncr.setCustomValueType(WSConstants.SOAPMESSAGE_NS11 + "#" + WSConstants.ENC_KEY_VALUE_TYPE); dkEncr.setSymmetricEncAlgorithm(algorithmSuite.getEncryption()); dkEncr.setDerivedKeyLength(algorithmSuite.getEncryptionDerivedKeyLength()/8); dkEncr.prepare(doc); rmd, this.encrTokenElement, dkEncr.getdktElement()); } else { this.encrDKTElement = RampartUtil.insertSiblingBefore( rmd, this.sigDKTElement, dkEncr.getdktElement()); refList = dkEncr.encryptForExternalRef(null, encrParts);
/** * Create a KeyInfo object * @throws ConversationException */ private KeyInfo createKeyInfo() throws WSSecurityException, ConversationException { KeyInfo keyInfo = new KeyInfo(document); SecurityTokenReference secToken = new SecurityTokenReference(document); secToken.addWSSENamespace(); Reference ref = new Reference(document); ref.setURI("#" + dktId); String ns = ConversationConstants.getWSCNs(getWscVersion()) + ConversationConstants.TOKEN_TYPE_DERIVED_KEY_TOKEN; ref.setValueType(ns); secToken.setReference(ref); keyInfo.addUnknownElement(secToken.getElement()); Element keyInfoElement = keyInfo.getElement(); keyInfoElement.setAttributeNS( WSConstants.XMLNS_NS, "xmlns:" + WSConstants.SIG_PREFIX, WSConstants.SIG_NS ); return keyInfo; }
WSSecDKEncrypt dkEncr = new WSSecDKEncrypt(); dkEncr.setWscVersion(ConversationConstants.VERSION_05_12); dkEncr.setExternalKey(encrTok.getSecret(), (Element) doc .importNode((Element) encrTok.getAttachedReference(), true)); } else if(encrTok.getUnattachedReference() != null) { dkEncr.setExternalKey(encrTok.getSecret(), (Element) doc .importNode((Element) encrTok.getUnattachedReference(), true)); dkEncr.setExternalKey(encrTok.getSecret(), tokenRef.getElement()); dkEncr.setExternalKey(encrTok.getSecret(), encrTok.getId()); dkEncr.setCustomValueType(WSConstants.SOAPMESSAGE_NS11 + "#" + WSConstants.ENC_KEY_VALUE_TYPE); dkEncr.setSymmetricEncAlgorithm(rpd.getAlgorithmSuite().getEncryption()); dkEncr.setDerivedKeyLength(rpd.getAlgorithmSuite().getEncryptionDerivedKeyLength()/8); dkEncr.prepare(doc); Element encrDKTokenElem = null; encrDKTokenElem = dkEncr.getdktElement(); if(encrTokElem != null) { RampartUtil.insertSiblingAfter(rmd, encrTokElem, encrDKTokenElem); refList = dkEncr.encryptForExternalRef(null, encrParts);
public Document build(Document doc, WSSecHeader secHeader) throws WSSecurityException, ConversationException { // // Setup the encrypted key // prepare(doc); envelope = doc.getDocumentElement(); // // prepend elements in the right order to the security header // prependDKElementToHeader(secHeader); String soapNamespace = WSSecurityUtil.getSOAPNamespace(envelope); if (parts == null) { parts = new ArrayList<WSEncryptionPart>(1); WSEncryptionPart encP = new WSEncryptionPart( WSConstants.ELEM_BODY, soapNamespace, "Content" ); parts.add(encP); } Element externRefList = encryptForExternalRef(null, parts); addExternalRefElement(externRefList, secHeader); return doc; }
keyInfo = createKeyInfo(); } catch (ConversationException ex) { throw new WSSecurityException(ex.getMessage(), ex); document, getWsConfig(), keyInfo, key, symEncAlgo, references, callbackLookup ); if (dataRef == null) {