added logging
This commit is contained in:
@ -8,6 +8,8 @@ import org.apache.shiro.authc.UsernamePasswordToken;
|
||||
import org.apache.shiro.realm.activedirectory.ActiveDirectoryRealm;
|
||||
import org.apache.shiro.realm.ldap.LdapContextFactory;
|
||||
import org.apache.shiro.realm.ldap.LdapUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -15,10 +17,12 @@ import org.apache.shiro.realm.ldap.LdapUtils;
|
||||
*/
|
||||
public class UserNameActiveDirectoryRealm extends ActiveDirectoryRealm {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(UserNameActiveDirectoryRealm.class);
|
||||
|
||||
@Override
|
||||
protected AuthenticationInfo queryForAuthenticationInfo(AuthenticationToken token, LdapContextFactory ldapContextFactory) throws NamingException {
|
||||
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
|
||||
// Binds using the username and password provided by the user.
|
||||
|
||||
LdapContext ctx = null;
|
||||
String userName = upToken.getUsername();
|
||||
try {
|
||||
@ -28,13 +32,17 @@ public class UserNameActiveDirectoryRealm extends ActiveDirectoryRealm {
|
||||
}
|
||||
}
|
||||
|
||||
// use system context (system user / password) to connect to server
|
||||
// ctx = ldapContextFactory.getSystemLdapContext();
|
||||
// Binds using the username and password provided by the user.
|
||||
LOGGER.debug("start creating context");
|
||||
ctx = ldapContextFactory.getLdapContext(userName, upToken.getCredentials());
|
||||
LOGGER.debug("context created");
|
||||
} finally {
|
||||
LdapUtils.closeContext(ctx);
|
||||
}
|
||||
|
||||
return buildAuthenticationInfo(userName, upToken.getPassword());
|
||||
LOGGER.debug("building authentication info");
|
||||
AuthenticationInfo authInfo = buildAuthenticationInfo(userName, upToken.getPassword());
|
||||
LOGGER.debug("authentifaction info created");
|
||||
return authInfo;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user