Iterator statements = assertion.getStatements();
while (statements.hasNext()) {
SAMLStatement stmt = (SAMLStatement) statements.next();
if (stmt instanceof SAMLAttributeStatement) {
SAMLAttributeStatement attrStmt = (SAMLAttributeStatement) stmt;
SAMLSubject samlSubject = attrStmt.getSubject();
Element kiElem = samlSubject.getKeyInfo();
NodeList children = kiElem.getChildNodes();
int len = children.getLength();
for (int i = 0; i < len; i++) {
Node child = children.item(i);
if (child.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
QName el = new QName(child.getNamespaceURI(), child.getLocalName());
if (el.equals(WSSecurityEngine.ENCRYPTED_KEY)) {
EncryptedKeyProcessor proc = new EncryptedKeyProcessor();
proc.handleEncryptedKey((Element)child, cb, crypto, null);
return new SAMLKeyInfo(assertion, proc.getDecryptedBytes());
} else if (el.equals(new QName(WSConstants.WST_NS, "BinarySecret"))) {
Text txt = (Text)child.getFirstChild();
return new SAMLKeyInfo(assertion, Base64.decode(txt.getData()));
}
}
} else if (stmt instanceof SAMLAuthenticationStatement) {
SAMLAuthenticationStatement authStmt = (SAMLAuthenticationStatement)stmt;
SAMLSubject samlSubj = authStmt.getSubject();
if (samlSubj == null) {
throw new WSSecurityException(WSSecurityException.FAILURE,
"invalidSAMLToken", new Object[]{"for Signature (no Subject)"});
}
Element e = samlSubj.getKeyInfo();
X509Certificate[] certs = null;
try {
KeyInfo ki = new KeyInfo(e, null);
if (ki.containsX509Data()) {