Class BasicAuthSecurityContext

  • All Implemented Interfaces:
    javax.ws.rs.core.SecurityContext

    public final class BasicAuthSecurityContext
    extends java.lang.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.
    • Field Summary

      • Fields inherited from interface javax.ws.rs.core.SecurityContext

        BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
    • Constructor Summary

      Constructors 
      Constructor Description
      BasicAuthSecurityContext​(java.security.Principal principal, boolean secure)
      Creates a new instance, which has no support for roles.
      BasicAuthSecurityContext​(java.security.Principal principal, boolean secure, java.util.function.Predicate<java.lang.String> userInRolePredicate)
      Creates a new instance.
    • Constructor Detail

      • BasicAuthSecurityContext

        public BasicAuthSecurityContext​(java.security.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​(java.security.Principal principal,
                                        boolean secure,
                                        @Nullable
                                        java.util.function.Predicate<java.lang.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 Detail

      • getUserPrincipal

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

        public boolean isUserInRole​(java.lang.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 java.lang.String getAuthenticationScheme()
        Specified by:
        getAuthenticationScheme in interface javax.ws.rs.core.SecurityContext