Search in sources :

Example 1 with Authenticator

use of org.pac4j.core.credentials.authenticator.Authenticator in project cas by apereo.

the class CasOAuthConfiguration method oauthSecConfig.

@Bean
public Config oauthSecConfig() {
    final CasConfiguration cfg = new CasConfiguration(casProperties.getServer().getLoginUrl());
    final CasClient oauthCasClient = new CasClient(cfg);
    oauthCasClient.setRedirectActionBuilder(webContext -> oauthCasClientRedirectActionBuilder().build(oauthCasClient, webContext));
    oauthCasClient.setName(Authenticators.CAS_OAUTH_CLIENT);
    oauthCasClient.setUrlResolver(casCallbackUrlResolver());
    final Authenticator authenticator = oAuthClientAuthenticator();
    final DirectBasicAuthClient basicAuthClient = new DirectBasicAuthClient(authenticator);
    basicAuthClient.setName(Authenticators.CAS_OAUTH_CLIENT_BASIC_AUTHN);
    final DirectFormClient directFormClient = new DirectFormClient(authenticator);
    directFormClient.setName(Authenticators.CAS_OAUTH_CLIENT_DIRECT_FORM);
    directFormClient.setUsernameParameter(CLIENT_ID);
    directFormClient.setPasswordParameter(CLIENT_SECRET);
    final DirectFormClient userFormClient = new DirectFormClient(oAuthUserAuthenticator());
    userFormClient.setName(Authenticators.CAS_OAUTH_CLIENT_USER_FORM);
    final Config config = new Config(OAuth20Utils.casOAuthCallbackUrl(casProperties.getServer().getPrefix()), oauthCasClient, basicAuthClient, directFormClient, userFormClient);
    config.setSessionStore(new J2ESessionStore());
    return config;
}
Also used : J2ESessionStore(org.pac4j.core.context.session.J2ESessionStore) DirectFormClient(org.pac4j.http.client.direct.DirectFormClient) CasConfiguration(org.pac4j.cas.config.CasConfiguration) Config(org.pac4j.core.config.Config) DirectBasicAuthClient(org.pac4j.http.client.direct.DirectBasicAuthClient) OAuth20ClientAuthenticator(org.apereo.cas.support.oauth.authenticator.OAuth20ClientAuthenticator) Authenticator(org.pac4j.core.credentials.authenticator.Authenticator) OAuth20UserAuthenticator(org.apereo.cas.support.oauth.authenticator.OAuth20UserAuthenticator) CasClient(org.pac4j.cas.client.CasClient) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

OAuth20ClientAuthenticator (org.apereo.cas.support.oauth.authenticator.OAuth20ClientAuthenticator)1 OAuth20UserAuthenticator (org.apereo.cas.support.oauth.authenticator.OAuth20UserAuthenticator)1 CasClient (org.pac4j.cas.client.CasClient)1 CasConfiguration (org.pac4j.cas.config.CasConfiguration)1 Config (org.pac4j.core.config.Config)1 J2ESessionStore (org.pac4j.core.context.session.J2ESessionStore)1 Authenticator (org.pac4j.core.credentials.authenticator.Authenticator)1 DirectBasicAuthClient (org.pac4j.http.client.direct.DirectBasicAuthClient)1 DirectFormClient (org.pac4j.http.client.direct.DirectFormClient)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1