| 
					
				 | 
			
			
				@ -127,6 +127,15 @@ public class WlyyTokenGranter implements TokenGranter { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        requestFactory, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        userDetailsService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                )); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        tokenGranters.put(PwdAndCaptchaTokenGranter.GRANT_TYPE, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                new PwdAndCaptchaTokenGranter( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        authenticationManager, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        tokenServices, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        clientDetailsService, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        requestFactory, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        userDetailsService, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        wlyyRedisVerifyCodeService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                )); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -650,5 +659,72 @@ public class WlyyTokenGranter implements TokenGranter { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return new OAuth2Authentication(storedOAuth2Request, userAuth); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 密码+验证码登录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public static class PwdAndCaptchaTokenGranter extends AbstractTokenGranter { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        private static final String GRANT_TYPE = "pwdAndCaptcha"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        private final AuthenticationManager authenticationManager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        private final UserDetailsService userDetailsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        private final WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        private GrantedAuthoritiesMapper authoritiesMapper = new NullAuthoritiesMapper(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        public PwdAndCaptchaTokenGranter(AuthenticationManager authenticationManager, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         AuthorizationServerTokenServices tokenServices, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         ClientDetailsService clientDetailsService, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         OAuth2RequestFactory requestFactory, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         UserDetailsService userDetailsService, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, userDetailsService,wlyyRedisVerifyCodeService, GRANT_TYPE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        protected PwdAndCaptchaTokenGranter(AuthenticationManager authenticationManager, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            AuthorizationServerTokenServices tokenServices, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            ClientDetailsService clientDetailsService, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            OAuth2RequestFactory requestFactory, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            UserDetailsService userDetailsService, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            String grantType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            super(tokenServices, clientDetailsService, requestFactory, grantType); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            this.authenticationManager = authenticationManager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            this.wlyyRedisVerifyCodeService = wlyyRedisVerifyCodeService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            this.userDetailsService = userDetailsService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        protected OAuth2Authentication getOAuth2Authentication(ClientDetails client, TokenRequest tokenRequest) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String client_id = parameters.get("client_id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String username = parameters.get("username"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String captcha = parameters.get("captcha"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //todo cyx  部署应取消注释(自测试,可注释,不验证短信直接登录) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (!wlyyRedisVerifyCodeService.verification(client_id, username, captcha)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                throw new InvalidGrantException("Invalid captcha"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String password = parameters.get("password"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            parameters.remove("password"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Authentication userAuth = new UsernamePasswordAuthenticationToken(username, password); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            ((AbstractAuthenticationToken) userAuth).setDetails(parameters); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                userAuth = authenticationManager.authenticate(userAuth); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            catch (AccountStatusException ase) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                throw new InvalidGrantException(ase.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            catch (BadCredentialsException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                throw new InvalidGrantException(e.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (userAuth == null || !userAuth.isAuthenticated()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                throw new InvalidGrantException("Could not authenticate user: " + username); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            OAuth2Request storedOAuth2Request = getRequestFactory().createOAuth2Request(client, tokenRequest); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return new OAuth2Authentication(storedOAuth2Request, userAuth); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 |