use of com.iplanet.am.sdk.AMHashMap in project OpenAM by OpenRock.
the class RemoteServicesImpl method getAttributes.
public Map getAttributes(SSOToken token, String entryDN, Set attrNames, int profileType) throws AMException, SSOException {
try {
String tokenID = token.getTokenID().toString();
Object[] objs = { tokenID, entryDN, attrNames, new Integer(profileType) };
Map map = (Map) client.send(client.encodeMessage("getAttributes2", objs), sessionCookies.getLBCookie(tokenID), null);
AMHashMap res = new AMHashMap();
res.copy(map);
return res;
} catch (AMRemoteException amrex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getAttributes 2: entryDN=" + entryDN + "; AMRemoteException caught exception=", amrex);
}
throw convertException(amrex);
} catch (RemoteException rex) {
getDebug().error("RemoteServicesImpl.getAttributes: caught exception=", rex);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
} catch (SSOException ssoe) {
getDebug().error("RemoteServicesImpl.getAttributes: caught SSOException=", ssoe);
throw ssoe;
} catch (Exception ex) {
if (getDebug().messageEnabled()) {
getDebug().message("RemoteServicesImpl.getAttributes2: entryDN=" + entryDN + "; caught exception=", ex);
}
throw new AMException(AMSDKBundle.getString("1000"), "1000");
}
}
use of com.iplanet.am.sdk.AMHashMap in project OpenAM by OpenRock.
the class IdCachedServicesImpl method getAttributes.
public Map getAttributes(SSOToken token, IdType type, String name, Set attrNames, String amOrgName, String amsdkDN, boolean isStringValues) throws IdRepoException, SSOException {
if ((attrNames == null) || attrNames.isEmpty()) {
return getAttributes(token, type, name, amOrgName, amsdkDN);
}
cacheStats.incrementGetRequestCount(getSize());
if (MonitoringUtil.isRunning() && ((monIdRepo = Agent.getIdrepoSvcMBean()) != null)) {
long li = (long) getSize();
monIdRepo.incGetRqts(li);
}
// Get the entry 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 = IdUtils.getUniversalId(tokenId);
// Debug messages
if (DEBUG.messageEnabled()) {
DEBUG.message("In IdCachedServicesImpl." + "getAttributes(SSOToken, type, name, attrNames, " + "amOrgName, amsdkDN) (" + principalDN + ", " + dn + ", " + attrNames + " ," + amOrgName + " , " + amsdkDN + " method.");
}
// Attributes to be returned
AMHashMap attributes;
// Check in the cache
IdCacheBlock cb = (IdCacheBlock) idRepoCache.get(dn);
if (cb == null) {
// Entry not present in cache
if (DEBUG.messageEnabled()) {
DEBUG.message("IdCachedServicesImpl.getAttributes(): " + "NO entry found in Cachefor key = " + dn + ". Getting all these attributes from DS: " + attrNames);
}
// If the attributes returned here have an empty set as value, then
// such attributes do not have a value or invalid attributes.
// Internally keep track of these attributes.
attributes = (AMHashMap) super.getAttributes(token, type, name, attrNames, amOrgName, amsdkDN, isStringValues);
// Find the missing attributes and add to cache
Set missAttrNames = attributes.getMissingAndEmptyKeys(attrNames);
cb = new IdCacheBlock(dn, true);
cb.putAttributes(principalDN, attributes, missAttrNames, false, !isStringValues);
idRepoCache.put(dn, cb);
} else {
// Entry present in cache
attributes = (AMHashMap) cb.getAttributes(principalDN, attrNames, !isStringValues);
// Find the missing attributes that need to be obtained from DS
// Only find the missing keys as the ones with empty sets are not
// found in DS
Set missAttrNames = attributes.getMissingKeys(attrNames);
if (!missAttrNames.isEmpty()) {
if (DEBUG.messageEnabled()) {
DEBUG.message("IdCachedServicesImpl." + "getAttributes(): Trying to gett these missing " + "attributes from DS: " + missAttrNames);
}
AMHashMap dsAttributes = (AMHashMap) super.getAttributes(token, type, name, attrNames, amOrgName, amsdkDN, isStringValues);
attributes.putAll(dsAttributes);
// Add these attributes, may be found in DS or just mark them
// as invalid (Attribute level Negative caching)
Set newMissAttrNames = dsAttributes.getMissingAndEmptyKeys(missAttrNames);
cb.putAttributes(principalDN, dsAttributes, newMissAttrNames, false, !isStringValues);
} else {
// All attributes found in cache
cacheStats.updateGetHitCount(getSize());
if (MonitoringUtil.isRunning() && ((monIdRepo = Agent.getIdrepoSvcMBean()) != null)) {
long li = (long) getSize();
monIdRepo.incCacheHits(li);
}
if (DEBUG.messageEnabled()) {
DEBUG.message("IdCachedServicesImpl" + ".getAttributes(): " + amsdkDN + " found all attributes in Cache.");
}
}
}
return attributes;
}
use of com.iplanet.am.sdk.AMHashMap in project OpenAM by OpenRock.
the class IdCachedServicesImpl method getAttributes.
public Map getAttributes(SSOToken token, IdType type, String name, String amOrgName, String amsdkDN) throws IdRepoException, SSOException {
cacheStats.incrementGetRequestCount(getSize());
if (MonitoringUtil.isRunning() && ((monIdRepo = Agent.getIdrepoSvcMBean()) != null)) {
long li = (long) getSize();
monIdRepo.incGetRqts(li);
}
// Get the 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 = IdUtils.getUniversalId(tokenId);
// Get the cache entry
IdCacheBlock cb = (IdCacheBlock) idRepoCache.get(dn);
AMHashMap attributes;
if ((cb != null) && cb.hasCompleteSet(principalDN)) {
cacheStats.updateGetHitCount(getSize());
if (MonitoringUtil.isRunning() && ((monIdRepo = Agent.getIdrepoSvcMBean()) != null)) {
long li = (long) getSize();
monIdRepo.incCacheHits(li);
}
if (DEBUG.messageEnabled()) {
DEBUG.message("IdCachedServicesImpl." + "getAttributes(): DN: " + dn + " found all attributes in Cache.");
}
attributes = (AMHashMap) cb.getAttributes(principalDN, false);
} else {
// Get all the attributes from data store
if (DEBUG.messageEnabled()) {
DEBUG.message("IdCachedServicesImpl." + "getAttributes(): " + dn + " 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("IdCachedServicesImpl.getAttributes(): " + "attributes NOT found in cache. Fetched from DS.");
}
}
return attributes;
}
use of com.iplanet.am.sdk.AMHashMap in project OpenAM by OpenRock.
the class IdRemoteServicesImpl method getAttributes.
public Map getAttributes(SSOToken token, IdType type, String name, String amOrgName, String amsdkDN) throws IdRepoException, SSOException {
Map res = null;
try {
Object[] objs = { getTokenString(token), type.getName(), name, amOrgName, amsdkDN };
res = ((Map) client.send(client.encodeMessage("getAttributes2_idrepo", objs), sessionCookies.getLBCookie(token.getTokenID().toString()), null));
if (res != null) {
Map res2 = new AMHashMap();
Iterator it = res.keySet().iterator();
while (it.hasNext()) {
Object attr = it.next();
Set set = (Set) res.get(attr);
set = XMLUtils.decodeAttributeSet(set);
res2.put(attr, set);
}
res = res2;
}
} catch (Exception ex) {
processException(ex);
}
return res;
}
use of com.iplanet.am.sdk.AMHashMap 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