Skip to content

Instantly share code, notes, and snippets.

@hamnis
Created November 22, 2018 09:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamnis/547c550a532be7e8235aa653725b2ba2 to your computer and use it in GitHub Desktop.
Save hamnis/547c550a532be7e8235aa653725b2ba2 to your computer and use it in GitHub Desktop.
@Override
public void authenticationFinished(AuthenticationSessionModel authSession, BrokeredIdentityContext context) {
String prompt = authSession.getClientNote(OIDCLoginProtocol.PROMPT_PARAM);
if (OIDCLoginProtocol.PROMPT_VALUE_LOGIN.equals(prompt)) {
UserSessionModel usm = session.sessions().getUserSessionByBrokerSessionId(authSession.getRealm(), context.getBrokerSessionId());
if (!AuthenticationManager.isSessionValid(authSession.getRealm(), usm)) {
logger.debugf("User session '%s' is not valid, maybe creating a new one", context.getBrokerSessionId());
EventBuilder event = new EventBuilder(authSession.getRealm(), session, session.getContext().getConnection());
event.event(EventType.IDENTITY_PROVIDER_LOGIN);
ClientSessionContext ctx = AuthenticationProcessor.attachSession(authSession, usm, session, authSession.getRealm(), session.getContext().getConnection(), event);
usm = ctx.getClientSession().getUserSession();
}
usm.setLastSessionRefresh(Time.currentTime());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment