From d2ad6349ba534977c83dbbe354131047691a8b6d Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Tue, 4 Feb 2014 18:41:36 -0500 Subject: [PATCH] remove setComposite --- .../admin/partials/application-role-detail.html | 8 ++------ .../META-INF/resources/admin/partials/role-detail.html | 8 ++------ .../keycloak/representations/idm/RoleRepresentation.java | 9 --------- .../api/src/main/java/org/keycloak/models/RoleModel.java | 2 -- .../main/java/org/keycloak/models/jpa/RoleAdapter.java | 7 +------ .../org/keycloak/models/jpa/entities/RoleEntity.java | 9 --------- .../services/managers/ModelToRepresentation.java | 1 - .../org/keycloak/services/managers/RealmManager.java | 4 +--- .../services/resources/admin/RoleContainerResource.java | 1 - .../keycloak/services/resources/admin/RoleResource.java | 3 --- .../keycloak/testsuite/composites/CompositeRoleTest.java | 3 --- .../integration/src/test/resources/testcomposite.json | 3 --- 12 files changed, 6 insertions(+), 52 deletions(-) diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-detail.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-detail.html index 4c6b5b25fc..fc399120c9 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-detail.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-role-detail.html @@ -52,10 +52,6 @@ required> --> -
- - -
-
+
Composite Realm Roles
@@ -102,7 +98,7 @@
-
+
Composite Application Roles
diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/role-detail.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/role-detail.html index b835fcb7f8..5b1d3af4e2 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/role-detail.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/role-detail.html @@ -47,10 +47,6 @@
-
- - -
-
+
Composite Realm Roles
@@ -98,7 +94,7 @@
-
+
Composite Application Roles
diff --git a/core/src/main/java/org/keycloak/representations/idm/RoleRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/RoleRepresentation.java index e98eaa6c40..faf9a5dc12 100755 --- a/core/src/main/java/org/keycloak/representations/idm/RoleRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/RoleRepresentation.java @@ -12,7 +12,6 @@ public class RoleRepresentation { protected String id; protected String name; protected String description; - protected boolean composite; protected Composites composites; public static class Composites { @@ -69,14 +68,6 @@ public class RoleRepresentation { this.description = description; } - public boolean isComposite() { - return composite; - } - - public void setComposite(boolean composite) { - this.composite = composite; - } - public Composites getComposites() { return composites; } diff --git a/model/api/src/main/java/org/keycloak/models/RoleModel.java b/model/api/src/main/java/org/keycloak/models/RoleModel.java index 1cacaff3d6..49dabeb542 100755 --- a/model/api/src/main/java/org/keycloak/models/RoleModel.java +++ b/model/api/src/main/java/org/keycloak/models/RoleModel.java @@ -19,8 +19,6 @@ public interface RoleModel { boolean isComposite(); - void setComposite(boolean flag); - void addCompositeRole(RoleModel role); void removeCompositeRole(RoleModel role); diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/RoleAdapter.java b/model/jpa/src/main/java/org/keycloak/models/jpa/RoleAdapter.java index 69aa3ae245..2c9a8c95a9 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/RoleAdapter.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/RoleAdapter.java @@ -62,12 +62,7 @@ public class RoleAdapter implements RoleModel { @Override public boolean isComposite() { - return role.isComposite(); - } - - @Override - public void setComposite(boolean flag) { - role.setComposite(flag); + return getComposites().size() > 0; } @Override diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java index 0d67e34d4f..1c21d125cc 100755 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RoleEntity.java @@ -26,7 +26,6 @@ public abstract class RoleEntity { private String name; private String description; - private boolean composite; @ManyToMany(fetch = FetchType.LAZY, cascade = {}) //@JoinTable(name = "COMPOSITE_ROLE") private Collection compositeRoles = new ArrayList(); @@ -56,14 +55,6 @@ public abstract class RoleEntity { this.description = description; } - public boolean isComposite() { - return composite; - } - - public void setComposite(boolean composite) { - this.composite = composite; - } - public Collection getCompositeRoles() { return compositeRoles; } diff --git a/services/src/main/java/org/keycloak/services/managers/ModelToRepresentation.java b/services/src/main/java/org/keycloak/services/managers/ModelToRepresentation.java index a706360ade..efcd1dccae 100755 --- a/services/src/main/java/org/keycloak/services/managers/ModelToRepresentation.java +++ b/services/src/main/java/org/keycloak/services/managers/ModelToRepresentation.java @@ -51,7 +51,6 @@ public class ModelToRepresentation { rep.setId(role.getId()); rep.setName(role.getName()); rep.setDescription(role.getDescription()); - rep.setComposite(role.isComposite()); return rep; } diff --git a/services/src/main/java/org/keycloak/services/managers/RealmManager.java b/services/src/main/java/org/keycloak/services/managers/RealmManager.java index 9afb3ea294..461159983a 100755 --- a/services/src/main/java/org/keycloak/services/managers/RealmManager.java +++ b/services/src/main/java/org/keycloak/services/managers/RealmManager.java @@ -260,7 +260,6 @@ public class RealmManager { for (RoleRepresentation roleRep : entry.getValue()) { RoleModel role = app.addRole(roleRep.getName()); role.setDescription(roleRep.getDescription()); - role.setComposite(roleRep.isComposite()); } } } @@ -375,7 +374,7 @@ public class RealmManager { } public void addComposites(RoleModel role, RoleRepresentation roleRep, RealmModel realm) { - if (!roleRep.isComposite() || roleRep.getComposites() == null) return; + if (roleRep.getComposites() == null) return; if (roleRep.getComposites().getRealm() != null) { for (String roleStr : roleRep.getComposites().getRealm()) { RoleModel realmRole = realm.getRole(roleStr); @@ -404,7 +403,6 @@ public class RealmManager { public void createRole(RealmModel newRealm, RoleRepresentation roleRep) { RoleModel role = newRealm.addRole(roleRep.getName()); if (roleRep.getDescription() != null) role.setDescription(roleRep.getDescription()); - role.setComposite(roleRep.isComposite()); } public void createRole(RealmModel newRealm, ApplicationModel app, RoleRepresentation roleRep) { diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java index 7728d61544..e1f07fb333 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RoleContainerResource.java @@ -59,7 +59,6 @@ public class RoleContainerResource extends RoleResource { throw new NotFoundException(); } role.setDescription(rep.getDescription()); - role.setComposite(rep.isComposite()); return Response.created(uriInfo.getAbsolutePathBuilder().path(role.getName()).build()).build(); } diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RoleResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RoleResource.java index 8bab186c79..91e42b44b8 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RoleResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RoleResource.java @@ -36,7 +36,6 @@ public class RoleResource { protected void updateRole(RoleRepresentation rep, RoleModel role) { role.setName(rep.getName()); role.setDescription(rep.getDescription()); - role.setComposite(rep.isComposite()); } protected void addComposites(List roles, RoleModel role) { @@ -45,7 +44,6 @@ public class RoleResource { if (composite == null) { throw new NotFoundException("Could not find composite role: " + rep.getName()); } - if (!role.isComposite()) role.setComposite(true); role.addCompositeRole(composite); } } @@ -96,6 +94,5 @@ public class RoleResource { } role.removeCompositeRole(composite); } - if (role.getComposites().size() == 0) role.setComposite(false); } } diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/composites/CompositeRoleTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/composites/CompositeRoleTest.java index 3cc1e4093c..8c0d19f0a5 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/composites/CompositeRoleTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/composites/CompositeRoleTest.java @@ -69,7 +69,6 @@ public class CompositeRoleTest { final RoleModel realmRole2 = realm.addRole("REALM_ROLE_2"); final RoleModel realmRole3 = realm.addRole("REALM_ROLE_3"); final RoleModel realmComposite1 = realm.addRole("REALM_COMPOSITE_1"); - realmComposite1.setComposite(true); realmComposite1.addCompositeRole(realmRole1); final UserModel realmComposite1User = realm.addUser("REALM_COMPOSITE_1_USER"); @@ -106,7 +105,6 @@ public class CompositeRoleTest { final RoleModel appRole2 = appRoleApplication.addRole("APP_ROLE_2"); final RoleModel realmAppCompositeRole = realm.addRole("REALM_APP_COMPOSITE_ROLE"); - realmAppCompositeRole.setComposite(true); realmAppCompositeRole.addCompositeRole(appRole1); final UserModel realmAppCompositeUser = realm.addUser("REALM_APP_COMPOSITE_USER"); @@ -125,7 +123,6 @@ public class CompositeRoleTest { appCompositeApplication.setManagementUrl("http://localhost:8081/app/logout"); realm.updateCredential(appCompositeApplication.getApplicationUser(), UserCredentialModel.password("password")); final RoleModel appCompositeRole = appCompositeApplication.addRole("APP_COMPOSITE_ROLE"); - appCompositeRole.setComposite(true); appCompositeApplication.addScope(appRole2); appCompositeRole.addCompositeRole(realmRole1); appCompositeRole.addCompositeRole(realmRole2); diff --git a/testsuite/integration/src/test/resources/testcomposite.json b/testsuite/integration/src/test/resources/testcomposite.json index 2b6a48a9d6..1ac78c2a3b 100755 --- a/testsuite/integration/src/test/resources/testcomposite.json +++ b/testsuite/integration/src/test/resources/testcomposite.json @@ -164,14 +164,12 @@ }, { "name": "REALM_COMPOSITE_1", - "composite": true, "composites": { "realm": ["REALM_ROLE_1"] } }, { "name": "REALM_APP_COMPOSITE_ROLE", - "composite": true, "composites": { "application": { "APP_ROLE_APPLICATION" :[ @@ -193,7 +191,6 @@ "APP_COMPOSITE_APPLICATION" : [ { "name": "APP_COMPOSITE_ROLE", - "composite": true, "composites": { "realm" : [ "REALM_ROLE_1",