• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Authenticator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: oAuthUserAuthenticator

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


示例17: getAuthenticator

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


示例18: getAuthenticator

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
@Override
protected Authenticator<TokenCredentials> getAuthenticator(final Credential credential) {
    final TokenCredential tokenCredential = (TokenCredential) credential;
    LOGGER.debug("Locating token secret for service [{}]", tokenCredential.getService());

    final RegisteredService service = this.servicesManager.findServiceBy(tokenCredential.getService());
    final String signingSecret = getRegisteredServiceJwtSigningSecret(service);
    final String encryptionSecret = getRegisteredServiceJwtEncryptionSecret(service);

    final String signingSecretAlg =
            StringUtils.defaultString(getRegisteredServiceJwtSecret(service, TokenConstants.PROPERTY_NAME_TOKEN_SECRET_SIGNING_ALG),
                    JWSAlgorithm.HS256.getName());

    final String encryptionSecretAlg =
            StringUtils.defaultString(getRegisteredServiceJwtSecret(service, TokenConstants.PROPERTY_NAME_TOKEN_SECRET_ENCRYPTION_ALG),
                    JWEAlgorithm.DIR.getName());

    final String encryptionSecretMethod =
            StringUtils.defaultString(getRegisteredServiceJwtSecret(service, TokenConstants.PROPERTY_NAME_TOKEN_SECRET_ENCRYPTION_METHOD),
                    EncryptionMethod.A192CBC_HS384.getName());

    if (StringUtils.isNotBlank(signingSecret)) {
        Set<Algorithm> sets = new HashSet<>();
        sets.addAll(JWSAlgorithm.Family.EC);
        sets.addAll(JWSAlgorithm.Family.HMAC_SHA);
        sets.addAll(JWSAlgorithm.Family.RSA);
        sets.addAll(JWSAlgorithm.Family.SIGNATURE);

        final JWSAlgorithm signingAlg = findAlgorithmFamily(sets, signingSecretAlg);

        final JwtAuthenticator a = new JwtAuthenticator();
        a.setSignatureConfiguration(new SecretSignatureConfiguration(signingSecret, signingAlg));

        if (StringUtils.isNotBlank(encryptionSecret)) {
            sets = new HashSet<>();
            sets.addAll(JWEAlgorithm.Family.AES_GCM_KW);
            sets.addAll(JWEAlgorithm.Family.AES_KW);
            sets.addAll(JWEAlgorithm.Family.ASYMMETRIC);
            sets.addAll(JWEAlgorithm.Family.ECDH_ES);
            sets.addAll(JWEAlgorithm.Family.PBES2);
            sets.addAll(JWEAlgorithm.Family.RSA);
            sets.addAll(JWEAlgorithm.Family.SYMMETRIC);

            final JWEAlgorithm encAlg = findAlgorithmFamily(sets, encryptionSecretAlg);

            sets = new HashSet<>();
            sets.addAll(EncryptionMethod.Family.AES_CBC_HMAC_SHA);
            sets.addAll(EncryptionMethod.Family.AES_GCM);

            final EncryptionMethod encMethod = findAlgorithmFamily(sets, encryptionSecretMethod);
            a.setEncryptionConfiguration(new SecretEncryptionConfiguration(encryptionSecret, encAlg, encMethod));
        } else {
            LOGGER.warn("JWT authentication is configured to share a single key for both signing/encryption");
        }
        return a;
    }
    LOGGER.warn("No token signing secret is defined for service [{}]. Ensure [{}] property is defined for service",
            service.getServiceId(), TokenConstants.PROPERTY_NAME_TOKEN_SECRET_SIGNING);
    return null;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:61,代码来源:TokenAuthenticationHandler.java


示例19: DirectBasicAuthClient

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
public DirectBasicAuthClient(Authenticator usernamePasswordAuthenticator) {
    this.defaultAuthenticator(usernamePasswordAuthenticator);
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:4,代码来源:DirectBasicAuthClient.java


示例20: getAuthenticator

import org.pac4j.core.credentials.authenticator.Authenticator; //导入依赖的package包/类
public Authenticator<C, WC> getAuthenticator() {
    return authenticator;
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:4,代码来源:BaseClient.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PublicKeyFactoryBean类代码示例发布时间:2022-05-22
下一篇:
Java JCalendarDialog类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap