Class RouteAuthority

java.lang.Object
tech.lastbox.lastshield.security.core.RouteAuthority

public class RouteAuthority extends Object
Represents the authorization configuration for a specific route within the application.

A RouteAuthority defines the access control for a specific path, including the roles required to access it and the HTTP methods (GET, POST, etc.) allowed on that path. This class is used to specify the security constraints for each route in the application's security configuration.

  • Constructor Details

    • RouteAuthority

      public RouteAuthority(String path)
      Constructs a RouteAuthority with the specified path and no roles. The route can be accessed with any role or no role, depending on additional configuration.
      Parameters:
      path - the path of the route to which this authority applies.
    • RouteAuthority

      public RouteAuthority(String path, String role)
      Constructs a RouteAuthority with the specified path and a single role.
      Parameters:
      path - the path of the route to which this authority applies.
      role - the role that is required to access this route.
    • RouteAuthority

      public RouteAuthority(String path, String role, HttpMethod... httpMethods)
      Constructs a RouteAuthority with the specified path, role, and HTTP methods.
      Parameters:
      path - the path of the route to which this authority applies.
      role - the role that is required to access this route.
      httpMethods - the HTTP methods (e.g., GET, POST) allowed on this route.
    • RouteAuthority

      public RouteAuthority(String path, List<String> roles)
      Constructs a RouteAuthority with the specified path and list of roles.
      Parameters:
      path - the path of the route to which this authority applies.
      roles - the list of roles that are allowed to access this route.
    • RouteAuthority

      public RouteAuthority(String path, HttpMethod... httpMethods)
      Constructs a RouteAuthority with the specified path and HTTP methods.
      Parameters:
      path - the path of the route to which this authority applies.
      httpMethods - the HTTP methods (e.g., GET, POST) allowed on this route.
  • Method Details

    • getPath

      public String getPath()
      Gets the path associated with this RouteAuthority.
      Returns:
      the path for this route.
    • getRoles

      public String[] getRoles()
      Gets the roles associated with this RouteAuthority.
      Returns:
      the roles that are allowed to access this route.
    • getHttpMethods

      public List<HttpMethod> getHttpMethods()
      Gets the HTTP methods allowed on this route.
      Returns:
      a list of allowed HTTP methods (GET, POST, etc.).
    • toString

      public String toString()
      Returns a string representation of the RouteAuthority. This includes the path, roles, and HTTP methods associated with the route.
      Overrides:
      toString in class Object
      Returns:
      a string representing the RouteAuthority.