Class LogicalCondition
- java.lang.Object
-
- com.sun.identity.entitlement.EntitlementConditionAdaptor
-
- com.sun.identity.entitlement.LogicalCondition
-
- All Implemented Interfaces:
EntitlementCondition
- Direct Known Subclasses:
AndCondition,NotCondition,OrCondition
public abstract class LogicalCondition extends EntitlementConditionAdaptor
-
-
Constructor Summary
Constructors Constructor Description LogicalCondition()Constructor.LogicalCondition(Set<EntitlementCondition> eConditions)Constructor.LogicalCondition(Set<EntitlementCondition> eConditions, String pConditionName)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidclearMemberRejection()Clears a recorded refusal.booleanequals(Object obj)Returnstrueif the passed in object is equal to this objectabstract ConditionDecisionevaluate(String realm, Subject subject, String resourceName, Map<String,Set<String>> environment)ReturnsConditionDecisionofEntitlementConditionevaluationSet<EntitlementCondition>getEConditions()Returns the nestedEntitlementCondition(s).StringgetPConditionName()Returns OpenAM policy Condition nameprotected List<org.json.JSONObject>getRejectedMembers()Returns the refused members, kept verbatim for re-emission bytoJSONObject().StringgetState()Returns state of the object.inthashCode()Returns hash code of the objectbooleanhasRejectedMemberInSubtree()Returns whether this wrapper, or any logical condition nested below it, had a member class name refused bysetState(String).booleanisMemberRejected()Returns whethersetState(String)refused a member class name, leaving this wrapper with fewer members than the stored policy declares.protected voidmarkMemberRejected(org.json.JSONObject rejectedMember)Records that a member could not be rebuilt from the state being applied, keeping the member's JSON so thattoJSONObject()can write it back out.voidsetEConditions(Set<EntitlementCondition> eConditions)Sets the nestedEntitlementCondition(s).voidsetPConditionName(String pConditionName)Sets OpenAM policy Condition namevoidsetState(String state)Sets state of the objectorg.json.JSONObjecttoJSONObject()Returns JSONObject mapping of the objectStringtoString()Returns string representation of the objectvoidvalidate()Checks that this condition is configured correctly.-
Methods inherited from class com.sun.identity.entitlement.EntitlementConditionAdaptor
getDisplayType, init, setDisplayType, setState, toJSONObject
-
-
-
-
Constructor Detail
-
LogicalCondition
public LogicalCondition()
Constructor.
-
LogicalCondition
public LogicalCondition(Set<EntitlementCondition> eConditions)
Constructor.- Parameters:
eConditions- wrappedEntitlementCondition(s)
-
LogicalCondition
public LogicalCondition(Set<EntitlementCondition> eConditions, String pConditionName)
Constructor.- Parameters:
eConditions- wrappedEntitlementCondition(s)pConditionName- subject name as used in OpenAM policy, this is relevant only when UserECondition was created from OpenAM policy Condition
-
-
Method Detail
-
setState
public void setState(String state)
Sets state of the object- Parameters:
state- State of the object encoded as string
-
getState
public String getState()
Returns state of the object.- Returns:
- state of the object encoded as string.
-
evaluate
public abstract ConditionDecision evaluate(String realm, Subject subject, String resourceName, Map<String,Set<String>> environment) throws EntitlementException
ReturnsConditionDecisionofEntitlementConditionevaluation- Parameters:
realm- Realm name.subject- EntitlementCondition who is under evaluation.resourceName- Resource name.environment- Environment parameters.- Returns:
ConditionDecisionofEntitlementConditionevaluation- Throws:
EntitlementException- if error occurs.
-
setEConditions
public void setEConditions(Set<EntitlementCondition> eConditions)
Sets the nestedEntitlementCondition(s).- Parameters:
eConditions- the nestedEntitlementCondition(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 thattoJSONObject()can write it back out. Subclasses that read the member themselves -NotConditionkeeps a single member of its own - have to call this, or a refusal below them stays invisible tohasRejectedMemberInSubtree()and an enclosingNOTnegates the resulting failure back into a grant.- Parameters:
rejectedMember- the refused member as it appeared in the state, ornullwhen 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 bytoJSONObject().- Returns:
- the refused members; never
null.
-
isMemberRejected
public boolean isMemberRejected()
Returns whethersetState(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: an empty member set is satisfied both in
AndConditionand inOrCondition, so the truncated wrapper would grant what the stored policy restricts.AndConditionhas to fail on any refusal,OrConditiononly when nothing survived - dropping a member from a non-empty OR can only make it stricter. A subclass that negates its member must usehasRejectedMemberInSubtree()instead.- Returns:
trueif at least one member was rejected.
-
hasRejectedMemberInSubtree
public boolean hasRejectedMemberInSubtree()
Returns whether this wrapper, or any logical condition nested below it, had a member class name refused bysetState(String).isMemberRejected()deliberately reports this wrapper's own refusal only: forAndCondition/OrConditiona refusal further down is already handled where it happened, because the damaged member fails closed and a failing member can only make an AND or an OR stricter. Negation is the exception -NotConditionturns its member's decision around, so the damaged member's fail-closed decision would come back out of theNOTas a grant. It has to look at the whole subtree.- Returns:
trueif a member was refused anywhere in this subtree.
-
getEConditions
public Set<EntitlementCondition> getEConditions()
Returns the nestedEntitlementCondition(s).- Returns:
- the nested
EntitlementCondition(s).
-
setPConditionName
public void setPConditionName(String pConditionName)
Sets OpenAM policy Condition name- Parameters:
pConditionName- subject name as used in OpenAM policy, this is relevant only when UserECondition was created from OpenAM policy Condition
-
getPConditionName
public String getPConditionName()
Returns OpenAM policy Condition name- Returns:
- subject name as used in OpenAM policy, this is relevant only when UserECondition was created from OpenAM policy Condition
-
toJSONObject
public org.json.JSONObject toJSONObject() throws org.json.JSONExceptionReturns 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
-
equals
public boolean equals(Object obj)
Returnstrueif the passed in object is equal to this object- Overrides:
equalsin classEntitlementConditionAdaptor- Parameters:
obj- object to check for equality- Returns:
trueif the passed in object is equal to this object
-
hashCode
public int hashCode()
Returns hash code of the object- Overrides:
hashCodein classEntitlementConditionAdaptor- Returns:
- hash code of the object
-
validate
public void validate() throws EntitlementExceptionDescription copied from interface:EntitlementConditionChecks that this condition is configured correctly. ThrowsEntitlementExceptionif not with an informative message to display to the user creating/updating the policy.- Throws:
EntitlementException- if the configuration state is not valid.
-
-