samlCallback.setIssuer("xs:anyURI");
SubjectBean subjectBean = new SubjectBean();
samlCallback.setSubject(subjectBean);
SamlAssertionWrapper samlAssertionWrapper = new SamlAssertionWrapper(samlCallback);
SamlSecurityTokenImpl samlSecurityToken = new SamlSecurityTokenImpl(
samlAssertionWrapper, getX509Token(WSSecurityTokenConstants.X509V3Token), null, null, WSSecurityTokenConstants.KeyIdentifier_X509KeyIdentifier,
null);
samlSecurityToken.setElementPath(samlTokenPath);
samlSecurityToken.setXMLSecEvent(samlTokenXmlEvent);
samlSecurityToken.addTokenUsage(WSSecurityTokenConstants.TokenUsage_Encryption);
SamlTokenSecurityEvent samlTokenSecurityEvent = new SamlTokenSecurityEvent();
samlTokenSecurityEvent.setSecurityToken(samlSecurityToken);
inboundWSSecurityContext.registerSecurityEvent(samlTokenSecurityEvent);
List<XMLSecurityConstants.ContentType> protectionOrder = new LinkedList<XMLSecurityConstants.ContentType>();
protectionOrder.add(XMLSecurityConstants.ContentType.ENCRYPTION);
protectionOrder.add(XMLSecurityConstants.ContentType.SIGNATURE);
List<QName> usernamePath = new LinkedList<QName>();
usernamePath.addAll(WSSConstants.WSSE_SECURITY_HEADER_PATH);
usernamePath.add(WSSConstants.TAG_wsse_UsernameToken);
XMLSecEvent usernameTokenXmlEvent = XMLSecEventFactory.createXmlSecStartElement(WSSConstants.TAG_wsse_UsernameToken, null, null);
EncryptedElementSecurityEvent usernameEncryptedElementSecurityEvent = new EncryptedElementSecurityEvent(samlSecurityToken, true, protectionOrder);
usernameEncryptedElementSecurityEvent.setElementPath(usernamePath);
usernameEncryptedElementSecurityEvent.setXmlSecEvent(usernameTokenXmlEvent);
inboundWSSecurityContext.registerSecurityEvent(usernameEncryptedElementSecurityEvent);
List<QName> usernameTokenPath = new LinkedList<QName>();
usernameTokenPath.addAll(WSSConstants.WSSE_SECURITY_HEADER_PATH);
usernameTokenPath.add(WSSConstants.TAG_wsse_UsernameToken);
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(usernamePath);
usernameSecurityToken.setXMLSecEvent(usernameTokenXmlEvent);
usernameTokenSecurityEvent.setSecurityToken(usernameSecurityToken);
inboundWSSecurityContext.registerSecurityEvent(usernameTokenSecurityEvent);
List<QName> signaturePath = new LinkedList<QName>();
signaturePath.addAll(WSSConstants.WSSE_SECURITY_HEADER_PATH);
signaturePath.add(WSSConstants.TAG_dsig_Signature);
EncryptedElementSecurityEvent signatureEncryptedElementSecurityEvent = new EncryptedElementSecurityEvent(samlSecurityToken, true, protectionOrder);
signatureEncryptedElementSecurityEvent.setElementPath(signaturePath);
inboundWSSecurityContext.registerSecurityEvent(signatureEncryptedElementSecurityEvent);
samlSecurityToken.addTokenUsage(WSSecurityTokenConstants.TokenUsage_Signature);
samlTokenSecurityEvent = new SamlTokenSecurityEvent();
samlTokenSecurityEvent.setSecurityToken(samlSecurityToken);
inboundWSSecurityContext.registerSecurityEvent(samlTokenSecurityEvent);
SignatureValueSecurityEvent signatureValueSecurityEvent = new SignatureValueSecurityEvent();