Class SessionToken

    • Constructor Detail

      • SessionToken

        public SessionToken​(@NotNull
                            @NotNull String accessToken,
                            @NotNull
                            @NotNull String refreshToken,
                            long expiresIn)
        Creates a new SessionToken from preexisting token values.
        Parameters:
        accessToken - The access token String value.
        refreshToken - The refresh token String value.
        expiresIn - The token expiry time in seconds.
      • SessionToken

        public SessionToken()
        Creates a new, empty SessionToken.
    • Method Detail

      • getToken

        @NotNull
        public @NotNull String getToken()
        Returns the access token String value. Shall return an empty String for an uninitialized session.
        Specified by:
        getToken in interface AuthMaterial
        Specified by:
        getToken in interface JWTToken
        Returns:
        The access token String value.
      • refresh

        public void refresh()

        Replaces the access token with the refresh token.

        Be aware: Using the refresh token as auth material is only valid and advisable while refreshing the webPDF access token - other calls to the server will fail until a new access token is provided.
        Synchronization of webservice calls is absolutely necessary during a token refresh and it is recommended to delay other calls until a fresh and valid access token is available.
        This SessionToken should be discarded after refreshing the token has finished.

      • isExpired

        public boolean isExpired​(int skewTime)
        Returns true, if the current access token is expired and refresh() should be called to request a new access token for the Session.
        Parameters:
        skewTime - An additional skew time, in seconds, that is added during expiry evaluation. (Adding a skew time helps in avoiding to use expired access tokens because of transfer delays.)
        Returns:
        true, if the current access token is expired.