keycloak
公開メンバ関数 | 関数 | 全メンバ一覧
org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache クラス
org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache の継承関係図
Inheritance graph
org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache 連携図
Collaboration graph

公開メンバ関数

Resource create (String name, ResourceServer resourceServer, String owner)
 
Resource create (String id, String name, ResourceServer resourceServer, String owner)
 
void delete (String id)
 
Resource findById (String id, String resourceServerId)
 
Resource findByName (String name, String resourceServerId)
 
Resource findByName (String name, String ownerId, String resourceServerId)
 
List< ResourcefindByOwner (String ownerId, String resourceServerId)
 
void findByOwner (String ownerId, String resourceServerId, Consumer< Resource > consumer)
 
List< ResourcefindByUri (String uri, String resourceServerId)
 
List< ResourcefindByResourceServer (String resourceServerId)
 
List< ResourcefindByResourceServer (Map< String, String[]> attributes, String resourceServerId, int firstResult, int maxResult)
 
List< ResourcefindByScope (List< String > ids, String resourceServerId)
 
void findByScope (List< String > ids, String resourceServerId, Consumer< Resource > consumer)
 
List< ResourcefindByType (String type, String resourceServerId)
 
void findByType (String type, String resourceServerId, Consumer< Resource > consumer)
 

関数

private< R, Q extends ResourceQuery > List< R > cacheQuery (String cacheKey, Class< Q > queryType, Supplier< List< R >> resultSupplier, BiFunction< Long, List< R >, Q > querySupplier, String resourceServerId)
 
private< R, Q extends ResourceQuery > List< R > cacheQuery (String cacheKey, Class< Q > queryType, Supplier< List< R >> resultSupplier, BiFunction< Long, List< R >, Q > querySupplier, String resourceServerId, Consumer< R > consumer)
 

詳解

関数詳解

◆ cacheQuery() [1/2]

private<R, Q extends ResourceQuery> List<R> org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.cacheQuery ( String  cacheKey,
Class< Q >  queryType,
Supplier< List< R >>  resultSupplier,
BiFunction< Long, List< R >, Q >  querySupplier,
String  resourceServerId 
)
inlinepackage
715  {
716  return cacheQuery(cacheKey, queryType, resultSupplier, querySupplier, resourceServerId, null);
717  }
private< R, Q extends ResourceQuery > List< R > cacheQuery(String cacheKey, Class< Q > queryType, Supplier< List< R >> resultSupplier, BiFunction< Long, List< R >, Q > querySupplier, String resourceServerId)
Definition: StoreFactoryCacheSession.java:715

◆ cacheQuery() [2/2]

private<R, Q extends ResourceQuery> List<R> org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.cacheQuery ( String  cacheKey,
Class< Q >  queryType,
Supplier< List< R >>  resultSupplier,
BiFunction< Long, List< R >, Q >  querySupplier,
String  resourceServerId,
Consumer< R >  consumer 
)
inlinepackage
719  {
720  Q query = cache.get(cacheKey, queryType);
721  if (query != null) {
722  logger.tracev("cache hit for key: {0}", cacheKey);
723  }
724  if (query == null) {
725  Long loaded = cache.getCurrentRevision(cacheKey);
726  List<R> model = resultSupplier.get();
727  if (model == null) return null;
728  if (invalidations.contains(cacheKey)) return model;
729  query = querySupplier.apply(loaded, model);
731  if (consumer != null) {
732  for (R resource : model) {
733  consumer.accept(resource);
734  }
735  }
736  return model;
737  } else if (query.isInvalid(invalidations)) {
738  List<R> result = resultSupplier.get();
739 
740  if (consumer != null) {
741  for (R resource : result) {
742  consumer.accept(resource);
743  }
744  }
745 
746  return result;
747  } else {
748  Set<String> resources = query.getResources();
749 
750  if (consumer != null) {
751  resources.stream().map(resourceId -> (R) findById(resourceId, resourceServerId)).forEach(consumer);
752  return Collections.emptyList();
753  }
754 
755  return resources.stream().map(resourceId -> (R) findById(resourceId, resourceServerId)).collect(Collectors.toList());
756  }
757  }
Long getCurrentRevision(String id)
Definition: CacheManager.java:77
Set< String > invalidations
Definition: StoreFactoryCacheSession.java:98
public< T extends Revisioned > T get(String id, Class< T > type)
Definition: CacheManager.java:94
Resource findById(String id, String resourceServerId)
Definition: StoreFactoryCacheSession.java:590
StoreFactoryCacheManager cache
Definition: StoreFactoryCacheSession.java:89
void addRevisioned(Revisioned object, long startupRevision)
Definition: CacheManager.java:132
static final Logger logger
Definition: StoreFactoryCacheSession.java:87
final long startupRevision
Definition: StoreFactoryCacheSession.java:102

