@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ResourceServer)) return false; ResourceServer that = (ResourceServer) o; return that.getId().equals(getId()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || !(o instanceof ResourceServer)) return false; ResourceServer that = (ResourceServer) o; return that.getId().equals(getId()); }
public static ResourceServerEntity toEntity(EntityManager em, ResourceServer resource) { if (resource instanceof ResourceAdapter) { return ((ResourceServerAdapter)resource).getEntity(); } else { return em.getReference(ResourceServerEntity.class, resource.getId()); } }
@Override public String getId() { if (isUpdated()) return updated.getId(); return cached.getId(); }
public CachedResourceServer(Long revision, ResourceServer resourceServer) { super(revision, resourceServer.getId()); this.allowRemoteResourceManagement = resourceServer.isAllowRemoteResourceManagement(); this.policyEnforcementMode = resourceServer.getPolicyEnforcementMode(); }
@Override public List<Scope> getScopes() { return getMongoEntity().getScopes().stream() .map(id -> authorizationProvider.getStoreFactory().getScopeStore().findById(id, getResourceServer().getId())) .collect(toList()); }
@Override public Resource create(String id, String name, ResourceServer resourceServer, String owner) { Resource resource = getResourceStoreDelegate().create(id, name, resourceServer, owner); Resource cached = findById(resource.getId(), resourceServer.getId()); registerResourceInvalidation(resource.getId(), resource.getName(), resource.getType(), resource.getUris(), resource.getScopes().stream().map(scope -> scope.getId()).collect(Collectors.toSet()), resourceServer.getId(), resource.getOwner()); if (cached == null) { cached = findById(resource.getId(), resourceServer.getId()); } return cached; }
@Override public Policy create(AbstractPolicyRepresentation representation, ResourceServer resourceServer) { Policy policy = getPolicyStoreDelegate().create(representation, resourceServer); Policy cached = findById(policy.getId(), resourceServer.getId()); registerPolicyInvalidation(policy.getId(), representation.getName(), representation.getResources(), representation.getScopes(), null, resourceServer.getId()); if (cached == null) { cached = findById(policy.getId(), resourceServer.getId()); } return cached; }
@Override public void delete(String id) { if (id == null) return; Resource resource = findById(id, null); if (resource == null) return; cache.invalidateObject(id); invalidationEvents.add(ResourceRemovedEvent.create(id, resource.getName(), resource.getType(), resource.getUris(), resource.getOwner(), resource.getScopes().stream().map(scope -> scope.getId()).collect(Collectors.toSet()), resource.getResourceServer().getId())); cache.resourceRemoval(id, resource.getName(), resource.getType(), resource.getUris(), resource.getOwner(), resource.getScopes().stream().map(scope -> scope.getId()).collect(Collectors.toSet()), resource.getResourceServer().getId(), invalidations); getResourceStoreDelegate().delete(id); }
@Override public void delete(String id) { if (id == null) return; Scope scope = findById(id, null); if (scope == null) return; cache.invalidateObject(id); invalidationEvents.add(ScopeRemovedEvent.create(id, scope.getName(), scope.getResourceServer().getId())); cache.scopeRemoval(id, scope.getName(), scope.getResourceServer().getId(), invalidations); getScopeStoreDelegate().delete(id); }
@Override public void delete(String id) { if (id == null) return; ResourceServer server = findById(id); if (server == null) return; cache.invalidateObject(id); invalidationEvents.add(ResourceServerRemovedEvent.create(id, server.getId())); cache.resourceServerRemoval(id, invalidations); getResourceServerStoreDelegate().delete(id); }
@Override public ResourceServer create(String clientId) { if (!StorageId.isLocalStorage(clientId)) { throw new ModelException("Creating resource server from federated ClientModel not supported"); } ResourceServer server = getResourceServerStoreDelegate().create(clientId); registerResourceServerInvalidation(server.getId()); return server; }
@Override public Scope create(String id, String name, ResourceServer resourceServer) { Scope scope = getScopeStoreDelegate().create(id, name, resourceServer); registerScopeInvalidation(scope.getId(), scope.getName(), resourceServer.getId()); return scope; }
@Override public Scope getScope() { ScopeEntity scope = entity.getScope(); if (scope == null) { return null; } return storeFactory.getScopeStore().findById(scope.getId(), getResourceServer().getId()); }
public CachedScope(Long revision, Scope scope) { super(revision, scope.getId()); this.name = scope.getName(); this.displayName = scope.getDisplayName(); this.iconUri = scope.getIconUri(); this.resourceServerId = scope.getResourceServer().getId(); }
@Override public Resource getResource() { return storeFactory.getResourceStore().findById(entity.getResource().getId(), getResourceServer().getId()); }
@Override public PermissionTicket create(String resourceId, String scopeId, String requester, ResourceServer resourceServer) { PermissionTicket created = getPermissionTicketStoreDelegate().create(resourceId, scopeId, requester, resourceServer); registerPermissionTicketInvalidation(created.getId(), created.getOwner(), created.getRequester(), created.getResource().getId(), scopeId, created.getResourceServer().getId()); return created; }
@Override public Scope create(final String name, final ResourceServer resourceServer) { ScopeEntity entity = new ScopeEntity(); entity.setId(KeycloakModelUtils.generateId()); entity.setName(name); entity.setResourceServerId(resourceServer.getId()); getMongoStore().insertEntity(entity, getInvocationContext()); return new ScopeAdapter(entity, getInvocationContext(), this.authorizationProvider); }
@Override public Policy create(String name, String type, ResourceServer resourceServer) { PolicyEntity entity = new PolicyEntity(); entity.setId(KeycloakModelUtils.generateId()); entity.setName(name); entity.setType(type); entity.setResourceServerId(resourceServer.getId()); getMongoStore().insertEntity(entity, getInvocationContext()); return new PolicyAdapter(entity, getInvocationContext(), this.authorizationProvider) ; }
@Override public Resource create(String name, ResourceServer resourceServer, String owner) { ResourceEntity entity = new ResourceEntity(); entity.setId(KeycloakModelUtils.generateId()); entity.setName(name); entity.setResourceServerId(resourceServer.getId()); entity.setOwner(owner); getMongoStore().insertEntity(entity, getInvocationContext()); return new ResourceAdapter(entity, getInvocationContext(), this.authorizationProvider); }