Class AuthenticationAPI


  • public final class AuthenticationAPI
    extends Object
    Implementation of a connector for the remote API's Authentication endpoint.


    Provides static access to all routes of this endpoint which may be used for obtaining and refreshing JWT tokens. Acquired tokens will automatically be propagated to the given connection. Such authenticated/initialized connections may then be used to invoke further remote API routes.

    • Method Detail

      • login

        public static void login​(@Nonnull
                                 APIConnection con)
                          throws APIException
        Initializes the given connection by requesting a new token from the remote API. This token will be used for authentication of all subsequent requests that are sent to the remote service using this connection. The initialization will be performed based on the connections current authentication settings. It is strongly recommended to call this route once in order to initialize a connection before using it to invoke other remote routes. However, if an API call is made without proper initialization, an implicit login attempt will be performed.


        Corresponds to remote API route: [POST] /login

        Parameters:
        con - Connection to be used for API communication and to which the Issued JWT token should be propagated to
        Throws:
        APIException - If an exception with the remote API occurs, e.g. due to an IO error or if the API returned an invalid or unparsable JWT token
      • refreshSession

        public static void refreshSession​(@Nonnull
                                          APIConnection con)
                                   throws APIException
        Refreshes the current, valid JWT token of the given connection. This method can be used to extend the expiration date (24 hours) of the current token without the need of a complete new login.


        Corresponds to remote API route: [GET] /refresh_token

        Parameters:
        con - Connection to be used for API communication and for which the JWT token should be refreshed
        Throws:
        APIException - If an exception with the remote API occurs, e.g. due to an IO error or if the API returned an invalid or unparsable JWT token