当前位置: 首页>>代码示例>>Java>>正文


Java Authenticator类代码示例

本文整理汇总了Java中org.pac4j.core.credentials.authenticator.Authenticator的典型用法代码示例。如果您正苦于以下问题:Java Authenticator类的具体用法?Java Authenticator怎么用?Java Authenticator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Authenticator类属于org.pac4j.core.credentials.authenticator包,在下文中一共展示了Authenticator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: oauthSecConfig

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
@RefreshScope
@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);
    return new Config(OAuth20Utils.casOAuthCallbackUrl(casProperties.getServer().getPrefix()),
            oauthCasClient, basicAuthClient, directFormClient, userFormClient);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:24,代码来源:CasOAuthConfiguration.java

示例2: internalTestRestForm

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
private void internalTestRestForm(final Authenticator authenticator) throws HttpAction {
    final CasRestFormClient client = new CasRestFormClient();
    client.setAuthenticator(authenticator);

    final MockWebContext context = MockWebContext.create();
    context.addRequestParameter(client.getUsernameParameter(), USER);
    context.addRequestParameter(client.getPasswordParameter(), USER);

    final UsernamePasswordCredentials credentials = client.getCredentials(context);
    final CasRestProfile profile = client.getUserProfile(credentials, context);
    assertEquals(USER, profile.getId());
    assertNotNull(profile.getTicketGrantingTicketId());

    final TokenCredentials casCreds = client.requestServiceTicket(PAC4J_BASE_URL, profile);
    final CasProfile casProfile = client.validateServiceTicket(PAC4J_BASE_URL, casCreds);
    assertNotNull(casProfile);
    assertEquals(USER, casProfile.getId());
    assertTrue(casProfile.getAttributes().size() > 0);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:20,代码来源:CasRestClientIT.java

示例3: getConfig

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
default Config getConfig() {
    // login not used because the ajax resolver always answer true
    Authenticator<UsernamePasswordCredentials> auth = new SimpleTestUsernamePasswordAuthenticator();
    FormClient client = new FormClient("notUsedLoginUrl", auth);
    DirectFormClient client2 = new DirectFormClient(auth);
    DirectFormClient client3 = new DirectFormClient(auth);
    client3.setName(DEFAULT_CLIENT);

    Clients clients = new Clients("notUsedCallbackUrl", client, client2, client3);
    // in case of invalid credentials, we simply want the error, not a redirect to the login url
    clients.setAjaxRequestResolver((c) -> true);
    // so that callback url have the correct prefix w.r.t. the container's context
    clients.setUrlResolver(new JaxRsUrlResolver());

    JaxRsConfig config = new JaxRsConfig();
    config.setClients(clients);
    config.setDefaultClients(DEFAULT_CLIENT);

    return config;
}
 
开发者ID:pac4j,项目名称:jax-rs-pac4j,代码行数:21,代码来源:TestConfig.java

示例4: form

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
/**
 * Add a form auth client.
 *
 * @param pattern URL pattern to protect.
 * @param authenticator Authenticator to use.
 * @return This module.
 */
public Auth form(final String pattern,
    final Class<? extends Authenticator<UsernamePasswordCredentials>> authenticator) {
  bindings.put(pattern, (binder, conf) -> {
    TypeLiteral<Authenticator<UsernamePasswordCredentials>> usernamePasswordAuthenticator = new TypeLiteral<Authenticator<UsernamePasswordCredentials>>() {
    };
    binder.bind(usernamePasswordAuthenticator.getRawType()).to(authenticator);

    bindProfile(binder, CommonProfile.class);

    Multibinder.newSetBinder(binder, Client.class)
        .addBinding().toProvider(FormAuth.class);

    return new FormFilter(conf.getString("auth.form.loginUrl"),
        conf.getString("application.path") + authCallbackPath(conf));
  });

  return this;
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:26,代码来源:Auth.java

示例5: basic

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
/**
 * Add a basic auth client.
 *
 * @param pattern URL pattern to protect.
 * @param authenticator Authenticator to use.
 * @return This module.
 */
public Auth basic(final String pattern,
    final Class<? extends Authenticator<UsernamePasswordCredentials>> authenticator) {
  bindings.put(pattern, (binder, config) -> {
    TypeLiteral<Authenticator<UsernamePasswordCredentials>> usernamePasswordAuthenticator = new TypeLiteral<Authenticator<UsernamePasswordCredentials>>() {
    };
    binder.bind(usernamePasswordAuthenticator.getRawType()).to(authenticator);

    bindProfile(binder, CommonProfile.class);

    Multibinder.newSetBinder(binder, Client.class)
        .addBinding().toProvider(BasicAuth.class);

    return new AuthFilter(IndirectBasicAuthClient.class, CommonProfile.class);
  });
  return this;
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:24,代码来源:Auth.java

示例6: doAuthentication

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
    CommonHelper.assertNotNull("profileCreator", this.profileCreator);

    final C credentials = convertToPac4jCredentials((I) credential);
    LOGGER.debug("credentials: [{}]", credentials);

    try {
        final Authenticator authenticator = getAuthenticator(credential);
 
        if (authenticator instanceof InitializableObject) {
            ((InitializableObject) authenticator).init();
        }
        if (authenticator instanceof InitializableWebObject) {
            ((InitializableWebObject) authenticator).init(getWebContext());
        }
        
        CommonHelper.assertNotNull("authenticator", authenticator);
        authenticator.validate(credentials, getWebContext());

        final UserProfile profile = this.profileCreator.create(credentials, getWebContext());
        LOGGER.debug("profile: [{}]", profile);

        return createResult(new ClientCredential(credentials), profile);
    } catch (final Exception e) {
        LOGGER.error("Failed to validate credentials", e);
        throw new FailedLoginException("Failed to validate credentials: " + e.getMessage());
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:30,代码来源:AbstractWrapperAuthenticationHandler.java

示例7: getAuthenticator

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
@Override
protected Authenticator<UsernamePasswordCredentials> getAuthenticator(final Credential credential) {
    final MongoClientURI uri = new MongoClientURI(this.mongoHostUri);
    final MongoClient client = new MongoClient(uri);
    LOGGER.info("Connected to MongoDb instance @ [{}] using database [{}]",
            uri.getHosts(), uri.getDatabase());

    final MongoAuthenticator mongoAuthenticator = new MongoAuthenticator(client, this.attributes);
    mongoAuthenticator.setUsersCollection(this.collectionName);
    mongoAuthenticator.setUsersDatabase(uri.getDatabase());
    mongoAuthenticator.setUsernameAttribute(this.usernameAttribute);
    mongoAuthenticator.setPasswordAttribute(this.passwordAttribute);
    mongoAuthenticator.setPasswordEncoder(this.mongoPasswordEncoder);
    return mongoAuthenticator;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:16,代码来源:MongoAuthenticationHandler.java

示例8: ParameterClient

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
public ParameterClient(final String parameterName,
                       final Authenticator tokenAuthenticator,
                       final ProfileCreator profileCreator) {
    this.parameterName = parameterName;
    setAuthenticator(tokenAuthenticator);
    setProfileCreator(profileCreator);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:ParameterClient.java

示例9: HeaderClient

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
public HeaderClient(final String headerName, final String prefixHeader,
                    final Authenticator tokenAuthenticator, final ProfileCreator profileCreator) {
    this.headerName = headerName;
    this.prefixHeader = prefixHeader;
    setAuthenticator(tokenAuthenticator);
    setProfileCreator(profileCreator);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:HeaderClient.java

示例10: FormClient

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
public FormClient(final String loginUrl, final String usernameParameter, final String passwordParameter,
                  final Authenticator usernamePasswordAuthenticator) {
    this.loginUrl = loginUrl;
    this.usernameParameter = usernameParameter;
    this.passwordParameter = passwordParameter;
    setAuthenticator(usernamePasswordAuthenticator);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:FormClient.java

示例11: getCasRestAuthenticator

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
public CasRestAuthenticator getCasRestAuthenticator() {
    Authenticator authenticator = getAuthenticator();
    if (authenticator instanceof LocalCachingAuthenticator) {
        authenticator = ((LocalCachingAuthenticator) authenticator).getDelegate();
    }
    if (authenticator instanceof CasRestAuthenticator) {
        return (CasRestAuthenticator) authenticator;
    }
    throw new TechnicalException("authenticator must be a CasRestAuthenticator (or via a LocalCachingAuthenticator)");
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:11,代码来源:AbstractCasRestClient.java

示例12: setup

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
@Override
public void setup(Bootstrap<?> bootstrap) {
    ObjectMapper om = bootstrap.getObjectMapper();

    // for Config
    om.addMixIn(SessionStore.class, sessionStoreMixin());
    om.addMixIn(Authorizer.class, authorizerMixin());
    om.addMixIn(HttpActionAdapter.class, httpActionAdapterMixin());
    om.addMixIn(Matcher.class, matcherMixin());
    om.addMixIn(SecurityLogic.class, securityLogicMixin());
    om.addMixIn(CallbackLogic.class, callbackLogicMixin());
    om.addMixIn(LogoutLogic.class, logoutLogicMixin());

    // for Clients
    om.addMixIn(Client.class, clientMixin());
    om.addMixIn(BaseClient.class, baseClientMixin());

    // for Clients and Client subsclasses
    om.addMixIn(AjaxRequestResolver.class, ajaxRequestResolverMixin());
    om.addMixIn(UrlResolver.class, urlResolverMixin());
    om.addMixIn(AuthorizationGenerator.class,
            authorizationGeneratorMixin());

    // for Client/BaseClient
    om.addMixIn(Authenticator.class, authenticatorMixin());
    om.addMixIn(CredentialsExtractor.class, credentialExtractorMixin());
    om.addMixIn(ProfileCreator.class, profileCreatorMixin());

    // for IndirectClient
    om.addMixIn(RedirectActionBuilder.class, redirectActionBuilderMixin());
    om.addMixIn(LogoutActionBuilder.class, logoutActionBuilderMixin());
    
    // for some of the Authenticators
    om.addMixIn(PasswordEncoder.class, passwordEncoderMixin());
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:36,代码来源:DefaultFeatureSupport.java

示例13: getAuthenticator

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
@Override
protected Authenticator<UsernamePasswordCredentials> getAuthenticator(final Credential credential) {
    return this.authenticator;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:5,代码来源:UsernamePasswordWrapperAuthenticationHandler.java

示例14: setAuthenticator

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
public void setAuthenticator(final Authenticator<UsernamePasswordCredentials> authenticator) {
    this.authenticator = authenticator;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:4,代码来源:UsernamePasswordWrapperAuthenticationHandler.java

示例15: oAuthClientAuthenticator

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
@ConditionalOnMissingBean(name = "oAuthClientAuthenticator")
@Bean
@RefreshScope
public Authenticator<UsernamePasswordCredentials> oAuthClientAuthenticator() {
    return new OAuthClientAuthenticator(oAuthValidator(), this.servicesManager);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:7,代码来源:CasOAuthConfiguration.java


注:本文中的org.pac4j.core.credentials.authenticator.Authenticator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。