/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: RequestImpl.java,v 1.4 2008/11/10 22:57:05 veiming Exp $
*
*/
/**
* The <code>Request</code> element is the top-level element in the XACML
* context schema. Its an abstraction layer used by the policy language.
* It contains <code>Subject</code>, <code>Resource</code>, <code>Action
* </code> and <code>Environment<code> elements.
* <p>
* <pre>
* <xs:complexType name="RequestType">
* <xs:sequence>
* <xs:element ref="xacml-context:Subject" maxOccurs="unbounded"/>
* <xs:element ref="xacml-context:Resource" maxOccurs="unbounded"/>
* <xs:element ref="xacml-context:Action"/>
* <xs:element ref="xacml-context:Environment"/>
* <xs:sequence>
* <xs:complexType>
* </pre>
*@supported.all.api
*/
private boolean isMutable = true;
static {
};
/**
* Default constructor
*/
public RequestImpl() {
}
/**
* This constructor is used to build <code>Request</code> object from a
* XML string.
*
* @param xml A <code>java.lang.String</code> representing
* a <code>Request</code> object
* @exception XACMLException if it could not process the XML string
*/
} else {
"RequestImpl.processElement(): invalid XML input");
throw new XACMLException(
"errorObtainingElement"));
}
}
/**
* This constructor is used to build <code>Request</code> object from a
* block of existing XML that has already been built into a DOM.
*
* @param element A <code>org.w3c.dom.Element</code> representing
* DOM tree for <code>Request</code> object
* @exception XACML2Exception if it could not process the Element
*/
}
"RequestImpl.processElement(): invalid root element");
throw new XACMLException(
"invalid_element"));
}
"RequestImpl.processElement(): local name missing");
throw new XACMLException(
"missing_local_name"));
}
"RequestImpl.processElement(): invalid local name " +
elemName);
throw new XACMLException(
"invalid_local_name"));
}
// starts processing subelements
if (numOfNodes < 1) {
"RequestImpl.processElement(): request has no subelements");
throw new XACMLException(
"missing_subelements"));
}
int i = 0;
while ( i < numOfNodes) {
}
i++;
}
+ " request has no subelements");
throw new XACMLException(
"missing_subelements"));
}
// The first subelement should be <Subject>
" the first element is not <Subject>");
throw new XACMLException(
"missing_subelement_subject"));
}
{
+"category in subject not supported");
throw new XACMLException(
"unsupported_subject_category"));
}
boolean resourceFound = false;
boolean actionFound = false;
boolean envFound = false;
// so far <Resource> is not encountered
// Go through next sub elements for <Subject> and <Resource>
// The next subelement may be <Resource> or <Subject>
if (resourceFound) {
// all <Subject> should be before <Resource>
+"processElement(): <Subject> should be "
+ "before <Resource>");
throw new XACMLException(
"element_out_of_place"));
} else { // found another resource
}
} else { // childname is resource
resourceFound = true;
}
if (!resourceFound) {
+"processElement(): <Resource> should be "
+ "before <Action>");
throw new XACMLException(
"element_out_of_place"));
} else {
actionFound = true;
}
if (!resourceFound || !actionFound){
+"processElement(): <Resource> and "
+"Action should be before <Environment>");
throw new XACMLException(
"element_out_of_place"));
} else {
envFound = true;
}
}
}
}
+"of required elements are missing");
throw new XACMLException(
"missing_subelements"));
}
}
/**
* Returns the one to many <code>Subject</code> elements of this object
*
* @return the <code>Subject</code> elements of this object
*/
return subjects;
}
/**
* Sets the one to many <code>Subject</code> elements of this object
*
* @param subjects the one to many <code>Subject</code> elements of this
* object
*
* @exception XACMLException if the object is immutable
* An object is considered <code>immutable</code> if <code>
* makeImmutable()</code> has been invoked on it. It can
* be determined by calling <code>isMutable</code> on the object.
*/
if (!isMutable) {
throw new XACMLException(
"objectImmutable"));
}
throw new XACMLException(
"null_not_valid"));
}
}
/**
* Returns the one to many <code>Resource</code> elements of this object
*
* @return the <code>Resource</code> elements of this object
*/
return resources;
}
/**
* Sets the one to many <code>Resource</code> elements of this object
*
* @param resources the one to many <code>Resource</code> elements of this
* object
*
* @exception XACMLException if the object is immutable
* An object is considered <code>immutable</code> if <code>
* makeImmutable()</code> has been invoked on it. It can
* be determined by calling <code>isMutable</code> on the object.
*/
if (!isMutable) {
throw new XACMLException(
"objectImmutable"));
}
throw new XACMLException(
}
}
/**
* Returns the instance of <code>Action</code> element
*
* @return the instance of <code>Action</code>.
*/
return action;
}
/**
* Sets the instance of <code>Action</code>
*
* @param argAction instance of <code>Action</code>.
*
* @exception XACMLException if the object is immutable
* An object is considered <code>immutable</code> if <code>
* makeImmutable()</code> has been invoked on it. It can
* be determined by calling <code>isMutable</code> on the object.
*/
if (!isMutable) {
throw new XACMLException(
"objectImmutable"));
}
throw new XACMLException(
}
}
/**
* Returns the instance of <code>Environment</code> element.
*
* @return the instance of <code>Environment</code>.
*/
return env;
}
/**
* Sets the instance of the <code>Environment</code>
*
* @param argEnv instance of <code>Environment</code>.
* @throws XACMLException if the object is immutable
* An object is considered <code>immutable</code> if <code>
* makeImmutable()</code> has been invoked on it. It can
* be determined by calling <code>isMutable</code> on the object.
*/
if (!isMutable) {
throw new XACMLException(
"objectImmutable"));
}
throw new XACMLException(
}
}
/**
* Returns a <code>String</code> representation of this object
* @param includeNSPrefix Determines whether or not the namespace qualifier
* is prepended to the Element when converted
* @param declareNS Determines whether or not the namespace is declared
* within the Element.
* @return a string representation of this object
* @exception XACMLException if conversion fails for any reason
*/
throws XACMLException {
if (declareNS) {
}
if (includeNSPrefix) {
}
int length = 0;
for (int i = 0; i < length; i++) {
}
}
for (int i = 0; i < length; i++) {
}
}
}
}
append(">\n");
}
/**
* Returns a string representation of this object
*
* @return a string representation of this object
* @exception XACMLException if conversion fails for any reason
*/
return this.toXMLString(true, false);
}
/**
* Makes the object immutable
*/
public void makeImmutable() {}
/**
* Checks if the object is mutable
*
* @return <code>true</code> if the object is mutable,
* <code>false</code> otherwise
*/
public boolean isMutable() {
return isMutable;
}
}