Class BasicAuthSecurityContext

java.lang.Object
io.servicetalk.http.security.auth.basic.jersey.BasicAuthSecurityContext
All Implemented Interfaces:
javax.ws.rs.core.SecurityContext

public final class BasicAuthSecurityContext extends Object implements javax.ws.rs.core.SecurityContext
A generic SecurityContext that wraps a user provided Principal, and which is designed for the SecurityContext.BASIC_AUTH authentication scheme.
  • Constructor Details

    • BasicAuthSecurityContext

      public BasicAuthSecurityContext(Principal principal, boolean secure)
      Creates a new instance, which has no support for roles.
      Parameters:
      principal - the wrapped Principal
      secure - true if the request was received over a secure channel
      See Also:
      • SecurityContext.isSecure()
    • BasicAuthSecurityContext

      public BasicAuthSecurityContext(Principal principal, boolean secure, @Nullable Predicate<String> userInRolePredicate)
      Creates a new instance.
      Parameters:
      principal - the wrapped Principal.
      secure - true if the request was received over a secure channel
      userInRolePredicate - the Predicate used to check if the user is in a role
      See Also:
      • SecurityContext.isSecure()
  • Method Details

    • getUserPrincipal

      public Principal getUserPrincipal()
      Specified by:
      getUserPrincipal in interface javax.ws.rs.core.SecurityContext
    • isUserInRole

      public boolean isUserInRole(String role)
      Specified by:
      isUserInRole in interface javax.ws.rs.core.SecurityContext
    • isSecure

      public boolean isSecure()
      Specified by:
      isSecure in interface javax.ws.rs.core.SecurityContext
    • getAuthenticationScheme

      public String getAuthenticationScheme()
      Specified by:
      getAuthenticationScheme in interface javax.ws.rs.core.SecurityContext