Search in sources :

Example 1 with AuthorizationDecisionQuery

use of com.sun.identity.saml.protocol.AuthorizationDecisionQuery in project OpenAM by OpenRock.

the class FSRequest method parseQuery.

/**
     * Parses the Query or <code>SubjectQuery</code> represented by
     * a DOM tree Node. It then checks and sets data members if it is a
     * supported query, such as <code>AuthenticationQuery</code>,
     * <code>AttributeQeury</code>, or <code>AuthorizationDecisionQuery</code>.
     *
     * @param child a <code>DOM</code> Node.
     * @throws <code>SAMLException</code> if the <code>Query</code> is invalid.
     */
private void parseQuery(Node child) throws SAMLException {
    NamedNodeMap nm = child.getAttributes();
    int len = nm.getLength();
    String attrName;
    String attrValue;
    Attr attr;
    boolean found = false;
    for (int j = 0; j < len; j++) {
        attr = (Attr) nm.item(j);
        attrName = attr.getLocalName();
        if ((attrName != null) && (attrName.equals("type"))) {
            attrValue = attr.getNodeValue();
            if (attrValue.equals("AuthenticationQueryType")) {
                if (contentType != NOT_SUPPORTED) {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("Request(Element): should" + " contain only one AuthenticationQuery.");
                    }
                    throw new SAMLRequesterException(FSUtils.BUNDLE_NAME, "wrongInput", null);
                }
                contentType = AUTHENTICATION_QUERY;
                query = new AuthenticationQuery((Element) child);
            } else if (attrValue.equals("AuthorizationDecisionQueryType")) {
                if (contentType != NOT_SUPPORTED) {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("Request(Element): should " + "contain one " + "AuthorizationDecisionQuery.");
                    }
                    throw new SAMLRequesterException(FSUtils.BUNDLE_NAME, "wrongInput", null);
                }
                contentType = AUTHORIZATION_DECISION_QUERY;
                query = new AuthorizationDecisionQuery((Element) child);
            } else if (attrValue.equals("AttributeQueryType")) {
                if (contentType != NOT_SUPPORTED) {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("Request(Element): should " + "contain one AttributeQuery.");
                    }
                    throw new SAMLRequesterException(FSUtils.BUNDLE_NAME, "wrongInput", null);
                }
                contentType = ATTRIBUTE_QUERY;
                query = new AttributeQuery((Element) child);
            } else {
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("Request(Element): This type of" + " " + attrName + " is not supported.");
                }
                throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "queryNotSupported", null);
            }
            // check typevalue
            found = true;
            break;
        }
    // if found type attribute
    }
    // if not found type
    if (!found) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("Request(Element): missing" + " xsi:type definition in " + child.getLocalName());
        }
        throw new SAMLRequesterException(FSUtils.BUNDLE_NAME, "wrongInput", null);
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) AttributeQuery(com.sun.identity.saml.protocol.AttributeQuery) Element(org.w3c.dom.Element) SAMLRequesterException(com.sun.identity.saml.common.SAMLRequesterException) AuthenticationQuery(com.sun.identity.saml.protocol.AuthenticationQuery) AuthorizationDecisionQuery(com.sun.identity.saml.protocol.AuthorizationDecisionQuery) Attr(org.w3c.dom.Attr) SAMLResponderException(com.sun.identity.saml.common.SAMLResponderException)

Aggregations

SAMLRequesterException (com.sun.identity.saml.common.SAMLRequesterException)1 SAMLResponderException (com.sun.identity.saml.common.SAMLResponderException)1 AttributeQuery (com.sun.identity.saml.protocol.AttributeQuery)1 AuthenticationQuery (com.sun.identity.saml.protocol.AuthenticationQuery)1 AuthorizationDecisionQuery (com.sun.identity.saml.protocol.AuthorizationDecisionQuery)1 Attr (org.w3c.dom.Attr)1 Element (org.w3c.dom.Element)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1