Table of Contents

Search

  1. Preface
  2. RulePoint Interfaces
  3. RulePoint Services
  4. Custom Service API
  5. Java Adapter for REST API
  6. RulePoint REST API
  7. Sample XML and JSON Requests and Responses
  8. RulePoint Pluggable Authentication Module
  9. HTTP Request and Response Attributes

Developer Guide

Developer Guide

PAUserDetailsServiceImpl

PAUserDetailsServiceImpl

The following code shows you how to create the
PAUserDetailsServiceImpl.java
class:
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; } }

0 COMMENTS

We’d like to hear from you!