use of com.sun.identity.common.CaseInsensitiveHashMap in project OpenAM by OpenRock.
the class AMIdentity method getAttributes.
/**
* Returns requested attributes and values of this object.
*
* This method is only valid for AMIdentity object of type User, Agent,
* Group, and Role.
*
* @param attrNames
* Set of attribute names to be read
* @return Map of attribute-values.
* @throws IdRepoException
* If there are repository related error conditions.
* @throws SSOException
* If user's single sign on token is invalid.
* @supported.api
*/
public Map getAttributes(Set attrNames) throws IdRepoException, SSOException {
IdServices idServices = IdServicesFactory.getDataStoreServices();
Map attrs = idServices.getAttributes(token, type, name, attrNames, orgName, univDN, true);
CaseInsensitiveHashMap caseAttrs = new CaseInsensitiveHashMap(attrs);
CaseInsensitiveHashMap resultMap = new CaseInsensitiveHashMap();
Iterator it = attrNames.iterator();
while (it.hasNext()) {
String attrName = (String) it.next();
if (caseAttrs.containsKey(attrName)) {
resultMap.put(attrName, caseAttrs.get(attrName));
}
}
if (debug.messageEnabled()) {
debug.message("AMIdentity.getAttributes 6: attrNames=" + attrNames + "; resultMap=" + resultMap + "; attrs=" + attrs);
}
return resultMap;
}
use of com.sun.identity.common.CaseInsensitiveHashMap in project OpenAM by OpenRock.
the class DatabaseRepo method getAttributes.
/*
* Returns just --requested-- attributes and values of name object.
* Allows user to provide a set of attributes that should be returned,
* and this set of attributes to retrieve is provided in parameter
* Set attrNames.
*
* @see com.sun.identity.idm.IdRepo#getAttributes(com.iplanet.sso.SSOToken,
* com.sun.identity.idm.IdType, java.lang.String, java.util.Set)
*/
public Map getAttributes(SSOToken token, IdType type, String name, Set attrNames) throws IdRepoException, SSOException {
if (initializationException != null) {
debug.error("DatabaseRepo.getAttributes: throwing initialization exception");
throw (initializationException);
}
if (debug.messageEnabled()) {
debug.message("DatabaseRepo.getAttributes called with: " + " token=" + token + " type=" + type + " name=" + name + "\n\treturn attributes=" + attrNames);
}
//throw exception if this type user not allowed to do this
isValidType(type, "getAttributes");
// Get all the attributes and return the subset
//Map answer = (attrNames == null) ? null : new HashMap();
Map answer = (attrNames == null) ? null : new CaseInsensitiveHashMap();
//get all attributes and their corresponding values Sets
Map map = getAttributes(token, type, name);
if (attrNames == null) {
answer = map;
} else {
//paramater Set attrNames,
for (Iterator items = attrNames.iterator(); items.hasNext(); ) {
Object key = items.next();
Object value = map.get(key);
if (value != null) {
answer.put(key, value);
}
}
}
return (answer);
}
use of com.sun.identity.common.CaseInsensitiveHashMap in project OpenAM by OpenRock.
the class DatabaseRepo method getAttributes.
/*
* Returns --all-- attributes and values of name object
* so whole row of DB table for this user for example
*
* I think it makes a map where map contains the attribute/column name as
* a String key and a Set as the value where Set can be the String values
* for that attribute. Does the case matter????
* Should the values to a CaseSenstiveHashMap ???? or all lowercase?
* should keys be lowercase ???
* What should I put in the case of when an attribute has no values???
*
* @see com.sun.identity.idm.IdRepo#getAttributes(com.iplanet.sso.SSOToken,
* com.sun.identity.idm.IdType, java.lang.String)
*/
public Map getAttributes(SSOToken token, IdType type, String name) throws IdRepoException, SSOException {
if (initializationException != null) {
debug.error("DatabaseRepo.getAttributes: throwing" + " initialization exception");
throw (initializationException);
}
if (debug.messageEnabled()) {
debug.message("DatabaseRepo.getAttributes: get all attrs called: " + " token=" + token + " type=" + type.getName() + " name=" + name);
}
//throw exception if this type user not allowed to do this
isValidType(type, "getAttributes");
Map users = Collections.EMPTY_MAP;
if (type.equals(IdType.USER)) {
users = dao.getAttributes(name, userIDAttributeName, userAtttributesAllowed);
} else if (type.equals(IdType.GROUP)) {
//RFE: consider making the groups allowed to be fetched set a
//config option in UI as with userAtttributesAllowed
Set<String> groupAttrsAllowed = new HashSet<String>();
groupAttrsAllowed.add(membershipIdAttributeName);
users = dao.getGroupAttributes(name, membershipIdAttributeName, groupAttrsAllowed);
}
//not sure this is how case insensitive map works???
//are keys insensitive or set of values or ????
Map answer = new CaseInsensitiveHashMap(users);
return answer;
}
use of com.sun.identity.common.CaseInsensitiveHashMap in project OpenAM by OpenRock.
the class AMIdentityRepository method combineSearchResults.
private IdSearchResults combineSearchResults(SSOToken token, Object[][] arrayOfResult, int sizeOfArray, IdType type, String orgName, boolean amsdkIncluded, Object[][] amsdkResults) {
Map amsdkDNs = new CaseInsensitiveHashMap();
Map resultsMap = new CaseInsensitiveHashMap();
int errorCode = IdSearchResults.SUCCESS;
if (amsdkIncluded) {
RepoSearchResults amsdkRepoRes = (RepoSearchResults) amsdkResults[0][0];
Set results = amsdkRepoRes.getSearchResults();
Map attrResults = amsdkRepoRes.getResultAttributes();
for (String dn : (Set<String>) results) {
String name = LDAPUtils.rdnValueFromDn(dn);
amsdkDNs.put(name, dn);
Set attrMaps = new HashSet();
attrMaps.add((Map) attrResults.get(dn));
resultsMap.put(name, attrMaps);
}
errorCode = amsdkRepoRes.getErrorCode();
}
for (int i = 0; i < sizeOfArray; i++) {
RepoSearchResults current = (RepoSearchResults) arrayOfResult[i][0];
Map configMap = (Map) arrayOfResult[i][1];
Map allAttrMaps = current.getResultAttributes();
for (String m : (Set<String>) current.getSearchResults()) {
String mname = DNUtils.DNtoName(m);
Map attrMap = (Map) allAttrMaps.get(m);
attrMap = reverseMapAttributeNames(attrMap, configMap);
Set attrMaps = (Set) resultsMap.get(mname);
if (attrMaps == null) {
attrMaps = new HashSet();
}
attrMaps.add(attrMap);
resultsMap.put(mname, attrMaps);
}
}
IdSearchResults results = new IdSearchResults(type, orgName);
for (String mname : (Set<String>) resultsMap.keySet()) {
Map combinedMap = combineAttrMaps((Set) resultsMap.get(mname), true);
AMIdentity id = new AMIdentity(token, mname, type, orgName, (String) amsdkDNs.get(mname));
results.addResult(id, combinedMap);
}
results.setErrorCode(errorCode);
return results;
}
use of com.sun.identity.common.CaseInsensitiveHashMap in project OpenAM by OpenRock.
the class DJLDAPv3Repo method isActive.
/**
* Tells whether the given identity is considered as "active" or not. In case the user status attribute is not
* configured, this method will always return <code>true</code>. In case of Active Directory the returned
* userAccountControl attribute will be masked with 0x2 to detect whether the given account is disabled or not.
*
* @param token Not used.
* @param type The type of the identity, this should be always USER.
* @param name The name of the identity.
* @return <code>true</code> if user status attribute is not configured, or decision based on the status
* attribute value. If there was any error while retrieving the status attribute this method will return
* <code>false</code>.
* @throws IdRepoException If the identity type is invalid.
*/
@Override
public boolean isActive(SSOToken token, IdType type, String name) throws IdRepoException {
if (DEBUG.messageEnabled()) {
DEBUG.message("isActive invoked");
}
if (!type.equals(IdType.USER)) {
throw new IdRepoUnsupportedOpException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.PLUGIN_OPERATION_NOT_SUPPORTED, new Object[] { CLASS_NAME, IdOperation.READ.getName(), type.getName() });
}
if (alwaysActive) {
try {
return isExists(token, type, name);
} catch (IdRepoException ide) {
return false;
}
}
Map<String, Set<String>> attrMap;
try {
attrMap = getAttributes(token, type, name, asSet(userStatusAttr));
attrMap = new CaseInsensitiveHashMap(attrMap);
} catch (IdRepoException ire) {
return false;
}
String status = CollectionHelper.getMapAttr(attrMap, userStatusAttr);
if (status != null) {
return helper.isActive(status, inactiveValue);
} else {
return true;
}
}
Aggregations