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


Java ProviderManager类代码示例

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


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

示例1: logonSecondUser

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
/**
 * authenticates a second user while the main user is already authenticated. The authentication information for the
 * second user are not stored in the security context but in Cibet context. A second authentication is necessary for
 * the Two-man-rule actuator.
 * 
 * @param auth
 *           Credentials of the second user
 * @throws AuthenticationException
 *            in case of error
 */
public void logonSecondUser(Authentication auth) throws AuthenticationException {
   try {
      AuthenticationManager authManager = context.getBean(ProviderManager.class);
      Authentication result = authManager.authenticate(auth);
      Context.internalSessionScope().setSecondUser(result.getName());
      Context.internalSessionScope().setProperty(InternalSessionScope.SECOND_PRINCIPAL, result);
      if (log.isDebugEnabled()) {
         log.debug("User " + result.getName() + " is successfully authenticated");
      }
   } catch (NoSuchBeanDefinitionException e1) {
      String msg = "Failed to authenticate second user: "
            + "Failed to find a ProviderManager bean in Spring context. Configure Spring context correctly: "
            + e1.getMessage();
      log.error(msg);
      throw new RuntimeException(msg, e1);
   }
}
 
开发者ID:Wolfgang-Winter,项目名称:cibet,代码行数:28,代码来源:SpringSecurityService.java

