use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class PersistentObject method getAttributes.
/**
* Gets attribute values
*
* @param attrs
* Array of strings representing attribute names
* @param cacheOnly
* if true, read attributes from cache only without contacting
* data stroe
* @return attribute value set for the return values
* @see #getAttribute(String)
*
* @supported.api
*/
public AttrSet getAttributes(String[] attrs, boolean cacheOnly) throws UMSException {
if (attrs == null) {
throw new IllegalArgumentException(i18n.getString(IUMSConstants.BAD_ATTRNAMES));
}
AttrSet attrSet = new AttrSet();
if (!cacheOnly) {
Collection attributesNotInCache = findAttributesNotRead(attrs);
if ((!attributesNotInCache.isEmpty()) && (getGuid() != null) && (getPrincipal() != null)) {
readAttributesFromDataStore(attributesNotInCache);
}
}
int length = attrs.length;
for (int i = 0; i < length; i++) {
Attr attr = getAttributeFromCache(attrs[i]);
if (attr != null) {
attrSet.add(attr);
}
}
return attrSet;
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class AMCommonUtils method mapToAttrSet.
/**
* Method to convert a Map to AttrSet.
*
* @param map
* a map contaning attribute names as keys and a Set of attribute
* values corresponding to each map key.
* @param byteValues
* if true then values are bytes otherwise strings
* @return an AttrSet having the contents of the supplied map
*/
protected static AttrSet mapToAttrSet(Map map, boolean byteValues) {
AttrSet attrSet = new AttrSet();
if (map == null) {
return attrSet;
}
if (!byteValues) {
Iterator itr = map.keySet().iterator();
while (itr.hasNext()) {
String attrName = (String) (itr.next());
Set set = (Set) (map.get(attrName));
String[] attrValues = (set == null ? null : (String[]) set.toArray(new String[set.size()]));
attrSet.replace(new Attr(attrName, attrValues));
}
} else {
Iterator itr = map.keySet().iterator();
while (itr.hasNext()) {
String attrName = (String) (itr.next());
byte[][] attrValues = (byte[][]) (map.get(attrName));
attrSet.replace(new Attr(attrName, attrValues));
}
}
return attrSet;
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class DirectoryServicesImpl method createAssignDynamicGroup.
private void createAssignDynamicGroup(SSOToken token, PersistentObject parentObj, Map attributes, String profileName) throws UMSException, AMException {
// Invoke the Pre Processing plugin
String orgDN = getOrganizationDN(internalToken, parentObj.getDN());
String entryDN = getNamingAttribute(AMObject.GROUP) + "=" + profileName + "," + parentObj.getDN();
attributes = callBackHelper.preProcess(token, entryDN, orgDN, null, attributes, CallBackHelper.CREATE, AMObject.ASSIGNABLE_DYNAMIC_GROUP, false);
AttrSet attrSet = CommonUtils.mapToAttrSet(attributes);
makeNamingFirst(attrSet, getNamingAttribute(AMObject.ASSIGNABLE_DYNAMIC_GROUP), profileName);
TemplateManager tempMgr = TemplateManager.getTemplateManager();
CreationTemplate creationTemp = tempMgr.getCreationTemplate("BasicAssignableDynamicGroup", new Guid(orgDN), TemplateManager.SCOPE_ANCESTORS);
attrSet = combineOCs(creationTemp, attrSet);
AssignableDynamicGroup adgroup = new AssignableDynamicGroup(creationTemp, attrSet);
adgroup.setSearchFilter("(memberof=" + entryDN + ")");
adgroup.setSearchScope(SearchScope.WHOLE_SUBTREE.intValue());
adgroup.setSearchBase(new Guid(orgDN));
parentObj.addChild(adgroup);
// Invoke Post processing impls
callBackHelper.postProcess(token, adgroup.getDN(), orgDN, null, attributes, CallBackHelper.CREATE, AMObject.ASSIGNABLE_DYNAMIC_GROUP, false);
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class ConfigManagerUMS method updateCache.
/**
* CACHE MANAGEMENT for entity and template components.
*
* @param org A string identifier for the cache.
* @throws ConfigManagerException
* The default components would be loaded through an XML
* schema/configuration file <code>ConfigManager</code> has to
* get the components and the related attributes from the directory
* Server initially to store them in the cache by calling the SMS
* API.
*/
void updateCache(String org) throws ConfigManagerException {
Set eNames = new HashSet();
Set sNames = new HashSet();
Set cNames = new HashSet();
// If org = "" (base level), then add OBJECTRESOLVER ATTRSET TO CACHE
if (org.equals(_rootDN)) {
Set oSet = new HashSet();
oSet.add(OBJECTRESOLVERPATH);
loadCache(org, oSet, OBJECTRESOLVER);
}
try {
eNames = getServiceComponents(org, ENTITYPATH, true);
} catch (SMSException smse) {
// cache will just return NULL
if (_debug.warningEnabled())
_debug.warning("ConfigManager->updateCache: SMSException: " + smse.toString());
} catch (SSOException ssoe) {
// cache will just return NULL
if (_debug.warningEnabled())
_debug.warning("ConfigManager->updateCache: SSOException: " + ssoe.toString());
}
try {
sNames = getServiceComponents(org, SEARCHPATH, true);
} catch (SMSException smse) {
// cache will just return NULL
if (_debug.warningEnabled())
_debug.warning("ConfigManager->updateCache: SMSException: " + smse.toString());
} catch (SSOException ssoe) {
// cache will just return NULL
if (_debug.warningEnabled())
_debug.warning("ConfigManager->updateCache: SSOException: " + ssoe.toString());
}
try {
cNames = getServiceComponents(org, CREATIONPATH, true);
} catch (SMSException smse) {
// cache will just return NULL
if (_debug.warningEnabled())
_debug.warning("ConfigManager->updateCache: SMSException: " + smse.toString());
} catch (SSOException ssoe) {
// cache will just return NULL
if (_debug.warningEnabled())
_debug.warning("ConfigManager->updateCache: SSOException: " + ssoe.toString());
}
if (cNames.isEmpty() && eNames.isEmpty() && sNames.isEmpty()) {
_checkListCache.put(org.toLowerCase(), "dummy");
return;
}
// This is a search for searchTemplateNames only.
if (!sNames.isEmpty()) {
Iterator it = sNames.iterator();
Set set = new HashSet();
while (it.hasNext()) {
String s = new String();
String t;
t = (String) it.next();
int count = t.lastIndexOf("/");
s = t.substring(count + 1);
set.add(s);
}
_cch.put(org + "/" + SEARCH + "Names", set);
if (_debug.messageEnabled())
_debug.message("ConfigManager->updateCache: " + org + "/" + SEARCH + "Names :" + set);
}
// This is a search for creationTemplateNames only.
if (!cNames.isEmpty()) {
Iterator it = cNames.iterator();
Set set = new HashSet();
while (it.hasNext()) {
String s = new String();
String t;
t = (String) it.next();
int count = t.lastIndexOf("/");
s = t.substring(count + 1);
set.add(s);
}
_cch.put(org + "/" + CREATION + "Names", set);
if (_debug.messageEnabled())
_debug.message("ConfigManager->updateCache: " + org + "/" + CREATION + "Names :" + set);
}
loadCache(org, eNames, ENTITY);
loadCache(org, cNames, CREATION);
loadCache(org, sNames, SEARCH);
_checkListCache.put(org.toLowerCase(), "dummy");
}
use of com.iplanet.services.ldap.AttrSet in project OpenAM by OpenRock.
the class ConfigManagerUMS method loadCache.
/**
* Reads the directory server, via SMS APIs for a given org (/b/a) and for a
* given template (<code>StructureTemplates</code>,
* <code>CreationTemplates</code>, etc.).
*
* @param org Name of organization <code>/pepsi/coke</code>.
* @param c List of template names.
* @param template Name of template.
*/
private void loadCache(String org, Set c, String template) {
//
// To get all attributes for each component name from DS and store
// in cache. Calls getServiceAttrs()
//
Iterator iter = c.iterator();
String entName = "";
AttrSet attrSet = null;
while (iter.hasNext()) {
entName = iter.next().toString();
Map entityAttributes = new HashMap();
attrSet = new AttrSet();
try {
entityAttributes = getServiceAttributes(org, entName);
} catch (SMSException smse) {
// Don't throw an exception, just log it. Cache will return
// a null
_debug.error("ConfigManager->loadCache: SMSException: " + smse.toString());
} catch (SSOException ssoe) {
// Don't throw an exception, just log it. Cache will return
// a null
_debug.error("ConfigManager->loadCache: SSOException: " + ssoe.toString());
}
if (entityAttributes.isEmpty())
continue;
for (Iterator it = entityAttributes.entrySet().iterator(); it.hasNext(); ) {
Map.Entry ent = (Map.Entry) it.next();
Set hs = (Set) ent.getValue();
Iterator itera = hs.iterator();
itera = hs.iterator();
while (itera.hasNext()) {
attrSet.add(new Attr((String) ent.getKey(), (String) itera.next()));
}
}
String key = org + "/" + template + "/";
Attr classAttr = null;
if (template.equals(ENTITY)) {
// This search is for EntityManager
classAttr = attrSet.getAttribute(CLASS);
if (classAttr != null) {
Set hs = new HashSet();
if (_cch.containsKey(key + classAttr.getValue())) {
hs = (Set) _cch.get(key + classAttr.getValue());
hs.add(attrSet);
} else {
hs.add(attrSet);
}
_cch.put(key + classAttr.getValue(), hs);
if (_debug.messageEnabled())
_debug.message("ConfigManager->loadCache KEY:" + key + classAttr.getValue() + " VALUE:" + hs);
}
int l = entName.lastIndexOf("/");
String cname = entName.substring(l + 1);
// This search is for EntityManager
Set hset = new HashSet();
hset.add(attrSet);
_cch.put(key + cname, hset);
if (_debug.messageEnabled())
_debug.message("ConfigManager->loadCache KEY:" + key + cname + " VALUE:" + hset);
}
// } else {
if ((template.equals(SEARCH)) || template.equals(CREATION)) {
// This search is for TemplateManager
classAttr = attrSet.getAttribute(JAVACLASS);
if (classAttr != null) {
_cch.put(key + classAttr.getValue(), attrSet);
if (_debug.messageEnabled())
_debug.message("ConfigManager->loadCache KEY:" + key + classAttr.getValue() + " VALUE:" + attrSet);
}
// This search is for TemplateManager
classAttr = attrSet.getAttribute(ATTRNAME);
if (classAttr != null) {
_cch.put(key + classAttr.getValue(), attrSet);
_debug.message("ConfigManager->loadCache KEY:" + key + classAttr.getValue() + " VALUE:" + attrSet);
}
}
if (template.equals(OBJECTRESOLVER)) {
// This adds the String[][] for ObjectResolver to cache
String oc_jc_map_string = attrSet.getValue(OC_JC_MAP);
if (oc_jc_map_string != null) {
_cch.put(OBJECTRESOLVERPATH, getOC_JC_MAP(oc_jc_map_string));
_debug.message("ConfigManager->loadCache KEY:" + OBJECTRESOLVERPATH + " VALUE:" + attrSet);
}
}
}
}
Aggregations