use of com.sun.identity.idm.common.IdCacheBlock in project OpenAM by OpenRock.
the class IdRemoteCachedServicesImpl method isExists.
// @Override
public boolean isExists(SSOToken token, IdType type, String name, String amOrgName) throws SSOException, IdRepoException {
AMIdentity id = new AMIdentity(token, name, type, amOrgName, null);
String dn = id.getUniversalId().toLowerCase();
IdCacheBlock cb = (IdCacheBlock) idRepoCache.get(dn);
if (cb == null) {
// Entry not present in cache
if (DEBUG.messageEnabled()) {
DEBUG.message("IdRemoteCachedServicesImpl." + "isExist(): NO entry found in Cachefor key = " + dn);
}
return super.isExists(token, type, name, amOrgName);
}
// Get the principal DN
AMIdentity tokenId = IdUtils.getIdentity(token);
String principalDN = tokenId.getUniversalId();
if (cb.hasCache(principalDN)) {
return true;
} else {
return super.isExists(token, type, name, amOrgName);
}
}
use of com.sun.identity.idm.common.IdCacheBlock in project OpenAM by OpenRock.
the class IdRemoteCachedServicesImpl method removeCachedAttributes.
// *************************************************************************
// Update/Dirty methods of this class.
// *************************************************************************
private void removeCachedAttributes(String affectDNs, Set attrNames) {
Enumeration cacheKeys = idRepoCache.keys();
while (cacheKeys.hasMoreElements()) {
String key = (String) cacheKeys.nextElement();
int l1 = key.length();
int l2 = affectDNs.length();
if (key.regionMatches(true, (l1 - l2), affectDNs, 0, l2)) {
// key ends with 'affectDN' string
IdCacheBlock cb = (IdCacheBlock) idRepoCache.get(key);
if (cb != null) {
// key ends with 'affectDN' string
if ((attrNames != null) && !cb.hasExpiredAndUpdated() && cb.isExists()) {
cb.removeAttributes(attrNames);
} else {
cb.clear();
}
}
}
}
}
use of com.sun.identity.idm.common.IdCacheBlock in project OpenAM by OpenRock.
the class IdRemoteCachedServicesImpl method getAttributes.
// @Override
public Map getAttributes(SSOToken token, IdType type, String name, String amOrgName, String amsdkDN) throws IdRepoException, SSOException {
cacheStats.incrementGetRequestCount(getSize());
if (SystemProperties.isServerMode() && MonitoringUtil.isRunning() && ((monIdRepo = Agent.getIdrepoSvcMBean()) != null)) {
long li = (long) getSize();
monIdRepo.incGetRqts(li);
}
// Get identity DN
AMIdentity id = new AMIdentity(token, name, type, amOrgName, amsdkDN);
String dn = id.getUniversalId().toLowerCase();
// Get the principal DN
AMIdentity tokenId = IdUtils.getIdentity(token);
String principalDN = tokenId.getUniversalId();
IdCacheBlock cb = (IdCacheBlock) idRepoCache.get(dn);
AMHashMap attributes;
if ((cb != null) && cb.hasCompleteSet(principalDN)) {
cacheStats.updateGetHitCount(getSize());
if (SystemProperties.isServerMode() && MonitoringUtil.isRunning() && ((monIdRepo = Agent.getIdrepoSvcMBean()) != null)) {
long li = (long) getSize();
monIdRepo.incCacheHits(li);
}
if (DEBUG.messageEnabled()) {
DEBUG.message("IdRemoteCachedServicesImpl." + "getAttributes(): found all attributes in " + "Cache.");
}
attributes = (AMHashMap) cb.getAttributes(principalDN, false);
} else {
// Get the whole set from DS and store it;
if (DEBUG.messageEnabled()) {
DEBUG.message("IdRemoteCachedServicesImpl." + "getAttributes(): complete attribute set NOT " + "found in cache. Getting from DS.");
}
attributes = (AMHashMap) super.getAttributes(token, type, name, amOrgName, amsdkDN);
if (cb == null) {
cb = new IdCacheBlock(dn, true);
idRepoCache.put(dn, cb);
}
cb.putAttributes(principalDN, attributes, null, true, false);
if (DEBUG.messageEnabled()) {
DEBUG.message("IdRemoteCachedServicesImpl." + "getAttributes(): attributes NOT found in cache. " + "Fetched from DS.");
}
}
return attributes;
}
Aggregations