Class KeycloakAuthentication

All Implemented Interfaces:
Serializable, Principal, Authentication

public class KeycloakAuthentication extends AbstractAuthenticationToken
Author:
Mohammad Nadeem, dev.lauer@elnarion.de
See Also:
  • Constructor Details

    • KeycloakAuthentication

      public KeycloakAuthentication(org.keycloak.representations.IDToken idToken, org.keycloak.representations.AccessToken accessToken, String refreshToken, org.keycloak.representations.AccessTokenResponse tokenResponse)
      Constructor
      Parameters:
      idToken - the keycloak id token
      accessToken - the keycloak access token
      refreshToken - the keycloak refresh token
      tokenResponse - the AccessTokenResponse
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface Principal
      Overrides:
      getName in class AbstractAuthenticationToken
    • getCredentials

      public Object getCredentials()
    • getPrincipal

      public Object getPrincipal()
    • getRefreshToken

      public String getRefreshToken()
      Get the keycloak refresh token
      Returns:
      String the refresh token
    • getAccessToken

      public String getAccessToken()
      Get the keycloak access token
      Returns:
      String the access token
    • setRefreshToken

      public void setRefreshToken(String refreshToken)
      Sets the refresh token
      Parameters:
      refreshToken - String
    • setAccessToken

      public void setAccessToken(String accessToken)
      Sets the access token
      Parameters:
      accessToken - String
    • getAccessTokenResponse

      public org.keycloak.representations.AccessTokenResponse getAccessTokenResponse()
      Returns the latest AccessTokenResponse
      Returns:
      AccessTokenResponse
    • setAccessTokenResponse

      public void setAccessTokenResponse(org.keycloak.representations.AccessTokenResponse accessTokenResponse)
      Sets the latest AccessTokenResponse
      Parameters:
      accessTokenResponse -
    • getLastRefresh

      public Date getLastRefresh()
      Get the date the token is from
      Returns:
      Date
    • getLastRefreshDateAsCalendar

      public Calendar getLastRefreshDateAsCalendar()
      Get the date the token is from
      Returns:
      Calendar
    • setLastRefresh

      public void setLastRefresh(Date lastRefresh)
      Set the date the token is from
      Parameters:
      lastRefresh -
    • isRefreshExpired

      public boolean isRefreshExpired()
      Checks whether the refresh token is expired or not.
      Returns:
      boolean - the result of the check
    • isAccessExpired

      public boolean isAccessExpired()
      Checks whether the access token is expired or not.
      Returns:
      boolean - the result of the check