Search in sources :

Example 16 with EncryptedAssertion

use of com.sun.identity.saml2.assertion.EncryptedAssertion in project OpenAM by OpenRock.

the class NameIDMappingResponseImpl method parseElement.

private void parseElement(Element element) throws SAML2Exception {
    AssertionFactory af = AssertionFactory.getInstance();
    ProtocolFactory pf = ProtocolFactory.getInstance();
    // make sure that the input xml block is not null
    if (element == null) {
        if (SAML2SDKUtils.debug.messageEnabled()) {
            SAML2SDKUtils.debug.message("NameIDMappingResponseImpl.parseElement: Input is null.");
        }
        throw new SAML2Exception(SAML2SDKUtils.bundle.getString("nullInput"));
    }
    // Make sure this is an EncryptedAssertion.
    String tag = null;
    tag = element.getLocalName();
    if ((tag == null) || (!tag.equals(elementName))) {
        if (SAML2SDKUtils.debug.messageEnabled()) {
            SAML2SDKUtils.debug.message("NameIDMappingResponseImpl.parseElement: " + "not ManageNameIDResponse.");
        }
        throw new SAML2Exception(SAML2SDKUtils.bundle.getString("wrongInput"));
    }
    responseId = element.getAttribute("ID");
    validateID(responseId);
    version = element.getAttribute("Version");
    validateVersion(version);
    String issueInstantStr = element.getAttribute("IssueInstant");
    validateIssueInstant(issueInstantStr);
    destination = element.getAttribute("Destination");
    consent = element.getAttribute("Consent");
    inResponseTo = element.getAttribute("InResponseTo");
    NodeList nList = element.getChildNodes();
    if ((nList != null) && (nList.getLength() > 0)) {
        for (int i = 0; i < nList.getLength(); i++) {
            Node childNode = nList.item(i);
            String cName = childNode.getLocalName();
            if (cName != null) {
                if (cName.equals("Issuer")) {
                    issuer = af.createIssuer((Element) childNode);
                } else if (cName.equals("Signature")) {
                    signatureString = XMLUtils.getElementString((Element) childNode);
                    isSigned = true;
                } else if (cName.equals("Extensions")) {
                    extensions = pf.createExtensions((Element) childNode);
                } else if (cName.equals("NameID")) {
                    nameID = af.createNameID((Element) childNode);
                } else if (cName.equals("EncryptedID")) {
                    encryptedID = af.createEncryptedID((Element) childNode);
                } else if (cName.equals("Status")) {
                    status = pf.createStatus((Element) childNode);
                }
            }
        }
    }
}
Also used : ProtocolFactory(com.sun.identity.saml2.protocol.ProtocolFactory) SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) AssertionFactory(com.sun.identity.saml2.assertion.AssertionFactory) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element)

Aggregations

Assertion (com.sun.identity.saml2.assertion.Assertion)11 EncryptedAssertion (com.sun.identity.saml2.assertion.EncryptedAssertion)11 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)11 ArrayList (java.util.ArrayList)7 List (java.util.List)6 Issuer (com.sun.identity.saml2.assertion.Issuer)5 Element (org.w3c.dom.Element)5 Node (org.w3c.dom.Node)5 NodeList (org.w3c.dom.NodeList)5 ProtocolFactory (com.sun.identity.saml2.protocol.ProtocolFactory)4 X509Certificate (java.security.cert.X509Certificate)4 Date (java.util.Date)4 Iterator (java.util.Iterator)4 AssertionFactory (com.sun.identity.saml2.assertion.AssertionFactory)3 EncInfo (com.sun.identity.saml2.key.EncInfo)3 SAML2MetaException (com.sun.identity.saml2.meta.SAML2MetaException)3 Response (com.sun.identity.saml2.protocol.Response)3 PrivateKey (java.security.PrivateKey)3 Attribute (com.sun.identity.saml2.assertion.Attribute)2 AttributeStatement (com.sun.identity.saml2.assertion.AttributeStatement)2