/** * Method which creates a <Code>Domain Component Tree </Code> for the given organization, if the * <code>sunPreferredDomain</code> attribute is present and has a fully qualified domain name as * value. * * @param token SSO Token * @param orgGuid identifiication of organization entry to be mapped from <Code>dctree</Code> to * organization DIT organization * @param attrSet the attributes to be set on creation of domain. * @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, AttrSet attrSet) throws AMException, SSOException { if (DCTREE_START_DN == null) { throw new AMException(AMSDKBundle.getString("355"), "355"); } // Create a DC tree is value is specified for // sunPreferredDomain attribute String domainName = attrSet.getValue(IPLANET_DOMAIN_NAME_ATTR); // remove the attribute from the attribute set. attrSet.remove(IPLANET_DOMAIN_NAME_ATTR); if ((domainName != null) && (domainName != "")) { 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); } AttrSet[] attrSetArray = splitAttrSet(orgGuid.getDn(), attrSet); if (attrSetArray[1] != null) { setDomainAttributes(token, orgGuid.getDn(), attrSetArray[1]); } } 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"); } } }
protected void setDomainAttributes(SSOToken token, String orgDN, AttrSet attrSet) throws AMException { String domainName = null; try { domainName = getCanonicalDomain(token, orgDN); DomainComponentTree dcTree = new DomainComponentTree(token, new Guid(DCTREE_START_DN)); if (domainName == null) { if (debug.messageEnabled()) { debug.message("DCTree.setDomainAttrs: " + "No domain found for org : " + orgDN); } return; } DomainComponent dcNode = dcTree.getDomainComponent(domainName); if (attrSet != null) { if (debug.messageEnabled()) { debug.message( "DCTree.setDomainAttrs: " + " setting attributes on domain " + domainName + ": " + attrSet.toString()); } Attr ocAttr = attrSet.getAttribute("objectclass"); if (ocAttr != null) { Attr oldOCAttr = dcNode.getAttribute("objectclass"); if (oldOCAttr != null) { ocAttr.addValues(oldOCAttr.getStringValues()); } if (debug.messageEnabled()) { debug.message( "DCTree.setDomainAttrs-> " + "objectclasses to be set " + ocAttr.toString()); } if (ocAttr.size() == 0) dcNode.modify(ocAttr, ModSet.DELETE); else dcNode.modify(ocAttr, ModSet.REPLACE); dcNode.save(); attrSet.remove("objectclass"); } int size = attrSet.size(); for (int i = 0; i < size; i++) { Attr attr = attrSet.elementAt(i); if (attr.size() == 0) { // remove attribute dcNode.modify(attr, ModSet.DELETE); } else { // replace attribute dcNode.modify(attr, ModSet.REPLACE); } } dcNode.save(); } } catch (UMSException umse) { debug.error( "DCTree.setDomainAttributes: " + " error setting " + " attribute for domain " + domainName, umse); } }