RulePoint
- RulePoint 6.2
- All Products
package com.informatica.cep.design.custom.application.security.web; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import com.informatica.cep.design.application.security.repo.DTUserRepo; public class PAUserDetailsServiceImpl implements UserDetailsService { private Logger logger = Logger.getLogger(PAUserDetailsServiceImpl.class); @Autowired private DTUserRepo userRepo; @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { UserDetails ud = userRepo.findLocalUserByUserNameForAuthentication(normalize(username)); if(ud == null) throw new BadCredentialsException("Username :"+username+" not found in Rulepoint"); return ud; } //this can be used in the main code as well that way we will not require this special class just for this private String normalize(String arg) { logger.debug((new StringBuilder()).append("normalize in ").append(arg).toString()); if(arg.indexOf('=') != -1) arg = arg.substring(arg.indexOf('=') + 1); logger.debug((new StringBuilder()).append("normalize out ").append(arg).toString()); return arg; } }