java.lang.Object
cloud.piranha.extension.slim.security.SlimSecurityManager
All Implemented Interfaces:
SecurityManager

public class SlimSecurityManager extends Object implements SecurityManager
The SlimSecurityManager.
Author:
Manfred Riem ([email protected])
  • Field Details

    • denyUncoveredHttpMethods

      protected boolean denyUncoveredHttpMethods
      Stores the denyUncoveredHttpMethods flag.
    • logins

      protected final HashMap<String,String> logins
      Stores the logins.
    • roles

      protected ArrayList<String> roles
      Stores the roles.
    • userRoles

      protected final HashMap<String,String[]> userRoles
      Stores the user roles.
    • webApplication

      protected WebApplication webApplication
      Stores the web application.
  • Constructor Details

    • SlimSecurityManager

      public SlimSecurityManager()
  • Method Details

    • addUser

      public void addUser(String username, String password, String... roles)
      Add user.
      Parameters:
      username - the username.
      password - the password.
      roles - the roles.
    • addUserRole

      public void addUserRole(String username, String... roles)
      Add the user roles.
      Parameters:
      username - the username.
      roles - the roles.
    • authenticate

      public boolean authenticate(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException, jakarta.servlet.ServletException
      Description copied from interface: SecurityManager
      Authenticate the request.
      Specified by:
      authenticate in interface SecurityManager
      Parameters:
      request - the request.
      response - the response.
      Returns:
      true if authenticated.
      Throws:
      IOException - when an I/O error occurs.
      jakarta.servlet.ServletException - when a servlet error occurs.
    • declareRoles

      public void declareRoles(String[] roles)
      Description copied from interface: SecurityManager
      Declare roles.
      Specified by:
      declareRoles in interface SecurityManager
      Parameters:
      roles - the roles.
    • getDenyUncoveredHttpMethods

      public boolean getDenyUncoveredHttpMethods()
      Description copied from interface: SecurityManager
      Get if we are denying uncovered HTTP methods.
      Specified by:
      getDenyUncoveredHttpMethods in interface SecurityManager
      Returns:
      true if we are, false otherwise.
    • getRoles

      public Set<String> getRoles()
      Description copied from interface: SecurityManager
      Get the declared roles
      Specified by:
      getRoles in interface SecurityManager
      Returns:
      the roles
    • getWebApplication

      public WebApplication getWebApplication()
      Description copied from interface: SecurityManager
      Get the web application.
      Specified by:
      getWebApplication in interface SecurityManager
      Returns:
      the web application.
    • isUserInRole

      public boolean isUserInRole(jakarta.servlet.http.HttpServletRequest request, String role)
      Description copied from interface: SecurityManager
      Is the user in the specific role.
      Specified by:
      isUserInRole in interface SecurityManager
      Parameters:
      request - the request.
      role - the role.
      Returns:
      true if in the role, false otherwise.
    • login

      public void login(jakarta.servlet.http.HttpServletRequest request, String username, String password) throws jakarta.servlet.ServletException
      Description copied from interface: SecurityManager
      Login.
      Specified by:
      login in interface SecurityManager
      Parameters:
      request - the request.
      username - the username.
      password - the password.
      Throws:
      jakarta.servlet.ServletException - when unable to login.
    • logout

      public void logout(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException
      Description copied from interface: SecurityManager
      Logout.
      Specified by:
      logout in interface SecurityManager
      Parameters:
      request - the request.
      response - the response.
      Throws:
      jakarta.servlet.ServletException - when a servlet error occurs.
    • removeUser

      public void removeUser(String username)
      Remove the given user.
      Parameters:
      username - the username.
    • setDenyUncoveredHttpMethods

      public void setDenyUncoveredHttpMethods(boolean denyUncoveredHttpMethods)
      Description copied from interface: SecurityManager
      Set if we are denying uncovered HTTP methods.
      Specified by:
      setDenyUncoveredHttpMethods in interface SecurityManager
      Parameters:
      denyUncoveredHttpMethods - the boolean value.
    • setWebApplication

      public void setWebApplication(WebApplication webApplication)
      Description copied from interface: SecurityManager
      Set the web application.
      Specified by:
      setWebApplication in interface SecurityManager
      Parameters:
      webApplication - the web application.