use of com.iplanet.ums.Guid in project OpenAM by OpenRock.
the class DCTreeServicesImpl method updateCacheAndReturnDomain.
/**
* This is a private method to update cache
*/
private String updateCacheAndReturnDomain(SSOToken token, String canonOrgDN) throws AMException {
try {
DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
SearchControl scontrol = new SearchControl();
scontrol.setSearchScope(SearchControl.SCOPE_SUB);
PersistentObject po = UMSObject.getObject(token, new Guid(DCTREE_START_DN));
String searchFilter = "(inetDomainBaseDN=" + canonOrgDN + ")";
if (debug.messageEnabled()) {
debug.message("DCTree.updateCache-> " + "searchFilter= " + searchFilter);
}
SearchResults results = po.search(searchFilter, null);
int count = 0;
String domainName = null;
String canonDomain = null;
while (results.hasMoreElements()) {
DomainComponent dcNode = (DomainComponent) results.next();
count++;
domainName = dcTree.mapDCToDomainName(dcNode);
if (debug.messageEnabled()) {
debug.message("DCTree:updateCache-> " + "domainName= " + domainName);
}
Attr isCanonical = dcNode.getAttribute(INET_CANONICAL_DOMAIN);
if (isCanonical != null) {
/*
* if (AMCacheManager.isCachingEnabled()) {
* synchronized(canonicalDomainMap) {
* canonicalDomainMap.put(canonOrgDN, domainName); } }
*/
canonDomain = domainName;
}
/*
* if (AMCacheManager.isCachingEnabled()) {
* synchronized(domainMap) { domainMap.put(canonOrgDN,
* domainName); } }
*/
}
results.abandon();
if (count == 1) {
canonDomain = domainName;
/*
* if (AMCacheManager.isCachingEnabled()) {
* canonicalDomainMap.put(canonOrgDN, domainName); }
*/
}
if (debug.messageEnabled()) {
debug.message("DCTree.updateCache-> " + "returning domain= " + canonDomain);
}
return canonDomain;
} catch (UMSException umse) {
debug.error("DCTree:updateCache: UMSException", umse);
return null;
}
}
use of com.iplanet.ums.Guid in project OpenAM by OpenRock.
the class DCTreeServicesImpl method getOrganizationDN.
/**
* Returns the organization DN matching the domain name
*
* @param token
* SSOToken
* @param domainName
* String representing domin name
* @return
* the organization dn
* @throws AMException
*/
public String getOrganizationDN(SSOToken token, String domainName) throws AMException {
try {
DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
Hashtable domainToOrgTable = dcTree.getChildDomainIDs();
if (debug.messageEnabled()) {
debug.message("DCTree:getOrgDN-> domain=" + domainName);
}
return ((String) domainToOrgTable.get(domainName));
} catch (UMSException umse) {
// Deepa: Is there a localized property for 1000?
debug.error("DCTree:getOrganizationDN: " + "UMS Exception: ", umse);
throw new AMException(AMSDKBundle.getString("1000"), "1000");
}
}
use of com.iplanet.ums.Guid in project OpenAM by OpenRock.
the class DCTreeServicesImpl method createDomain.
/**
* Method which creates a DC Tree for the given org, if the
* <code>sunPreferredDomain</code> attribute is present and has a fully
* qualified domain name as value.
*
* @param token
* SSOToken
* @param orgGuid
* identifiication of Organization entry to be mapped from dctree
* to organization DIT organization
* @param domainName
* set the domain this organization belongs to.
* @param attrSet
* the AttrSet of the organization
*
* @exception AMException
* if unsuccessful in creating a dc tree for the organization
* or unsuccessful in setting the mapping between dc tree and
* the organization
*/
protected void createDomain(SSOToken token, Guid orgGuid, String domainName, AttrSet attrSet) throws AMException {
if (DCTREE_START_DN == null) {
throw new AMException(AMSDKBundle.getString("355"), "355");
}
// Create a DC tree for specified domain.
if ((domainName != null) && (!domainName.equals(""))) {
try {
DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
dcTree.addDomain(domainName);
// Set the domain mapping
dcTree.setDomainMapping(domainName, orgGuid);
String status = attrSet.getValue(INET_DOMAIN_STATUS_ATTR);
if (status != null) {
dcTree.setDomainStatus(domainName, status);
}
} catch (InvalidDCRootException ie) {
debug.error("DCTree.createDomain(): ", ie);
throw new AMException(AMSDKBundle.getString("343"), "343");
} catch (UMSException ue) {
debug.error("DCTree.createDomain(): ", ue);
throw new AMException(AMSDKBundle.getString("344"), "344");
}
}
}
use of com.iplanet.ums.Guid in project OpenAM by OpenRock.
the class DCTreeServicesImpl method updateDomainStatus.
/**
* Method which update attribute inetdomainstatus of the DC Tree
* corresponding to the Org
*
* @param token
* SSOToken
* @param orgDN
* String representing the DN correponding to the organization
* @param status
* inetdomainstatus value
*
* @exception AMException
* if error occured in accessing the org corresponding to
* orgDN or during the attribute change of the dc tree
* corresponding to the orgDN
*/
protected void updateDomainStatus(SSOToken token, String orgDN, String status) throws AMException {
try {
String domainName = getCanonicalDomain(token, orgDN);
if ((domainName != null) && (domainName.length() > 0)) {
DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN));
dcTree.setDomainStatus(domainName, status);
} else {
debug.warning("DCTree.updateDomainStatus(): value for " + IPLANET_DOMAIN_NAME_ATTR + " attribute " + "null or empty");
}
// }
} catch (UMSException ue) {
debug.error("DCTree.removeDomain(): ", ue);
throw new AMException(AMSDKBundle.getString("356"), "356");
}
}
use of com.iplanet.ums.Guid in project OpenAM by OpenRock.
the class DirectoryServicesImpl method modifyAndSaveEntry.
private void modifyAndSaveEntry(SSOToken token, String entryDN, Map stringAttributes, Map byteAttributes, boolean isAdd) throws AccessRightsException, EntryNotFoundException, UMSException {
PersistentObject po = UMSObject.getObjectHandle(token, new Guid(entryDN));
// Add string attributes
if (stringAttributes != null && !stringAttributes.isEmpty()) {
Iterator itr = stringAttributes.keySet().iterator();
while (itr.hasNext()) {
String attrName = (String) (itr.next());
if (!attrName.equalsIgnoreCase("dn")) {
Set set = (Set) (stringAttributes.get(attrName));
String[] attrValues = (set == null) ? null : (String[]) set.toArray(new String[set.size()]);
Attr attr = new Attr(attrName, attrValues);
/*
* AMObjectImpl.removeAttributes(...) sets the values to be
* Collections.EMPTY_SET.
*/
modifyPersistentObject(po, attr, isAdd, (set == AMConstants.REMOVE_ATTRIBUTE));
}
}
}
// Add byte attributes
if (byteAttributes != null && !byteAttributes.isEmpty()) {
Iterator itr = byteAttributes.keySet().iterator();
while (itr.hasNext()) {
String attrName = (String) (itr.next());
byte[][] attrValues = (byte[][]) (byteAttributes.get(attrName));
Attr attr = new Attr(attrName, attrValues);
modifyPersistentObject(po, attr, isAdd, false);
}
}
po.save();
}
Aggregations