Skip to content

Commit

Permalink
IdCachedServicesImpl implement getAssignedServices (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
vharseko authored Jan 19, 2024
1 parent c5d7fc8 commit b160703
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ private void initializeCache() {
idCacheServiceAttributes= CacheBuilder.newBuilder().maximumSize(maxSize).expireAfterWrite(SystemProperties.getAsInt("org.openidentityplatform.com.iplanet.am.sdk.service.cache.maxTime", 300), TimeUnit.SECONDS).build();
idRepoMembers = CacheBuilder.newBuilder().maximumSize(maxSize).expireAfterWrite(SystemProperties.getAsInt("org.openidentityplatform.com.iplanet.am.sdk.cache.maxTime", 10), TimeUnit.SECONDS).build();
idRepoMemberships = CacheBuilder.newBuilder().maximumSize(maxSize).expireAfterWrite(SystemProperties.getAsInt("org.openidentityplatform.com.iplanet.am.sdk.cache.maxTime", 10), TimeUnit.SECONDS).build();
idCacheAssignedServices = CacheBuilder.newBuilder().maximumSize(maxSize).expireAfterWrite(SystemProperties.getAsInt("org.openidentityplatform.com.iplanet.am.sdk.cache.maxTime", 300), TimeUnit.SECONDS).build();

}

private void resetCache(int maxCacheSize) {
Expand Down Expand Up @@ -242,6 +244,7 @@ public synchronized void clearCache() {
idCacheServiceAttributes.invalidateAll();
idRepoMembers.invalidateAll();
idRepoMemberships.invalidateAll();
idCacheAssignedServices.invalidateAll();
initializeCache();
}

Expand Down Expand Up @@ -547,6 +550,26 @@ public void modifyService(SSOToken token, IdType type, String name, String servi
idCacheServiceAttributes.invalidate(cacheKey);
}

Cache<String,Set<String>> idCacheAssignedServices;

@Override
public Set<String> getAssignedServices(SSOToken token, IdType type, String name, Map mapOfServiceNamesAndOCs,String amOrgName, String amsdkDN) throws IdRepoException, SSOException {
final String key=(new AMIdentity(token, name, type, amOrgName, amsdkDN).getUniversalId());
Set<String> res=idCacheAssignedServices.getIfPresent(key);
if (res==null) {
res=super.getAssignedServices(token, type, name, mapOfServiceNamesAndOCs, amOrgName, amsdkDN);
idCacheAssignedServices.put(key, res==null?Collections.emptySet():res);
}
return res;
}

@Override
public void assignService(SSOToken token, IdType type, String name, String serviceName, SchemaType stype,Map attrMap, String amOrgName, String amsdkDN) throws IdRepoException, SSOException {
final String key=(new AMIdentity(token, name, type, amOrgName, amsdkDN).getUniversalId());
super.assignService(token, type, name, serviceName, stype, attrMap, amOrgName, amsdkDN);
idCacheAssignedServices.invalidate(key);
}

@Override
public boolean isExists(SSOToken token, IdType type, String name, String amOrgName) throws SSOException, IdRepoException {
final String key=new AMIdentity(token, name, type, amOrgName, null).getUniversalId().toLowerCase();
Expand All @@ -569,6 +592,7 @@ public boolean isActive(SSOToken token, IdType type, String name, String amOrgNa
return res;
}


public Map getAttributes(SSOToken token, IdType type, String name,
String amOrgName, String amsdkDN)
throws IdRepoException, SSOException {
Expand Down

0 comments on commit b160703

Please sign in to comment.