fixed Username AD realm
added missing serail version uid to config service update shiro to 1.3.2
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package de.muehlencord.shared.account.business;
|
||||
|
||||
import de.muehlencord.shared.account.entity.ConfigEntity;
|
||||
import java.io.Serializable;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Singleton;
|
||||
import javax.ejb.Startup;
|
||||
@ -13,7 +14,9 @@ import javax.persistence.PersistenceContext;
|
||||
*/
|
||||
@Singleton
|
||||
@Startup
|
||||
public class ConfigService {
|
||||
public class ConfigService implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3195224653632853003L;
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
@ -32,10 +35,10 @@ public class ConfigService {
|
||||
this.maxFailedLogins = Integer.parseInt(configEntity.getConfigValue());
|
||||
}
|
||||
}
|
||||
|
||||
public String getConfigValue (String configKey) {
|
||||
ConfigEntity configEntity = em.find(ConfigEntity.class, configKey);
|
||||
return (configEntity == null ? null : configEntity.getConfigValue());
|
||||
|
||||
public String getConfigValue(String configKey) {
|
||||
ConfigEntity configEntity = em.find(ConfigEntity.class, configKey);
|
||||
return (configEntity == null ? null : configEntity.getConfigValue());
|
||||
}
|
||||
|
||||
/* *** getter *** */
|
||||
|
||||
@ -14,21 +14,23 @@ import org.apache.shiro.realm.ldap.LdapUtils;
|
||||
* @author joern.muehlencord
|
||||
*/
|
||||
public class UserNameActiveDirectoryRealm extends ActiveDirectoryRealm {
|
||||
|
||||
|
||||
@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 {
|
||||
try {
|
||||
if (principalSuffix != null) {
|
||||
if (!userName.contains(principalSuffix))
|
||||
if (!userName.contains(principalSuffix)) {
|
||||
userName += principalSuffix;
|
||||
}
|
||||
}
|
||||
|
||||
ctx = ldapContextFactory.getLdapContext(userName, String.valueOf(upToken.getPassword()));
|
||||
|
||||
// use system context (system user / password) to connect to server
|
||||
// ctx = ldapContextFactory.getSystemLdapContext();
|
||||
ctx = ldapContextFactory.getLdapContext(userName, upToken.getCredentials());
|
||||
} finally {
|
||||
LdapUtils.closeContext(ctx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user