Merge pull request #586 from mposolda/master

Ensure that displayName is persisted. Add 'user' to ActiveDirectory clas...
This commit is contained in:
Marek Posolda 2014-08-04 16:43:41 +02:00
commit 3655db2a30
6 changed files with 25 additions and 3 deletions

View file

@ -485,7 +485,7 @@ module.controller('LDAPCtrl', function($scope, $location, Notifications, Dialog,
if ($scope.lastVendor === "ad") { if ($scope.lastVendor === "ad") {
$scope.instance.config.usernameLDAPAttribute = "cn"; $scope.instance.config.usernameLDAPAttribute = "cn";
$scope.instance.config.userObjectClasses = "person, organizationalPerson"; $scope.instance.config.userObjectClasses = "person, organizationalPerson, user";
} else { } else {
$scope.instance.config.usernameLDAPAttribute = "uid"; $scope.instance.config.usernameLDAPAttribute = "uid";
$scope.instance.config.userObjectClasses = "inetOrgPerson, organizationalPerson"; $scope.instance.config.userObjectClasses = "inetOrgPerson, organizationalPerson";

View file

@ -781,8 +781,9 @@ public class RealmAdapter implements RealmModel {
entity.setPriority(model.getPriority()); entity.setPriority(model.getPriority());
String displayName = model.getDisplayName(); String displayName = model.getDisplayName();
if (displayName == null) { if (displayName == null) {
entity.setDisplayName(entity.getId()); displayName = entity.getId();
} }
entity.setDisplayName(displayName);
em.persist(entity); em.persist(entity);
realm.getUserFederationProviders().add(entity); realm.getUserFederationProviders().add(entity);

View file

@ -766,6 +766,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
if (displayName == null) { if (displayName == null) {
displayName = entity.getId(); displayName = entity.getId();
} }
entity.setDisplayName(displayName);
realm.getUserFederationProviders().add(entity); realm.getUserFederationProviders().add(entity);
updateRealm(); updateRealm();
@ -840,6 +841,7 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
if (displayName == null) { if (displayName == null) {
entity.setDisplayName(entity.getId()); entity.setDisplayName(entity.getId());
} }
entity.setDisplayName(displayName);
entities.add(entity); entities.add(entity);
} }

View file

@ -43,7 +43,7 @@ public class LDAPConnectionTestManager {
ldapContext = new InitialLdapContext(env, null); ldapContext = new InitialLdapContext(env, null);
return true; return true;
} catch (NamingException ne) { } catch (Exception ne) {
String errorMessage = (TEST_AUTHENTICATION.equals(action)) ? "Error when authenticating to LDAP: " : "Error when connecting to LDAP: "; String errorMessage = (TEST_AUTHENTICATION.equals(action)) ? "Error when authenticating to LDAP: " : "Error when connecting to LDAP: ";
logger.error(errorMessage + ne.getMessage(), ne); logger.error(errorMessage + ne.getMessage(), ne);
return false; return false;

View file

@ -12,6 +12,7 @@ import org.keycloak.models.RealmModel;
import org.keycloak.models.RequiredCredentialModel; import org.keycloak.models.RequiredCredentialModel;
import org.keycloak.models.RoleModel; import org.keycloak.models.RoleModel;
import org.keycloak.models.SocialLinkModel; import org.keycloak.models.SocialLinkModel;
import org.keycloak.models.UserFederationProviderModel;
import org.keycloak.models.UserModel; import org.keycloak.models.UserModel;
import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.services.managers.RealmManager; import org.keycloak.services.managers.RealmManager;
@ -194,6 +195,14 @@ public class ImportTest extends AbstractModelTest {
Assert.assertEquals("abc", socialConfig.get("google.key")); Assert.assertEquals("abc", socialConfig.get("google.key"));
Assert.assertEquals("def", socialConfig.get("google.secret")); Assert.assertEquals("def", socialConfig.get("google.secret"));
// Test federation providers
List<UserFederationProviderModel> fedProviders = realm.getUserFederationProviders();
Assert.assertTrue(fedProviders.size() == 1);
UserFederationProviderModel ldap = fedProviders.get(0);
Assert.assertEquals("MyLDAPProvider", ldap.getDisplayName());
Assert.assertEquals("dummy", ldap.getProviderName());
Assert.assertEquals(1, ldap.getPriority());
Assert.assertEquals("ldap://foo", ldap.getConfig().get("important.config"));
} }
@Test @Test

View file

@ -16,6 +16,16 @@
"google.key": "abc", "google.key": "abc",
"google.secret": "def" "google.secret": "def"
}, },
"userFederationProviders": [
{
"displayName": "MyLDAPProvider",
"providerName": "dummy",
"priority": 1,
"config": {
"important.config": "ldap://foo"
}
}
],
"users": [ "users": [
{ {
"username": "wburke", "username": "wburke",