Package org.jenkinsci.plugins
Class KeycloakAuthentication
java.lang.Object
org.acegisecurity.providers.AbstractAuthenticationToken
org.jenkinsci.plugins.KeycloakAuthentication
- All Implemented Interfaces:
Serializable
,Principal
,Authentication
- Author:
- Mohammad Nadeem, dev.lauer@elnarion.de
- See Also:
-
Constructor Summary
ConstructorDescriptionKeycloakAuthentication
(org.keycloak.representations.IDToken idToken, org.keycloak.representations.AccessToken accessToken, String refreshToken, org.keycloak.representations.AccessTokenResponse tokenResponse) Constructor -
Method Summary
Modifier and TypeMethodDescriptionGet the keycloak access tokenorg.keycloak.representations.AccessTokenResponse
Returns the latest AccessTokenResponseGet the date the token is fromGet the date the token is fromgetName()
Get the keycloak refresh tokenboolean
Checks whether the access token is expired or not.boolean
Checks whether the refresh token is expired or not.void
setAccessToken
(String accessToken) Sets the access tokenvoid
setAccessTokenResponse
(org.keycloak.representations.AccessTokenResponse accessTokenResponse) Sets the latest AccessTokenResponsevoid
setLastRefresh
(Date lastRefresh) Set the date the token is fromvoid
setRefreshToken
(String refreshToken) Sets the refresh tokenMethods inherited from class org.acegisecurity.providers.AbstractAuthenticationToken
equals, getAuthorities, getDetails, hashCode, isAuthenticated, setAuthenticated, setDetails, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.acegisecurity.Authentication
toSpring
-
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 tokenaccessToken
- the keycloak access tokenrefreshToken
- the keycloak refresh tokentokenResponse
- theAccessTokenResponse
-
-
Method Details
-
getName
- Specified by:
getName
in interfacePrincipal
- Overrides:
getName
in classAbstractAuthenticationToken
-
getCredentials
-
getPrincipal
-
getRefreshToken
Get the keycloak refresh token- Returns:
String
the refresh token
-
getAccessToken
Get the keycloak access token- Returns:
String
the access token
-
setRefreshToken
Sets the refresh token- Parameters:
refreshToken
-String
-
setAccessToken
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
Get the date the token is from- Returns:
Date
-
getLastRefreshDateAsCalendar
Get the date the token is from- Returns:
Calendar
-
setLastRefresh
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
-