@Override
	protected Authentication doAuthentication(Authentication authentication)
			throws AuthenticationException {

		if (!(authentication instanceof CustomAuthenticationToken)) {			
			throw new IllegalArgumentException("Only CustomAuthenticationManager is supported");
		}
		
		CustomAuthenticationToken authenticationToken = (CustomAuthenticationToken) authentication;		

		final String userName = (String) authenticationToken.getPrincipal();				
		final String password = (String) authenticationToken.getCredentials();		
		final String company = (String) authenticationToken.getCompany();
		
		if (AppUtil.isNullOrEmpty(userName) ||
			AppUtil.isNullOrEmpty(password) ||
			AppUtil.isNullOrEmpty(company)) {
			
			throw new BadCredentialsException("Invalid username/password");
		}
		
		User user = null;
		
		try {			
			
			//Actual service call
			user = loginAppSvc.login(userName, password, company);
			
		} catch (AppSvcException ase) {
			throw new BadCredentialsException(ase.getMessage());
		}
		
		List<GrantedAuthority> grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
		grantedAuthoritiesList.add(new GrantedAuthorityImpl("ROLE_USER"));
		
		
		return createSuccesssAuthentication(user,
											authenticationToken,
											grantedAuthoritiesList);

	}