◆ create() [1/2]

Resource org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.create ( String  name,
ResourceServer  resourceServer,
String  owner 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

561  {
562  return create(null, name, resourceServer, owner);
563  }
Resource create(String name, ResourceServer resourceServer, String owner)
Definition: StoreFactoryCacheSession.java:561

◆ create() [2/2]

Resource org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.create ( String  id,
String  name,
ResourceServer  resourceServer,
String  owner 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

566  {
567  Resource resource = getResourceStoreDelegate().create(id, name, resourceServer, owner);
568  Resource cached = findById(resource.getId(), resourceServer.getId());
569  registerResourceInvalidation(resource.getId(), resource.getName(), resource.getType(), resource.getUris(), resource.getScopes().stream().map(scope -> scope.getId()).collect(Collectors.toSet()), resourceServer.getId(), resource.getOwner());
570  if (cached == null) {
571  cached = findById(resource.getId(), resourceServer.getId());
572  }
573  return cached;
574  }
void registerResourceInvalidation(String id, String name, String type, Set< String > uris, Set< String > scopes, String serverId, String owner)
Definition: StoreFactoryCacheSession.java:269
Resource create(String name, ResourceServer resourceServer, String owner)
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
Resource findById(String id, String resourceServerId)
Definition: StoreFactoryCacheSession.java:590

◆ delete()

void org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.delete ( String  id)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

577  {
578  if (id == null) return;
579  Resource resource = findById(id, null);
580  if (resource == null) return;
581 
583  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()));
584  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);
586 
587  }
Set< String > invalidations
Definition: StoreFactoryCacheSession.java:98
void resourceRemoval(String id, String name, String type, Set< String > uris, String owner, Set< String > scopes, String serverId, Set< String > invalidations)
Definition: StoreFactoryCacheManager.java:106
Set< InvalidationEvent > invalidationEvents
Definition: StoreFactoryCacheSession.java:99
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
Object invalidateObject(String id)
Definition: CacheManager.java:116
Resource findById(String id, String resourceServerId)
Definition: StoreFactoryCacheSession.java:590
StoreFactoryCacheManager cache
Definition: StoreFactoryCacheSession.java:89

◆ findById()

