Guest User

Untitled

a guest
Oct 26th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. ....
  2. class CustomLdapAuthenticationProvider extends LdapAuthenticationProvider {
  3.  
  4. def ldapAuthProvider
  5. def daoAuthenticationProvider
  6. def springSecurityService
  7. def userDetailsService
  8. def dataSource
  9. def grailsApplication
  10.  
  11. CustomLdapAuthenticationProvider(LdapAuthenticationProvider ldapAuthenticationProvider) {
  12. super(ldapAuthenticationProvider.authenticator, ldapAuthenticationProvider.authoritiesPopulator)
  13. }
  14.  
  15. @Override
  16. public Authentication authenticate(Authentication authentication) throws AuthenticationException {
  17. String username = authentication.principal?.toString()?.toLowerCase()
  18. String password = authentication.credentials
  19. Boolean isExistingLdapUser = User.withCriteria {
  20. eq("personUsername", username)
  21. eq("personIsldap", true)
  22. }[0] as Boolean
  23. if (isExistingLdapUser) {
  24. authentication = ldapAuthProvider.authenticate(authentication)
  25. springSecurityService.loggedIn ? Person.findByPersonUsername(authentication.principal.username) : null
  26. .....
  27. .....
  28. .....
  29.  
  30. }
  31. }
  32.  
  33. @Override
  34. @Transactional
  35. public Authentication authenticate(Authentication authentication) throws AuthenticationException {
Add Comment
Please, Sign In to add comment