commit
2ad873a87f
12 changed files with 6 additions and 52 deletions
|
@ -52,10 +52,6 @@
|
||||||
required> -->
|
required> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group clearfix block">
|
|
||||||
<label for="composite" class="control-label">Composite</label>
|
|
||||||
<input ng-model="role.composite" name="composite" id="composite" onoffswitch />
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="form-actions" data-ng-show="create">
|
<div class="form-actions" data-ng-show="create">
|
||||||
<button type="submit" kc-save class="primary" data-ng-show="changed">Save
|
<button type="submit" kc-save class="primary" data-ng-show="changed">Save
|
||||||
|
@ -74,7 +70,7 @@
|
||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<fieldset data-ng-show="!create && role.composite">
|
<fieldset data-ng-show="!create">
|
||||||
<legend collapsed><span class="text">Composite Realm Roles</span> </legend>
|
<legend collapsed><span class="text">Composite Realm Roles</span> </legend>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="controls changing-selectors">
|
<div class="controls changing-selectors">
|
||||||
|
@ -102,7 +98,7 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset ng-show="applications.length > 0 && !create && role.composite">
|
<fieldset ng-show="applications.length > 0 && !create">
|
||||||
<legend collapsed><span class="text">Composite Application Roles</span> </legend>
|
<legend collapsed><span class="text">Composite Application Roles</span> </legend>
|
||||||
<div class="form-group input-select">
|
<div class="form-group input-select">
|
||||||
<label for="applications">Application</label>
|
<label for="applications">Application</label>
|
||||||
|
|
|
@ -47,10 +47,6 @@
|
||||||
<textarea rows="5" cols="50" id="description" name="description" data-ng-model="role.description"></textarea>
|
<textarea rows="5" cols="50" id="description" name="description" data-ng-model="role.description"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group clearfix block">
|
|
||||||
<label for="composite" class="control-label">Composite</label>
|
|
||||||
<input ng-model="role.composite" name="composite" id="composite" onoffswitch />
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="form-actions" data-ng-show="create">
|
<div class="form-actions" data-ng-show="create">
|
||||||
<button type="submit" kc-save class="primary" data-ng-show="changed">Save
|
<button type="submit" kc-save class="primary" data-ng-show="changed">Save
|
||||||
|
@ -70,7 +66,7 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<fieldset data-ng-show="!create && role.composite">
|
<fieldset data-ng-show="!create">
|
||||||
<legend collapsed><span class="text">Composite Realm Roles</span> </legend>
|
<legend collapsed><span class="text">Composite Realm Roles</span> </legend>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="controls changing-selectors">
|
<div class="controls changing-selectors">
|
||||||
|
@ -98,7 +94,7 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset ng-show="applications.length > 0 && !create && role.composite">
|
<fieldset ng-show="applications.length > 0 && !create">
|
||||||
<legend collapsed><span class="text">Composite Application Roles</span> </legend>
|
<legend collapsed><span class="text">Composite Application Roles</span> </legend>
|
||||||
<div class="form-group input-select">
|
<div class="form-group input-select">
|
||||||
<label for="applications">Application</label>
|
<label for="applications">Application</label>
|
||||||
|
|
|
@ -12,7 +12,6 @@ public class RoleRepresentation {
|
||||||
protected String id;
|
protected String id;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String description;
|
protected String description;
|
||||||
protected boolean composite;
|
|
||||||
protected Composites composites;
|
protected Composites composites;
|
||||||
|
|
||||||
public static class Composites {
|
public static class Composites {
|
||||||
|
@ -69,14 +68,6 @@ public class RoleRepresentation {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isComposite() {
|
|
||||||
return composite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComposite(boolean composite) {
|
|
||||||
this.composite = composite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Composites getComposites() {
|
public Composites getComposites() {
|
||||||
return composites;
|
return composites;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,6 @@ public interface RoleModel {
|
||||||
|
|
||||||
boolean isComposite();
|
boolean isComposite();
|
||||||
|
|
||||||
void setComposite(boolean flag);
|
|
||||||
|
|
||||||
void addCompositeRole(RoleModel role);
|
void addCompositeRole(RoleModel role);
|
||||||
|
|
||||||
void removeCompositeRole(RoleModel role);
|
void removeCompositeRole(RoleModel role);
|
||||||
|
|
|
@ -62,12 +62,7 @@ public class RoleAdapter implements RoleModel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isComposite() {
|
public boolean isComposite() {
|
||||||
return role.isComposite();
|
return getComposites().size() > 0;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setComposite(boolean flag) {
|
|
||||||
role.setComposite(flag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,7 +26,6 @@ public abstract class RoleEntity {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private boolean composite;
|
|
||||||
@ManyToMany(fetch = FetchType.LAZY, cascade = {})
|
@ManyToMany(fetch = FetchType.LAZY, cascade = {})
|
||||||
//@JoinTable(name = "COMPOSITE_ROLE")
|
//@JoinTable(name = "COMPOSITE_ROLE")
|
||||||
private Collection<RoleEntity> compositeRoles = new ArrayList<RoleEntity>();
|
private Collection<RoleEntity> compositeRoles = new ArrayList<RoleEntity>();
|
||||||
|
@ -56,14 +55,6 @@ public abstract class RoleEntity {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isComposite() {
|
|
||||||
return composite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComposite(boolean composite) {
|
|
||||||
this.composite = composite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<RoleEntity> getCompositeRoles() {
|
public Collection<RoleEntity> getCompositeRoles() {
|
||||||
return compositeRoles;
|
return compositeRoles;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ public class ModelToRepresentation {
|
||||||
rep.setId(role.getId());
|
rep.setId(role.getId());
|
||||||
rep.setName(role.getName());
|
rep.setName(role.getName());
|
||||||
rep.setDescription(role.getDescription());
|
rep.setDescription(role.getDescription());
|
||||||
rep.setComposite(role.isComposite());
|
|
||||||
return rep;
|
return rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,6 @@ public class RealmManager {
|
||||||
for (RoleRepresentation roleRep : entry.getValue()) {
|
for (RoleRepresentation roleRep : entry.getValue()) {
|
||||||
RoleModel role = app.addRole(roleRep.getName());
|
RoleModel role = app.addRole(roleRep.getName());
|
||||||
role.setDescription(roleRep.getDescription());
|
role.setDescription(roleRep.getDescription());
|
||||||
role.setComposite(roleRep.isComposite());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -375,7 +374,7 @@ public class RealmManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addComposites(RoleModel role, RoleRepresentation roleRep, RealmModel realm) {
|
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) {
|
if (roleRep.getComposites().getRealm() != null) {
|
||||||
for (String roleStr : roleRep.getComposites().getRealm()) {
|
for (String roleStr : roleRep.getComposites().getRealm()) {
|
||||||
RoleModel realmRole = realm.getRole(roleStr);
|
RoleModel realmRole = realm.getRole(roleStr);
|
||||||
|
@ -404,7 +403,6 @@ public class RealmManager {
|
||||||
public void createRole(RealmModel newRealm, RoleRepresentation roleRep) {
|
public void createRole(RealmModel newRealm, RoleRepresentation roleRep) {
|
||||||
RoleModel role = newRealm.addRole(roleRep.getName());
|
RoleModel role = newRealm.addRole(roleRep.getName());
|
||||||
if (roleRep.getDescription() != null) role.setDescription(roleRep.getDescription());
|
if (roleRep.getDescription() != null) role.setDescription(roleRep.getDescription());
|
||||||
role.setComposite(roleRep.isComposite());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createRole(RealmModel newRealm, ApplicationModel app, RoleRepresentation roleRep) {
|
public void createRole(RealmModel newRealm, ApplicationModel app, RoleRepresentation roleRep) {
|
||||||
|
|
|
@ -59,7 +59,6 @@ public class RoleContainerResource extends RoleResource {
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
}
|
}
|
||||||
role.setDescription(rep.getDescription());
|
role.setDescription(rep.getDescription());
|
||||||
role.setComposite(rep.isComposite());
|
|
||||||
return Response.created(uriInfo.getAbsolutePathBuilder().path(role.getName()).build()).build();
|
return Response.created(uriInfo.getAbsolutePathBuilder().path(role.getName()).build()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ public class RoleResource {
|
||||||
protected void updateRole(RoleRepresentation rep, RoleModel role) {
|
protected void updateRole(RoleRepresentation rep, RoleModel role) {
|
||||||
role.setName(rep.getName());
|
role.setName(rep.getName());
|
||||||
role.setDescription(rep.getDescription());
|
role.setDescription(rep.getDescription());
|
||||||
role.setComposite(rep.isComposite());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addComposites(List<RoleRepresentation> roles, RoleModel role) {
|
protected void addComposites(List<RoleRepresentation> roles, RoleModel role) {
|
||||||
|
@ -45,7 +44,6 @@ public class RoleResource {
|
||||||
if (composite == null) {
|
if (composite == null) {
|
||||||
throw new NotFoundException("Could not find composite role: " + rep.getName());
|
throw new NotFoundException("Could not find composite role: " + rep.getName());
|
||||||
}
|
}
|
||||||
if (!role.isComposite()) role.setComposite(true);
|
|
||||||
role.addCompositeRole(composite);
|
role.addCompositeRole(composite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,6 +94,5 @@ public class RoleResource {
|
||||||
}
|
}
|
||||||
role.removeCompositeRole(composite);
|
role.removeCompositeRole(composite);
|
||||||
}
|
}
|
||||||
if (role.getComposites().size() == 0) role.setComposite(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,6 @@ public class CompositeRoleTest {
|
||||||
final RoleModel realmRole2 = realm.addRole("REALM_ROLE_2");
|
final RoleModel realmRole2 = realm.addRole("REALM_ROLE_2");
|
||||||
final RoleModel realmRole3 = realm.addRole("REALM_ROLE_3");
|
final RoleModel realmRole3 = realm.addRole("REALM_ROLE_3");
|
||||||
final RoleModel realmComposite1 = realm.addRole("REALM_COMPOSITE_1");
|
final RoleModel realmComposite1 = realm.addRole("REALM_COMPOSITE_1");
|
||||||
realmComposite1.setComposite(true);
|
|
||||||
realmComposite1.addCompositeRole(realmRole1);
|
realmComposite1.addCompositeRole(realmRole1);
|
||||||
|
|
||||||
final UserModel realmComposite1User = realm.addUser("REALM_COMPOSITE_1_USER");
|
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 appRole2 = appRoleApplication.addRole("APP_ROLE_2");
|
||||||
|
|
||||||
final RoleModel realmAppCompositeRole = realm.addRole("REALM_APP_COMPOSITE_ROLE");
|
final RoleModel realmAppCompositeRole = realm.addRole("REALM_APP_COMPOSITE_ROLE");
|
||||||
realmAppCompositeRole.setComposite(true);
|
|
||||||
realmAppCompositeRole.addCompositeRole(appRole1);
|
realmAppCompositeRole.addCompositeRole(appRole1);
|
||||||
|
|
||||||
final UserModel realmAppCompositeUser = realm.addUser("REALM_APP_COMPOSITE_USER");
|
final UserModel realmAppCompositeUser = realm.addUser("REALM_APP_COMPOSITE_USER");
|
||||||
|
@ -125,7 +123,6 @@ public class CompositeRoleTest {
|
||||||
appCompositeApplication.setManagementUrl("http://localhost:8081/app/logout");
|
appCompositeApplication.setManagementUrl("http://localhost:8081/app/logout");
|
||||||
realm.updateCredential(appCompositeApplication.getApplicationUser(), UserCredentialModel.password("password"));
|
realm.updateCredential(appCompositeApplication.getApplicationUser(), UserCredentialModel.password("password"));
|
||||||
final RoleModel appCompositeRole = appCompositeApplication.addRole("APP_COMPOSITE_ROLE");
|
final RoleModel appCompositeRole = appCompositeApplication.addRole("APP_COMPOSITE_ROLE");
|
||||||
appCompositeRole.setComposite(true);
|
|
||||||
appCompositeApplication.addScope(appRole2);
|
appCompositeApplication.addScope(appRole2);
|
||||||
appCompositeRole.addCompositeRole(realmRole1);
|
appCompositeRole.addCompositeRole(realmRole1);
|
||||||
appCompositeRole.addCompositeRole(realmRole2);
|
appCompositeRole.addCompositeRole(realmRole2);
|
||||||
|
|
|
@ -164,14 +164,12 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "REALM_COMPOSITE_1",
|
"name": "REALM_COMPOSITE_1",
|
||||||
"composite": true,
|
|
||||||
"composites": {
|
"composites": {
|
||||||
"realm": ["REALM_ROLE_1"]
|
"realm": ["REALM_ROLE_1"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "REALM_APP_COMPOSITE_ROLE",
|
"name": "REALM_APP_COMPOSITE_ROLE",
|
||||||
"composite": true,
|
|
||||||
"composites": {
|
"composites": {
|
||||||
"application": {
|
"application": {
|
||||||
"APP_ROLE_APPLICATION" :[
|
"APP_ROLE_APPLICATION" :[
|
||||||
|
@ -193,7 +191,6 @@
|
||||||
"APP_COMPOSITE_APPLICATION" : [
|
"APP_COMPOSITE_APPLICATION" : [
|
||||||
{
|
{
|
||||||
"name": "APP_COMPOSITE_ROLE",
|
"name": "APP_COMPOSITE_ROLE",
|
||||||
"composite": true,
|
|
||||||
"composites": {
|
"composites": {
|
||||||
"realm" : [
|
"realm" : [
|
||||||
"REALM_ROLE_1",
|
"REALM_ROLE_1",
|
||||||
|
|
Loading…
Reference in a new issue