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

Java AuthenticationManager类代码示例

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

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



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

示例1: afterPropertiesSet

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
/**
 * Ensure that we have an authentication manager to work with. If one has not been
 * specifically wired in, then look for beans to "auto-wire" in. Look for a bean of
 * one of the following types (in order): {@link ProviderManager},
 * {@link AuthenticationProvider}, and {@link AuthenticationManager}.
 * 
 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
 */
public void afterPropertiesSet() {
    // Ensure that we have our authentication manager
    if( authenticationManager == null ) {
        if( logger.isDebugEnabled() ) {
            logger.debug( "No AuthenticationManager defined, look for one" );
        }

        // Try the class types in sequence
        Class[] types = new Class[] { ProviderManager.class, AuthenticationProvider.class,
                AuthenticationManager.class };

        for( int i = 0; i < types.length; i++ ) {
            if( tryToWire( types[i] ) ) {
                break;
            }
        }
    }

    // If we still don't have one, then that's it
    if( authenticationManager == null ) {
        throw new IllegalArgumentException( "authenticationManager must be defined" );
    }
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:32,代码来源:DefaultApplicationSecurityManager.java


示例2: shouldConvey_itsBasicProcessingFilter

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
@Test
public void shouldConvey_itsBasicProcessingFilter() throws IOException, ServletException {
    BasicAuthenticationFilter filter = new BasicAuthenticationFilter(localizer);
    final Boolean[] hadBasicMarkOnInsideAuthenticationManager = new Boolean[]{false};

    filter.setAuthenticationManager(new AuthenticationManager() {
        public Authentication authenticate(Authentication authentication) throws AuthenticationException {
            hadBasicMarkOnInsideAuthenticationManager[0] = BasicAuthenticationFilter.isProcessingBasicAuth();
            return new UsernamePasswordAuthenticationToken("school-principal", "u can be principal if you know this!");
        }
    });
    assertThat(BasicAuthenticationFilter.isProcessingBasicAuth(), is(false));
    MockHttpServletRequest httpRequest = new MockHttpServletRequest();
    httpRequest.addHeader("Authorization", "Basic " + Base64.getEncoder().encodeToString("loser:boozer".getBytes()));
    filter.doFilterHttp(httpRequest, new MockHttpServletResponse(), new FilterChain() {
        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException {

        }
    });
    assertThat(BasicAuthenticationFilter.isProcessingBasicAuth(), is(false));

    assertThat(hadBasicMarkOnInsideAuthenticationManager[0], is(true));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:24,代码来源:BasicAuthenticationFilterTest.java


示例3: setUp

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    request = mock(HttpServletRequest.class);
    response = mock(HttpServletResponse.class);
    filterChain = mock(FilterChain.class);
    authenticationManager = mock(AuthenticationManager.class);
    authorizationExtension = mock(AuthorizationExtension.class);
    configService = mock(GoConfigService.class);
    filter = new PreAuthenticatedRequestsProcessingFilter(authorizationExtension, configService);
    securityConfig = new SecurityConfig();

    filter.setAuthenticationManager(authenticationManager);
    filter.setFilterProcessesUrl("^/go/plugin/([\\w\\-.]+)/authenticate$");
    stub(configService.security()).toReturn(securityConfig);
    stub(request.getHeaderNames()).toReturn(Collections.emptyEnumeration());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:17,代码来源:PreAuthenticatedRequestsProcessingFilterTest.java


示例4: tryToWire

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
/**
 * Try to locate and "wire in" a suitable authentication manager.
 * @param type The type of bean to look for
 * @return true if we found and wired a suitable bean
 */
protected boolean tryToWire(Class type) {
    boolean success = false;
    String className = type.getName();
    Map map = Application.instance().getApplicationContext().getBeansOfType( type );
    if( logger.isDebugEnabled() ) {
        logger.debug( "Search for '" + className + "' found: " + map );
    }

    if( map.size() == 1 ) {
        // Got one - wire it in
        Map.Entry entry = (Map.Entry) map.entrySet().iterator().next();
        String name = (String) entry.getKey();
        AuthenticationManager am = (AuthenticationManager) entry.getValue();

        setAuthenticationManager( am );
        success = true;

        if( logger.isInfoEnabled() ) {
            logger.info( "Auto-configuration using '" + name + "' as authenticationManager" );
        }
    } else if( map.size() > 1 ) {
        if( logger.isInfoEnabled() ) {
            logger.info( "Need a single '" + className + "', found: " + map.keySet() );
        }
    } else {
        // Size 0, no potentials
        if( logger.isInfoEnabled() ) {
            logger.info( "Auto-configuration did not find a suitable authenticationManager of type " + type );
        }
    }

    return success;
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:39,代码来源:DefaultApplicationSecurityManager.java


示例5: testConfiguration

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
public void testConfiguration() {
    Object asm = applicationContext.getBean( "applicationSecurityManager" );
    Object am = applicationContext.getBean( "authenticationManager" );
    Object sc = applicationContext.getBean( "securityConfigurer" );

    assertTrue( "securityManager must implement ApplicationSecurityManager",
        asm instanceof ApplicationSecurityManager );
    assertTrue( "securityManager must be instance of DefaultApplicationSecurityManager",
        asm instanceof DefaultApplicationSecurityManager );
    assertTrue( "authenticationManager must implement AuthenticationManager", am instanceof AuthenticationManager );
    assertTrue( "authenticationManager must be instance of TestAuthenticationManager",
        am instanceof TestAuthenticationManager );
    assertEquals( asm, ApplicationServicesLocator.services().getService(ApplicationSecurityManager.class) );
    assertTrue( "securityConfigurer must implement SecurityAwareConfigurer", sc instanceof SecurityAwareConfigurer );
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:16,代码来源:SecurityAwareConfigurerTests.java


示例6: testConfiguration

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
public void testConfiguration() {
    prepareApplication( "security-test-ctx.xml" );

    Object asm = ac.getBean( "applicationSecurityManager" );
    Object am = ac.getBean( "authenticationManager" );

    assertTrue( "securityManager must implement ApplicationSecurityManager",
        asm instanceof ApplicationSecurityManager );
    assertTrue( "securityManager must be instance of DefaultApplicationSecurityManager",
        asm instanceof DefaultApplicationSecurityManager );
    assertTrue( "authenticationManager must implement AuthenticationManager", am instanceof AuthenticationManager );
    assertTrue( "authenticationManager must be instance of TestAuthenticationManager",
        am instanceof TestAuthenticationManager );
    assertEquals( asm, ApplicationServicesLocator.services().getService(ApplicationSecurityManager.class) );
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:16,代码来源:DefaultApplicationSecurityManagerTests.java


示例7: setUp

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    securityContext = mock(SecurityContext.class);
    SecurityContextHolder.setContext(securityContext);
    authenticationManager = mock(AuthenticationManager.class);
    filter = new OauthAuthenticationFilter(authenticationManager);
    req = mock(HttpServletRequest.class);
    res = mock(HttpServletResponse.class);
    chain = mock(FilterChain.class);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:11,代码来源:OauthAuthenticationFilterTest.java


示例8: testRejectAccessForUnauthorizedUser

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
/**
 * DB에 등록된 사용자의 인증 실패 테스트
 * @throws Exception
 */
@Test
@ExpectedException(BadCredentialsException.class)
public void testRejectAccessForUnauthorizedUser() throws Exception {
   
   UsernamePasswordAuthenticationToken login = new UsernamePasswordAuthenticationToken("jimi", "wrongpw");
   AuthenticationManager authManager =
   	(AuthenticationManager) context.getBean(BeanIds.AUTHENTICATION_MANAGER);
   
   log.debug("### jimi's password is wrong!!");
   SecurityContextHolder.getContext().setAuthentication(authManager.authenticate(login));
   
}
 
开发者ID:eGovFrame,项目名称:egovframework.rte.root,代码行数:17,代码来源:EgovSecurityServiceTest.java


示例9: getAuthenticationManager

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
public AuthenticationManager getAuthenticationManager()
{
	return authenticationManager;
}
 
开发者ID:Rospaccio,项目名称:pentaho-authentication-ext,代码行数:5,代码来源:AuthenticationExtensionFilter.java


示例10: setAuthenticationManager

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
public void setAuthenticationManager(AuthenticationManager authenticationManager)
{
	this.authenticationManager = authenticationManager;
}
 
开发者ID:Rospaccio,项目名称:pentaho-authentication-ext,代码行数:5,代码来源:AuthenticationExtensionFilter.java


示例11: setAuthenticationManager

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
public void setAuthenticationManager(AuthenticationManager manager) {
    this.authenticationManager = manager;
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:4,代码来源:SessionDetails.java


示例12: OauthAuthenticationFilter

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
public OauthAuthenticationFilter(AuthenticationManager authenticationManager) {
    this.authenticationManager = authenticationManager;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:4,代码来源:OauthAuthenticationFilter.java


示例13: setAuthenticationManager

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
/**
 * Set the authentication manager to use.
 * @param authenticationManager instance to use for authentication requests
 */
public void setAuthenticationManager(AuthenticationManager authenticationManager) {
    this.authenticationManager = authenticationManager;
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:8,代码来源:DefaultApplicationSecurityManager.java


示例14: getAuthenticationManager

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
/**
 * Get the authentication manager in use.
 * @return authenticationManager instance used for authentication requests
 */
public AuthenticationManager getAuthenticationManager() {
    return authenticationManager;
}
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:8,代码来源:DefaultApplicationSecurityManager.java


示例15: setAuthenticationManager

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
/**
 * Set the authentication manager to use.
 * @param authenticationManager instance to use for authentication requests
 */
public void setAuthenticationManager(AuthenticationManager authenticationManager);
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:6,代码来源:ApplicationSecurityManager.java


示例16: getAuthenticationManager

import org.springframework.security.AuthenticationManager; //导入依赖的package包/类
/**
 * Get the authentication manager in use.
 * @return authenticationManager instance used for authentication requests
 */
public AuthenticationManager getAuthenticationManager();
 
开发者ID:shevek,项目名称:spring-rich-client,代码行数:6,代码来源:ApplicationSecurityManager.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java IPluginExecutionMetadata类代码示例发布时间:2022-05-23
下一篇:
Java OptimizeImportsAction类代码示例发布时间: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