Пример #1
0
 @Override
 public RoleModel addRole(String id, String name) {
   getDelegateForUpdate();
   RoleModel role = updated.addRole(id, name);
   cacheSession.registerRoleInvalidation(role.getId());
   return role;
 }
Пример #2
0
  public Set<RoleModel> getRealmScopeMappings() {
    Set<RoleModel> roleMappings = getScopeMappings();

    Set<RoleModel> appRoles = new HashSet<RoleModel>();
    for (RoleModel role : roleMappings) {
      RoleContainerModel container = role.getContainer();
      if (container instanceof RealmModel) {
        if (((RealmModel) container).getId().equals(cachedRealm.getId())) {
          appRoles.add(role);
        }
      }
    }

    return appRoles;
  }
Пример #3
0
  @Override
  public Set<RoleModel> getClientScopeMappings(ClientModel client) {
    Set<RoleModel> roleMappings = client.getScopeMappings();

    Set<RoleModel> appRoles = new HashSet<RoleModel>();
    for (RoleModel role : roleMappings) {
      RoleContainerModel container = role.getContainer();
      if (container instanceof RealmModel) {
      } else {
        ClientModel app = (ClientModel) container;
        if (app.getId().equals(getId())) {
          appRoles.add(role);
        }
      }
    }

    return appRoles;
  }
Пример #4
0
  @Override
  public boolean hasScope(RoleModel role) {
    if (updated != null) return updated.hasScope(role);
    if (cached.isFullScopeAllowed() || cached.getScope().contains(role.getId())) return true;

    Set<RoleModel> roles = getScopeMappings();

    for (RoleModel mapping : roles) {
      if (mapping.hasRole(role)) return true;
    }

    roles = getRoles();
    if (roles.contains(role)) return true;

    for (RoleModel mapping : roles) {
      if (mapping.hasRole(role)) return true;
    }
    return false;
  }
Пример #5
0
 @Override
 public boolean removeRole(RoleModel role) {
   cacheSession.registerRoleInvalidation(role.getId());
   getDelegateForUpdate();
   return updated.removeRole(role);
 }