WSSSecurityProperties securityProperties) throws WSSecurityException {
super(wsInboundSecurityContext, id, keyIdentifier, false);
this.securityProperties = securityProperties;
if (securityProperties.getCallbackHandler() != null) {
// Try to get the Assertion from a CallbackHandler
WSPasswordCallback pwcb =
new WSPasswordCallback(id, WSPasswordCallback.Usage.CUSTOM_TOKEN);
try {
securityProperties.getCallbackHandler().handle(new Callback[]{pwcb});
} catch (IOException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
} catch (UnsupportedCallbackException e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noPassword", e);
}
Element assertionElem = pwcb.getCustomToken();
if (assertionElem != null && "Assertion".equals(assertionElem.getLocalName())
&& (WSSConstants.NS_SAML.equals(assertionElem.getNamespaceURI())
|| WSSConstants.NS_SAML2.equals(assertionElem))) {
this.samlAssertionWrapper = new SamlAssertionWrapper(assertionElem);
subjectKeyInfo =
SAMLUtil.getCredentialFromSubject(samlAssertionWrapper, null,
securityProperties.getSignatureVerificationCrypto(),
securityProperties.getCallbackHandler());
} else {
// Possibly an Encrypted Assertion...just get the key
this.samlAssertionWrapper = null;
secret = pwcb.getKey();
key = pwcb.getKeyObject();
if (this.key instanceof PrivateKey) {
super.setAsymmetric(true);
}
}