use of org.keycloak.adapters.saml.SamlSession in project keycloak by keycloak.
the class FilterSamlSessionStore method isLoggedIn.
@Override
public boolean isLoggedIn() {
HttpSession session = request.getSession(false);
if (session == null) {
log.debug("session was null, returning false");
return false;
}
final SamlSession samlSession = SamlUtil.validateSamlSession(session.getAttribute(SamlSession.class.getName()), deployment);
if (samlSession == null) {
log.debug("SamlSession was not in session, returning null");
return false;
}
if (idMapper != null && !idMapper.hasSession(session.getId())) {
logoutAccount();
return false;
}
needRequestRestore = restoreRequest();
return true;
}
use of org.keycloak.adapters.saml.SamlSession in project keycloak by keycloak.
the class FilterSamlSessionStore method logoutAccount.
@Override
public void logoutAccount() {
HttpSession session = request.getSession(false);
if (session == null)
return;
if (session != null) {
if (idMapper != null)
idMapper.removeSession(session.getId());
SamlSession samlSession = (SamlSession) session.getAttribute(SamlSession.class.getName());
if (samlSession != null) {
session.removeAttribute(SamlSession.class.getName());
}
clearSavedRequest(session);
}
}
use of org.keycloak.adapters.saml.SamlSession in project keycloak by keycloak.
the class FilterSamlSessionStore method getWrap.
public HttpServletRequestWrapper getWrap() {
HttpSession session = request.getSession(true);
final SamlSession samlSession = (SamlSession) session.getAttribute(SamlSession.class.getName());
final KeycloakAccount account = samlSession;
return buildWrapper(session, account);
}
use of org.keycloak.adapters.saml.SamlSession in project keycloak by keycloak.
the class ServletSamlSessionStore method logoutAccount.
@Override
public void logoutAccount() {
HttpSession session = getSession(false);
if (session != null) {
SamlSession samlSession = (SamlSession) session.getAttribute(SamlSession.class.getName());
if (samlSession != null) {
if (samlSession.getSessionIndex() != null) {
idMapperUpdater.removeSession(idMapper, session.getId());
}
session.removeAttribute(SamlSession.class.getName());
}
session.removeAttribute(SAML_REDIRECT_URI);
}
}
use of org.keycloak.adapters.saml.SamlSession in project keycloak by keycloak.
the class ServletSamlSessionStore method isLoggedIn.
@Override
public boolean isLoggedIn() {
HttpSession session = getSession(false);
if (session == null) {
log.debug("Session was not found");
return false;
}
if (!idMapper.hasSession(session.getId()) && !idMapperUpdater.refreshMapping(idMapper, session.getId())) {
log.debugf("Session %s has expired on some other node", session.getId());
session.removeAttribute(SamlSession.class.getName());
return false;
}
final SamlSession samlSession = SamlUtil.validateSamlSession(session.getAttribute(SamlSession.class.getName()), deployment);
if (samlSession == null) {
return false;
}
Account undertowAccount = new Account() {
@Override
public Principal getPrincipal() {
return samlSession.getPrincipal();
}
@Override
public Set<String> getRoles() {
return samlSession.getRoles();
}
};
securityContext.authenticationComplete(undertowAccount, "KEYCLOAK-SAML", false);
restoreRequest();
return true;
}
Aggregations