public CachedGroup(Long revision, RealmModel realm, GroupModel group) { super(revision, group.getId()); this.realm = realm.getId(); this.name = group.getName(); this.parentId = group.getParentId(); this.attributes = new DefaultLazyLoader<>(source -> new MultivaluedHashMap<>(source.getAttributes()), MultivaluedHashMap::new); this.roleMappings = new DefaultLazyLoader<>(source -> source.getRoleMappings().stream().map(RoleModel::getId).collect(Collectors.toSet()), Collections::emptySet); this.subGroups = new DefaultLazyLoader<>(source -> source.getSubGroups().stream().map(GroupModel::getId).collect(Collectors.toSet()), Collections::emptySet); }
public CachedUser(Long revision, RealmModel realm, UserModel user, int notBefore) { super(revision, user.getId()); this.realm = realm.getId(); this.username = user.getUsername(); this.createdTimestamp = user.getCreatedTimestamp(); this.firstName = user.getFirstName(); this.lastName = user.getLastName(); this.email = user.getEmail(); this.emailVerified = user.isEmailVerified(); this.enabled = user.isEnabled(); this.federationLink = user.getFederationLink(); this.serviceAccountClientLink = user.getServiceAccountClientLink(); this.notBefore = notBefore; this.requiredActions = new DefaultLazyLoader<>(UserModel::getRequiredActions, Collections::emptySet); this.attributes = new DefaultLazyLoader<>(userModel -> new MultivaluedHashMap<>(userModel.getAttributes()), MultivaluedHashMap::new); this.roleMappings = new DefaultLazyLoader<>(userModel -> userModel.getRoleMappings().stream().map(RoleModel::getId).collect(Collectors.toSet()), Collections::emptySet); this.groups = new DefaultLazyLoader<>(userModel -> userModel.getGroups().stream().map(GroupModel::getId).collect(Collectors.toCollection(LinkedHashSet::new)), LinkedHashSet::new); }
this.associatedPoliciesIds = source -> data; } else { this.associatedPoliciesIds = new DefaultLazyLoader<>(source -> source.getAssociatedPolicies().stream().map(Policy::getId).collect(Collectors.toSet()), Collections::emptySet); this.resourcesIds = source -> data; } else { this.resourcesIds = new DefaultLazyLoader<>(source -> source.getResources().stream().map(Resource::getId).collect(Collectors.toSet()), Collections::emptySet); this.scopesIds = source -> data; } else { this.scopesIds = new DefaultLazyLoader<>(source -> source.getScopes().stream().map(Scope::getId).collect(Collectors.toSet()), Collections::emptySet); this.config = source -> data; } else { this.config = new DefaultLazyLoader<>(source -> new HashMap<>(source.getConfig()), Collections::emptyMap);
public CachedResource(Long revision, Resource resource) { super(revision, resource.getId()); this.name = resource.getName(); this.displayName = resource.getDisplayName(); this.type = resource.getType(); this.owner = resource.getOwner(); this.iconUri = resource.getIconUri(); this.resourceServerId = resource.getResourceServer().getId(); ownerManagedAccess = resource.isOwnerManagedAccess(); if (resource.isFetched("uris")) { Set<String> data = new HashSet<>(resource.getUris()); this.uris = source -> data; } else { this.uris = new DefaultLazyLoader<>(source -> new HashSet<>(source.getUris()), Collections::emptySet); } if (resource.isFetched("scopes")) { Set<String> data = resource.getScopes().stream().map(Scope::getId).collect(Collectors.toSet()); this.scopesIds = source -> data; } else { this.scopesIds = new DefaultLazyLoader<>(source -> source.getScopes().stream().map(Scope::getId).collect(Collectors.toSet()), Collections::emptySet); } if (resource.isFetched("attributes")) { MultivaluedHashMap<String, String> data = new MultivaluedHashMap<>(resource.getAttributes()); this.attributes = source -> data; } else { this.attributes = new DefaultLazyLoader<>(source -> new MultivaluedHashMap<>(source.getAttributes()), MultivaluedHashMap::new); } }
public CachedRole(Long revision, RoleModel model, RealmModel realm) { super(revision, model.getId()); composite = model.isComposite(); description = model.getDescription(); name = model.getName(); this.realm = realm.getId(); if (composite) { for (RoleModel child : model.getComposites()) { composites.add(child.getId()); } } attributes = new DefaultLazyLoader<>(roleModel -> new MultivaluedHashMap<>(roleModel.getAttributes()), MultivaluedHashMap::new); }