use of org.pac4j.core.exception.http.FoundAction in project cas by apereo.
the class OAuth20DefaultCasClientRedirectActionBuilder method build.
/**
* Build with predefined renew and gateway parameters.
*
* @param casClient the cas client config
* @param context the context
* @param renew ask for credentials again
* @param gateway skip asking for credentials
* @return the redirect action
*/
protected Optional<RedirectionAction> build(final CasClient casClient, final WebContext context, final boolean renew, final boolean gateway) {
val serviceUrl = casClient.computeFinalCallbackUrl(context);
val casServerLoginUrl = casClient.getConfiguration().getLoginUrl();
val redirectionUrl = casServerLoginUrl + (casServerLoginUrl.contains("?") ? "&" : "?") + CasProtocolConstants.PARAMETER_SERVICE + '=' + EncodingUtils.urlEncode(serviceUrl) + (renew ? '&' + CasProtocolConstants.PARAMETER_RENEW + "=true" : StringUtils.EMPTY) + (gateway ? '&' + CasProtocolConstants.PARAMETER_GATEWAY + "=true" : StringUtils.EMPTY);
LOGGER.debug("Final redirect url is [{}]", redirectionUrl);
return Optional.of(new FoundAction(redirectionUrl));
}
use of org.pac4j.core.exception.http.FoundAction in project ddf by codice.
the class OidcLogoutActionProviderTest method testGetAction.
@Test
public void testGetAction() {
String actionUrl = "https://localhost:8993/services/oidc/logout";
FoundAction foundAction = mock(FoundAction.class);
when(foundAction.getLocation()).thenReturn(actionUrl);
when(oidcLogoutActionBuilder.getLogoutAction(any(), any(), any())).thenReturn(Optional.of(foundAction));
Action action = oidcLogoutActionProvider.getAction(ImmutableMap.of(SecurityConstants.SECURITY_SUBJECT, subject, "http_request", request, "http_response", response));
assertEquals(actionUrl, action.getUrl().toString());
}
use of org.pac4j.core.exception.http.FoundAction in project cas by apereo.
the class DelegatedAuthenticationClientFinishLogoutActionTests method verifyOperationFailsWithError.
@Test
public void verifyOperationFailsWithError() throws Exception {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
request.addParameter(SamlProtocolConstants.PARAMETER_SAML_RELAY_STATE, "SAML2Client");
val response = new MockHttpServletResponse();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, response));
val samlClient = (SAML2Client) builtClients.findClient("SAML2Client").get();
val handler = mock(SAML2ProfileHandler.class);
when(handler.receive(any())).thenThrow(new FoundAction("https://google.com"));
samlClient.setLogoutProfileHandler(handler);
val result = delegatedAuthenticationClientFinishLogoutAction.execute(context);
assertNull(result);
assertEquals(HttpStatus.FOUND.value(), response.getStatus());
assertEquals("https://google.com", response.getHeader("Location"));
}
Aggregations