SAMLAuthenticationStatement.AuthenticationMethod_Password;
}
Date authInstant = new Date();
Collection bindings = null;
SAMLSubject subject =
new SAMLSubject(nameId,
Arrays.asList(confirmationMethods),
null,
null);
SAMLStatement[] statements =
{
new SAMLAuthenticationStatement(subject,
authMethod,
authInstant,
subjectIP,
null,
bindings)};
sa =
new SAMLAssertion(issuer,
null,
null,
null,
null,
Arrays.asList(statements));
if (!senderVouches) {
KeyInfo ki = new KeyInfo(instanceDoc);
try {
X509Certificate[] certs =
userCrypto.getCertificates(username);
if (sendKeyValue) {
PublicKey key = certs[0].getPublicKey();
String pubKeyAlgo = key.getAlgorithm();
if ("DSA".equalsIgnoreCase(pubKeyAlgo)) {
DSAKeyValue dsaKeyValue = new DSAKeyValue(instanceDoc, key);
ki.add(dsaKeyValue);
} else if ("RSA".equalsIgnoreCase(pubKeyAlgo)) {
RSAKeyValue rsaKeyValue = new RSAKeyValue(instanceDoc, key);
ki.add(rsaKeyValue);
}
} else {
X509Data certElem = new X509Data(instanceDoc);
certElem.addCertificate(certs[0]);
ki.add(certElem);
}
} catch (WSSecurityException ex) {
if (log.isDebugEnabled()) {
log.debug(ex.getMessage(), ex);
}
return null;
} catch (XMLSecurityException ex) {
if (log.isDebugEnabled()) {
log.debug(ex.getMessage(), ex);
}
return null;
}
Element keyInfoElement = ki.getElement();
keyInfoElement.setAttributeNS(WSConstants.XMLNS_NS, "xmlns:"
+ WSConstants.SIG_PREFIX, WSConstants.SIG_NS);
subject.setKeyInfo(ki);
// prepare to sign the SAML token
try {
X509Certificate[] issuerCerts =
issuerCrypto.getCertificates(issuerKeyName);