Class AbstractCachingSecurityService

    • Constructor Detail

      • AbstractCachingSecurityService

        public AbstractCachingSecurityService​(Module module,
                                              String username)
      • AbstractCachingSecurityService

        public AbstractCachingSecurityService​(Module module,
                                              String consumerKey,
                                              String userClass,
                                              String username)
    • Method Detail

      • canAccessResource

        public boolean canAccessResource​(String resourceClass,
                                         String resourceId)
        Description copied from interface: 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");
          }
          }
        Specified by:
        canAccessResource in interface SecurityService
        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: 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");
          }
          }
        Specified by:
        canAccessResource in interface SecurityService
        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: 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");
          }
          }
        Specified by:
        canPerformAction in interface SecurityService
        Parameters:
        actionName - The action name.
        Returns:
        True if the user can perform the named action, false otherwise.
      • close

        public void close()
      • getModuleName

        public String getModuleName()
      • getUserClass

        public String getUserClass()
        Description copied from interface: SecurityService

        Get the classification (type) of user account.

        Specified by:
        getUserClass in interface SecurityService
        Returns:
        The classification (type) of user account.
      • isInGroup

        public boolean isInGroup​(String groupName)
        Description copied from interface: 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");
          }
          }
        Specified by:
        isInGroup in interface SecurityService
        Parameters:
        groupName - The group name.
        Returns:
        True if the user is a member of the group, false otherwise.
      • loadActionPermission

        protected Boolean loadActionPermission​(String actionName)
      • loadGroupPermission

        protected Boolean loadGroupPermission​(String groupName)
      • loadResourceAccessPermission

        protected Boolean loadResourceAccessPermission​(String resourceClass,
                                                       String resourceId,
                                                       String actionName)
      • loadUserAttributes

        protected Map<String,​Object> loadUserAttributes()
      • setActionPermission

        protected void setActionPermission​(String actionName,
                                           Boolean actionPermission)
      • setConsumerKey

        protected void setConsumerKey​(String userId)
      • setGroupPermission

        protected void setGroupPermission​(String groupName,
                                          Boolean groupPermission)
      • setResourceAccessPermission

        protected void setResourceAccessPermission​(String resourceClass,
                                                   String resourceId,
                                                   String actionName,
                                                   Boolean accessPermission)
      • setUserAttributes

        protected void setUserAttributes​(Map<String,​Object> userAttributes)
      • setUserClass

        protected void setUserClass​(String userClass)
      • setUsername

        protected void setUsername​(String username)