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

The following examples show how to use org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext#setRememberMe() . 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: 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 2
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 3
Source File: DefaultAuthenticationRequestHandler.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private void handleRememberMeOptionFromLoginPage(HttpServletRequest request, AuthenticationContext context) {

        // If the remember me flag is already set in one step, we don't need to override.
        if (context.isRememberMe()) {
            return;
        }

        String rememberMe = request.getParameter(FrameworkConstants.RequestParams.REMEMBER_ME);

        if (FrameworkConstants.REMEMBER_ME_OPT_ON.equalsIgnoreCase(rememberMe)) {
            context.setRememberMe(true);
        } else {
            context.setRememberMe(false);
        }
    }
 
Example 4
Source File: DefaultAuthenticationRequestHandler.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private void handleRememberMeOptionFromLoginPage(HttpServletRequest request, AuthenticationContext context) {
    String rememberMe = request.getParameter("chkRemember");

    if (rememberMe != null && "on".equalsIgnoreCase(rememberMe)) {
        context.setRememberMe(true);
    } else {
        context.setRememberMe(false);
    }
}