Java Code Examples for org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext#setRequestAuthenticated()

The following examples show how to use org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext#setRequestAuthenticated() . 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: GraphBasedSequenceHandler.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
private void handleEndOfSequence(HttpServletRequest request, HttpServletResponse response,
                                 AuthenticationContext context, SequenceConfig sequenceConfig) throws
        FrameworkException {

    if (log.isDebugEnabled()) {
        log.debug("There are no more steps to execute");
    }

    context.getSequenceConfig().setCompleted(true);
    context.setRequestAuthenticated(true);

    // if no step failed at authentication we should do post authentication work (e.g.
    // claim handling, provision etc)

    if (log.isDebugEnabled()) {
        log.debug("Request is successfully authenticated");
    }

    handlePostAuthentication(request, response, context);

    // we should get out of steps now.
    if (log.isDebugEnabled()) {
        log.debug("Step processing is completed");
    }
}
 
Example 2
Source File: DefaultAuthenticationRequestHandlerTest.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
@Test(dataProvider = "sendResponseDataProvider")
public void testSendResponse(boolean isRequestAuthenticated,
                             boolean isRememberMe,
                             String callerPath,
                             String sessionDataKey,
                             String expectedRedirectUrl) throws Exception {

    AuthenticationContext context = new AuthenticationContext();
    context.setRequestAuthenticated(isRequestAuthenticated);
    context.setRememberMe(isRememberMe);
    context.setCallerPath(callerPath);
    context.setCallerSessionKey(sessionDataKey);

    SequenceConfig sequenceConfig = spy(new SequenceConfig());
    context.setSequenceConfig(sequenceConfig);

    DefaultAuthenticationRequestHandler requestHandler = spy(new DefaultAuthenticationRequestHandler());
    doNothing().when(requestHandler).populateErrorInformation(request, response, context);

    ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
    requestHandler.sendResponse(request, response, context);
    verify(response).sendRedirect(captor.capture());
    assertEquals(captor.getValue(), expectedRedirectUrl);
}
 
Example 3
Source File: DefaultAuthenticationRequestHandlerTest.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
@Test(expectedExceptions = FrameworkException.class)
public void testSendResponseException() throws Exception {

    AuthenticationContext context = new AuthenticationContext();
    context.setRequestAuthenticated(true);
    context.setRememberMe(true);
    context.setCallerPath("/samlsso");
    String sessionDataKey = UUID.randomUUID().toString();
    context.setCallerSessionKey(sessionDataKey);

    SequenceConfig sequenceConfig = spy(new SequenceConfig());
    context.setSequenceConfig(sequenceConfig);

    doThrow(new IOException()).when(response).sendRedirect(anyString());
    authenticationRequestHandler.sendResponse(request, response, context);
}
 
Example 4
Source File: DefaultAuthenticationRequestHandler.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private void handleDenyFromLoginPage(HttpServletRequest request, HttpServletResponse response,
                                     AuthenticationContext context) throws FrameworkException {

    if (log.isDebugEnabled()) {
        log.debug("User has pressed Deny or Cancel in the login page. Terminating the authentication flow");
    }

    context.getSequenceConfig().setCompleted(true);
    context.setRequestAuthenticated(false);
    //No need to handle authorization, because the authentication is not completed
    concludeFlow(request, response, context);
}
 
Example 5
Source File: DefaultStepHandler.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
protected void handleFailedAuthentication(HttpServletRequest request,
                                          HttpServletResponse response,
                                          AuthenticationContext context,
                                          AuthenticatorConfig authenticatorConfig,
                                          User user) {
    context.setRequestAuthenticated(false);
    request.setAttribute(FrameworkConstants.RequestParams.FLOW_STATUS, AuthenticatorFlowStatus.FAIL_COMPLETED);
}
 
Example 6
Source File: DefaultAuthenticationRequestHandler.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private void handleDenyFromLoginPage(HttpServletRequest request, HttpServletResponse response,
                                     AuthenticationContext context) throws FrameworkException {
    if (log.isDebugEnabled()) {
        log.debug("User has pressed Deny or Cancel in the login page. Terminating the authentication flow");
    }

    context.getSequenceConfig().setCompleted(true);
    context.setRequestAuthenticated(false);
    concludeFlow(request, response, context);
}