bstPath.addAll(WSSConstants.WSSE_SECURITY_HEADER_PATH);
bstPath.add(WSSConstants.TAG_wsse_BinarySecurityToken);
XMLSecEvent recipientTokenXmlEvent = XMLSecEventFactory.createXmlSecStartElement(WSSConstants.TAG_wsse_UsernameToken, null, null);
X509TokenSecurityEvent recipientX509TokenSecurityEvent = new X509TokenSecurityEvent();
X509SecurityTokenImpl recipientToken = getX509Token(WSSecurityTokenConstants.X509V3Token);
recipientX509TokenSecurityEvent.setSecurityToken(recipientToken);
recipientToken.setElementPath(bstPath);
recipientToken.setXMLSecEvent(recipientTokenXmlEvent);
recipientToken.addTokenUsage(WSSecurityTokenConstants.TokenUsage_Encryption);
inboundWSSecurityContext.registerSecurityEvent(recipientX509TokenSecurityEvent);
List<XMLSecurityConstants.ContentType> protectionOrder = new LinkedList<XMLSecurityConstants.ContentType>();
protectionOrder.add(XMLSecurityConstants.ContentType.ENCRYPTION);
protectionOrder.add(XMLSecurityConstants.ContentType.SIGNATURE);
List<QName> signaturePath = new LinkedList<QName>();
signaturePath.addAll(WSSConstants.WSSE_SECURITY_HEADER_PATH);
signaturePath.add(WSSConstants.TAG_dsig_Signature);
EncryptedElementSecurityEvent signatureEncryptedElementSecurityEvent = new EncryptedElementSecurityEvent(recipientToken, true, protectionOrder);
signatureEncryptedElementSecurityEvent.setElementPath(signaturePath);
inboundWSSecurityContext.registerSecurityEvent(signatureEncryptedElementSecurityEvent);
List<QName> usernameTokenPath = new LinkedList<QName>();
usernameTokenPath.addAll(WSSConstants.WSSE_SECURITY_HEADER_PATH);
usernameTokenPath.add(WSSConstants.TAG_wsse_UsernameToken);
XMLSecEvent usernameTokenXmlEvent = XMLSecEventFactory.createXmlSecStartElement(WSSConstants.TAG_wsse_UsernameToken, null, null);
EncryptedElementSecurityEvent usernameEncryptedElementSecurityEvent = new EncryptedElementSecurityEvent(recipientToken, true, protectionOrder);
usernameEncryptedElementSecurityEvent.setElementPath(usernameTokenPath);
usernameEncryptedElementSecurityEvent.setXmlSecEvent(usernameTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(usernameEncryptedElementSecurityEvent);
XMLSecEvent signedEndorsingEncryptedTokenXmlEvent = XMLSecEventFactory.createXmlSecStartElement(WSSConstants.TAG_wsse_UsernameToken, null, null);
EncryptedElementSecurityEvent signedEndorsedEncryptedTokenEncryptedElementSecurityEvent = new EncryptedElementSecurityEvent(recipientToken, true, protectionOrder);
signedEndorsedEncryptedTokenEncryptedElementSecurityEvent.setElementPath(bstPath);
signedEndorsedEncryptedTokenEncryptedElementSecurityEvent.setXmlSecEvent(signedEndorsingEncryptedTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(signedEndorsedEncryptedTokenEncryptedElementSecurityEvent);
XMLSecEvent encryptedSupportingTokenXmlEvent = XMLSecEventFactory.createXmlSecStartElement(WSSConstants.TAG_wsse_UsernameToken, null, null);
EncryptedElementSecurityEvent encryptedSupportingTokenEncryptedElementSecurityEvent = new EncryptedElementSecurityEvent(recipientToken, true, protectionOrder);
encryptedSupportingTokenEncryptedElementSecurityEvent.setElementPath(bstPath);
encryptedSupportingTokenEncryptedElementSecurityEvent.setXmlSecEvent(encryptedSupportingTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(encryptedSupportingTokenEncryptedElementSecurityEvent);
UsernameTokenSecurityEvent usernameTokenSecurityEvent = new UsernameTokenSecurityEvent();
UsernameSecurityTokenImpl usernameSecurityToken = new UsernameSecurityTokenImpl(
WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT,
"username", "password", new Date().toString(), null, new byte[10], 10L,
null, IDGenerator.generateID(null), WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference);
usernameSecurityToken.setElementPath(usernameTokenPath);
usernameSecurityToken.setXMLSecEvent(usernameTokenXmlEvent);
usernameTokenSecurityEvent.setSecurityToken(usernameSecurityToken);
inboundWSSecurityContext.registerSecurityEvent(usernameTokenSecurityEvent);
XMLSecEvent signedEndorsingTokenXmlEvent = XMLSecEventFactory.createXmlSecStartElement(WSSConstants.TAG_wsse_UsernameToken, null, null);
X509TokenSecurityEvent signedEndorsingSupporting509TokenSecurityEvent = new X509TokenSecurityEvent();
X509SecurityTokenImpl signedEndorsingSupportingToken = getX509Token(WSSecurityTokenConstants.X509V3Token);
signedEndorsingSupporting509TokenSecurityEvent.setSecurityToken(signedEndorsingSupportingToken);
signedEndorsingSupportingToken.setElementPath(bstPath);
signedEndorsingSupportingToken.setXMLSecEvent(signedEndorsingTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(signedEndorsingSupporting509TokenSecurityEvent);
X509TokenSecurityEvent encryptedSupporting509TokenSecurityEvent = new X509TokenSecurityEvent();
X509SecurityTokenImpl encryptedSupportingToken = getX509Token(WSSecurityTokenConstants.X509V3Token);
encryptedSupporting509TokenSecurityEvent.setSecurityToken(encryptedSupportingToken);
encryptedSupportingToken.setElementPath(bstPath);
encryptedSupportingToken.setXMLSecEvent(encryptedSupportingTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(encryptedSupporting509TokenSecurityEvent);
X509TokenSecurityEvent supporting509TokenSecurityEvent = new X509TokenSecurityEvent();
X509SecurityTokenImpl supportingToken = getX509Token(WSSecurityTokenConstants.X509V3Token);
supporting509TokenSecurityEvent.setSecurityToken(supportingToken);
supportingToken.setElementPath(bstPath);
inboundWSSecurityContext.registerSecurityEvent(supporting509TokenSecurityEvent);
X509TokenSecurityEvent signedEndorsingEncryptedSupporting509TokenSecurityEvent = new X509TokenSecurityEvent();
X509SecurityTokenImpl signedEndorsingEncryptedSupportingToken = getX509Token(WSSecurityTokenConstants.X509V3Token);
signedEndorsingEncryptedSupporting509TokenSecurityEvent.setSecurityToken(signedEndorsingEncryptedSupportingToken);
signedEndorsingEncryptedSupportingToken.setElementPath(bstPath);
signedEndorsingEncryptedSupportingToken.setXMLSecEvent(signedEndorsingEncryptedTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(signedEndorsingEncryptedSupporting509TokenSecurityEvent);
XMLSecEvent initiatorTokenXmlEvent = XMLSecEventFactory.createXmlSecStartElement(WSSConstants.TAG_wsse_UsernameToken, null, null);
X509TokenSecurityEvent initiator509TokenSecurityEvent = new X509TokenSecurityEvent();
X509SecurityTokenImpl initiatorToken = getX509Token(WSSecurityTokenConstants.X509V3Token);
initiator509TokenSecurityEvent.setSecurityToken(initiatorToken);
initiatorToken.setElementPath(bstPath);
initiatorToken.setXMLSecEvent(initiatorTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(initiator509TokenSecurityEvent);
initiator509TokenSecurityEvent = new X509TokenSecurityEvent();
initiator509TokenSecurityEvent.setSecurityToken(initiatorToken);
initiatorToken.addTokenUsage(WSSecurityTokenConstants.TokenUsage_Signature);
inboundWSSecurityContext.registerSecurityEvent(initiator509TokenSecurityEvent);
SignatureValueSecurityEvent signatureValueSecurityEvent = new SignatureValueSecurityEvent();
inboundWSSecurityContext.registerSecurityEvent(signatureValueSecurityEvent);
SignedElementSecurityEvent signedTimestampElementSecurityEvent = new SignedElementSecurityEvent(initiatorToken, true, protectionOrder);
signedTimestampElementSecurityEvent.setElementPath(timestampPath);
inboundWSSecurityContext.registerSecurityEvent(signedTimestampElementSecurityEvent);
SignedElementSecurityEvent signedSCElementSecurityEvent = new SignedElementSecurityEvent(initiatorToken, true, protectionOrder);
signedSCElementSecurityEvent.setElementPath(scPath);
inboundWSSecurityContext.registerSecurityEvent(signedSCElementSecurityEvent);
SignedElementSecurityEvent signedUsernameTokenElementSecurityEvent = new SignedElementSecurityEvent(initiatorToken, true, protectionOrder);
signedUsernameTokenElementSecurityEvent.setElementPath(usernameTokenPath);
signedUsernameTokenElementSecurityEvent.setXmlSecEvent(usernameTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(signedUsernameTokenElementSecurityEvent);
SignedElementSecurityEvent bstElementSecurityEvent = new SignedElementSecurityEvent(initiatorToken, true, protectionOrder);
bstElementSecurityEvent.setElementPath(bstPath);
bstElementSecurityEvent.setXmlSecEvent(signedEndorsingTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(bstElementSecurityEvent);
bstElementSecurityEvent = new SignedElementSecurityEvent(initiatorToken, true, protectionOrder);
bstElementSecurityEvent.setElementPath(bstPath);
bstElementSecurityEvent.setXmlSecEvent(signedEndorsingEncryptedTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(bstElementSecurityEvent);
bstElementSecurityEvent = new SignedElementSecurityEvent(initiatorToken, true, protectionOrder);
bstElementSecurityEvent.setElementPath(bstPath);
bstElementSecurityEvent.setXmlSecEvent(initiatorTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(bstElementSecurityEvent);
List<QName> header1Path = new LinkedList<QName>();
header1Path.addAll(WSSConstants.SOAP_11_HEADER_PATH);
header1Path.add(new QName("x", "Header1", "x"));
SignedPartSecurityEvent header1SignedPartSecurityEvent = new SignedPartSecurityEvent(initiatorToken, true, protectionOrder);
header1SignedPartSecurityEvent.setElementPath(header1Path);
inboundWSSecurityContext.registerSecurityEvent(header1SignedPartSecurityEvent);
List<QName> header2Path = new LinkedList<QName>();
header2Path.addAll(WSSConstants.SOAP_11_HEADER_PATH);
header2Path.add(new QName("x", "Header1", "x"));
SignedPartSecurityEvent header2SignedPartSecurityEvent = new SignedPartSecurityEvent(initiatorToken, true, protectionOrder);
header2SignedPartSecurityEvent.setElementPath(header2Path);
inboundWSSecurityContext.registerSecurityEvent(header2SignedPartSecurityEvent);
List<QName> bodyPath = new LinkedList<QName>();
bodyPath.addAll(WSSConstants.SOAP_11_BODY_PATH);
SignedPartSecurityEvent bodySignedPartSecurityEvent = new SignedPartSecurityEvent(initiatorToken, true, protectionOrder);
bodySignedPartSecurityEvent.setElementPath(bodyPath);
inboundWSSecurityContext.registerSecurityEvent(bodySignedPartSecurityEvent);
signedEndorsingSupporting509TokenSecurityEvent = new X509TokenSecurityEvent();
signedEndorsingSupporting509TokenSecurityEvent.setSecurityToken(signedEndorsingSupportingToken);
signedEndorsingSupportingToken.addTokenUsage(WSSecurityTokenConstants.TokenUsage_Signature);
inboundWSSecurityContext.registerSecurityEvent(signedEndorsingSupporting509TokenSecurityEvent);
SignatureValueSecurityEvent signature2ValueSecurityEvent = new SignatureValueSecurityEvent();
inboundWSSecurityContext.registerSecurityEvent(signature2ValueSecurityEvent);
SignedElementSecurityEvent signatureElementSecurityEvent = new SignedElementSecurityEvent(signedEndorsingSupportingToken, true, protectionOrder);
signatureElementSecurityEvent.setElementPath(signaturePath);
inboundWSSecurityContext.registerSecurityEvent(signatureElementSecurityEvent);
bstElementSecurityEvent = new SignedElementSecurityEvent(signedEndorsingSupportingToken, true, protectionOrder);
bstElementSecurityEvent.setElementPath(bstPath);
bstElementSecurityEvent.setXmlSecEvent(signedEndorsingTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(bstElementSecurityEvent);
signedEndorsingEncryptedSupporting509TokenSecurityEvent = new X509TokenSecurityEvent();
signedEndorsingEncryptedSupporting509TokenSecurityEvent.setSecurityToken(signedEndorsingEncryptedSupportingToken);
signedEndorsingEncryptedSupportingToken.addTokenUsage(WSSecurityTokenConstants.TokenUsage_Signature);
inboundWSSecurityContext.registerSecurityEvent(signedEndorsingEncryptedSupporting509TokenSecurityEvent);
signature2ValueSecurityEvent = new SignatureValueSecurityEvent();