use of org.pac4j.core.http.url.DefaultUrlResolver 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.DefaultUrlResolver in project pac4j by pac4j.
the class QueryParameterCallbackUrlResolverTests method testComputeCallbackUrlAlreadyDefined.
@Test
public void testComputeCallbackUrlAlreadyDefined() {
final String callbackUrl = CALLBACK_URL + '?' + Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER + "=cn";
final String url = resolver.compute(new DefaultUrlResolver(), callbackUrl, CLIENT_NAME, MockWebContext.create());
assertEquals(callbackUrl, url);
}
use of org.pac4j.core.http.url.DefaultUrlResolver in project pac4j by pac4j.
the class QueryParameterCallbackUrlResolverTests method testParams.
@Test
public void testParams() {
final String url = new QueryParameterCallbackUrlResolver(ImmutableMap.of("param1", "value", "param2", "value2")).compute(new DefaultUrlResolver(), CALLBACK_URL, CLIENT_NAME, MockWebContext.create());
assertEquals(CALLBACK_URL + '?' + Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER + '=' + CLIENT_NAME + "¶m1=value¶m2=value2", url);
}
use of org.pac4j.core.http.url.DefaultUrlResolver in project pac4j by pac4j.
the class CasConfiguration method internalInit.
@Override
protected void internalInit() {
if (CommonHelper.isBlank(this.loginUrl) && CommonHelper.isBlank(this.prefixUrl) && CommonHelper.isBlank(this.restUrl)) {
throw new TechnicalException("loginUrl, prefixUrl and restUrl cannot be all blank");
}
if (urlResolver == null) {
urlResolver = new DefaultUrlResolver();
}
initializeClientConfiguration();
initializeLogoutHandler();
}
use of org.pac4j.core.http.url.DefaultUrlResolver in project pac4j by pac4j.
the class IndirectClient method internalInit.
@Override
protected final void internalInit() {
// check configuration
CommonHelper.assertNotBlank("callbackUrl", this.callbackUrl, "set it up either on this IndirectClient or on the global Config");
if (this.urlResolver == null) {
this.urlResolver = new DefaultUrlResolver();
}
if (this.callbackUrlResolver == null) {
this.callbackUrlResolver = new QueryParameterCallbackUrlResolver();
}
if (this.ajaxRequestResolver == null) {
ajaxRequestResolver = new DefaultAjaxRequestResolver();
}
clientInit();
// ensures components have been properly initialized
CommonHelper.assertNotNull("redirectActionBuilder", this.redirectActionBuilder);
CommonHelper.assertNotNull("credentialsExtractor", getCredentialsExtractor());
CommonHelper.assertNotNull("authenticator", getAuthenticator());
CommonHelper.assertNotNull("profileCreator", getProfileCreator());
CommonHelper.assertNotNull("logoutActionBuilder", this.logoutActionBuilder);
}
Aggregations