use of org.pac4j.core.http.callback.CallbackUrlResolver in project pac4j by pac4j.
the class ClientsTests method testValuesSet.
@Test
public void testValuesSet() {
var facebookClient = newFacebookClient();
final var clients = new Clients(facebookClient);
final AjaxRequestResolver ajaxRequestResolver = new DefaultAjaxRequestResolver();
final UrlResolver urlResolver = new DefaultUrlResolver();
final CallbackUrlResolver callbackUrlResolver = new QueryParameterCallbackUrlResolver();
final AuthorizationGenerator authorizationGenerator = (context, store, profile) -> Optional.of(profile);
clients.setCallbackUrl(CALLBACK_URL);
clients.setAjaxRequestResolver(ajaxRequestResolver);
clients.setUrlResolver(urlResolver);
clients.setCallbackUrlResolver(callbackUrlResolver);
clients.addAuthorizationGenerator(authorizationGenerator);
clients.findAllClients();
assertEquals(CALLBACK_URL, facebookClient.getCallbackUrl());
assertEquals(urlResolver, facebookClient.getUrlResolver());
assertEquals(callbackUrlResolver, facebookClient.getCallbackUrlResolver());
assertEquals(ajaxRequestResolver, facebookClient.getAjaxRequestResolver());
assertEquals(authorizationGenerator, facebookClient.getAuthorizationGenerators().get(0));
}
use of org.pac4j.core.http.callback.CallbackUrlResolver in project pac4j by pac4j.
the class CasClientTests method testCallbackUrlResolver.
@Test
public void testCallbackUrlResolver() {
final var configuration = new CasConfiguration();
configuration.setPrefixUrl(CAS);
configuration.setLoginUrl(CAS + LOGIN);
final var casClient = new CasClient(configuration);
casClient.setCallbackUrl(CASBACK);
casClient.setUrlResolver((url, context) -> HOST + url);
casClient.setCallbackUrlResolver(new CallbackUrlResolver() {
@Override
public String compute(final UrlResolver urlResolver, final String url, final String clientName, final WebContext context) {
return null;
}
@Override
public boolean matches(final String clientName, final WebContext context) {
return false;
}
});
casClient.init();
assertEquals(HOST + CAS + LOGIN, configuration.computeFinalLoginUrl(null));
assertEquals(HOST + CAS + "/", configuration.computeFinalPrefixUrl(null));
}
Aggregations