Remove org.keycloak.protocol.oidc.TokenManager.RefreshResult (#12196)
Closes #12194
This commit is contained in:
parent
eed944292b
commit
86883fd68a
2 changed files with 9 additions and 26 deletions
|
@ -357,7 +357,7 @@ public class TokenManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RefreshResult refreshAccessToken(KeycloakSession session, UriInfo uriInfo, ClientConnection connection, RealmModel realm, ClientModel authorizedClient,
|
public AccessTokenResponseBuilder refreshAccessToken(KeycloakSession session, UriInfo uriInfo, ClientConnection connection, RealmModel realm, ClientModel authorizedClient,
|
||||||
String encodedRefreshToken, EventBuilder event, HttpHeaders headers, HttpRequest request) throws OAuthErrorException {
|
String encodedRefreshToken, EventBuilder event, HttpHeaders headers, HttpRequest request) throws OAuthErrorException {
|
||||||
RefreshToken refreshToken = verifyRefreshToken(session, realm, authorizedClient, request, encodedRefreshToken, true);
|
RefreshToken refreshToken = verifyRefreshToken(session, realm, authorizedClient, request, encodedRefreshToken, true);
|
||||||
|
|
||||||
|
@ -410,9 +410,7 @@ public class TokenManager {
|
||||||
responseBuilder.generateIDToken().generateAccessTokenHash();
|
responseBuilder.generateIDToken().generateAccessTokenHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
AccessTokenResponse res = responseBuilder.build();
|
return responseBuilder;
|
||||||
|
|
||||||
return new RefreshResult(res, TokenUtil.TOKEN_TYPE_OFFLINE.equals(refreshToken.getType()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateTokenReuseForRefresh(KeycloakSession session, RealmModel realm, RefreshToken refreshToken,
|
private void validateTokenReuseForRefresh(KeycloakSession session, RealmModel realm, RefreshToken refreshToken,
|
||||||
|
@ -1192,6 +1190,10 @@ public class TokenManager {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isOfflineToken() {
|
||||||
|
return refreshToken != null && TokenUtil.TOKEN_TYPE_OFFLINE.equals(refreshToken.getType());
|
||||||
|
}
|
||||||
|
|
||||||
public AccessTokenResponse build() {
|
public AccessTokenResponse build() {
|
||||||
if (accessToken != null) {
|
if (accessToken != null) {
|
||||||
event.detail(Details.TOKEN_ID, accessToken.getId());
|
event.detail(Details.TOKEN_ID, accessToken.getId());
|
||||||
|
@ -1279,25 +1281,6 @@ public class TokenManager {
|
||||||
return TokenUtil.TOKEN_TYPE_BEARER;
|
return TokenUtil.TOKEN_TYPE_BEARER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RefreshResult {
|
|
||||||
|
|
||||||
private final AccessTokenResponse response;
|
|
||||||
private final boolean offlineToken;
|
|
||||||
|
|
||||||
private RefreshResult(AccessTokenResponse response, boolean offlineToken) {
|
|
||||||
this.response = response;
|
|
||||||
this.offlineToken = offlineToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AccessTokenResponse getResponse() {
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOfflineToken() {
|
|
||||||
return offlineToken;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class NotBeforeCheck implements TokenVerifier.Predicate<JsonWebToken> {
|
public static class NotBeforeCheck implements TokenVerifier.Predicate<JsonWebToken> {
|
||||||
|
|
||||||
private final int notBefore;
|
private final int notBefore;
|
||||||
|
|
|
@ -502,10 +502,10 @@ public class TokenEndpoint {
|
||||||
AccessTokenResponse res;
|
AccessTokenResponse res;
|
||||||
try {
|
try {
|
||||||
// KEYCLOAK-6771 Certificate Bound Token
|
// KEYCLOAK-6771 Certificate Bound Token
|
||||||
TokenManager.RefreshResult result = tokenManager.refreshAccessToken(session, session.getContext().getUri(), clientConnection, realm, client, refreshToken, event, headers, request);
|
TokenManager.AccessTokenResponseBuilder responseBuilder = tokenManager.refreshAccessToken(session, session.getContext().getUri(), clientConnection, realm, client, refreshToken, event, headers, request);
|
||||||
res = result.getResponse();
|
res = responseBuilder.build();
|
||||||
|
|
||||||
if (!result.isOfflineToken()) {
|
if (!responseBuilder.isOfflineToken()) {
|
||||||
UserSessionModel userSession = session.sessions().getUserSession(realm, res.getSessionState());
|
UserSessionModel userSession = session.sessions().getUserSession(realm, res.getSessionState());
|
||||||
AuthenticatedClientSessionModel clientSession = userSession.getAuthenticatedClientSessionByClient(client.getId());
|
AuthenticatedClientSessionModel clientSession = userSession.getAuthenticatedClientSessionByClient(client.getId());
|
||||||
updateClientSession(clientSession);
|
updateClientSession(clientSession);
|
||||||
|
|
Loading…
Reference in a new issue