@Override
    public Authentication attemptAuthentication(HttpServletRequest request,
    		HttpServletResponse response) throws AuthenticationException {
    	
    	if (postOnly && !request.getMethod().equals("POST")) {  
            throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());  
        }  
    	String username = obtainUsername(request);  
        String password = obtainPassword(request);  
        String redirectUrl = obtainRedercitUrl(request);  
        if (username == null) {  
            username = "";  
        }  
        if (password == null) {  
            password = "";  
        }  
        //自定义回调URL，若存在则放入Session  
        if(redirectUrl != null && !"".equals(redirectUrl)){  
            request.getSession().setAttribute("callCustomRediretUrl", redirectUrl);  
        }  
        username = username.trim();  
        UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);  
        // Allow subclasses to set the "details" property  
        setDetails(request, authRequest);  
        return this.getAuthenticationManager().authenticate(authRequest);  
    }