Resource org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findById ( String  id,
String  resourceServerId 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

590  {
591  if (id == null) return null;
592  CachedResource cached = cache.get(id, CachedResource.class);
593  if (cached != null) {
594  logger.tracev("by id cache hit: {0}", cached.getId());
595  }
596  if (cached == null) {
597  Long loaded = cache.getCurrentRevision(id);
598  if (! modelMightExist(id)) return null;
599  Resource model = getResourceStoreDelegate().findById(id, resourceServerId);
600  if (model == null) {
601  setModelDoesNotExists(id, loaded);
602  return null;
603  }
604  if (invalidations.contains(id)) return model;
605  cached = new CachedResource(loaded, model);
607  } else if (invalidations.contains(id)) {
608  return getResourceStoreDelegate().findById(id, resourceServerId);
609  } else if (managedResources.containsKey(id)) {
610  return managedResources.get(id);
611  }
612  ResourceAdapter adapter = new ResourceAdapter(cached, StoreFactoryCacheSession.this);
613  managedResources.put(id, adapter);
614  return adapter;
615  }
Long getCurrentRevision(String id)
Definition: CacheManager.java:77
boolean modelMightExist(String id)
Definition: StoreFactoryCacheSession.java:410
Set< String > invalidations
Definition: StoreFactoryCacheSession.java:98
void setModelDoesNotExists(String id, Long loaded)
Definition: StoreFactoryCacheSession.java:404
Map< String, ResourceAdapter > managedResources
Definition: StoreFactoryCacheSession.java:95
public< T extends Revisioned > T get(String id, Class< T > type)
Definition: CacheManager.java:94
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
StoreFactoryCacheSession(StoreFactoryCacheManager cache, KeycloakSession session)
Definition: StoreFactoryCacheSession.java:111
Resource findById(String id, String resourceServerId)
StoreFactoryCacheManager cache
Definition: StoreFactoryCacheSession.java:89
void addRevisioned(Revisioned object, long startupRevision)
Definition: CacheManager.java:132
static final Logger logger
Definition: StoreFactoryCacheSession.java:87
final long startupRevision
Definition: StoreFactoryCacheSession.java:102

◆ findByName() [1/2]

Resource org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findByName ( String  name,
String  resourceServerId 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

618  {
619  return findByName(name, resourceServerId, resourceServerId);
620  }
Resource findByName(String name, String resourceServerId)
Definition: StoreFactoryCacheSession.java:618

◆ findByName() [2/2]

Resource org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findByName ( String  name,
String  ownerId,
String  resourceServerId 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

623  {
624  if (name == null) return null;
625  String cacheKey = getResourceByNameCacheKey(name, ownerId, resourceServerId);
626  List<Resource> result = cacheQuery(cacheKey, ResourceListQuery.class, () -> {
627  Resource resource = getResourceStoreDelegate().findByName(name, ownerId, resourceServerId);
628 
629  if (resource == null) {
630  return Collections.emptyList();
631  }
632 
633  return Arrays.asList(resource);
634  },
635  (revision, resources) -> new ResourceListQuery(revision, cacheKey, resources.stream().map(resource -> resource.getId()).collect(Collectors.toSet()), resourceServerId), resourceServerId);
636 
637  if (result.isEmpty()) {
638  return null;
639  }
640 
641  return result.get(0);
642  }
static String getResourceByNameCacheKey(String name, String ownerId, String serverId)
Definition: StoreFactoryCacheSession.java:342
private< R, Q extends ResourceQuery > List< R > cacheQuery(String cacheKey, Class< Q > queryType, Supplier< List< R >> resultSupplier, BiFunction< Long, List< R >, Q > querySupplier, String resourceServerId)
Definition: StoreFactoryCacheSession.java:715

◆ findByOwner() [1/2]

List<Resource> org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findByOwner ( String  ownerId,
String  resourceServerId 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

645  {
646  String cacheKey = getResourceByOwnerCacheKey(ownerId, resourceServerId);
647  return cacheQuery(cacheKey, ResourceListQuery.class, () -> getResourceStoreDelegate().findByOwner(ownerId, resourceServerId),
648  (revision, resources) -> new ResourceListQuery(revision, cacheKey, resources.stream().map(resource -> resource.getId()).collect(Collectors.toSet()), resourceServerId), resourceServerId);
649  }
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
private< R, Q extends ResourceQuery > List< R > cacheQuery(String cacheKey, Class< Q > queryType, Supplier< List< R >> resultSupplier, BiFunction< Long, List< R >, Q > querySupplier, String resourceServerId)
Definition: StoreFactoryCacheSession.java:715
List< Resource > findByOwner(String ownerId, String resourceServerId)
Definition: StoreFactoryCacheSession.java:645
static String getResourceByOwnerCacheKey(String owner, String serverId)
Definition: StoreFactoryCacheSession.java:346

◆ findByOwner() [2/2]

void org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findByOwner ( String  ownerId,
String  resourceServerId,
Consumer< Resource consumer 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

652  {
653  String cacheKey = getResourceByOwnerCacheKey(ownerId, resourceServerId);
654  cacheQuery(cacheKey, ResourceListQuery.class, () -> getResourceStoreDelegate().findByOwner(ownerId, resourceServerId),
655  (revision, resources) -> new ResourceListQuery(revision, cacheKey, resources.stream().map(resource -> resource.getId()).collect(Collectors.toSet()), resourceServerId), resourceServerId, consumer);
656  }
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
private< R, Q extends ResourceQuery > List< R > cacheQuery(String cacheKey, Class< Q > queryType, Supplier< List< R >> resultSupplier, BiFunction< Long, List< R >, Q > querySupplier, String resourceServerId)
Definition: StoreFactoryCacheSession.java:715
List< Resource > findByOwner(String ownerId, String resourceServerId)
Definition: StoreFactoryCacheSession.java:645
static String getResourceByOwnerCacheKey(String owner, String serverId)
Definition: StoreFactoryCacheSession.java:346

◆ findByResourceServer() [1/2]

List<Resource> org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findByResourceServer ( String  resourceServerId)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

667  {
668  return getResourceStoreDelegate().findByResourceServer(resourceServerId);
669  }
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
List< Resource > findByResourceServer(String resourceServerId)

◆ findByResourceServer() [2/2]

List<Resource> org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findByResourceServer ( Map< String, String[]>  attributes,
String  resourceServerId,
int  firstResult,
int  maxResult 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

672  {
673  return getResourceStoreDelegate().findByResourceServer(attributes, resourceServerId, firstResult, maxResult);
674  }
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
List< Resource > findByResourceServer(String resourceServerId)

◆ findByScope() [1/2]

List<Resource> org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findByScope ( List< String >  ids,
String  resourceServerId 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

677  {
678  if (ids == null) return null;
679  List<Resource> result = new ArrayList<>();
680 
681  for (String id : ids) {
682  String cacheKey = getResourceByScopeCacheKey(id, resourceServerId);
683  result.addAll(cacheQuery(cacheKey, ResourceScopeListQuery.class, () -> getResourceStoreDelegate().findByScope(Arrays.asList(id), resourceServerId), (revision, resources) -> new ResourceScopeListQuery(revision, cacheKey, id, resources.stream().map(resource -> resource.getId()).collect(Collectors.toSet()), resourceServerId), resourceServerId));
684  }
685 
686  return result;
687  }
static String getResourceByScopeCacheKey(String scopeId, String serverId)
Definition: StoreFactoryCacheSession.java:358
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
private< R, Q extends ResourceQuery > List< R > cacheQuery(String cacheKey, Class< Q > queryType, Supplier< List< R >> resultSupplier, BiFunction< Long, List< R >, Q > querySupplier, String resourceServerId)
Definition: StoreFactoryCacheSession.java:715
List< Resource > findByScope(List< String > ids, String resourceServerId)
Definition: StoreFactoryCacheSession.java:677

◆ findByScope() [2/2]

void org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findByScope ( List< String >  ids,
String  resourceServerId,
Consumer< Resource consumer 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

690  {
691  if (ids == null) return;
692 
693  for (String id : ids) {
694  String cacheKey = getResourceByScopeCacheKey(id, resourceServerId);
695  cacheQuery(cacheKey, ResourceScopeListQuery.class, () -> getResourceStoreDelegate().findByScope(Arrays.asList(id), resourceServerId), (revision, resources) -> new ResourceScopeListQuery(revision, cacheKey, id, resources.stream().map(resource -> resource.getId()).collect(Collectors.toSet()), resourceServerId), resourceServerId, consumer);
696  }
697  }
static String getResourceByScopeCacheKey(String scopeId, String serverId)
Definition: StoreFactoryCacheSession.java:358
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
private< R, Q extends ResourceQuery > List< R > cacheQuery(String cacheKey, Class< Q > queryType, Supplier< List< R >> resultSupplier, BiFunction< Long, List< R >, Q > querySupplier, String resourceServerId)
Definition: StoreFactoryCacheSession.java:715
List< Resource > findByScope(List< String > ids, String resourceServerId)
Definition: StoreFactoryCacheSession.java:677

◆ findByType() [1/2]

List<Resource> org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findByType ( String  type,
String  resourceServerId 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

700  {
701  if (type == null) return Collections.emptyList();
702  String cacheKey = getResourceByTypeCacheKey(type, resourceServerId);
703  return cacheQuery(cacheKey, ResourceListQuery.class, () -> getResourceStoreDelegate().findByType(type, resourceServerId),
704  (revision, resources) -> new ResourceListQuery(revision, cacheKey, resources.stream().map(resource -> resource.getId()).collect(Collectors.toSet()), resourceServerId), resourceServerId);
705  }
static String getResourceByTypeCacheKey(String type, String serverId)
Definition: StoreFactoryCacheSession.java:350
List< Resource > findByType(String type, String resourceServerId)
Definition: StoreFactoryCacheSession.java:700
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
private< R, Q extends ResourceQuery > List< R > cacheQuery(String cacheKey, Class< Q > queryType, Supplier< List< R >> resultSupplier, BiFunction< Long, List< R >, Q > querySupplier, String resourceServerId)
Definition: StoreFactoryCacheSession.java:715

◆ findByType() [2/2]

void org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findByType ( String  type,
String  resourceServerId,
Consumer< Resource consumer 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

708  {
709  if (type == null) return;
710  String cacheKey = getResourceByTypeCacheKey(type, resourceServerId);
711  cacheQuery(cacheKey, ResourceListQuery.class, () -> getResourceStoreDelegate().findByType(type, resourceServerId),
712  (revision, resources) -> new ResourceListQuery(revision, cacheKey, resources.stream().map(resource -> resource.getId()).collect(Collectors.toSet()), resourceServerId), resourceServerId, consumer);
713  }
static String getResourceByTypeCacheKey(String type, String serverId)
Definition: StoreFactoryCacheSession.java:350
List< Resource > findByType(String type, String resourceServerId)
Definition: StoreFactoryCacheSession.java:700
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
private< R, Q extends ResourceQuery > List< R > cacheQuery(String cacheKey, Class< Q > queryType, Supplier< List< R >> resultSupplier, BiFunction< Long, List< R >, Q > querySupplier, String resourceServerId)
Definition: StoreFactoryCacheSession.java:715

◆ findByUri()

List<Resource> org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession.ResourceCache.findByUri ( String  uri,
String  resourceServerId 
)
inline

org.keycloak.authorization.store.ResourceStoreを実装しています。

659  {
660  if (uri == null) return null;
661  String cacheKey = getResourceByUriCacheKey(uri, resourceServerId);
662  return cacheQuery(cacheKey, ResourceListQuery.class, () -> getResourceStoreDelegate().findByUri(uri, resourceServerId),
663  (revision, resources) -> new ResourceListQuery(revision, cacheKey, resources.stream().map(resource -> resource.getId()).collect(Collectors.toSet()), resourceServerId), resourceServerId);
664  }
ResourceStore getResourceStoreDelegate()
Definition: StoreFactoryCacheSession.java:322
private< R, Q extends ResourceQuery > List< R > cacheQuery(String cacheKey, Class< Q > queryType, Supplier< List< R >> resultSupplier, BiFunction< Long, List< R >, Q > querySupplier, String resourceServerId)
Definition: StoreFactoryCacheSession.java:715
static String getResourceByUriCacheKey(String uri, String serverId)
Definition: StoreFactoryCacheSession.java:354
List< Resource > findByUri(String uri, String resourceServerId)
Definition: StoreFactoryCacheSession.java:659

このクラス詳解は次のファイルから抽出されました: