samlParms.setSAMLVersion(SAMLVersion.VERSION_11);
} else if (token.isUseSamlVersion20Profile11()) {
samlParms.setSAMLVersion(SAMLVersion.VERSION_20);
}
info.setAsserted(true);
AssertionWrapper assertion = new AssertionWrapper(samlParms);
boolean selfSignAssertion =
MessageUtils.getContextualBoolean(
message, SecurityConstants.SELF_SIGN_SAML_ASSERTION, false
);
if (selfSignAssertion) {
Crypto crypto = getSignatureCrypto(null);
String userNameKey = SecurityConstants.SIGNATURE_USERNAME;
String user = (String)message.getContextualProperty(userNameKey);
if (crypto != null && StringUtils.isEmpty(user)) {
try {
user = crypto.getDefaultX509Identifier();
} catch (WSSecurityException e1) {
throw new Fault(e1);
}
}
if (StringUtils.isEmpty(user)) {
policyNotAsserted(token, "No username found.");
return null;
}
String password = getPassword(user, token, WSPasswordCallback.SIGNATURE);
// TODO configure using a KeyValue here
assertion.signAssertion(user, password, crypto, false);
}
return assertion;
}