Class AuthLib


  • public class AuthLib
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      AuthLib()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.net.Authenticator authenticator​(java.lang.String user, java.lang.String password)
      Create a JDK Authenticator for this (username and password).
      static <T> java.net.http.HttpResponse<T> authExecute​(java.net.http.HttpClient httpClient, java.net.http.HttpRequest httpRequest, java.net.http.HttpResponse.BodyHandler<T> bodyHandler)
      Call HttpClient.send(java.net.http.HttpRequest, java.net.http.HttpResponse.BodyHandler<T>) after applying an active AuthRequestModifier to modify the HttpRequest.Builder.
      static java.net.PasswordAuthentication getPasswordAuthentication​(java.net.Authenticator authenticator)
      Get the PasswordAuthentication from an Authenticator
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AuthLib

        public AuthLib()
    • Method Detail

      • authExecute

        public static <T> java.net.http.HttpResponse<T> authExecute​(java.net.http.HttpClient httpClient,
                                                                    java.net.http.HttpRequest httpRequest,
                                                                    java.net.http.HttpResponse.BodyHandler<T> bodyHandler)
        Call HttpClient.send(java.net.http.HttpRequest, java.net.http.HttpResponse.BodyHandler<T>) after applying an active AuthRequestModifier to modify the HttpRequest.Builder. If no AuthRequestModifier is available and if a 401 response is received, setup a AuthRequestModifier passed on registered username and password information. This function supports basic and digest authentication.
        Parameters:
        httpClient - HttpClient
        httpRequest -
        bodyHandler -
        Returns:
        HttpResponse
      • authenticator

        public static java.net.Authenticator authenticator​(java.lang.String user,
                                                           java.lang.String password)
        Create a JDK Authenticator for this (username and password). The java.net.http as supplied only supports basic authentication.
      • getPasswordAuthentication

        public static java.net.PasswordAuthentication getPasswordAuthentication​(java.net.Authenticator authenticator)
        Get the PasswordAuthentication from an Authenticator