Class LogicalSubject

    • Constructor Detail

      • LogicalSubject

        public LogicalSubject()
        Constructor.
      • LogicalSubject

        public LogicalSubject​(Set<EntitlementSubject> eSubjects)
        Constructor.
        Parameters:
        eSubjects - wrapped EntitlementSubject(s)
      • LogicalSubject

        public LogicalSubject​(Set<EntitlementSubject> eSubjects,
                              String pSubjectName)
        Constructor.
        Parameters:
        eSubjects - wrapped EntitlementSubject(s)
        pSubjectName - subject name as used in OpenAM policy, this is relevant only when UserESubject was created from OpenAM policy Subject
    • Method Detail

      • setState

        public void setState​(String state)
        Sets state of the object
        Specified by:
        setState in interface EntitlementSubject
        Parameters:
        state - State of the object encoded as string
      • getState

        public String getState()
        Returns state of the object
        Specified by:
        getState in interface EntitlementSubject
        Returns:
        state of the object encoded as string
      • setESubjects

        public void setESubjects​(Set<EntitlementSubject> eSubjects)
        Sets the nested EntitlementSubject(s)
        Parameters:
        eSubjects - the nested EntitlementSubject(s)
      • markMemberRejected

        protected void markMemberRejected​(org.json.JSONObject rejectedMember)
        Records that a member could not be rebuilt from the state being applied, keeping the member's JSON so that toJSONObject() can write it back out. Subclasses that read the member themselves - NotSubject keeps a single member of its own - have to call this, or a refusal below them stays invisible to hasRejectedMemberInSubtree() and an enclosing NOT negates the resulting deny back into a match.
        Parameters:
        rejectedMember - the refused member as it appeared in the state, or null when it was not even a JSON object; an empty object is then re-emitted in its place, which the next load refuses again and so keeps the wrapper fail-closed across a save.
      • clearMemberRejection

        protected void clearMemberRejection()
        Clears a recorded refusal. Called whenever the members are redefined wholesale, so that programmatic construction is unaffected by what a previous state string contained.
      • getRejectedMembers

        protected List<org.json.JSONObject> getRejectedMembers()
        Returns the refused members, kept verbatim for re-emission by toJSONObject().
        Returns:
        the refused members; never null.
      • isMemberRejected

        public boolean isMemberRejected()
        Returns whether setState(String) refused a member class name, leaving this wrapper with fewer members than the stored policy declares.

        Any subclass whose evaluation gets weaker as members are dropped must consult this before evaluating: AndSubject is satisfied by an empty member set, so evaluating the truncated set would grant what the stored policy restricts. OrSubject denies on an empty set and only gets stricter as members are dropped, so it needs no guard. A subclass that negates its member must use hasRejectedMemberInSubtree() instead.

        Returns:
        true if at least one member was rejected.
      • hasRejectedMemberInSubtree

        public boolean hasRejectedMemberInSubtree()
        Returns whether this wrapper, or any logical subject nested below it, had a member class name refused by setState(String).

        isMemberRejected() deliberately reports this wrapper's own refusal only: for AndSubject/OrSubject a refusal further down is already handled where it happened, because the damaged member denies and a denying member can only make an AND or an OR stricter. Negation is the exception - NotSubject turns its member's decision around, so the damaged member's deny would come back out of the NOT as a match. It has to look at the whole subtree.

        Returns:
        true if a member was refused anywhere in this subtree.
      • getESubjects

        public Set<EntitlementSubject> getESubjects()
        Returns the nested EntitlementSubject(s)
        Returns:
        the nested EntitlementSubject(s)
      • setPSubjectName

        public void setPSubjectName​(String pSubjectName)
        Sets OpenAM policy Subject name
        Parameters:
        pSubjectName - subject name as used in OpenAM policy, this is relevant only when UserESubject was created from OpenAM policy Subject
      • getPSubjectName

        public String getPSubjectName()
        Returns OpenAM policy Subject name
        Returns:
        subject name as used in OpenAM policy, this is relevant only when UserESubject was created from OpenAM policy Subject
      • toJSONObject

        public org.json.JSONObject toJSONObject()
                                         throws org.json.JSONException
        Returns JSONObject mapping of the object
        Returns:
        JSONObject mapping of the object
        Throws:
        org.json.JSONException - if can not map to JSONObject
      • toString

        public String toString()
        Returns string representation of the object
        Overrides:
        toString in class Object
        Returns:
        string representation of the object
      • equals

        public boolean equals​(Object obj)
        Returns true if the passed in object is equal to this object
        Overrides:
        equals in class Object
        Parameters:
        obj - object to check for equality
        Returns:
        true if the passed in object is equal to this object
      • hashCode

        public int hashCode()
        Returns hash code of the object
        Overrides:
        hashCode in class Object
        Returns:
        hash code of the object
      • isIdentity

        public boolean isIdentity()
        Returns true is this subject is an identity object.
        Specified by:
        isIdentity in interface EntitlementSubject
        Returns:
        true is this subject is an identity object.