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());
}
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);
}
Aggregations