}
Element e = samlSubj.getKeyInfo();
X509Certificate[] certs = null;
try {
KeyInfo ki = new KeyInfo(e, null);
if (ki.containsX509Data()) {
X509Data data = ki.itemX509Data(0);
if (data != null && data.containsCertificate()) {
XMLX509Certificate certElem = data.itemCertificate(0);
if (certElem != null) {
X509Certificate cert = certElem.getX509Certificate();
certs = new X509Certificate[1];
certs[0] = cert;
return new SAMLKeyInfo(assertion, certs);
}
} else if (data != null && data.containsIssuerSerial()) {
XMLX509IssuerSerial issuerSerial = data.itemIssuerSerial(0);
String alias =
crypto.getAliasForX509Cert(
issuerSerial.getIssuerName(), issuerSerial.getSerialNumber()
);
certs = crypto.getCertificates(alias);
return new SAMLKeyInfo(assertion, certs);
}
} else if (ki.containsKeyValue()) {
PublicKey pk = ki.getPublicKey();
return new SAMLKeyInfo(assertion, pk);
}
} catch (XMLSecurityException e3) {
throw new WSSecurityException(WSSecurityException.FAILURE,
"invalidSAMLsecurity",