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


Java Config类代码示例

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


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

示例1: shiroFilterFactoryBean

import org.pac4j.core.config.Config; //导入依赖的package包/类
/**
 * 对过滤器进行调整
 *
 * @param securityManager
 * @return
 */
@Bean(name = "shiroFilter")
protected ShiroFilterFactoryBean shiroFilterFactoryBean(DefaultWebSecurityManager securityManager, Config config) {
    ShiroFilterFactoryBean filterFactoryBean = super.shiroFilterFactoryBean();
    filterFactoryBean.setSecurityManager(securityManager);
    
    //过滤器设置
    Map<String, Filter> filters = new HashMap<>();
    SecurityFilter securityFilter = new SecurityFilter();
    securityFilter.setClients("cas,rest,jwt");
    securityFilter.setConfig(config);
    filters.put("casSecurityFilter", securityFilter);
    
    CallbackFilter callbackFilter = new CallbackFilter();
    callbackFilter.setConfig(config);
    filters.put("callbackFilter", callbackFilter);
    
    filterFactoryBean.setFilters(filters);
    

    return filterFactoryBean;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:ShiroConfiguration.java

示例2: OAuth20CallbackAuthorizeEndpointController

import org.pac4j.core.config.Config; //导入依赖的package包/类
public OAuth20CallbackAuthorizeEndpointController(final ServicesManager servicesManager,
                                                  final TicketRegistry ticketRegistry,
                                                  final OAuth20Validator validator,
                                                  final AccessTokenFactory accessTokenFactory,
                                                  final PrincipalFactory principalFactory,
                                                  final ServiceFactory<WebApplicationService> webApplicationServiceServiceFactory,
                                                  final Config config,
                                                  final CallbackController callbackController,
                                                  final OAuth20CallbackAuthorizeViewResolver oAuth20CallbackAuthorizeViewResolver,
                                                  final OAuth20ProfileScopeToAttributesFilter scopeToAttributesFilter,
                                                  final CasConfigurationProperties casProperties,
                                                  final CookieRetrievingCookieGenerator cookieGenerator) {
    super(servicesManager, ticketRegistry, validator, accessTokenFactory, principalFactory,
            webApplicationServiceServiceFactory, scopeToAttributesFilter, casProperties, cookieGenerator);
    this.callbackController = callbackController;
    this.oAuth20CallbackAuthorizeViewResolver = oAuth20CallbackAuthorizeViewResolver;
    this.callbackController.setConfig(config);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:19,代码来源:OAuth20CallbackAuthorizeEndpointController.java

示例3: oauthSecConfig

import org.pac4j.core.config.Config; //导入依赖的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

示例4: build

import org.pac4j.core.config.Config; //导入依赖的package包/类
public Config build() {
    final List<Client> clients = new ArrayList<>();
    tryCreateFacebookClient(clients);
    tryCreateTwitterClient(clients);
    tryCreateSaml2Client(clients);
    tryCreateCasClient(clients);
    tryCreateOidcClient(clients);
    tryCreateDropboxClient(clients);
    tryCreateGithubClient(clients);
    tryCreateYahooClient(clients);
    tryCreateGoogleClient(clients);
    tryCreateFoursquareClient(clients);
    tryCreateWindowsLiveClient(clients);
    tryCreateLinkedInClient(clients);
    return new Config(callbackUrl, clients);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:17,代码来源:PropertiesConfigFactory.java

示例5: clients

import org.pac4j.core.config.Config; //导入依赖的package包/类
@Test
public void clients() throws Exception {
    Pac4jFactory conf = getPac4jFactory("clients.yaml");
    Config config = conf.build();

    assertThat(config.getClients().getClients()).hasSize(2);

    Client client = config.getClients().getClients().get(0);
    assertThat(client).isInstanceOf(DirectBasicAuthClient.class);
    assertThat(client.getName()).isEqualTo("DirectBasicAuthClient");
    assertThat(((DirectBasicAuthClient) client).getAuthenticator())
            .isNotNull()
            .isInstanceOf(SimpleTestUsernamePasswordAuthenticator.class);

    Client client1 = config.getClients().getClients().get(1);
    assertThat(client1).isInstanceOf(DirectBasicAuthClient.class);
    assertThat(client1.getName()).isEqualTo("basic");
    assertThat(((DirectBasicAuthClient) client1).getAuthenticator())
            .isNull();
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:21,代码来源:DefaultConfigurationTest.java

示例6: allOptionsClients

import org.pac4j.core.config.Config; //导入依赖的package包/类
@Test
public void allOptionsClients() throws Exception {
    Pac4jFactory conf = getPac4jFactory("alloptions-pac4j.yaml");
    Config config = conf.build();

    assertThat(config).isExactlyInstanceOf(FakeConfig.class);
    final FakeConfig fakeConfig = (FakeConfig) config;
    assertThat(fakeConfig.getProperties().size()).isEqualTo(2);
    assertThat(config.getClients().getClients()).hasSize(2);

    Client client0 = config.getClients().getClients().get(0);
    assertThat(client0).isExactlyInstanceOf(FacebookClient.class);
    assertThat(((FacebookClient) client0).getKey()).isEqualTo("fbId");

    Client client1 = config.getClients().getClients().get(1);
    assertThat(client1).isInstanceOf(DirectBasicAuthClient.class);
    assertThat(client1.getName()).isEqualTo("DirectBasicAuthClient");
    assertThat(((DirectBasicAuthClient) client1).getAuthenticator())
        .isNotNull()
        .isInstanceOf(SimpleTestUsernamePasswordAuthenticator.class);

    assertThat(config.getAuthorizers().size()).isEqualTo(1);

    assertThat(config.getMatchers().size()).isEqualTo(1);
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:26,代码来源:DefaultConfigurationTest.java

示例7: clientsAndProperties

import org.pac4j.core.config.Config; //导入依赖的package包/类
@Test
public void clientsAndProperties() throws Exception {
    Pac4jFactory conf = getPac4jFactory("clientsandproperties-pac4j.yaml");
    Config config = conf.build();

    assertThat(config).isExactlyInstanceOf(JaxRsConfig.class);
    assertThat(config.getClients().getClients()).hasSize(2);

    Client client0 = config.getClients().getClients().get(0);
    assertThat(client0).isExactlyInstanceOf(FacebookClient.class);
    assertThat(((FacebookClient) client0).getKey()).isEqualTo("fbId");

    Client client1 = config.getClients().getClients().get(1);
    assertThat(client1).isInstanceOf(DirectBasicAuthClient.class);
    assertThat(client1.getName()).isEqualTo("DirectBasicAuthClient");
    assertThat(((DirectBasicAuthClient) client1).getAuthenticator())
        .isNotNull()
        .isInstanceOf(SimpleTestUsernamePasswordAuthenticator.class);

    assertThat(config.getAuthorizers().size()).isEqualTo(0);

    assertThat(config.getMatchers().size()).isEqualTo(0);
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:24,代码来源:DefaultConfigurationTest.java

示例8: clientsProperties

import org.pac4j.core.config.Config; //导入依赖的package包/类
@Test
public void clientsProperties() throws Exception {
    Pac4jFactory conf = getPac4jFactory("clientsproperties-pac4j.yaml");
    Config config = conf.build();

    assertThat(config).isExactlyInstanceOf(JaxRsConfig.class);
    assertThat(config.getClients().getClients()).hasSize(1);

    Client client0 = config.getClients().getClients().get(0);
    assertThat(client0).isExactlyInstanceOf(FacebookClient.class);
    assertThat(((FacebookClient) client0).getKey()).isEqualTo("fbId");

    assertThat(config.getAuthorizers().size()).isEqualTo(1);

    assertThat(config.getMatchers().size()).isEqualTo(0);
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:17,代码来源:DefaultConfigurationTest.java

示例9: emptyPac4jInConfig

import org.pac4j.core.config.Config; //导入依赖的package包/类
@Test
public void emptyPac4jInConfig() {
    setup(App.class, "empty-pac4j.yaml");

    App app = dropwizardTestSupport.getApplication();
    ObjectMapper om = dropwizardTestSupport.getObjectMapper();
    Environment env = dropwizardTestSupport.getEnvironment();

    Config config = app.bundle.getConfig();
    assertThat(config).isNotNull();
    // this is the default url resolver!
    assertThat(config.getClients().getUrlResolver())
            .isInstanceOf(JaxRsUrlResolver.class);
    assertThat(om.findMixInClassFor(Client.class)).isNotNull();
    assertThat(env.jersey().getResourceConfig().getSingletons())
            .haveAtLeastOne(CONDSI);

    assertThat(env.getApplicationContext().getSessionHandler())
            .isInstanceOf(SessionHandler.class);
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:21,代码来源:BundleFactoryTest.java

示例10: filter

import org.pac4j.core.config.Config; //导入依赖的package包/类
@Override
protected void filter(JaxRsContext context) throws IOException {

    Config config = getConfig();

    String cs;
    // no client was set
    if (clients == null && config instanceof JaxRsConfig) {
        cs = ((JaxRsConfig) config).getDefaultClients();
    } else {
        cs = clients;
    }

    // Note: basically, there is two possible outcomes:
    // either the access is granted or there was an error or a redirect!
    // For the former, we do nothing (see SecurityGrantedAccessOutcome comments)
    // For the later, we interpret the error and abort the request using jax-rs abstractions
    SecurityLogic<Object, JaxRsContext> logic = buildLogic(config);
    AuthorizationCheckerWrapper wrapper = null;
    if (logic instanceof DefaultSecurityLogic) {
        wrapper = new AuthorizationCheckerWrapper(((DefaultSecurityLogic) logic).getAuthorizationChecker());
        ((DefaultSecurityLogic) logic).setAuthorizationChecker(wrapper);
    }
    logic.perform(context, config, new SecurityGrantedAccessOutcome(wrapper), adapter(config), cs, authorizers,
            matchers, multiProfile);
}
 
开发者ID:pac4j,项目名称:jax-rs-pac4j,代码行数:27,代码来源:SecurityFilter.java

示例11: getConfig

import org.pac4j.core.config.Config; //导入依赖的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

示例12: CallbackDeployingPac4jAuthHandler

import org.pac4j.core.config.Config; //导入依赖的package包/类
public CallbackDeployingPac4jAuthHandler(final Vertx vertx,
                                         final SessionStore<VertxWebContext> sessionStore,
                                         final Config config,
                                         final Router router,
                                         final Pac4jAuthProvider authProvider,
                                         final SecurityHandlerOptions options,
                                         final CallbackHandlerOptions callbackOptions) {
    super(vertx, sessionStore, config, authProvider, options);
    // Other null checks performed by parent class
    CommonHelper.assertNotNull("router", router);
    CommonHelper.assertNotBlank("callbackUrl", config.getClients().getCallbackUrl());

    final URI uri;
    try {
        uri = new URI(config.getClients().getCallbackUrl());
    } catch (URISyntaxException e) {
        LOG.error(e.getMessage());
        throw toTechnicalException(e);
    }

    // Start manager verticle
    router.route(HttpMethod.GET, uri.getPath()).handler(authResultHandler(vertx, sessionStore, config, callbackOptions));
}
 
开发者ID:pac4j,项目名称:vertx-pac4j,代码行数:24,代码来源:CallbackDeployingPac4jAuthHandler.java

示例13: SecurityHandler

import org.pac4j.core.config.Config; //导入依赖的package包/类
public SecurityHandler(final Vertx vertx,
                       final SessionStore<VertxWebContext> sessionStore,
                       final Config config, final Pac4jAuthProvider authProvider,
                       final SecurityHandlerOptions options) {
    super(authProvider);
    CommonHelper.assertNotNull("vertx", vertx);
    CommonHelper.assertNotNull("sessionStore", sessionStore);
    CommonHelper.assertNotNull("config", config);
    CommonHelper.assertNotNull("config.getClients()", config.getClients());
    CommonHelper.assertNotNull("authProvider", authProvider);
    CommonHelper.assertNotNull("options", options);

    clientNames = options.getClients();
    authorizerName = options.getAuthorizers();
    matcherName = options.getMatchers();
    multiProfile = options.isMultiProfile();
    this.vertx = vertx;
    this.sessionStore = sessionStore;
    this.config = config;

    final DefaultSecurityLogic<Void, VertxWebContext> securityLogic = new DefaultSecurityLogic<>();
    securityLogic.setProfileManagerFactory(VertxProfileManager::new);
    this.securityLogic = securityLogic;
}
 
开发者ID:pac4j,项目名称:vertx-pac4j,代码行数:25,代码来源:SecurityHandler.java

示例14: LogoutHandler

import org.pac4j.core.config.Config; //导入依赖的package包/类
/**
 * Construct based on the option values provided
 *
 * @param options - the options to configure this handler
 */
public LogoutHandler(final Vertx vertx,
                     final SessionStore<VertxWebContext> sessionStore ,
                     final LogoutHandlerOptions options, final Config config) {
    final DefaultLogoutLogic<Void, VertxWebContext> defaultApplicationLogoutLogic =
            new DefaultLogoutLogic<>();
    defaultApplicationLogoutLogic.setProfileManagerFactory(VertxProfileManager::new);
    logoutLogic = defaultApplicationLogoutLogic;
    this.defaultUrl = options.getDefaultUrl();
    this.logoutUrlPattern = options.getLogoutUrlPattern();
    this.config = config;
    this.vertx = vertx;
    this.sessionStore = sessionStore;
    this.localLogout = options.isLocalLogout();
    this.destroySession = options.isDestroySession();
    this.centralLogout = options.isCentralLogout();
}
 
开发者ID:pac4j,项目名称:vertx-pac4j,代码行数:22,代码来源:LogoutHandler.java

示例15: loginFormHandler

import org.pac4j.core.config.Config; //导入依赖的package包/类
public static HttpHandler loginFormHandler(final Config config) {
    return exchange -> {
        FormClient formClient = (FormClient) config.getClients().findClient("FormClient");
        StringBuilder sb = new StringBuilder();
        sb.append("<html><body>");
        sb.append("<form action=\"").append(formClient.getCallbackUrl()).append("\" method=\"POST\">");
        sb.append("<input type=\"text\" name=\"username\" value=\"\" />");
        sb.append("<p />");
        sb.append("<input type=\"password\" name=\"password\" value=\"\" />");
        sb.append("<p />");
        sb.append("<input type=\"submit\" name=\"submit\" value=\"Submit\" />");
        sb.append("</form>");
        sb.append("</body></html>");

        sendEnd(exchange, sb);
    };
}
 
开发者ID:pac4j,项目名称:undertow-pac4j-demo,代码行数:18,代码来源:DemoHandlers.java


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