Search in sources :

Example 6 with AttributesContext

use of org.forgerock.services.context.AttributesContext in project OpenAM by OpenRock.

the class AuthenticationServiceV1 method getHttpServletResponse.

private HttpServletResponse getHttpServletResponse(Context context) {
    AttributesContext requestContext = context.asContext(AttributesContext.class);
    Map<String, Object> requestAttributes = requestContext.getAttributes();
    return (HttpServletResponse) requestAttributes.get(HttpServletResponse.class.getName());
}
Also used : AttributesContext(org.forgerock.services.context.AttributesContext) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Example 7 with AttributesContext

use of org.forgerock.services.context.AttributesContext in project OpenAM by OpenRock.

the class SessionResourceTest method shouldUsePAPLogoutRedirectUrlWhenSet.

@Test
public void shouldUsePAPLogoutRedirectUrlWhenSet() throws Exception {
    // Given
    final String sessionId = "SSO_TOKEN_ID";
    final String logoutUrl = "http://forgerock.com/about";
    final ActionRequest request = mock(ActionRequest.class);
    final HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
    final AttributesContext context = new AttributesContext(new AdviceContext(realmContext, Collections.<String>emptyList()));
    final SSOTokenID tokenId = mock(SSOTokenID.class);
    context.getAttributes().put(HttpServletRequest.class.getName(), httpServletRequest);
    given(request.getAction()).willReturn(LOGOUT_ACTION_ID);
    given(ssoTokenManager.createSSOToken(sessionId)).willReturn(ssoToken);
    given(ssoToken.getTokenID()).willReturn(tokenId);
    given(tokenId.toString()).willReturn(sessionId);
    given(authUtilsWrapper.logout(eq(sessionId), eq(httpServletRequest), any(HttpServletResponse.class))).willReturn(true);
    given(authUtilsWrapper.getPostProcessLogoutURL(httpServletRequest)).willReturn(logoutUrl);
    // When
    ActionResponse response = sessionResource.actionInstance(context, sessionId, request).getOrThrowUninterruptibly();
    // Then
    assertThat(response).isNotNull().withContent().stringAt("goto").isEqualTo(logoutUrl);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SSOTokenID(com.iplanet.sso.SSOTokenID) AttributesContext(org.forgerock.services.context.AttributesContext) HttpServletResponse(javax.servlet.http.HttpServletResponse) Test(org.testng.annotations.Test)

Aggregations

AttributesContext (org.forgerock.services.context.AttributesContext)7 SessionContext (org.forgerock.http.session.SessionContext)4 RootContext (org.forgerock.services.context.RootContext)4 Test (org.testng.annotations.Test)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 SSOTokenID (com.iplanet.sso.SSOTokenID)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Request (org.forgerock.http.protocol.Request)2 Response (org.forgerock.http.protocol.Response)2 RealmContext (org.forgerock.openam.rest.RealmContext)2 JsonValue (org.forgerock.json.JsonValue)1 SSOTokenContext (org.forgerock.openam.rest.resource.SSOTokenContext)1 ClientContext (org.forgerock.services.context.ClientContext)1 Context (org.forgerock.services.context.Context)1 RequestAuditContext (org.forgerock.services.context.RequestAuditContext)1 SecurityContext (org.forgerock.services.context.SecurityContext)1