示例2: runUserSynchronizerJob

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
private void runUserSynchronizerJob() {
	if (LOG.isDebugEnabled()) {
		LOG.debug("Run user synchronizer job ...");
	}
	long t = System.currentTimeMillis();

	// JobDetail userSynchronizerJob = (JobDetail)
	// getSpringBean("userSynchronizerJob");
	ProviderManager authenticationManager = (ProviderManager) getSpringBean("authenticationManager");
	UserSynchronizerJob userSynchronizerJob = new UserSynchronizerJob();
	userSynchronizerJob.setAuthenticationManager(authenticationManager);
	userSynchronizerJob.setStorageService((StorageService) getSpringBean("storageService"));
	userSynchronizerJob.syncUsers();

	if (LOG.isDebugEnabled()) {
		t = System.currentTimeMillis() - t;
		LOG.debug("Users synchronized in " + t + " ms");
	}
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:20,代码来源:NextServerApplication.java

示例3: authenticationManager

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
@Bean("authenticationManager")
public ProviderManager authenticationManager() {
    List<AuthenticationProvider> authProviderList = new ArrayList<AuthenticationProvider>();
    authProviderList.add(authProvider());
    ProviderManager providerManager = new ProviderManager(authProviderList);
    return providerManager;
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:8,代码来源:SecurityConfig.java

示例4: clientAuthenticationManager

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
@Bean
public AuthenticationManager clientAuthenticationManager() {
    DaoAuthenticationProvider clientAuthenticationProvider = new DaoAuthenticationProvider();
    clientAuthenticationProvider.setUserDetailsService(clientDetailsUserDetailsService());
    clientAuthenticationProvider.setHideUserNotFoundExceptions(false);
    return new ProviderManager(Collections.singletonList(clientAuthenticationProvider));
}
 
开发者ID:gravitee-io,项目名称:graviteeio-access-management,代码行数:8,代码来源:AuthorizationServerConfiguration.java

示例5: getUser

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
private UserDetails getUser() {
	ProviderManager parent = (ProviderManager) this.context
			.getBean(AuthenticationManager.class);
	DaoAuthenticationProvider provider = (DaoAuthenticationProvider) parent
			.getProviders().get(0);
	UserDetailsService service = (UserDetailsService) ReflectionTestUtils
			.getField(provider, "userDetailsService");
	UserDetails user = service.loadUserByUsername("user");
	return user;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:ManagementWebSecurityAutoConfigurationTests.java

示例6: getInvitationProvider

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
/**
 * @param identifier
 *            Identifier of the provider to use. if <code>null</code> the next possible provider
 *            will be used.
 * @return Get the provider, which is able to handle an invitation.
 */
public BaseCommunoteAuthenticationProvider getInvitationProvider(String identifier) {
    ProviderManager authenticationManager = getProviderManager();

    // all providers to iterate for
    List<AuthenticationProvider> providers = new ArrayList<AuthenticationProvider>(
            authenticationManager.getProviders());
    // also add the plugin providers
    // TODO far from perfect, it would be better to have them all in single list, but this means
    // moving the authentication provider stuff into the core
    List<CommunoteAuthenticationProvider> pluginProviders = ServiceLocator.instance()
            .getService(AuthenticationProviderManagement.class).getProviders();
    providers.addAll(pluginProviders);

    for (Object object : providers) {
        if (!(object instanceof BaseCommunoteAuthenticationProvider)) {
            continue;
        }
        BaseCommunoteAuthenticationProvider provider = (BaseCommunoteAuthenticationProvider) object;
        if (provider.supportsUserQuerying()
                && (identifier == null || provider.getIdentifier().equals(identifier))) {
            return provider;
        }
    }
    throw new IllegalStateException("There is no provider that allows an invitation!");

}
 
开发者ID:Communote,项目名称:communote-server,代码行数:33,代码来源:WebServiceLocator.java

示例7: authenticate

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
/**
 * Iterates over the internal list of authentication providers an tries to authenticate.
 * 
 * @param authentication
 *            The authentication.
 * @return The resulting authentication.
 */
public Authentication authenticate(Authentication authentication) {
    ProviderManager providerManager = getManager();
    if (providerManager != null) {
        try {
            return providerManager.authenticate(authentication);
        } catch (ProviderNotFoundException e) {
            // will be thrown if there is no supporting provider, ignore it since we are not
            // calling supports methods of the registered providers
        }
    }
    return null;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:20,代码来源:AuthenticationProviderManagement.java

示例8: getManager

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
/**
 * @return the lazily initialized manager or null if no providers are registered
 */
private ProviderManager getManager() {
    if (manager == null && !providers.isEmpty()) {
        initProviderManager();
    }
    return manager;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:10,代码来源:AuthenticationProviderManagement.java

示例9: init

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
/**
 * @param alias
 *            the alias
 * @param password
 *            the password
 * @param email
 *            the email
 * @throws Exception
 *             in case of an error
 */
@BeforeClass(dependsOnGroups = "integration-test-setup")
public void init() throws Exception {
    UserVO userVO = TestUtils.createKenmeiUserVO(TestUtils.createRandomUserAlias(),
            UserRole.ROLE_KENMEI_USER);
    userVO.setPassword("123456");
    AuthenticationTestUtils.setManagerContext();
    userManagement.createUser(userVO, false, false);
    Map<ClientConfigurationPropertyConstant, String> map;
    map = new HashMap<ClientConfigurationPropertyConstant, String>();
    // set lower limit for getting permanently locked (to speed up test)
    map.put(ClientPropertySecurity.FAILED_AUTH_LIMIT_PERMLOCK, String.valueOf(6));
    // set shorter wait time for temporarily locked users
    map.put(ClientPropertySecurity.FAILED_AUTH_LOCKED_TIMESPAN, String.valueOf(3));
    CommunoteRuntime.getInstance().getConfigurationManager()
            .updateClientConfigurationProperties(map);
    AuthenticationTestUtils.setAuthentication(null);
    // initiate authenticationManager
    ArrayList<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(new DatabaseAuthenticationProvider());
    ProviderManager providerManager = new ProviderManager(providers);
    providerManager.setAuthenticationEventPublisher(new AuthenticationFailedEventPublisher());
    authManager = providerManager;
    // create valid user + password-token
    validAuth = new UsernamePasswordAuthenticationToken(userVO.getAlias(),
            userVO.getPassword());
    // create invalid user + password-token
    invalidAuth = new UsernamePasswordAuthenticationToken(userVO.getAlias(),
            userVO.getPassword() + "invalid");
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:40,代码来源:AuthenticationFailedLockoutTest.java

示例10: configure

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
@Override
public void configure(HttpSecurity http) throws Exception {
    PreAuthenticatedAuthenticationProvider casAuthenticationProvider = new PreAuthenticatedAuthenticationProvider();
    casAuthenticationProvider.setPreAuthenticatedUserDetailsService(
            new UserDetailsByNameServiceWrapper<>(peticionamentoUserDetailService.orElseThrow(() ->
                            SingularServerException.rethrow(
                                    String.format("Bean %s do tipo %s não pode ser nulo. Para utilizar a configuração de segurança %s é preciso declarar um bean do tipo %s identificado pelo nome %s .",
                                            UserDetailsService.class.getName(),
                                            "peticionamentoUserDetailService",
                                            SingularCASSpringSecurityConfig.class.getName(),
                                            UserDetailsService.class.getName(),
                                            "peticionamentoUserDetailService"
                                    ))
            )
            )
    );

    ProviderManager authenticationManager = new ProviderManager(Arrays.asList(new AuthenticationProvider[]{casAuthenticationProvider}));

    J2eePreAuthenticatedProcessingFilter j2eeFilter = new J2eePreAuthenticatedProcessingFilter();
    j2eeFilter.setAuthenticationManager(authenticationManager);

    http
            .regexMatcher(getContext().getPathRegex())
            .httpBasic().authenticationEntryPoint(new Http403ForbiddenEntryPoint())
            .and()
            .csrf().disable()
            .headers().frameOptions().sameOrigin()
            .and()
            .jee().j2eePreAuthenticatedProcessingFilter(j2eeFilter)
            .and()
            .authorizeRequests()
            .antMatchers(getContext().getContextPath()).authenticated();

}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:36,代码来源:SingularCASSpringSecurityConfig.java

示例11: authenticationManager

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
@Bean
  @SuppressWarnings({ "rawtypes", "unchecked" })
  public AuthenticationManager authenticationManager(){
      
      if (authenticationManager == null){
List providers = new ArrayList();
      providers.add(daoAuthenticationProvider());
      providers.add(new AnonymousAuthenticationProvider("changeThis"));
      providers.add(new RememberMeAuthenticationProvider("changeThis"));
      
      ProviderManager bean = new ProviderManager(providers);
      authenticationManager = bean;
      }
      return authenticationManager;
  }
 
开发者ID:dovier,项目名称:coj-web,代码行数:16,代码来源:SecurityConfiguration.java

示例12: authenticationManager

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
@Bean
public AuthenticationManager authenticationManager(UserDetailsService userDetailsService,
		RunAsImplAuthenticationProvider runAsProvider, PasswordEncoder passwordEncoder) {
	List<AuthenticationProvider> providers = Lists.newArrayList();
	providers.add(runAsProvider);
	DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
	authenticationProvider.setUserDetailsService(userDetailsService);
	authenticationProvider.setPasswordEncoder(passwordEncoder);
	providers.add(authenticationProvider);
	return new ProviderManager(providers);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:12,代码来源:AbstractJpaSecurityConfig.java

示例13: authenticationManager

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
@Bean
@Override
public AuthenticationManager authenticationManager()
{
    PreAuthenticatedAuthenticationProvider authenticationProvider = new PreAuthenticatedAuthenticationProvider();
    authenticationProvider.setPreAuthenticatedUserDetailsService(herdUserDetailsService);
    List<AuthenticationProvider> providers = new ArrayList<>();
    providers.add(authenticationProvider);
    return new ProviderManager(providers);
}
 
开发者ID:FINRAOS,项目名称:herd,代码行数:11,代码来源:AppSpringModuleConfig.java

示例14: refreshContext

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
public void refreshContext(boolean ssoMode, String entityId) {
    LOG.info("Context refresh process started. SSO mode: {}", ssoMode);
    CONTEXT_REFRESH_IN_PROCESS = true;
    //for sso
    if(ssoMode) {
        // do not change order of context refreshes
        // we need to refresh root context otherwise springSecurityFilterChain will not be updated
        // https://jira.spring.io/browse/SPR-6228
        XmlWebApplicationContext rootContext = (XmlWebApplicationContext) applicationContext.getParent();
        rootContext.setConfigLocations("/WEB-INF/spring-security-saml.xml");
        // add property entityId to root context, it will be used as psw for jks
        rootContext.getEnvironment().getPropertySources().addLast((new RefreshRootContextPropertySource(entityId)));
        rootContext.refresh();

        // refresh application context
        applicationContext.setConfigLocations("/WEB-INF/spring-web-config.xml");
        applicationContext.refresh();

        // set userService property to userDetails bean, so we could manage users roles within ssoLogin mode
        applicationContext.getBean(SamlUserDetails.class).setUserService(applicationContext.getBean(UserService.class));
        applicationContext.getBean(SAMLAuthenticationProviderImpl.class).setConfigurationMediator(applicationContext.getBean(ConfigurationMediator.class));
        applicationContext.getBean(SAMLAuthenticationProviderImpl.class).setUserService(applicationContext.getBean(UserService.class));
    }
    // for local authentication
    else {
        applicationContext.setConfigLocations("/WEB-INF/spring-web-config.xml", "/WEB-INF/spring-security-dynamoDB.xml");
        applicationContext.refresh();
        // clearing init auth providers
        ((ProviderManager)applicationContext.getBean("authenticationManager")).getProviders().clear();

        // adding main auth provider
        ((ProviderManager)applicationContext.getBean("authenticationManager")).getProviders()
                .add((AuthenticationProvider) applicationContext.getBean("authProvider"));
    }

    LOG.info("Context refreshed successfully.");
    SecurityContextHolder.clearContext();
    CONTEXT_REFRESH_IN_PROCESS = false;
}
 
开发者ID:SungardAS,项目名称:enhanced-snapshots,代码行数:40,代码来源:ContextManager.java

示例15: getProviderManager

import org.springframework.security.authentication.ProviderManager; //导入依赖的package包/类
/**
 * Gets the provider manager.
 *
 * @return the provider manager
 */
@Bean(name = "authenticationManager")
public ProviderManager getProviderManager() {
  List<AuthenticationProvider> providers = new ArrayList<>();
  providers.add(getPreAuthenticatedAuthenticationProvider());
  return new ProviderManager(providers);
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:12,代码来源:ProbeSecurityConfig.java


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