Search in sources :

Example 6 with DefaultUrlResolver

use of org.pac4j.core.http.url.DefaultUrlResolver in project pac4j by pac4j.

the class PathParameterCallbackUrlResolverTests method testCompute.

@Test
public void testCompute() {
    final String url = resolver.compute(new DefaultUrlResolver(), CALLBACK_URL, CLIENT_NAME, MockWebContext.create());
    assertEquals(CALLBACK_URL + "/" + CLIENT_NAME, url);
}
Also used : DefaultUrlResolver(org.pac4j.core.http.url.DefaultUrlResolver) Test(org.junit.Test)

Example 7 with DefaultUrlResolver

use of org.pac4j.core.http.url.DefaultUrlResolver in project pac4j by pac4j.

the class QueryParameterCallbackUrlResolverTests method testComputeSpecificParameter.

@Test
public void testComputeSpecificParameter() {
    final QueryParameterCallbackUrlResolver resolver = new QueryParameterCallbackUrlResolver();
    resolver.setClientNameParameter(KEY);
    final String url = resolver.compute(new DefaultUrlResolver(), CALLBACK_URL, CLIENT_NAME, MockWebContext.create());
    assertEquals(CALLBACK_URL + '?' + KEY + '=' + CLIENT_NAME, url);
}
Also used : DefaultUrlResolver(org.pac4j.core.http.url.DefaultUrlResolver) Test(org.junit.Test)

Example 8 with DefaultUrlResolver

use of org.pac4j.core.http.url.DefaultUrlResolver in project pac4j by pac4j.

the class QueryParameterCallbackUrlResolverTests method testCompute.

@Test
public void testCompute() {
    final String url = resolver.compute(new DefaultUrlResolver(), CALLBACK_URL, CLIENT_NAME, MockWebContext.create());
    assertEquals(CALLBACK_URL + '?' + Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER + '=' + CLIENT_NAME, url);
}
Also used : DefaultUrlResolver(org.pac4j.core.http.url.DefaultUrlResolver) Test(org.junit.Test)

Example 9 with DefaultUrlResolver

use of org.pac4j.core.http.url.DefaultUrlResolver in project druid by druid-io.

the class Pac4jAuthenticator method createPac4jConfig.

private Config createPac4jConfig(OIDCConfig oidcConfig) {
    OidcConfiguration oidcConf = new OidcConfiguration();
    oidcConf.setClientId(oidcConfig.getClientID());
    oidcConf.setSecret(oidcConfig.getClientSecret().getPassword());
    oidcConf.setDiscoveryURI(oidcConfig.getDiscoveryURI());
    oidcConf.setExpireSessionWithToken(true);
    oidcConf.setUseNonce(true);
    oidcConf.setReadTimeout(Ints.checkedCast(pac4jCommonConfig.getReadTimeout().getMillis()));
    oidcConf.setResourceRetriever(// ResourceRetriever is used to get Auth server configuration from "discoveryURI"
    new CustomSSLResourceRetriever(pac4jCommonConfig.getReadTimeout().getMillis(), sslSocketFactory));
    OidcClient oidcClient = new OidcClient(oidcConf);
    oidcClient.setUrlResolver(new DefaultUrlResolver(true));
    oidcClient.setCallbackUrlResolver(new NoParameterCallbackUrlResolver());
    // This is used by OidcClient in various places to make HTTPrequests.
    if (sslSocketFactory != null) {
        HTTPRequest.setDefaultSSLSocketFactory(sslSocketFactory);
    }
    return new Config(Pac4jCallbackResource.SELF_URL, oidcClient);
}
Also used : OidcConfiguration(org.pac4j.oidc.config.OidcConfiguration) OidcClient(org.pac4j.oidc.client.OidcClient) Config(org.pac4j.core.config.Config) DefaultUrlResolver(org.pac4j.core.http.url.DefaultUrlResolver) NoParameterCallbackUrlResolver(org.pac4j.core.http.callback.NoParameterCallbackUrlResolver)

Aggregations

DefaultUrlResolver (org.pac4j.core.http.url.DefaultUrlResolver)9 Test (org.junit.Test)6 DefaultAjaxRequestResolver (org.pac4j.core.http.ajax.DefaultAjaxRequestResolver)2 QueryParameterCallbackUrlResolver (org.pac4j.core.http.callback.QueryParameterCallbackUrlResolver)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Assert (org.junit.Assert)1 AuthorizationGenerator (org.pac4j.core.authorization.generator.AuthorizationGenerator)1 Config (org.pac4j.core.config.Config)1 Credentials (org.pac4j.core.credentials.Credentials)1 TechnicalException (org.pac4j.core.exception.TechnicalException)1 AjaxRequestResolver (org.pac4j.core.http.ajax.AjaxRequestResolver)1 CallbackUrlResolver (org.pac4j.core.http.callback.CallbackUrlResolver)1 NoParameterCallbackUrlResolver (org.pac4j.core.http.callback.NoParameterCallbackUrlResolver)1 UrlResolver (org.pac4j.core.http.url.UrlResolver)1 CommonProfile (org.pac4j.core.profile.CommonProfile)1 RedirectAction (org.pac4j.core.redirect.RedirectAction)1 TestsConstants (org.pac4j.core.util.TestsConstants)1 TestsHelper (org.pac4j.core.util.TestsHelper)1 OidcClient (org.pac4j.oidc.client.OidcClient)1