Class BearerTokenAuthenticator

  • All Implemented Interfaces:
    Authenticator

    public class BearerTokenAuthenticator
    extends java.lang.Object
    implements Authenticator
    Implements an HTTP authenticator using JWT bearer tokens.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getAuthorizationHeaderValue​(com.smartgridready.ns.v0.DeviceFrame deviceDescription, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory)
      Retrieves the value of the authorization header of HTTP requests.
      boolean isTokenRenewalSupported()
      Tells if access tokens can be renewed instead of re-authenticating.
      void renewToken​(com.smartgridready.ns.v0.DeviceFrame deviceDescription, com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory)
      Renews the access token.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getAuthorizationHeaderValue

        public java.lang.String getAuthorizationHeaderValue​(com.smartgridready.ns.v0.DeviceFrame deviceDescription,
                                                            com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory)
                                                     throws java.io.IOException,
                                                            RestApiServiceCallException
        Description copied from interface: Authenticator
        Retrieves the value of the authorization header of HTTP requests.
        Specified by:
        getAuthorizationHeaderValue in interface Authenticator
        Parameters:
        deviceDescription - the SGr device specification
        httpClientFactory - the SGr HTTP client factory
        Returns:
        a string
        Throws:
        java.io.IOException - when a communication error occurred
        RestApiServiceCallException - when the authentication failed
      • isTokenRenewalSupported

        public boolean isTokenRenewalSupported()
        Description copied from interface: Authenticator
        Tells if access tokens can be renewed instead of re-authenticating. Defaults to false.
        Specified by:
        isTokenRenewalSupported in interface Authenticator
        Returns:
        a boolean
      • renewToken

        public void renewToken​(com.smartgridready.ns.v0.DeviceFrame deviceDescription,
                               com.smartgridready.driver.api.http.GenHttpClientFactory httpClientFactory)
                        throws java.io.IOException,
                               RestApiServiceCallException
        Description copied from interface: Authenticator
        Renews the access token. Defaults to an empty implementation.
        Specified by:
        renewToken in interface Authenticator
        Parameters:
        deviceDescription - the SGr device specification
        httpClientFactory - the SGr HTTP client factory
        Throws:
        java.io.IOException - when a communication error occurred
        RestApiServiceCallException - when the renewal failed