public class Entitlement extends Object
Example of how to use this class
Set set = new HashSet(); set.add("GET"); Evaluator evaluator = new Evaluator(adminToken); boolean isAllowed = evaluator.hasEntitlement(subject, new Entitlement("http://www.sun.com/example", set), Collections.EMPTY_MAP);Or do a sub tree search like this.
Evaluator evaluator = new Evaluator(adminToken); List<Entitlement> entitlements = evaluator.getEntitlements( subject, "http://www.sun.com", Collections.EMPTY_MAP, true); for (Entitlement e : entitlements) { String resource = e.getResourceNames(); boolean isAllowed =((Boolean)e.getActionValue("GET")).booleanValue(); ... }
Constructor and Description |
---|
Entitlement()
Creates an entitlement object with default service name.
|
Entitlement(org.json.JSONObject jo) |
Entitlement(Set<String> resourceNames,
Set<String> actionNames)
Creates an entitlement object.
|
Entitlement(String resourceName,
Map<String,Boolean> actionValues)
Creates an entitlement object.
|
Entitlement(String resourceName,
Set<String> actionNames)
Creates an entitlement object.
|
Entitlement(String applicationName,
Set<String> resourceNames,
Map<String,Boolean> actionValues)
Creates an entitlement object.
|
Entitlement(String applicationName,
String resourceName,
Map<String,Boolean> actionValues)
Creates an entitlement object.
|
Entitlement(String applicationName,
String resourceName,
Set<String> actionNames)
Creates an entitlement object.
|
Modifier and Type | Method and Description |
---|---|
void |
canonicalizeResources(Subject adminSubject,
String realm)
Canonicalizes resource name before persistence.
|
void |
clearCache()
Sets this entitlement's current application to null.
|
boolean |
equals(Object obj)
Returns
true if the passed in object is equal to this object |
Set<String> |
evaluate(Subject adminSubject,
String realm,
Subject subject,
String applicationName,
String resourceName,
Set<String> actionNames,
Map<String,Set<String>> environment,
boolean recursive)
Returns a set of resource names that match the given resource.
|
Boolean |
getActionValue(String name)
Returns action value.
|
Map<String,Boolean> |
getActionValues()
Returns action values.
|
Set<Object> |
getActionValues(String name)
Returns action values.
|
Map<String,Set<String>> |
getAdvices()
Returns advices.
|
Application |
getApplication(Subject adminSubject,
String realm)
Returns application for this entitlement.
|
String |
getApplicationName()
Returns application name.
|
Map<String,Set<String>> |
getAttributes()
Returns attributes.
|
protected Set<String> |
getMatchingResources(Subject adminSubject,
String realm,
Subject subject,
String applicationName,
String resourceName,
boolean recursive) |
String |
getName()
Returns the name of the entitlement
|
String |
getRequestedResourceName()
Returns non normalised resource name.
|
Set<String> |
getRequestedResourceNames()
Returns non normalised resource names.
|
String |
getResourceName()
Returns resource name.
|
Set<String> |
getResourceNames()
Returns resource names.
|
ResourceSaveIndexes |
getResourceSaveIndexes(Subject adminSubject,
String realm)
Returns resource save indexes.
|
ResourceSearchIndexes |
getResourceSearchIndexes(Subject adminSubject,
String realm)
Returns resource search indexes.
|
long |
getTTL()
Returns the TTL
|
boolean |
hasAdvice() |
int |
hashCode()
Returns hash code of the object
|
void |
setActionName(String actionName)
Sets action name
|
void |
setActionNames(Set<String> actionNames)
Sets action names
|
void |
setActionValues(Map<String,Boolean> actionValues)
Sets action values map.
|
void |
setAdvices(Map<String,Set<String>> advices)
Sets advices.
|
void |
setApplicationName(String applicationName)
Sets application name.
|
void |
setAttributes(Map<String,Set<String>> attributes)
Sets attributes.
|
void |
setName(String name)
Sets the name of the entitlement
|
void |
setRequestedResourceName(String requestedResourceName)
Sets non normalised resource name.
|
void |
setRequestedResourceNames(Set<String> requestedResourceNames)
Sets the non normalised resource names.
|
void |
setResourceName(String resourceName)
Sets resource name.
|
void |
setResourceNames(Set<String> resourceNames)
Sets resource names.
|
void |
setTTL(long ttl)
Sets this entitlements TTL
|
org.json.JSONObject |
toJSONObject()
Returns JSONObject mapping of the object
|
String |
toString()
Returns string representation of the object
|
public Entitlement()
public Entitlement(org.json.JSONObject jo) throws org.json.JSONException
org.json.JSONException
public Entitlement(Set<String> resourceNames, Set<String> actionNames)
resourceNames
- Resource names.actionNames
- Set of action names.public Entitlement(String resourceName, Set<String> actionNames)
resourceName
- Resource name.actionNames
- Set of action names.public Entitlement(String applicationName, String resourceName, Set<String> actionNames)
applicationName
- Application name.resourceName
- Resource name.actionNames
- Set of action names.public Entitlement(String resourceName, Map<String,Boolean> actionValues)
resourceName
- Resource namess.actionValues
- Map of action name to set of values.public Entitlement(String applicationName, String resourceName, Map<String,Boolean> actionValues)
applicationName
- applicationNameresourceName
- Resource namess.actionValues
- Map of action name to set of values.public void setName(String name)
name
- the name of the entitlementpublic String getName()
public void setResourceNames(Set<String> resourceNames)
resourceNames
- Resource Names.public Set<String> getResourceNames()
public void setResourceName(String resourceName)
resourceName
- Resource Name.public String getResourceName()
public void setRequestedResourceNames(Set<String> requestedResourceNames)
requestedResourceNames
- Non normalised resource names.public Set<String> getRequestedResourceNames()
public void setRequestedResourceName(String requestedResourceName)
requestedResourceName
- Non normalised resource name.public String getRequestedResourceName()
public String getApplicationName()
public void setApplicationName(String applicationName)
applicationName
- application name.public void setActionName(String actionName)
actionName
- Action name.public void setActionNames(Set<String> actionNames)
actionNames
- Set of action names.public void setActionValues(Map<String,Boolean> actionValues)
actionValues
- Action values.public Boolean getActionValue(String name)
name
- Name of the action.public Map<String,Boolean> getActionValues()
public Set<Object> getActionValues(String name)
name
- Name of the action.public void setAdvices(Map<String,Set<String>> advices)
advices
- Advices.public boolean hasAdvice()
public void setAttributes(Map<String,Set<String>> attributes)
attributes
- Attributes.public Map<String,Set<String>> getAttributes()
public void setTTL(long ttl)
ttl
- The TTL to setpublic long getTTL()
public Set<String> evaluate(Subject adminSubject, String realm, Subject subject, String applicationName, String resourceName, Set<String> actionNames, Map<String,Set<String>> environment, boolean recursive) throws EntitlementException
adminSubject
- Admin Subject.realm
- Realm Namesubject
- Subject who is under evaluation.applicationName
- application name.resourceName
- Resource name.environment
- Environment parameters.EntitlementException
- if resource names cannot be returned.protected Set<String> getMatchingResources(Subject adminSubject, String realm, Subject subject, String applicationName, String resourceName, boolean recursive) throws EntitlementException
EntitlementException
public String toString()
public org.json.JSONObject toJSONObject() throws org.json.JSONException
org.json.JSONException
- if can not map to JSONObjectpublic boolean equals(Object obj)
true
if the passed in object is equal to this objectpublic int hashCode()
public ResourceSearchIndexes getResourceSearchIndexes(Subject adminSubject, String realm) throws EntitlementException
adminSubject
- Admin Subject.realm
- Realm NameEntitlementException
public ResourceSaveIndexes getResourceSaveIndexes(Subject adminSubject, String realm) throws EntitlementException
adminSubject
- Admin Subject.realm
- Realm NameEntitlementException
public void clearCache()
public Application getApplication(Subject adminSubject, String realm) throws EntitlementException
adminSubject
- Admin Subject.realm
- Realm NameEntitlementException
public void canonicalizeResources(Subject adminSubject, String realm) throws EntitlementException
adminSubject
- Admin Subject.realm
- Realm NameEntitlementException
Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.