Skip to content

Commit

Permalink
#68 some ldap logging update
Browse files Browse the repository at this point in the history
  • Loading branch information
dk1844 committed Aug 25, 2023
1 parent d312d31 commit 9d4b458
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package za.co.absa.loginsvc.rest.provider.ad.ldap

import org.slf4j.LoggerFactory
import org.springframework.ldap.core.DirContextOperations
import org.springframework.security.authentication.{AuthenticationProvider, UsernamePasswordAuthenticationToken}
import org.springframework.security.authentication.{AuthenticationProvider, BadCredentialsException, UsernamePasswordAuthenticationToken}
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.security.core.{Authentication, GrantedAuthority}
import org.springframework.security.ldap.authentication.ad.{ActiveDirectoryLdapAuthenticationProvider => SpringSecurityActiveDirectoryLdapAuthenticationProvider}
Expand Down Expand Up @@ -55,8 +55,13 @@ class ActiveDirectoryLDAPAuthenticationProvider(config: ActiveDirectoryLDAPConfi
val fromBase = try {
baseImplementation.authenticate(authentication)
} catch {
case re: RuntimeException =>
case bc: BadCredentialsException =>
logger.error(s"Login of user $username: ${bc.getMessage}", bc)
throw bc // rethrow, just get short info to logs

case re: RuntimeException => // other exception
logger.error(s"Login of user $username: ${re.getMessage}", re)
re.printStackTrace()
throw re // rethrow, just get info to logs
}

Expand Down

0 comments on commit 9d4b458

Please sign in to comment.