use of org.pac4j.core.http.url.UrlResolver in project pac4j by pac4j.
the class ClientsTests method testValuesSet.
@Test
public void testValuesSet() {
MockIndirectClient facebookClient = newFacebookClient();
final Clients clients = new Clients(facebookClient);
final AjaxRequestResolver ajaxRequestResolver = new DefaultAjaxRequestResolver();
final UrlResolver urlResolver = new DefaultUrlResolver();
final CallbackUrlResolver callbackUrlResolver = new QueryParameterCallbackUrlResolver();
final AuthorizationGenerator authorizationGenerator = (context, profile) -> profile;
clients.setCallbackUrl(CALLBACK_URL);
clients.setAjaxRequestResolver(ajaxRequestResolver);
clients.setUrlResolver(urlResolver);
clients.setCallbackUrlResolver(callbackUrlResolver);
clients.addAuthorizationGenerator(authorizationGenerator);
clients.init();
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.url.UrlResolver in project pac4j by pac4j.
the class CasClientTests method testCallbackUrlResolver.
@Test
public void testCallbackUrlResolver() {
final CasConfiguration configuration = new CasConfiguration();
configuration.setPrefixUrl(CAS);
configuration.setLoginUrl(CAS + LOGIN);
final CasClient 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