use of org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheKey in project carbon-identity-framework by wso2.
the class FrameworkUtils method removeSessionContextFromCache.
/**
* @param key
* @param loginTenantDomain
*/
public static void removeSessionContextFromCache(String key, String loginTenantDomain) {
if (key != null) {
SessionContextCacheKey cacheKey = new SessionContextCacheKey(key);
SessionContextCache.getInstance().clearCacheEntry(cacheKey, loginTenantDomain);
}
}
use of org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheKey in project carbon-identity-framework by wso2.
the class FrameworkUtils method addSessionContextToCache.
/**
* @deprecated Use the {@link #addSessionContextToCache(String, SessionContext, String)}
*
* @param key
* @param sessionContext
*/
@Deprecated
public static void addSessionContextToCache(String key, SessionContext sessionContext) {
SessionContextCacheKey cacheKey = new SessionContextCacheKey(key);
SessionContextCacheEntry cacheEntry = new SessionContextCacheEntry();
Map<String, SequenceConfig> seqData = sessionContext.getAuthenticatedSequences();
if (seqData != null) {
for (Entry<String, SequenceConfig> entry : seqData.entrySet()) {
if (entry.getValue() != null) {
entry.getValue().getAuthenticatedUser().setUserAttributes(null);
entry.getValue().setAuthenticationGraph(null);
}
}
}
Object authenticatedUserObj = sessionContext.getProperty(FrameworkConstants.AUTHENTICATED_USER);
if (authenticatedUserObj instanceof AuthenticatedUser) {
AuthenticatedUser authenticatedUser = (AuthenticatedUser) authenticatedUserObj;
cacheEntry.setLoggedInUser(authenticatedUser.getAuthenticatedSubjectIdentifier());
}
cacheEntry.setContext(sessionContext);
SessionContextCache.getInstance().addToCache(cacheKey, cacheEntry);
}
use of org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheKey in project carbon-identity-framework by wso2.
the class FrameworkUtils method getSessionContextFromCache.
/**
* Retrieve session context from the session cache.
*
* @param request HttpServletRequest.
* @param context Authentication context.
* @param sessionContextKey Session context key.
* @return Session context key.
* @throws FrameworkException Error in triggering session expire event.
*/
public static SessionContext getSessionContextFromCache(HttpServletRequest request, AuthenticationContext context, String sessionContextKey) throws FrameworkException {
SessionContext sessionContext = null;
if (StringUtils.isNotBlank(sessionContextKey)) {
SessionContextCacheKey cacheKey = new SessionContextCacheKey(sessionContextKey);
SessionContextCache sessionContextCache = SessionContextCache.getInstance();
SessionContextCacheEntry cacheEntry = sessionContextCache.getSessionContextCacheEntry(cacheKey, context.getLoginTenantDomain());
if (cacheEntry != null) {
sessionContext = cacheEntry.getContext();
boolean isSessionExpired = sessionContextCache.isSessionExpired(cacheKey, cacheEntry);
if (isSessionExpired) {
triggerSessionExpireEvent(request, context, sessionContext);
if (log.isDebugEnabled()) {
log.debug("A SESSION_EXPIRE event was fired for the expired session found corresponding " + "to the key: " + cacheKey.getContextId());
}
return null;
}
}
}
return sessionContext;
}
use of org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheKey in project carbon-identity-framework by wso2.
the class FrameworkUtils method getSessionContextFromCache.
/**
* @param key
* @param loginTenantDomain
* @return
*/
public static SessionContext getSessionContextFromCache(String key, String loginTenantDomain) {
SessionContext sessionContext = null;
if (StringUtils.isNotBlank(key)) {
SessionContextCacheKey cacheKey = new SessionContextCacheKey(key);
Object cacheEntryObj = SessionContextCache.getInstance().getValueFromCache(cacheKey, loginTenantDomain);
if (cacheEntryObj != null) {
sessionContext = ((SessionContextCacheEntry) cacheEntryObj).getContext();
}
}
return sessionContext;
}
use of org.wso2.carbon.identity.application.authentication.framework.cache.SessionContextCacheKey in project carbon-identity-framework by wso2.
the class SessionContextCache method getSessionFromDB.
/**
* Retrieve session from the database.
*
* @param key Session context cache key.
* @return Session context cache entry.
*/
private SessionContextCacheEntry getSessionFromDB(SessionContextCacheKey key) {
SessionContextCacheEntry cacheEntry = null;
SessionContextDO sessionContextDO = SessionDataStore.getInstance().getSessionContextData(key.getContextId(), SESSION_CONTEXT_CACHE_NAME);
if (sessionContextDO != null) {
cacheEntry = new SessionContextCacheEntry(sessionContextDO);
}
return cacheEntry;
}
Aggregations