public abstract class AbstractCachingSecurityService extends Object implements SecurityService
Constructor and Description |
---|
AbstractCachingSecurityService(Module module,
String username) |
AbstractCachingSecurityService(Module module,
String consumerKey,
String userClass,
String username) |
Modifier and Type | Method and Description |
---|---|
boolean |
canAccessResource(String resourceClass,
String resourceId)
Check to see if the user can access the resource.
|
boolean |
canAccessResource(String resourceClass,
String resourceId,
String actionName)
Check to see if the user can perform the action on the resource.
|
boolean |
canPerformAction(String actionName)
Check to see if the user is can perform the named action.
|
void |
close() |
String |
getConsumerKey()
Get the consumer key of the user.
|
String |
getModuleName() |
Map<String,Object> |
getUserAttributes()
Get the additional attributes about the user.
|
String |
getUserClass()
Get the classification (type) of user account.
|
String |
getUsername()
Get the login username of the user.
|
boolean |
isInGroup(String groupName)
Check to see if the user is a member of the named group.
|
protected Boolean |
loadActionPermission(String actionName) |
protected Boolean |
loadGroupPermission(String groupName) |
protected Boolean |
loadResourceAccessPermission(String resourceClass,
String resourceId,
String actionName) |
protected Map<String,Object> |
loadUserAttributes() |
protected void |
setActionPermission(String actionName,
Boolean actionPermission) |
protected void |
setConsumerKey(String userId) |
protected void |
setGroupPermission(String groupName,
Boolean groupPermission) |
protected void |
setResourceAccessPermission(String resourceClass,
String resourceId,
String actionName,
Boolean accessPermission) |
protected void |
setUserAttributes(Map<String,Object> userAttributes) |
protected void |
setUserClass(String userClass) |
protected void |
setUsername(String username) |
String |
toString() |
public AbstractCachingSecurityService(Module module, String username)
public boolean canAccessResource(String resourceClass, String resourceId)
SecurityService
Check to see if the user can access the resource.
public void execute() { String resourceClass = "report"; String resourceId = "demo"; if (securityService.canAccessResource(resourceClass, resourceId)) { // Perform the request } else { throw new SecurityException("User cannot access the demo report"); } }
canAccessResource
in interface SecurityService
resourceClass
- The type of resource.resourceId
- The resource identifier.public boolean canAccessResource(String resourceClass, String resourceId, String actionName)
SecurityService
Check to see if the user can perform the action on the resource.
public void execute() { String resourceClass = "report"; String resourceId = "demo"; String actionName = "view"; if (securityService.canAccessResource(resourceClass, resourceId, actionName)) { // Perform the request } else { throw new SecurityException("User cannot perform the view action on the demo report"); } }
canAccessResource
in interface SecurityService
resourceClass
- The type of resource.resourceId
- The resource identifier.actionName
- The action name.public boolean canPerformAction(String actionName)
SecurityService
Check to see if the user is can perform the named action.
public void execute() { if (securityService.canPerformAction("view")) { // Perform the request } else { throw new SecurityException("User cannot perform the view action"); } }
canPerformAction
in interface SecurityService
actionName
- The action name.public void close()
public String getConsumerKey()
SecurityService
Get the consumer key of the user.
getConsumerKey
in interface SecurityService
public String getModuleName()
public Map<String,Object> getUserAttributes()
SecurityService
Get the additional attributes about the user.
getUserAttributes
in interface SecurityService
public String getUserClass()
SecurityService
Get the classification (type) of user account.
getUserClass
in interface SecurityService
public String getUsername()
SecurityService
Get the login username of the user.
getUsername
in interface SecurityService
public boolean isInGroup(String groupName)
SecurityService
Check to see if the user is a member of the named group.
public void execute() { if (securityService.isInGroup("DEMO_PARTNER")) { // Perform the request } else { throw new SecurityException("User is not a member of the DEMO_PARTNER_GROUP"); } }
isInGroup
in interface SecurityService
groupName
- The group name.protected Boolean loadResourceAccessPermission(String resourceClass, String resourceId, String actionName)
protected void setConsumerKey(String userId)
protected void setResourceAccessPermission(String resourceClass, String resourceId, String actionName, Boolean accessPermission)
protected void setUserClass(String userClass)
protected void setUsername(String username)
Copyright © 2008–2017 Province of British Columbia. All rights reserved.