/**
* 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: AttributeImpl.java,v 1.4 2008/11/10 22:57:05 veiming Exp $
*
*/
/**
* The <code>Attribute</code> element specifies information about the
* listing a sequence of <code>Attribute</code> elements associated with
* the action.
* <p>
* <pre>
* <xs:element name="Attribute" type="xacml-context:AttributeType"/>
* <xs:complexType name="AttributeType">
* <xs:sequence>
* <xs:element ref="xacml-context:AttributeValue"
* maxOccurs="unbounded"/>
* <xs:sequence>
* <xs:attribute name="AttributeId" type="xs:anyURI" use="required"/>
* <xs:attribute name="DataType" type="xs:anyURI" use="required"/>
* <xs:attribute name="Issuer" type="xs:string" use="optional"/>
* <xs:complexType>
* </pre>
*@supported.all.api
*/
private boolean isMutable = true;
/**
* Default constructor
*/
public AttributeImpl() {
}
/**
* This constructor is used to build <code>Attribute</code> object from a
* XML string.
*
* @param xml A <code>java.lang.String</code> representing
* an <code>Attribute</code> object
* @exception XACMLException if it could not process the XML string
*/
} else {
"AttributeImpl.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
*/
}
"AttributeImpl.processElement(): invalid root element");
throw new XACMLException(
"invalid_element"));
}
// First check that we're really parsing an Attribute
"AttributeImpl.processElement(): invalid root element");
throw new XACMLException(
"invalid_element"));
}
try {
.getNodeValue());
} catch (Exception e) {
throw new XACMLException(
"attribute_not_uri"));
}
throw new XACMLException(
"missing_attribute"));
}
try {
.getNodeValue());
} catch (Exception e) {
throw new XACMLException(
"attribute_not_uri"));
}
throw new XACMLException(
"missing_attribute"));
}
try {
if (issuerNode != null)
} catch (Exception e) {
throw new XACMLException(
"attribute_parsing_error"));
}
// now we get the attribute value
}
}
}
}
// make sure we got a value
throw new XACMLException(
"missing_attribute_value"));
}
}
/**
* Returns the issuer of the <code>Attribute</code>.
* @return <code>String</code> representing the issuer. It MAY be an
* x500Name that binds to a public key or some other identification
* exchanged out-of-band by participating entities.
*/
return issuer;
}
/**
* Sets the issuer of the <code>Attribute</code>.
* @param issuer <code>String</code> representing the issuer.
* It MAY be an x500Name that binds to a public key or some other
* identification exchanged out-of-band by participating entities.
* This is optional so return value could be null or an empty
* <code>String</code>.
* @exception XACMLException if the object is immutable
*/
if (!isMutable) {
throw new XACMLException(
"objectImmutable"));
}
}
/**
* Returns the AttributeId of the <code>Attribute</code>
* which the attribute identifier.
* @return the <code>URI</code> representing the data type.
*/
return id;
}
/**
* Sets the attribiteId of the <code>>Attribute</code>
* @param attributeId <code>URI</code> representing the attribite id.
* @exception XACMLException if the object is immutable
*/
if (!isMutable) {
throw new XACMLException(
"objectImmutable"));
}
if (attributeId == null) {
throw new XACMLException(
"null_not_valid"));
}
id = attributeId;
}
/**
* Returns the datatype of the contents of the <code>AttributeValue</code>
* elements. This will be either a primitive datatype defined by XACML 2.0
* specification or a type ( primitive or structured) defined in a
* namespace declared in the <xacml-context> element.
* @return the <code>URI</code> representing the data type.
*/
return type;
}
/**
* Sets the data type of the contents of the <code>AttributeValue</code>
* elements.
* @param dataType <code>URI</code> representing the data type.
* @exception XACMLException if the object is immutable
*/
if (!isMutable) {
throw new XACMLException(
"objectImmutable"));
}
throw new XACMLException(
"null_not_valid"));
}
}
/**
* Returns one to many values in the <code>AttributeValue</code> elements
* of this object
*
* @return the List containing <code>Element</code>s representing the
* <code>AttributeValue</code> of this object
*/
return values;
}
/**
* Sets the <code>AttributeValue</code> elements of this object
*
* @param values a <code>List</code> containing Element representing
* <code>AttributeValue</code> 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"));
}
"StatusMessageImpl.processElement():"
+ "local name missing or incorrect");
throw new XACMLException(
"missing_local_name"));
}
}
}
/**
* Sets the attribute values for this object
*
* @param stringValues a <code>List</code> containing
* <code>String<code> values of this object.
* @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.
*/
throws XACMLException {
if (!isMutable) {
throw new XACMLException(
"objectImmutable"));
}
}
throw new XACMLException(
"null_not_valid"));
}
.append(">\n");
}
}
}
}
/**
* 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
{
//TODO: remove the following 2 lines
includeNSPrefix = false;
declareNS = false;
if (declareNS) {
}
if (includeNSPrefix) {
}
}
}
append("\"");
}
int length = 0;
// ignore trailing ":"
}
if(declareNS) {
// does not seem to work to append namespace TODO
}
}
}
} else { // values are empty put empty tags
// This should not happen, not schema compliant
/*
sb.append("<").append(appendNS)
.append(XACMLConstants.ATTRIBUTE_VALUE);
sb.append(NS).append(">").append("\n");
sb.append("</").append(appendNS)
.append(XACMLConstants.ATTRIBUTE_VALUE);
sb.append(">").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 toXMLString(true, false);
}
/**
* Makes the object immutable
*/
}
/**
* Checks if the object is mutable
*
* @return <code>true</code> if the object is mutable,
* <code>false</code> otherwise
*/
public boolean isMutable() {
return isMutable;
}
}