Java Code Examples for org.wso2.carbon.identity.application.authentication.framework.util.FrameworkUtils#getAuthenticationResultFromCache()

The following examples show how to use org.wso2.carbon.identity.application.authentication.framework.util.FrameworkUtils#getAuthenticationResultFromCache() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IdentityProcessor.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Processes the IdentityMessageContext and retrieved the using {@code sessionDataKey} parameter and sets the
 * AuthenticationResult to message context if found in AuthenticationResultCache
 *
 * @param context IdentityMessageContext
 * @param identityRequest Current IdentityRequest object
 * @return AuthenticationResult
 */
protected AuthenticationResult processResponseFromFrameworkLogin(IdentityMessageContext context,
                                                                 IdentityRequest identityRequest) {

    String sessionDataKey = identityRequest.getParameter(InboundConstants.RequestProcessor.CONTEXT_KEY);
    AuthenticationResultCacheEntry entry = FrameworkUtils.getAuthenticationResultFromCache(sessionDataKey);
    AuthenticationResult authnResult = null;
    if(entry != null) {
        authnResult = entry.getResult();
    } else {
        throw FrameworkRuntimeException.error("Cannot find AuthenticationResult from the cache");
    }
    FrameworkUtils.removeAuthenticationResultFromCache(sessionDataKey);
    if (authnResult.isAuthenticated()) {
        context.addParameter(InboundConstants.RequestProcessor.AUTHENTICATION_RESULT, authnResult);
    }
    return authnResult;
}
 
Example 2
Source File: DefaultAuthenticationRequestHandler.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
private AuthenticationResult getAuthenticationResult(HttpServletRequest request,
                                                     HttpServletResponse response,
                                                     AuthenticationContext context) {

    AuthenticationResult authenticationResult = null;
    if (FrameworkUtils.getCacheDisabledAuthenticators().contains(context.getRequestType())
            && (response instanceof CommonAuthResponseWrapper) &&
            !((CommonAuthResponseWrapper) response).isWrappedByFramework()) {
        // Get the authentication result from the request
        authenticationResult =
                (AuthenticationResult) request.getAttribute(FrameworkConstants.RequestAttribute.AUTH_RESULT);
    } else {
        // Retrieve the authentication result from cache
        AuthenticationResultCacheEntry authenticationResultCacheEntry =
                FrameworkUtils.getAuthenticationResultFromCache(context.getCallerSessionKey());
        if (authenticationResultCacheEntry != null) {
            authenticationResult = authenticationResultCacheEntry.getResult();
        }
    }
    return authenticationResult;
}
 
Example 3
Source File: OpenIDHandler.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private AuthenticationResult getAuthenticationResultFromCache(String sessionDataKey) {
    AuthenticationResult authResult = null;
    AuthenticationResultCacheEntry authResultCacheEntry = FrameworkUtils.getAuthenticationResultFromCache(sessionDataKey);
    if (authResultCacheEntry != null) {
        authResult = authResultCacheEntry.getResult();
    } else {
        log.error("Cannot find AuthenticationResult from the cache");
    }

    return authResult;
}
 
Example 4
Source File: PassiveSTS.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private AuthenticationResult getAuthenticationResultFromCache(String sessionDataKey) {
    AuthenticationResult authResult = null;
    AuthenticationResultCacheEntry authResultCacheEntry = FrameworkUtils.getAuthenticationResultFromCache(sessionDataKey);
    if (authResultCacheEntry != null) {
        authResult = authResultCacheEntry.getResult();
    } else {
        log.error("AuthenticationResult does not exist. Probably due to cache timeout");
    }

    return authResult;
}
 
Example 5
Source File: SAMLSSOProviderServlet.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private AuthenticationResult getAuthenticationResultFromCache(String sessionDataKey) {
    AuthenticationResult authResult = null;
    AuthenticationResultCacheEntry authResultCacheEntry = FrameworkUtils
            .getAuthenticationResultFromCache(sessionDataKey);
    if (authResultCacheEntry != null) {
        authResult = authResultCacheEntry.getResult();
    } else {
        log.error("Cannot find AuthenticationResult from the cache");
    }
    return authResult;
}
 
Example 6
Source File: OAuth2AuthzEndpoint.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private AuthenticationResult getAuthenticationResultFromCache(String sessionDataKey) {
    AuthenticationResult authResult = null;
    AuthenticationResultCacheEntry authResultCacheEntry = FrameworkUtils
            .getAuthenticationResultFromCache(sessionDataKey);
    if (authResultCacheEntry != null) {
        authResult = authResultCacheEntry.getResult();
    } else {
        log.error("Cannot find AuthenticationResult from the cache");
    }
    return authResult;
}