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

Java CasClient类代码示例

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

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



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

示例1: configureCasClient

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
private void configureCasClient(final Collection<BaseClient> properties) {
    final AtomicInteger index = new AtomicInteger();
    casProperties.getAuthn().getPac4j().getCas()
            .stream()
            .filter(cas -> StringUtils.isNotBlank(cas.getLoginUrl()))
            .forEach(cas -> {
                final CasConfiguration cfg = new CasConfiguration(cas.getLoginUrl(), cas.getProtocol());
                final CasClient client = new CasClient(cfg);
                final int count = index.intValue();
                if (count > 0) {
                    client.setName(client.getClass().getSimpleName() + count);
                }
                index.incrementAndGet();
                LOGGER.debug("Created client [{}]", client);
                properties.add(client);
            });
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:Pac4jAuthenticationEventExecutionPlanConfiguration.java


示例2: oauthSecConfig

import org.pac4j.cas.client.CasClient; //导入依赖的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


示例3: tryCreateCasClient

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
private void tryCreateCasClient(final List<Client> clients) {
    for (int i = 0; i <= MAX_NUM_CLIENTS; i++) {
        final String loginUrl = getProperty(CAS_LOGIN_URL.concat(i == 0 ? "" : "." + i));
        final String protocol = getProperty(CAS_PROTOCOL.concat(i == 0 ? "" : "." + i));
        if (CommonHelper.isNotBlank(loginUrl)) {
            CasConfiguration configuration = new CasConfiguration();
            final CasClient casClient = new CasClient(configuration);
            configuration.setLoginUrl(loginUrl);
            if (CommonHelper.isNotBlank(protocol)) {
                configuration.setProtocol(CasProtocol.valueOf(protocol));
            }
            if (i != 0) {
                casClient.setName(casClient.getName().concat("." + i));
            }
            clients.add(casClient);
        }
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:19,代码来源:PropertiesConfigFactory.java


示例4: initCasSingleSignOn

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
/**
 * Initialize the BizDock SSO module based on CAS.
 */
private void initCasSingleSignOn() {
    log.info(">>>>>>>>>>>>>>>> Initialize CAS SSO");
    String casLoginUrl = getConfiguration().getString("cas.login.url");
    String casCallbackUrl = getPreferenceManagerPlugin().getPreferenceElseConfigurationValue(IFrameworkConstants.PUBLIC_URL_PREFERENCE, "maf.public.url")
            + getLocalRoutes().getCallbackRoute().url();
    final CasClient casClient = new CasClient();
    casClient.setLogoutHandler(new PlayLogoutHandler());
    casClient.setCasProtocol(CasClient.CasProtocol.SAML);
    casClient.setCasLoginUrl(casLoginUrl);
    casClient.setTimeTolerance(getConfiguration().getLong("cas.time_tolerance"));
    final Clients clients = new Clients(casCallbackUrl, casClient);
    Config.setClients(clients);
    Config.setDefaultLogoutUrl(getConfiguration().getString("cas.logout.url"));
    log.info(">>>>>>>>>>>>>>>> Initialize CAS SSO (end)");
}
 
开发者ID:theAgileFactory,项目名称:app-framework,代码行数:19,代码来源:AbstractAuthenticator.java


示例5: build

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
@Override
public RedirectAction build(final CasClient casClient, final WebContext context) {
    final Optional<Authentication> auth = oidcAuthorizationRequestSupport.isCasAuthenticationAvailable(context);
    auth.ifPresent(authentication -> oidcAuthorizationRequestSupport.configureClientForMaxAgeAuthorizationRequest(casClient, context, authentication));

    OidcAuthorizationRequestSupport.configureClientForPromptLoginAuthorizationRequest(casClient, context);
    OidcAuthorizationRequestSupport.configureClientForPromptNoneAuthorizationRequest(casClient, context);

    final RedirectAction action = super.build(casClient, context);
    LOGGER.debug("Final redirect action is [{}]", action);
    return action;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:13,代码来源:OidcCasClientRedirectActionBuilder.java


示例6: configureClientForPromptLoginAuthorizationRequest

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
/**
 * Configure client for prompt login authorization request.
 *
 * @param casClient the cas client
 * @param context   the context
 */
public static void configureClientForPromptLoginAuthorizationRequest(final CasClient casClient, final WebContext context) {
    final Set<String> prompts = getOidcPromptFromAuthorizationRequest(context);
    if (prompts.contains(OidcConstants.PROMPT_LOGIN)) {
        casClient.getConfiguration().setRenew(true);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:13,代码来源:OidcAuthorizationRequestSupport.java


示例7: configureClientForPromptNoneAuthorizationRequest

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
/**
 * Configure client for prompt none authorization request.
 *
 * @param casClient the cas client
 * @param context   the context
 */
public static void configureClientForPromptNoneAuthorizationRequest(final CasClient casClient, final WebContext context) {
    final Set<String> prompts = getOidcPromptFromAuthorizationRequest(context);
    if (prompts.contains(OidcConstants.PROMPT_NONE)) {
        casClient.getConfiguration().setRenew(false);
        casClient.getConfiguration().setGateway(true);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:14,代码来源:OidcAuthorizationRequestSupport.java


示例8: build

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
@Override
public RedirectAction build(final CasClient casClient, final WebContext context) {
    try {
        final CasConfiguration casConfiguration = casClient.getConfiguration();
        final String redirectionUrl = CommonUtils.constructRedirectUrl(casConfiguration.getLoginUrl(),
                CasProtocolConstants.PARAMETER_SERVICE,
                casClient.computeFinalCallbackUrl(context),
                casConfiguration.isRenew(), casConfiguration.isGateway());
        LOGGER.debug("Final redirect url is [{}]", redirectionUrl);
        return RedirectAction.redirect(redirectionUrl);
    } catch (final Exception e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:15,代码来源:OAuth20DefaultCasClientRedirectActionBuilder.java


示例9: requiresAuthenticationAuthorizeInterceptor

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
@Bean
public HandlerInterceptorAdapter requiresAuthenticationAuthorizeInterceptor() {
    final String name = oauthSecConfig.getClients().findClient(CasClient.class).getName();
    return new OidcSecurityInterceptor(oauthSecConfig, name, oidcAuthorizationRequestSupport());
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:6,代码来源:OidcConfiguration.java


示例10: test

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
@Test
public void test() {
    final Map<String, String> properties = new HashMap<>();
    properties.put(FACEBOOK_ID, ID);
    properties.put(FACEBOOK_SECRET, SECRET);
    properties.put(TWITTER_ID, ID);
    properties.put(TWITTER_SECRET, SECRET);
    properties.put(CAS_LOGIN_URL, CALLBACK_URL);
    properties.put(CAS_PROTOCOL, CasProtocol.CAS20.toString());
    properties.put(SAML_KEYSTORE_PASSWORD, PASSWORD);
    properties.put(SAML_PRIVATE_KEY_PASSWORD, PASSWORD);
    properties.put(SAML_KEYSTORE_PATH, PATH);
    properties.put(SAML_IDENTITY_PROVIDER_METADATA_PATH, PATH);
    properties.put(SAML_DESTINATION_BINDING_TYPE, SAMLConstants.SAML2_REDIRECT_BINDING_URI);
    properties.put(OIDC_ID, ID);
    properties.put(OIDC_SECRET, SECRET);
    properties.put(OIDC_DISCOVERY_URI, CALLBACK_URL);
    properties.put(OIDC_USE_NONCE, "true");
    properties.put(OIDC_PREFERRED_JWS_ALGORITHM, "RS384");
    properties.put(OIDC_MAX_CLOCK_SKEW, "60");
    properties.put(OIDC_CLIENT_AUTHENTICATION_METHOD, "CLIENT_SECRET_POST");
    properties.put(OIDC_CUSTOM_PARAM_KEY1, KEY);
    properties.put(OIDC_CUSTOM_PARAM_VALUE1, VALUE);

    properties.put(CAS_LOGIN_URL.concat(".1"), CALLBACK_URL);
    properties.put(CAS_PROTOCOL.concat(".1"), CasProtocol.CAS30.toString());

    properties.put(OIDC_TYPE.concat(".1"), "google");
    properties.put(OIDC_ID.concat(".1"), ID);
    properties.put(OIDC_SECRET.concat(".1"), SECRET);

    final PropertiesConfigFactory factory = new PropertiesConfigFactory(CALLBACK_URL, properties);
    final Config config = factory.build();
    final Clients clients = config.getClients();
    assertEquals(7, clients.getClients().size());

    final FacebookClient fbClient = (FacebookClient) clients.findClient("FacebookClient");
    assertEquals(ID, fbClient.getKey());
    assertEquals(SECRET, fbClient.getSecret());

    final TwitterClient twClient = (TwitterClient) clients.findClient("TwitterClient");
    assertEquals(ID, twClient.getKey());
    assertEquals(SECRET, twClient.getSecret());

    final CasClient casClient = (CasClient) clients.findClient("CasClient");
    assertEquals(CALLBACK_URL, casClient.getConfiguration().getLoginUrl());
    assertEquals(CasProtocol.CAS20, casClient.getConfiguration().getProtocol());

    final SAML2Client saml2client = (SAML2Client) clients.findClient("SAML2Client");
    assertNotNull(saml2client);
    assertEquals(SAMLConstants.SAML2_REDIRECT_BINDING_URI, saml2client.getConfiguration().getDestinationBindingType());

    final OidcClient oidcClient = (OidcClient) clients.findClient("OidcClient");
    assertNotNull(oidcClient);
    assertEquals(ClientAuthenticationMethod.CLIENT_SECRET_POST.toString(), oidcClient.getConfiguration().getClientAuthenticationMethod().toString().toLowerCase());

    final CasClient casClient1 = (CasClient) clients.findClient("CasClient.1");
    assertEquals(CasProtocol.CAS30, casClient1.getConfiguration().getProtocol());

    final GoogleOidcClient googleOidcClient = (GoogleOidcClient) clients.findClient("GoogleOidcClient.1");
    googleOidcClient.init(MockWebContext.create());
    assertEquals(ID, googleOidcClient.getConfiguration().getClientId());
    assertEquals(SECRET, googleOidcClient.getConfiguration().getSecret());
    assertEquals("https://accounts.google.com/.well-known/openid-configuration", googleOidcClient.getConfiguration().getDiscoveryURI());
    assertEquals(CALLBACK_URL + "?client_name=GoogleOidcClient.1", googleOidcClient.getCallbackUrl());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:67,代码来源:PropertiesConfigFactoryTests.java


示例11: build

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
public Config build() {
    final OidcClient oidcClient = new OidcClient();
    oidcClient.setClientID("343992089165-sp0l1km383i8cbm2j5nn20kbk5dk8hor.apps.googleusercontent.com");
    oidcClient.setSecret("uR3D8ej1kIRPbqAFaxIE3HWh");
    oidcClient.setDiscoveryURI("https://accounts.google.com/.well-known/openid-configuration");
    oidcClient.setUseNonce(true);
    //oidcClient.setPreferredJwsAlgorithm(JWSAlgorithm.RS256);
    oidcClient.addCustomParam("prompt", "consent");
    oidcClient.setAuthorizationGenerator(profile -> profile.addRole("ROLE_ADMIN"));

    final SAML2ClientConfiguration cfg = new SAML2ClientConfiguration("resource:samlKeystore.jks",
            "pac4j-demo-passwd",
            "pac4j-demo-passwd",
            "resource:metadata-okta.xml");
    cfg.setMaximumAuthenticationLifetime(3600);
    cfg.setServiceProviderEntityId("http://localhost:8080/callback?client_name=SAML2Client");
    cfg.setServiceProviderMetadataPath("sp-metadata.xml");
    final SAML2Client saml2Client = new SAML2Client(cfg);

    final FacebookClient facebookClient = new FacebookClient("145278422258960", "be21409ba8f39b5dae2a7de525484da8");
    final TwitterClient twitterClient = new TwitterClient("CoxUiYwQOSFDReZYdjigBA", "2kAzunH5Btc4gRSaMr7D7MkyoJ5u1VzbOOzE8rBofs");
    // HTTP
    final FormClient formClient = new FormClient("http://localhost:8080/loginForm.html", new SimpleTestUsernamePasswordAuthenticator());
    final IndirectBasicAuthClient indirectBasicAuthClient = new IndirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());

    // CAS
    final CasClient casClient = new CasClient("https://casserverpac4j.herokuapp.com/login");

    // REST authent with JWT for a token passed in the url as the token parameter
    ParameterClient parameterClient = new ParameterClient("token", new JwtAuthenticator(DemoServer.JWT_SALT));
    parameterClient.setSupportGetRequest(true);
    parameterClient.setSupportPostRequest(false);

    // basic auth
    final DirectBasicAuthClient directBasicAuthClient = new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());

    final AnonymousClient anonymousClient = new AnonymousClient();

    final Clients clients = new Clients("http://localhost:8080/callback", saml2Client, facebookClient, twitterClient,
            formClient, indirectBasicAuthClient, casClient, parameterClient, directBasicAuthClient, oidcClient, anonymousClient);

    final Config config = new Config(clients);
    config.addAuthorizer("admin", new RequireAnyRoleAuthorizer("ROLE_ADMIN"));
    config.addAuthorizer("custom", new CustomAuthorizer());
    return config;
}
 
开发者ID:pac4j,项目名称:undertow-pac4j-demo,代码行数:47,代码来源:DemoConfigFactory.java


示例12: configureClientForMaxAgeAuthorizationRequest

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
/**
 * Configure client for max age authorization request.
 * Sets the CAS client to ask for renewed authentication if
 * the authn time is too old based on the requested max age.
 *
 * @param casClient      the cas client
 * @param context        the context
 * @param authentication the authentication
 */
public void configureClientForMaxAgeAuthorizationRequest(final CasClient casClient, final WebContext context,
                                                         final Authentication authentication) {
    if (isCasAuthenticationOldForMaxAgeAuthorizationRequest(context, authentication)) {
        casClient.getConfiguration().setRenew(true);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:16,代码来源:OidcAuthorizationRequestSupport.java


示例13: build

import org.pac4j.cas.client.CasClient; //导入依赖的package包/类
/**
 * Build redirect action for the client dynamically
 * and configure the CAS client accordingly based
 * on the properties of the web context.
 *
 * @param casClient the cas client config
 * @param context   the context
 * @return the redirect action
 */
RedirectAction build(CasClient casClient, WebContext context);
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:11,代码来源:OAuth20CasClientRedirectActionBuilder.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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