in src/main/java/org/apache/sling/auth/oauth_client/impl/OidcAuthenticationHandler.java [444:481]
public boolean authenticationSucceeded(HttpServletRequest request, HttpServletResponse response, AuthenticationInfo authInfo) {
if (loginCookieManager == null) {
logger.debug("TokenUpdate service is not available");
return super.authenticationSucceeded(request, response, authInfo);
}
if (loginCookieManager.getLoginCookie(request) !=null) {
// A valid login cookie has been sent
// According to AuthenticationFeedbackHandler javadoc we send because we did not send a redirect to the user
return false;
}
Object creds = authInfo.get(JcrResourceConstants.AUTHENTICATION_INFO_CREDENTIALS);
if (creds instanceof OidcAuthCredentials oidcAuthCredentials) {
Object tokenValueObject = oidcAuthCredentials.getAttribute(".token");
if (tokenValueObject != null && !tokenValueObject.toString().isEmpty()) {
String token = tokenValueObject.toString();
if (!token.isEmpty()) {
logger.debug("Calling TokenUpdate service to update token cookie");
loginCookieManager.setLoginCookie(request, response, repository, oidcAuthCredentials);
}
}
try {
Object redirect = request.getAttribute(REDIRECT_ATTRIBUTE_NAME);
if (redirect instanceof String) {
response.sendRedirect(redirect.toString());
} else {
response.sendRedirect(defaultRedirect);
}
} catch (IOException e) {
logger.error("Error while redirecting to default redirect: {}", e.getMessage(), e);
throw new RuntimeException(e);
}
}
return true;
}