Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ....
- class CustomLdapAuthenticationProvider extends LdapAuthenticationProvider {
- def ldapAuthProvider
- def daoAuthenticationProvider
- def springSecurityService
- def userDetailsService
- def dataSource
- def grailsApplication
- CustomLdapAuthenticationProvider(LdapAuthenticationProvider ldapAuthenticationProvider) {
- super(ldapAuthenticationProvider.authenticator, ldapAuthenticationProvider.authoritiesPopulator)
- }
- @Override
- public Authentication authenticate(Authentication authentication) throws AuthenticationException {
- String username = authentication.principal?.toString()?.toLowerCase()
- String password = authentication.credentials
- Boolean isExistingLdapUser = User.withCriteria {
- eq("personUsername", username)
- eq("personIsldap", true)
- }[0] as Boolean
- if (isExistingLdapUser) {
- authentication = ldapAuthProvider.authenticate(authentication)
- springSecurityService.loggedIn ? Person.findByPersonUsername(authentication.principal.username) : null
- .....
- .....
- .....
- }
- }
- @Override
- @Transactional
- public Authentication authenticate(Authentication authentication) throws AuthenticationException {
Add Comment
Please, Sign In to add comment