367 Map<String, String[]> search =
new HashMap<>();
369 if (
id != null && !
"".equals(
id.trim())) {
370 search.put(
"id",
new String[] {
id});
373 if (name != null && !
"".equals(name.trim())) {
374 search.put(
"name",
new String[] {name});
377 if (uri != null && !
"".equals(uri.trim())) {
378 search.put(
"uri",
new String[] {uri});
381 if (owner != null && !
"".equals(owner.trim())) {
385 if (clientModel != null) {
386 owner = clientModel.
getId();
391 owner = user.
getId();
395 search.put(
"owner",
new String[] {owner});
398 if (type != null && !
"".equals(type.trim())) {
399 search.put(
"type",
new String[] {type});
402 if (scope != null && !
"".equals(scope.trim())) {
403 HashMap<String, String[]> scopeFilter =
new HashMap<>();
405 scopeFilter.put(
"name",
new String[] {scope});
409 if (scopes.isEmpty()) {
410 return Response.ok(Collections.emptyList()).build();
413 search.put(
"scope", scopes.stream().map(
Scope::getId).toArray(String[]::
new));
416 List<Resource> resources = storeFactory.getResourceStore().findByResourceServer(search, this.
resourceServer.
getId(), firstResult != null ? firstResult : -1, maxResult != null ? maxResult : Constants.DEFAULT_MAX_RESULTS);
418 if (matchingUri != null && matchingUri && resources.isEmpty()) {
419 HashMap<String, String[]> attributes =
new HashMap<>();
421 attributes.put(
"uri_not_null",
new String[] {
"true"});
424 List<Resource> serverResources = storeFactory.getResourceStore().findByResourceServer(attributes, this.
resourceServer.
getId(), firstResult != null ? firstResult : -1, maxResult != null ? maxResult : Constants.DEFAULT_MAX_RESULTS);
426 PathMatcher<Map.Entry<String, Resource>> pathMatcher =
new PathMatcher<Map.Entry<String, Resource>>() {
428 protected String getPath(Map.Entry<String, Resource> entry) {
429 return entry.getKey();
433 protected Collection<Map.Entry<String, Resource>> getPaths() {
434 Map<String, Resource> result =
new HashMap<>();
435 serverResources.forEach(resource -> resource.getUris().forEach(uri -> {
436 result.put(uri, resource);
439 return result.entrySet();
443 Map.Entry<String, Resource> matches = pathMatcher.matches(uri);
445 if (matches != null) {
446 resources = Collections.singletonList(matches.getValue());
450 Boolean finalDeep = deep;
454 .map(resource -> toRepresentation.apply(resource, finalDeep))
455 .collect(Collectors.toList()))
ClientModel getClientByClientId(String clientId)
KeycloakContext getContext()
final AuthorizationProvider authorization
Definition: ResourceSetService.java:80
ResourceServer resourceServer
Definition: ResourceSetService.java:84
ScopeStore getScopeStore()
StoreFactory getStoreFactory()
Definition: AuthorizationProvider.java:109
KeycloakSession getKeycloakSession()
Definition: AuthorizationProvider.java:165
List< Scope > findByResourceServer(String id)
void requireView()
Definition: ResourceSetService.java:459
UserModel getUserByUsername(String username, RealmModel realm)