Search in sources :

Example 31 with Subject

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

the class SubjectQueryAbstractImpl method parseDOMChileElements.

/** 
     * Parses child elements of the Docuemnt Element for this object.
     * 
     * @param iter the child elements iterator.
     * @throws SAML2Exception if error parsing the Document Element.
     */
protected void parseDOMChileElements(ListIterator iter) throws SAML2Exception {
    super.parseDOMChileElements(iter);
    if (iter.hasNext()) {
        Element childElement = (Element) iter.next();
        String localName = childElement.getLocalName();
        if (SAML2Constants.SUBJECT.equals(localName)) {
            subject = AssertionFactory.getInstance().createSubject(childElement);
            return;
        }
    }
    if (SAML2SDKUtils.debug.messageEnabled()) {
        SAML2SDKUtils.debug.message("SubjectQueryAbstractImpl." + "parseDOMChileElements: Subject is expected");
    }
    throw new SAML2Exception(SAML2SDKUtils.bundle.getString("schemaViolation"));
}
Also used : SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) Element(org.w3c.dom.Element)

Example 32 with Subject

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

the class XACMLRequestProcessor method processRequest.

/**
     * Processes an XACML context Request and returns an XACML context 
     * Response. 
     *
     * @param xacmlRequest XACML context Request. This describes the
     *        Resource(s), Subject(s), Action, Environment of the request
     *        and corresponds to XACML context schema element Request.
     *        One would contruct this Request object using XACML client SDK.
     *
     * @param pdpEntityId EntityID of PDP
     * @param pepEntityId EntityID of PEP
     * @return XACML context Response. This corresponds to 
     *               XACML context schema element Response
     * @exception XACMLException if request could not be processed 
     */
public Response processRequest(Request xacmlRequest, String pdpEntityId, String pepEntityId) throws XACMLException, SAML2Exception {
    if (XACMLSDKUtils.debug.messageEnabled()) {
        XACMLSDKUtils.debug.message("XACMLRequestProcessor.processRequest(), entering" + ":pdpEntityId=" + pdpEntityId + ":pepEntityId=" + pepEntityId + ":xacmlRequest=\n" + xacmlRequest.toXMLString(true, true));
    }
    XACMLAuthzDecisionQuery samlpQuery = createXACMLAuthzDecisionQuery(xacmlRequest);
    //set InputContextOnly
    samlpQuery.setInputContextOnly(true);
    //set ReturnContext
    samlpQuery.setReturnContext(true);
    if (XACMLSDKUtils.debug.messageEnabled()) {
        XACMLSDKUtils.debug.message("XACMLRequestProcessor.processRequest()," + "samlpQuery=\n" + samlpQuery.toXMLString(true, true));
    }
    com.sun.identity.saml2.protocol.Response samlpResponse = QueryClient.processXACMLQuery(samlpQuery, pepEntityId, pdpEntityId);
    if (XACMLSDKUtils.debug.messageEnabled()) {
        XACMLSDKUtils.debug.message("XACMLRequestProcessor.processRequest()," + ":samlpResponse=\n" + samlpResponse.toXMLString(true, true));
    }
    Response xacmlResponse = null;
    List assertions = samlpResponse.getAssertion();
    if (assertions != null) {
        Assertion assertion = (Assertion) (assertions.get(0));
        if (assertion != null) {
            List statements = assertion.getStatements();
            if (statements.size() > 0) {
                String statementString = (String) (statements.get(0));
                if (statementString != null) {
                    XACMLAuthzDecisionStatement statement = ContextFactory.getInstance().createXACMLAuthzDecisionStatement(statementString);
                    if (XACMLSDKUtils.debug.messageEnabled()) {
                        XACMLSDKUtils.debug.message("XACMLRequestProcessor.processRequest()," + ":xacmlAuthzDecisionStatement=\n" + statement.toXMLString(true, true));
                    }
                    if (statement != null) {
                        xacmlResponse = statement.getResponse();
                        if (xacmlResponse != null) {
                            if (XACMLSDKUtils.debug.messageEnabled()) {
                                XACMLSDKUtils.debug.message("XACMLRequestProcessor.processRequest()" + ",returning :xacmlResponse=\n" + xacmlResponse.toXMLString(true, true));
                            }
                            return xacmlResponse;
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : Response(com.sun.identity.xacml.context.Response) XACMLAuthzDecisionStatement(com.sun.identity.xacml.saml2.XACMLAuthzDecisionStatement) Assertion(com.sun.identity.saml2.assertion.Assertion) XACMLAuthzDecisionQuery(com.sun.identity.xacml.saml2.XACMLAuthzDecisionQuery) List(java.util.List)

Aggregations

SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)19 Subject (com.sun.identity.saml2.assertion.Subject)15 ArrayList (java.util.ArrayList)15 List (java.util.List)14 Date (java.util.Date)10 NameID (com.sun.identity.saml2.assertion.NameID)9 Assertion (com.sun.identity.saml2.assertion.Assertion)8 AttributeStatement (com.sun.identity.saml2.assertion.AttributeStatement)6 EncryptedAssertion (com.sun.identity.saml2.assertion.EncryptedAssertion)6 EncryptedID (com.sun.identity.saml2.assertion.EncryptedID)6 SubjectConfirmation (com.sun.identity.saml2.assertion.SubjectConfirmation)6 Map (java.util.Map)6 Issuer (com.sun.identity.saml2.assertion.Issuer)5 HashMap (java.util.HashMap)5 Element (org.w3c.dom.Element)5 AssertionFactory (com.sun.identity.saml2.assertion.AssertionFactory)4 AuthnStatement (com.sun.identity.saml2.assertion.AuthnStatement)4 SubjectConfirmationData (com.sun.identity.saml2.assertion.SubjectConfirmationData)4 Node (org.w3c.dom.Node)4 NodeList (org.w3c.dom.NodeList)4