Class SubjectImpl

  • All Implemented Interfaces:
    Subject

    @SupportedAll
    public class SubjectImpl
    extends Object
    implements Subject
    The Subject element specifies information about a subject of the Request context by listing a sequence of Attribute elements associated with the subject. A subject is an entity associated with the access request.

     <xs:complexType name="SubjectType">
      <xs:sequence>
       <xs:element ref="xacml-context:Attribute" minOccurs="0"
          maxOccurs="unbounded"/>
     <xs:sequence>
     <xs:attribute name="SubjectCategory" type="xs:anyURI" 
      default="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject"/>
     <xs:complexType>
     
    • Constructor Detail

      • SubjectImpl

        public SubjectImpl()
        Default constructor
      • SubjectImpl

        public SubjectImpl​(String xml)
                    throws XACMLException
        This constructor is used to build Subject object from a XML string.
        Parameters:
        xml - A java.lang.String representing a Subject object
        Throws:
        XACMLException - if it could not process the XML string
      • SubjectImpl

        public SubjectImpl​(Element element)
                    throws XACMLException
        This constructor is used to build Subject object from a block of existing XML that has already been built into a DOM.
        Parameters:
        element - A org.w3c.dom.Element representing DOM tree for Subject object
        Throws:
        XACMLException - if it could not process the Element
    • Method Detail

      • getAttributes

        public List getAttributes()
        Returns zero to many Attribute elements of this object If no attributes and present, empty List will be returned. Typically a Subject element will contain an Attribute with an AttributeId of "urn:oasis:names:tc:xacml:1.0:subject:subject-id", containing the identity of the Subject
        Specified by:
        getAttributes in interface Subject
        Returns:
        the Attribute elements of this object
      • setAttributes

        public void setAttributes​(List attributes)
                           throws XACMLException
        Sets the Attribute elements of this object
        Specified by:
        setAttributes in interface Subject
        Parameters:
        attributes - Attribute elements of this object attributes could be an empty List, if no attributes are present.
        Throws:
        XACMLException - if the object is immutable An object is considered immutable if makeImmutable() has been invoked on it. It can be determined by calling isMutable on the object.
      • getSubjectCategory

        public URI getSubjectCategory()
        Returns the SubjectCategory of this object. This is optional so could be null if not defined. This attribute indicates the role that the parent Subject played in the formation of the access request. If this attribute is not present in the Subject element, then the default value of urn:oasis:names:tc:xacml:1.0:subject-category:access-subject SHALL be used, indicating that the Subject represents the entity ultimately responsible for initiating the access request.
        Specified by:
        getSubjectCategory in interface Subject
        Returns:
        URI representing the SubjectCategory of this object.
      • setSubjectCategory

        public void setSubjectCategory​(URI subjectCategory)
                                throws XACMLException
        Sets the SubjectCategory of this object
        Specified by:
        setSubjectCategory in interface Subject
        Parameters:
        subjectCategory - URI
        Throws:
        XACMLException - if the object is immutable An object is considered immutable if makeImmutable() has been invoked on it. It can be determined by calling isMutable on the object.
      • toXMLString

        public String toXMLString​(boolean includeNSPrefix,
                                  boolean declareNS)
                           throws XACMLException
        Returns a String representation of this object
        Specified by:
        toXMLString in interface Subject
        Parameters:
        includeNSPrefix - Determines whether or not the namespace qualifier is prepended to the Element when converted
        declareNS - Determines whether or not the namespace is declared within the Element.
        Returns:
        a string representation of this object
        Throws:
        XACMLException - if conversion fails for any reason
      • toXMLString

        public String toXMLString()
                           throws XACMLException
        Returns a string representation of this object
        Specified by:
        toXMLString in interface Subject
        Returns:
        a string representation of this object
        Throws:
        XACMLException - if conversion fails for any reason
      • makeImmutable

        public void makeImmutable()
        Makes the object immutable
        Specified by:
        makeImmutable in interface Subject
      • isMutable

        public boolean isMutable()
        Checks if the object is mutable
        Specified by:
        isMutable in interface Subject
        Returns:
        true if the object is mutable, false otherwise