Class HttpAuthUtil

    • Constructor Detail

      • HttpAuthUtil

        public HttpAuthUtil()
    • Method Detail

      • setUnauthenticatedReason

        public static void setUnauthenticatedReason​(@NotNull
                                                    javax.servlet.http.HttpServletRequest request,
                                                    @Nullable
                                                    String reason)
        Sets unauthenticated reason for the request to be shown on login page
        Parameters:
        request - request
        reason - reason
      • getUnauthenticatedReason

        @Nullable
        public static String getUnauthenticatedReason​(@NotNull
                                                      javax.servlet.http.HttpServletRequest request)
        Returns unauthenticated reason set for the request or null if no reason was set
        Parameters:
        request - request
        Returns:
        see above
      • sendUnauthorized

        @NotNull
        public static HttpAuthenticationResult sendUnauthorized​(@NotNull
                                                                javax.servlet.http.HttpServletRequest request,
                                                                @NotNull
                                                                javax.servlet.http.HttpServletResponse response,
                                                                @NotNull
                                                                Throwable e,
                                                                @NotNull
                                                                HttpAuthenticationProtocolsProvider protocolsProvider,
                                                                @NotNull
                                                                Map<String,​String> properties)
                                                         throws IOException
        Sets status code "401", status message and needed headers in the response
        Parameters:
        request - request
        response - response
        e - exception to get error message from
        protocolsProvider - provider of the protocols to specify in the response headers
        properties - properties for the protocol provider
        Returns:
        HttpAuthenticationResult.unauthenticated()
        Throws:
        IOException - if I/O error occurred
      • sendUnauthorized

        @NotNull
        public static HttpAuthenticationResult sendUnauthorized​(@NotNull
                                                                javax.servlet.http.HttpServletRequest request,
                                                                @NotNull
                                                                javax.servlet.http.HttpServletResponse response,
                                                                @NotNull
                                                                Throwable e,
                                                                @NotNull
                                                                Set<HttpAuthenticationProtocol> protocols,
                                                                @Nullable
                                                                String loginPageUrl)
                                                         throws IOException
        Sets status code "401", status message and needed headers in the response
        Parameters:
        request - request
        response - response
        e - exception to get error message from
        protocols - protocols to specify in the response headers
        loginPageUrl - optional URL to login page to include into the response for non browser clients
        Returns:
        HttpAuthenticationResult.unauthenticated()
        Throws:
        IOException - if I/O error occurred
      • sendUnauthorized

        @NotNull
        public static HttpAuthenticationResult sendUnauthorized​(@NotNull
                                                                javax.servlet.http.HttpServletRequest request,
                                                                @NotNull
                                                                javax.servlet.http.HttpServletResponse response,
                                                                @Nullable
                                                                String reason,
                                                                @NotNull
                                                                HttpAuthenticationProtocolsProvider protocolsProvider,
                                                                @NotNull
                                                                Map<String,​String> properties)
                                                         throws IOException
        Sets status code "401", status message and needed headers in the response
        Parameters:
        request - request
        response - response
        reason - error message
        protocolsProvider - provider of the protocols to specify in the response headers
        properties - properties for the protocol provider
        Returns:
        HttpAuthenticationResult.unauthenticated()
        Throws:
        IOException - if I/O error occurred
      • sendAnswer

        @NotNull
        public static HttpAuthenticationResult sendAnswer​(@NotNull
                                                          javax.servlet.http.HttpServletRequest request,
                                                          @NotNull
                                                          javax.servlet.http.HttpServletResponse response,
                                                          @NotNull
                                                          String wwwAuthenticateHeader)
                                                   throws IOException
        Sets status code "401", status message and needed headers in the response, keeps connection
        Parameters:
        request - request
        response - response
        wwwAuthenticateHeader - answer for client according to the used protocol
        Returns:
        HttpAuthenticationResult.unauthenticated()
        Throws:
        IOException - if I/O error occurred