Class AbstractCachingSecurityService
- java.lang.Object
-
- ca.bc.gov.open.cpf.plugin.impl.security.AbstractCachingSecurityService
-
- All Implemented Interfaces:
SecurityService
- Direct Known Subclasses:
AuthorizationServiceUserSecurityService,MockSecurityService,WorkerSecurityService
public abstract class AbstractCachingSecurityService extends Object implements SecurityService
-
-
Constructor Summary
Constructors Constructor Description AbstractCachingSecurityService(Module module, String username)AbstractCachingSecurityService(Module module, String consumerKey, String userClass, String username)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanAccessResource(String resourceClass, String resourceId)Check to see if the user can access the resource.booleancanAccessResource(String resourceClass, String resourceId, String actionName)Check to see if the user can perform the action on the resource.booleancanPerformAction(String actionName)Check to see if the user is can perform the named action.voidclose()StringgetConsumerKey()Get the consumer key of the user.StringgetModuleName()Map<String,Object>getUserAttributes()Get the additional attributes about the user.StringgetUserClass()Get the classification (type) of user account.StringgetUsername()Get the login username of the user.booleanisInGroup(String groupName)Check to see if the user is a member of the named group.protected BooleanloadActionPermission(String actionName)protected BooleanloadGroupPermission(String groupName)protected BooleanloadResourceAccessPermission(String resourceClass, String resourceId, String actionName)protected Map<String,Object>loadUserAttributes()protected voidsetActionPermission(String actionName, Boolean actionPermission)protected voidsetConsumerKey(String userId)protected voidsetGroupPermission(String groupName, Boolean groupPermission)protected voidsetResourceAccessPermission(String resourceClass, String resourceId, String actionName, Boolean accessPermission)protected voidsetUserAttributes(Map<String,Object> userAttributes)protected voidsetUserClass(String userClass)protected voidsetUsername(String username)StringtoString()
-
-
-
Method Detail
-
canAccessResource
public boolean canAccessResource(String resourceClass, String resourceId)
Description copied from interface:SecurityServiceCheck 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"); } }- Specified by:
canAccessResourcein interfaceSecurityService- Parameters:
resourceClass- The type of resource.resourceId- The resource identifier.- Returns:
- True if the user can access the resource, false otherwise.
-
canAccessResource
public boolean canAccessResource(String resourceClass, String resourceId, String actionName)
Description copied from interface:SecurityServiceCheck 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"); } }- Specified by:
canAccessResourcein interfaceSecurityService- Parameters:
resourceClass- The type of resource.resourceId- The resource identifier.actionName- The action name.- Returns:
- True if the user can perform the action on the resource, false otherwise.
-
canPerformAction
public boolean canPerformAction(String actionName)
Description copied from interface:SecurityServiceCheck 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"); } }- Specified by:
canPerformActionin interfaceSecurityService- Parameters:
actionName- The action name.- Returns:
- True if the user can perform the named action, false otherwise.
-
close
public void close()
-
getConsumerKey
public String getConsumerKey()
Description copied from interface:SecurityServiceGet the consumer key of the user.
- Specified by:
getConsumerKeyin interfaceSecurityService- Returns:
- The user's consumer key.
-
getModuleName
public String getModuleName()
-
getUserAttributes
public Map<String,Object> getUserAttributes()
Description copied from interface:SecurityServiceGet the additional attributes about the user.
- Specified by:
getUserAttributesin interfaceSecurityService- Returns:
- The additional attributes about the user.
-
getUserClass
public String getUserClass()
Description copied from interface:SecurityServiceGet the classification (type) of user account.
- Specified by:
getUserClassin interfaceSecurityService- Returns:
- The classification (type) of user account.
-
getUsername
public String getUsername()
Description copied from interface:SecurityServiceGet the login username of the user.
- Specified by:
getUsernamein interfaceSecurityService- Returns:
- The login username of the user.
-
isInGroup
public boolean isInGroup(String groupName)
Description copied from interface:SecurityServiceCheck 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"); } }- Specified by:
isInGroupin interfaceSecurityService- Parameters:
groupName- The group name.- Returns:
- True if the user is a member of the group, false otherwise.
-
loadResourceAccessPermission
protected Boolean loadResourceAccessPermission(String resourceClass, String resourceId, String actionName)
-
setActionPermission
protected void setActionPermission(String actionName, Boolean actionPermission)
-
setConsumerKey
protected void setConsumerKey(String userId)
-
setResourceAccessPermission
protected void setResourceAccessPermission(String resourceClass, String resourceId, String actionName, Boolean accessPermission)
-
setUserClass
protected void setUserClass(String userClass)
-
setUsername
protected void setUsername(String username)
-
-