class CustomAuthenticationManager {
	
	protected final Log logger = LogFactory.getLog(getClass());
	
    @Value("${authToken.header}")
    private String tokenHeader;

	
	public String getTokenHeader() {
		return tokenHeader;
	}

	public void setTokenHeader(String tokenHeader) {
		this.tokenHeader = tokenHeader;
	}

	public void authenticateRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		
		if (logger.isDebugEnabled()) {
			logger.debug("Processing authentication");
		}
		
		Authentication authResult = null;

		try {
			authResult = this.attemptAuthentication(request, response);
			if (authResult == null) {
				// return immediately as subclass has indicated that it hasn't completed
				// authentication
				return;
			}
		} catch (AuthenticationException failed) {
			// Authentication failed
			unsuccess(request, response);
			return;
		}

		this.success(request, response, authResult);

		
	}
	
	private void success(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws AuthenticationException {<FILL_FUNCTION_BODY>}
	
	private void unsuccess(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {

		SecurityContextHolder.clearContext();
		
		if (logger.isDebugEnabled()) {
			logger.debug("Authentication request failed");
			logger.debug("Updated SecurityContextHolder to contain null Authentication");
		}
		
		unSuccessfullAuthentication(request, response);
	}

	
	public abstract Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, Exception;
	
	public abstract void successfullAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws AuthenticationException;

	public abstract void unSuccessfullAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException;

}


		SecurityContextHolder.getContext().setAuthentication(authentication);
		
		if (logger.isDebugEnabled()) {
			logger.debug("Authentication success");
			logger.debug("Updated SecurityContextHolder to containAuthentication");
		}
		
		successfullAuthentication(request, response, authentication);
	
<no_super_class>