zoukankan      html  css  js  c++  java
  • spring cloud oauth2授权服务 默认tokenService配置源码

    AuthorizationServerEndpointsConfiguration

    ...
    private AuthorizationServerEndpointsConfigurer endpoints = new AuthorizationServerEndpointsConfigurer();
    ...
    //注册工厂
    @Bean
    public FactoryBean<AuthorizationServerTokenServices> defaultAuthorizationServerTokenServices() {
    	return new AuthorizationServerTokenServicesFactoryBean(endpoints);
    }
    ...
    protected static class AuthorizationServerTokenServicesFactoryBean
    			extends AbstractFactoryBean<AuthorizationServerTokenServices> {
    	...
    	// 创建tokenService实例
    	@Override
    	protected AuthorizationServerTokenServices createInstance() throws Exception {
    		return endpoints.getDefaultAuthorizationServerTokenServices();
    	}
    	...
    }
    ...
    

    AuthorizationServerEndpointsConfigurer

    ...
    public AuthorizationServerTokenServices getDefaultAuthorizationServerTokenServices() {
    	if (defaultTokenServices != null) {
    		return defaultTokenServices;
    	}
    	// 创建默认tokenService实例
    	this.defaultTokenServices = createDefaultTokenServices();
    	return this.defaultTokenServices;
    }
    ...
    private DefaultTokenServices createDefaultTokenServices() {
    	DefaultTokenServices tokenServices = new DefaultTokenServices();
    	tokenServices.setTokenStore(tokenStore());
    	tokenServices.setSupportRefreshToken(true);
    	tokenServices.setReuseRefreshToken(reuseRefreshToken);
    	tokenServices.setClientDetailsService(clientDetailsService());
    	tokenServices.setTokenEnhancer(tokenEnhancer());
    	addUserDetailsService(tokenServices, this.userDetailsService);
    	return tokenServices;
    }
    ...
    private void addUserDetailsService(DefaultTokenServices tokenServices, UserDetailsService userDetailsService) {
    	if (userDetailsService != null) {
    		PreAuthenticatedAuthenticationProvider provider = new PreAuthenticatedAuthenticationProvider();
    		provider.setPreAuthenticatedUserDetailsService(new UserDetailsByNameServiceWrapper<PreAuthenticatedAuthenticationToken>(
    				userDetailsService));
    		tokenServices
    				.setAuthenticationManager(new ProviderManager(Arrays.<AuthenticationProvider> asList(provider)));
    	}
    }
    ...
    
  • 相关阅读:
    npm ERR! code EINTEGRITY npm! ERR! shal-
    Python 的类的下划线命名有什么不同?
    Linux下通过源码编译安装程序
    Mac OSX下Sublime Text配置使用Ctags实现代码跳转
    Python基础-*args和**kwargs魔法变量
    alpha版、beta版、rc版的意思
    英特尔第四代酷睿处理器数字和字母代表什么意思
    笔记本CPU低压和标压有什么区别?
    MySQL通过localhost无法连接数据库的解决
    sudo:无法解析主机 解决方案
  • 原文地址:https://www.cnblogs.com/luguojun/p/12677193.html
Copyright © 2011-2022 走看看