Package com.sun.identity.entitlement
Class Privilege
- java.lang.Object
-
- com.sun.identity.entitlement.Privilege
-
- All Implemented Interfaces:
IPrivilege
- Direct Known Subclasses:
OpenSSOPrivilege
public abstract class Privilege extends Object implements IPrivilege
Class representing entitlement privilege
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPPLICATION_ATTRIBUTEapplication index keystatic SearchAttributeAPPLICATION_SEARCH_ATTRIBUTEapplication search attributestatic StringCREATED_BY_ATTRIBUTECreated by index keystatic SearchAttributeCREATED_BY_SEARCH_ATTRIBUTECreated by search attributestatic StringCREATION_DATE_ATTRIBUTECreation date index keystatic SearchAttributeCREATION_DATE_SEARCH_ATTRIBUTECreation date index keystatic StringDESCRIPTION_ATTRIBUTEPrivilege description attribute name,static SearchAttributeDESCRIPTION_SEARCH_ATTRIBUTEPrivilege description search attribute name,static StringLAST_MODIFIED_BY_ATTRIBUTELast modified by index keystatic SearchAttributeLAST_MODIFIED_BY_SEARCH_ATTRIBUTELast modified by search attributestatic StringLAST_MODIFIED_DATE_ATTRIBUTELast modified date index keystatic SearchAttributeLAST_MODIFIED_DATE_SEARCH_ATTRIBUTELast modified date index keystatic StringNAME_ATTRIBUTEName attribute name,static SearchAttributeNAME_SEARCH_ATTRIBUTEName search attributestatic NoSubjectNOT_SUBJECTstatic StringPRIVILEGE_CLASS_PROPERTYThe system property defining the default Privilege sub-class to use when constructing new privilege instances.static StringRESOURCE_MACRO_ATTRIBUTEMacro used in conditionstatic StringRESOURCE_MACRO_SELFMacro used in resource namestatic StringRESOURCE_TYPE_UUID_ATTRIBUTEResource type uuid reference.static SearchAttributeRESOURCE_TYPE_UUID_SEARCH_ATTRIBUTEResource type uuid reference.
-
Constructor Summary
Constructors Constructor Description Privilege()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcanonicalizeResources(Subject adminSubject, String realm)Canonicalizes resource name before persistence.protected ConditionDecisiondoesConditionMatch(String realm, Subject subject, String resourceName, Map<String,Set<String>> environment)protected SubjectDecisiondoesSubjectMatch(Subject adminSubject, String realm, Subject subject, String resourceName, Map<String,Set<String>> environment)booleanequals(Object obj)Returnstrueif the passed in object is equal to this objectabstract List<Entitlement>evaluate(Subject adminSubject, String realm, Subject subject, String applicationName, String normalisedResourceName, String requestedResourceName, Set<String> actionNames, Map<String,Set<String>> environment, boolean recursive, Object context)Returns a list of entitlement for a given subject, resource name and environment.Set<String>getApplicationIndexes()protected Map<String,Set<String>>getAttributes(Subject adminSubject, String realm, Subject subject, String resourceName, Map<String,Set<String>> environment)EntitlementConditiongetCondition()Returns the eCondition the privilegeStringgetCreatedBy()Returns the user ID who created the policy.longgetCreationDate()Returns creation date.StringgetDescription()Returns the description of the privilege.EntitlementgetEntitlement()Returns entitlement defined in the privilegestatic PrivilegegetInstance(org.json.JSONObject jo)StringgetLastModifiedBy()Returns the user ID who last modified the policy.longgetLastModifiedDate()Returns last modified date.StringgetName()Returns the name of the privilege.static PrivilegegetNewInstance()Returns entitlement privilege.static PrivilegegetNewInstance(String jo)static PrivilegegetNewInstance(org.json.JSONObject jo)Set<ResourceAttribute>getResourceAttributes()Returns the eResurceAttributes of the privilegeResourceSaveIndexesgetResourceSaveIndexes(Subject adminSubject, String realm)Returns resource save indexes.StringgetResourceTypeUuid()Retrieves the resource type uuid that is associated with this policy.EntitlementSubjectgetSubject()Returns the eSubject the privilegePrivilegeTypegetType()Returns privilege Type.inthashCode()Returns hash code of the objectprotected abstract voidinit(org.json.JSONObject jo)booleanisActive()Returnstrueif this privilege is active.voidsetActive(boolean active)Sets this privilege active/inactive.voidsetApplicationIndexes(Set<String> indexes)voidsetCondition(EntitlementCondition condition)Sets condition.voidsetCreatedBy(String createdBy)Sets the user ID who created the policy.voidsetCreationDate(long creationDate)Sets the creation date.voidsetDescription(String description)Sets the description of the privilege.voidsetEntitlement(Entitlement entitlement)Sets entitlement.voidsetLastModifiedBy(String lastModifiedBy)Sets the user ID who last modified the policy.voidsetLastModifiedDate(long lastModifiedDate)Sets the last modified date.voidsetName(String name)Sets name.voidsetResourceAttributes(Set<ResourceAttribute> set)Sets resource attributes.voidsetResourceTypeUuid(String resourceTypeUuid)Sets the resource type uuid that this policy makes reference to.voidsetSubject(EntitlementSubject eSubject)Sets entitlement subject.org.json.JSONObjecttoJSONObject()Returns JSONObject mapping of the objectorg.json.JSONObjecttoMinimalJSONObject()StringtoString()Returns string representation of the object
-
-
-
Field Detail
-
PRIVILEGE_CLASS_PROPERTY
public static final String PRIVILEGE_CLASS_PROPERTY
The system property defining the default Privilege sub-class to use when constructing new privilege instances.- See Also:
- Constant Field Values
-
APPLICATION_ATTRIBUTE
public static final String APPLICATION_ATTRIBUTE
application index key- See Also:
- Constant Field Values
-
APPLICATION_SEARCH_ATTRIBUTE
public static final SearchAttribute APPLICATION_SEARCH_ATTRIBUTE
application search attribute
-
CREATED_BY_ATTRIBUTE
public static final String CREATED_BY_ATTRIBUTE
Created by index key- See Also:
- Constant Field Values
-
CREATED_BY_SEARCH_ATTRIBUTE
public static final SearchAttribute CREATED_BY_SEARCH_ATTRIBUTE
Created by search attribute
-
LAST_MODIFIED_BY_ATTRIBUTE
public static final String LAST_MODIFIED_BY_ATTRIBUTE
Last modified by index key- See Also:
- Constant Field Values
-
LAST_MODIFIED_BY_SEARCH_ATTRIBUTE
public static final SearchAttribute LAST_MODIFIED_BY_SEARCH_ATTRIBUTE
Last modified by search attribute
-
CREATION_DATE_ATTRIBUTE
public static final String CREATION_DATE_ATTRIBUTE
Creation date index key- See Also:
- Constant Field Values
-
CREATION_DATE_SEARCH_ATTRIBUTE
public static final SearchAttribute CREATION_DATE_SEARCH_ATTRIBUTE
Creation date index key
-
LAST_MODIFIED_DATE_ATTRIBUTE
public static final String LAST_MODIFIED_DATE_ATTRIBUTE
Last modified date index key- See Also:
- Constant Field Values
-
LAST_MODIFIED_DATE_SEARCH_ATTRIBUTE
public static final SearchAttribute LAST_MODIFIED_DATE_SEARCH_ATTRIBUTE
Last modified date index key
-
NAME_ATTRIBUTE
public static final String NAME_ATTRIBUTE
Name attribute name,- See Also:
- Constant Field Values
-
NAME_SEARCH_ATTRIBUTE
public static final SearchAttribute NAME_SEARCH_ATTRIBUTE
Name search attribute
-
RESOURCE_TYPE_UUID_ATTRIBUTE
public static final String RESOURCE_TYPE_UUID_ATTRIBUTE
Resource type uuid reference.- See Also:
- Constant Field Values
-
RESOURCE_TYPE_UUID_SEARCH_ATTRIBUTE
public static final SearchAttribute RESOURCE_TYPE_UUID_SEARCH_ATTRIBUTE
Resource type uuid reference.
-
RESOURCE_MACRO_SELF
public static final String RESOURCE_MACRO_SELF
Macro used in resource name- See Also:
- Constant Field Values
-
RESOURCE_MACRO_ATTRIBUTE
public static final String RESOURCE_MACRO_ATTRIBUTE
Macro used in condition- See Also:
- Constant Field Values
-
DESCRIPTION_ATTRIBUTE
public static final String DESCRIPTION_ATTRIBUTE
Privilege description attribute name,- See Also:
- Constant Field Values
-
DESCRIPTION_SEARCH_ATTRIBUTE
public static final SearchAttribute DESCRIPTION_SEARCH_ATTRIBUTE
Privilege description search attribute name,
-
NOT_SUBJECT
public static final NoSubject NOT_SUBJECT
-
-
Method Detail
-
getNewInstance
public static Privilege getNewInstance() throws EntitlementException
Returns entitlement privilege.- Returns:
- entitlement privilege.
- Throws:
EntitlementException- if entitlementPrivilege cannot be returned.
-
setSubject
public void setSubject(EntitlementSubject eSubject) throws EntitlementException
Sets entitlement subject.- Parameters:
eSubject- Entitlement subject- Throws:
EntitlementException- if subject is null.
-
getName
public String getName()
Returns the name of the privilege.- Specified by:
getNamein interfaceIPrivilege- Returns:
- name of the privilege.
-
getDescription
public String getDescription()
Returns the description of the privilege.- Returns:
- description of the privilege.
-
setDescription
public void setDescription(String description)
Sets the description of the privilege.- Parameters:
description- Description of the privilege.
-
getSubject
public EntitlementSubject getSubject()
Returns the eSubject the privilege- Returns:
- eSubject of the privilege.
-
getCondition
public EntitlementCondition getCondition()
Returns the eCondition the privilege- Returns:
- eCondition of the privilege.
-
getResourceAttributes
public Set<ResourceAttribute> getResourceAttributes()
Returns the eResurceAttributes of the privilege- Returns:
- eResourceAttributes of the privilege.
-
getEntitlement
public Entitlement getEntitlement()
Returns entitlement defined in the privilege- Returns:
- entitlement defined in the privilege
-
setResourceTypeUuid
public void setResourceTypeUuid(String resourceTypeUuid)
Sets the resource type uuid that this policy makes reference to.- Parameters:
resourceTypeUuid- the resource type uuid.
-
getResourceTypeUuid
public String getResourceTypeUuid()
Retrieves the resource type uuid that is associated with this policy.- Returns:
- the resource type uuid
-
getType
public PrivilegeType getType()
Returns privilege Type.- Returns:
- privilege Type.
- See Also:
PrivilegeType
-
evaluate
public abstract List<Entitlement> evaluate(Subject adminSubject, String realm, Subject subject, String applicationName, String normalisedResourceName, String requestedResourceName, Set<String> actionNames, Map<String,Set<String>> environment, boolean recursive, Object context) throws EntitlementException
Returns a list of entitlement for a given subject, resource name and environment.- Specified by:
evaluatein interfaceIPrivilege- Parameters:
adminSubject- Admin Subjectrealm- Realm Namesubject- Subject who is under evaluation.applicationName- Application name.normalisedResourceName- The normalised resource name.requestedResourceName- The requested resource name.actionNames- Set of action names.environment- Environment parameters.recursive-trueto perform evaluation on sub resources from the given resource name.context- A security context- Returns:
- a list of entitlement for a given subject, resource name and environment.
- Throws:
EntitlementException- if the result cannot be determined.
-
toString
public String toString()
Returns string representation of the object
-
toMinimalJSONObject
public org.json.JSONObject toMinimalJSONObject() throws org.json.JSONException- Throws:
org.json.JSONException
-
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
-
init
protected abstract void init(org.json.JSONObject jo)
-
getInstance
public static Privilege getInstance(org.json.JSONObject jo) throws EntitlementException
- Throws:
EntitlementException
-
equals
public boolean equals(Object obj)
Returnstrueif the passed in object is equal to this object
-
hashCode
public int hashCode()
Returns hash code of the object
-
doesSubjectMatch
protected SubjectDecision doesSubjectMatch(Subject adminSubject, String realm, Subject subject, String resourceName, Map<String,Set<String>> environment) throws EntitlementException
- Throws:
EntitlementException
-
doesConditionMatch
protected ConditionDecision doesConditionMatch(String realm, Subject subject, String resourceName, Map<String,Set<String>> environment) throws EntitlementException
- Throws:
EntitlementException
-
getCreationDate
public long getCreationDate()
Returns creation date.- Returns:
- creation date.
-
setCreationDate
public void setCreationDate(long creationDate)
Sets the creation date.- Parameters:
creationDate- creation date.
-
getLastModifiedDate
public long getLastModifiedDate()
Returns last modified date.- Specified by:
getLastModifiedDatein interfaceIPrivilege- Returns:
- last modified date.
-
setLastModifiedDate
public void setLastModifiedDate(long lastModifiedDate)
Sets the last modified date.- Parameters:
lastModifiedDate- last modified date.
-
getLastModifiedBy
public String getLastModifiedBy()
Returns the user ID who last modified the policy.- Returns:
- user ID who last modified the policy.
-
setLastModifiedBy
public void setLastModifiedBy(String lastModifiedBy)
Sets the user ID who last modified the policy.- Parameters:
lastModifiedBy- user ID who last modified the policy.
-
getCreatedBy
public String getCreatedBy()
Returns the user ID who created the policy.- Returns:
- user ID who created the policy.
-
setCreatedBy
public void setCreatedBy(String createdBy)
Sets the user ID who created the policy.- Parameters:
createdBy- user ID who created the policy.
-
canonicalizeResources
public void canonicalizeResources(Subject adminSubject, String realm) throws EntitlementException
Canonicalizes resource name before persistence.- Parameters:
adminSubject- Admin Subject.realm- Realm Name- Throws:
EntitlementException
-
getResourceSaveIndexes
public ResourceSaveIndexes getResourceSaveIndexes(Subject adminSubject, String realm) throws EntitlementException
Returns resource save indexes.- Specified by:
getResourceSaveIndexesin interfaceIPrivilege- Parameters:
adminSubject- Admin Subject.realm- Realm Name- Returns:
- resource save indexes.
- Throws:
EntitlementException
-
setName
public void setName(String name) throws EntitlementException
Sets name.- Parameters:
name- Name of privilege.- Throws:
EntitlementException- if name is null or empty.
-
setEntitlement
public void setEntitlement(Entitlement entitlement) throws EntitlementException
Sets entitlement.- Parameters:
entitlement- Entitlement.- Throws:
EntitlementException- if entitlement is null.
-
setCondition
public void setCondition(EntitlementCondition condition)
Sets condition.- Parameters:
condition- Condition.
-
setResourceAttributes
public void setResourceAttributes(Set<ResourceAttribute> set)
Sets resource attributes.- Parameters:
set- Set of resource attribute.
-
getAttributes
protected Map<String,Set<String>> getAttributes(Subject adminSubject, String realm, Subject subject, String resourceName, Map<String,Set<String>> environment) throws EntitlementException
- Throws:
EntitlementException
-
isActive
public boolean isActive()
Returnstrueif this privilege is active.- Returns:
trueif this privilege is active.
-
setActive
public void setActive(boolean active)
Sets this privilege active/inactive.- Parameters:
active-trueif this privilege is to be active.
-
getNewInstance
public static Privilege getNewInstance(String jo) throws EntitlementException
- Throws:
EntitlementException
-
getNewInstance
public static Privilege getNewInstance(org.json.JSONObject jo) throws EntitlementException
- Throws:
EntitlementException
-
-