Search in sources :

Example 21 with AMHashMap

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");
    }
}
Also used : AMHashMap(com.iplanet.am.sdk.AMHashMap) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException) RemoteException(java.rmi.RemoteException) AMHashMap(com.iplanet.am.sdk.AMHashMap) Map(java.util.Map) AMEntryExistsException(com.iplanet.am.sdk.AMEntryExistsException) AMEventManagerException(com.iplanet.am.sdk.AMEventManagerException) RemoteException(java.rmi.RemoteException) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException)

Example 22 with AMHashMap

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;
}
Also used : Set(java.util.Set) AMHashMap(com.iplanet.am.sdk.AMHashMap) AMIdentity(com.sun.identity.idm.AMIdentity) IdCacheBlock(com.sun.identity.idm.common.IdCacheBlock)

Example 23 with AMHashMap

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;
}
Also used : AMHashMap(com.iplanet.am.sdk.AMHashMap) AMIdentity(com.sun.identity.idm.AMIdentity) IdCacheBlock(com.sun.identity.idm.common.IdCacheBlock)

Example 24 with AMHashMap

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;
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) Set(java.util.Set) AMHashMap(com.iplanet.am.sdk.AMHashMap) Iterator(java.util.Iterator) SMSJAXRPCObject(com.sun.identity.sm.jaxrpc.SMSJAXRPCObject) AMHashMap(com.iplanet.am.sdk.AMHashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map) IdRepoException(com.sun.identity.idm.IdRepoException) SMSException(com.sun.identity.sm.SMSException) RemoteException(java.rmi.RemoteException) SSOException(com.iplanet.sso.SSOException)

Example 25 with AMHashMap

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;
}
Also used : AMHashMap(com.iplanet.am.sdk.AMHashMap) AMIdentity(com.sun.identity.idm.AMIdentity) IdCacheBlock(com.sun.identity.idm.common.IdCacheBlock)

Aggregations

AMHashMap (com.iplanet.am.sdk.AMHashMap)26 Map (java.util.Map)16 Set (java.util.Set)10 HashSet (java.util.HashSet)9 AMException (com.iplanet.am.sdk.AMException)6 SSOException (com.iplanet.sso.SSOException)6 HashMap (java.util.HashMap)6 RemoteException (java.rmi.RemoteException)5 Iterator (java.util.Iterator)5 AMEntryExistsException (com.iplanet.am.sdk.AMEntryExistsException)4 AMEventManagerException (com.iplanet.am.sdk.AMEventManagerException)4 CacheBlock (com.iplanet.am.sdk.common.CacheBlock)4 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)4 AMIdentity (com.sun.identity.idm.AMIdentity)4 IdCacheBlock (com.sun.identity.idm.common.IdCacheBlock)4 Attr (com.iplanet.services.ldap.Attr)3 CaseInsensitiveHashSet (com.sun.identity.common.CaseInsensitiveHashSet)3 IdRepoException (com.sun.identity.idm.IdRepoException)3 AttrSet (com.iplanet.services.ldap.AttrSet)2 Guid (com.iplanet.ums.Guid)2