8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: ResourceResultRequest.java,v 1.3 2008/06/25 05:43:54 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Portions Copyrighted [2011] [ForgeRock AS]
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This <code>ResourceResultRequest</code> class represents a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * GetResourceResults XML document. The GetResourceResults
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DTD is defined as the following:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <!-- GetResourceResults element is used by the client to request
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the policy evaluation decisions for a particular user regarding
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * a given service and a resource and possibly its sub resources.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The attribute userSSOToken provides the identity of the user.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The attribute serviceName specifies the service name and
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * resourceName specifies the name of the resource for which the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * policy is evaluated.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The attribute resourceScope gives the scope of the resources in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * terms of the policy evaluation. The value of the attribute could
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * be "self", "strict-subtree", or "subtree". Value "self" means the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * resource node itself only; value "strict-subtree" means the strict
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * subtree of the root, no wildcard matching subtree included; value
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "subtree" means to get all the subtrees with the resource node being
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the root of one of the subtree, the other subtree roots are those that
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * match the resourceName by wildcard.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The sub-element EnvParameters provides the environment
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * information which may be useful during the policy evaluation.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The sub-element GetResponseDecisions requests for the values for
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * a set of user response attributes.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <!ELEMENT GetResourceResults ( EnvParameters?, GetResponseDecisions? ) >
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <!ATTLIST GetResourceResults
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * userSSOToken CDATA #IMPLIED
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * serviceName NMTOKEN #REQUIRED
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * resourceName CDATA #REQUIRED
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * resourceScope (self | strict-subtree | subtree) "strict-subtree"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String USER_SSOTOKEN = "userSSOToken";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String SERVICE_NAME = "serviceName";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String RESOURCE_NAME = "resourceName";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String RESOURCE_SCOPE = "resourceScope";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String ENV_PARAMETERS = "EnvParameters";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String GET_RESPONSE_DECISIONS = "GetResponseDecisions";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String RESOURCE_SCOPE_SELF = "self";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String RESOURCE_SCOPE_STRICT_SUBTREE = "strict-subtree";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String RESOURCE_SCOPE_SUBTREE = "subtree";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String RESPONSE_ATTRIBUTES_ONLY = "response-attributes-only";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Default constructor for <code>ResourceResultRequest</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the user's single sign-on token.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return user's single sign-on token.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the user's single sign-on token.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param ssoToken user's single sign-on token.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the service name of the request.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the service name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the service name of the request.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name the service name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the resource name of the request.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the resource name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the resource name of the request.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param name Resource name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the resource scope of the request.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the resource scope.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the resource scope of the request.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param scope Resource scope.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the environment parameters.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the environment parameters.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the environment parameters.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param envs the environment parameters.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the response attributes.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return the response attributes.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets the response attributes.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param attrs response attributes.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns <code>ResourceResultRequest</code> object constructed from a
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param pNode the XML DOM node for the <code>ResourceResultRequest</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return constructed <code>ResourceResultRequest</code> object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static ResourceResultRequest parseXML(Node pNode)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ResourceResultRequest resResultReq = new ResourceResultRequest();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attr = XMLUtils.getNodeAttributeValue(pNode, USER_SSOTOKEN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("ResourceResultRequest: user sso toekn is null");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attr = XMLUtils.getNodeAttributeValue(pNode, SERVICE_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("ResourceResultRequest: missing attribute " +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw new PolicyEvaluationException(ResBundleUtils.rbName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attr = XMLUtils.getNodeAttributeValue(pNode, RESOURCE_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("ResourceResultRequest: missing attribute " +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw new PolicyEvaluationException(ResBundleUtils.rbName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster attr = XMLUtils.getNodeAttributeValue(pNode, RESOURCE_SCOPE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /* if the resource scope is not specified in the request,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * we take the default value RESOURCE_SCOPE_STRICT_SUBTREE
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster resResultReq.setResourceScope(RESOURCE_SCOPE_STRICT_SUBTREE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("ResourceResultRequest: invalid value "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + attr + " set for attribute " + RESOURCE_SCOPE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw new PolicyEvaluationException(ResBundleUtils.rbName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Node node = XMLUtils.getChildNode(pNode, ENV_PARAMETERS);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster node = XMLUtils.getChildNode(pNode, GET_RESPONSE_DECISIONS);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns a XML representation of this object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return a XML representation of this object.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .append(XMLUtils.escapeSpecialCharacters(resourceName))
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster xmlsb.append(PolicyUtils.envParametersToXMLString(envParms));