KEYCLOAK-264 Remove option to enable/disable acct mngmt
This commit is contained in:
1 parent
7a6f67dfdd
commit
c5366f1c81
10 files changed
+10
-42
No files matched your search
@@ -76,7 +76,6 @@ public class ApplianceBootstrap {
|
||||
|
||||
adminConsole.grantRole(adminUser, adminRole);
|
||||
|
||||
manager.enableAccountManagement(realm);
|
||||
ApplicationModel accountApp = realm.getApplicationNameMap().get(Constants.ACCOUNT_APPLICATION);
|
||||
for (String r : accountApp.getDefaultRoles()) {
|
||||
accountApp.grantRole(adminUser, accountApp.getRole(r));
|
||||
|
||||
@@ -78,6 +78,9 @@ public class RealmManager {
|
||||
realm.setName(name);
|
||||
realm.addRole(Constants.APPLICATION_ROLE);
|
||||
realm.addRole(Constants.IDENTITY_REQUESTER_ROLE);
|
||||
|
||||
setupAccountManagement(realm);
|
||||
|
||||
return realm;
|
||||
}
|
||||
|
||||
@@ -125,12 +128,6 @@ public class RealmManager {
|
||||
realm.updateDefaultRoles(rep.getDefaultRoles().toArray(new String[rep.getDefaultRoles().size()]));
|
||||
}
|
||||
|
||||
if (rep.getAccountManagement() != null && rep.getAccountManagement()) {
|
||||
enableAccountManagement(realm);
|
||||
} else {
|
||||
disableAccountManagement(realm);
|
||||
}
|
||||
|
||||
if (rep.getSmtpServer() != null) {
|
||||
realm.setSmtpConfig(new HashMap(rep.getSmtpServer()));
|
||||
}
|
||||
@@ -144,10 +141,12 @@ public class RealmManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void enableAccountManagement(RealmModel realm) {
|
||||
private void setupAccountManagement(RealmModel realm) {
|
||||
ApplicationModel application = realm.getApplicationNameMap().get(Constants.ACCOUNT_APPLICATION);
|
||||
if (application == null) {
|
||||
application = realm.addApplication(Constants.ACCOUNT_APPLICATION);
|
||||
application.setEnabled(true);
|
||||
|
||||
application.addDefaultRole(Constants.ACCOUNT_PROFILE_ROLE);
|
||||
application.addDefaultRole(Constants.ACCOUNT_MANAGE_ROLE);
|
||||
|
||||
@@ -160,14 +159,6 @@ public class RealmManager {
|
||||
RoleModel applicationRole = realm.getRole(Constants.APPLICATION_ROLE);
|
||||
realm.grantRole(application.getApplicationUser(), applicationRole);
|
||||
}
|
||||
application.setEnabled(true);
|
||||
}
|
||||
|
||||
public void disableAccountManagement(RealmModel realm) {
|
||||
ApplicationModel application = realm.getApplicationNameMap().get(Constants.ACCOUNT_APPLICATION);
|
||||
if (application != null) {
|
||||
application.setEnabled(false); // TODO Should we delete the application instead?
|
||||
}
|
||||
}
|
||||
|
||||
public RealmModel importRealm(RealmRepresentation rep, UserModel realmCreator) {
|
||||
@@ -180,7 +171,6 @@ public class RealmManager {
|
||||
return realm;
|
||||
}
|
||||
|
||||
|
||||
public void importRealm(RealmRepresentation rep, RealmModel newRealm) {
|
||||
newRealm.setName(rep.getRealm());
|
||||
if (rep.isEnabled() != null) newRealm.setEnabled(rep.isEnabled());
|
||||
@@ -270,10 +260,6 @@ public class RealmManager {
|
||||
|
||||
}
|
||||
|
||||
if (rep.getAccountManagement() != null && rep.getAccountManagement()) {
|
||||
enableAccountManagement(newRealm);
|
||||
}
|
||||
|
||||
// Now that all possible users and applications are created (users, apps, and oauth clients), do role mappings and scope mappings
|
||||
|
||||
Map<String, ApplicationModel> appMap = newRealm.getApplicationNameMap();
|
||||
@@ -492,7 +478,6 @@ public class RealmManager {
|
||||
}
|
||||
|
||||
ApplicationModel accountManagementApplication = realm.getApplicationNameMap().get(Constants.ACCOUNT_APPLICATION);
|
||||
rep.setAccountManagement(accountManagementApplication != null && accountManagementApplication.isEnabled());
|
||||
|
||||
List<String> defaultRoles = realm.getDefaultRoles();
|
||||
if (!defaultRoles.isEmpty()) {
|
||||
|
||||
@@ -438,8 +438,8 @@ public class AdapterTest extends AbstractKeycloakTest {
|
||||
RealmModel otherRealm = adapter.createRealm("other");
|
||||
otherRealm.addUser("bburke");
|
||||
|
||||
Assert.assertEquals(1, otherRealm.getUsers().size());
|
||||
Assert.assertEquals(1, otherRealm.searchForUser("u").size());
|
||||
Assert.assertEquals(2, otherRealm.getUsers().size());
|
||||
Assert.assertEquals(1, otherRealm.searchForUser("bu").size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ApplicationModelTest extends AbstractKeycloakServerTest {
|
||||
public void persist() {
|
||||
RealmModel persisted = manager.getRealm(realm.getId());
|
||||
|
||||
assertEquals(application, persisted.getApplications().get(0));
|
||||
assertEquals(application, persisted.getApplicationNameMap().get("app-name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ImportTest extends AbstractKeycloakTest {
|
||||
Assert.assertEquals(0, realm.getSocialLinks(user).size());
|
||||
|
||||
List<ApplicationModel> resources = realm.getApplications();
|
||||
Assert.assertEquals(2, resources.size());
|
||||
Assert.assertEquals(3, resources.size());
|
||||
|
||||
// Test scope relationship
|
||||
ApplicationModel application = realm.getApplicationNameMap().get("Application");
|
||||
|
||||
Reference in new issue
Block a user