Exemplo n.º 1
0
  /**
   * 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");
      }
    }
  }
Exemplo n.º 2
0
 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);
   }
 }
Exemplo n.º 3
0
  /**
   * 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 != "")) {
      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");
      }
    }
  }
Exemplo n.º 4
0
 protected AttrSet[] splitAttrSet(String orgDN, AttrSet attrSet) throws AMException, SSOException {
   AttrSet attrArray[] = new AttrSet[2];
   attrArray[0] = (attrSet != null) ? (AttrSet) attrSet.clone() : new AttrSet();
   attrArray[1] = new AttrSet();
   if (attrSet == null) {
     return (attrArray);
   }
   Set dcNodeAttrs = dcNodeAttributes();
   Iterator it = dcNodeAttrs.iterator();
   while (it.hasNext()) {
     String aName = (String) it.next();
     if (aName.indexOf("objectclass=") > -1) {
       Attr attr0 = attrSet.getAttribute("objectclass");
       Attr attr = (attr0 != null) ? (Attr) attr0.clone() : null;
       String oc = aName.substring("objectclass=".length());
       Attr dcAttr = new Attr("objectclass");
       if (attr != null && attr.contains(oc)) {
         attr.removeValue(oc);
         dcAttr.addValue(oc);
         attrArray[0].replace(attr);
         attrArray[1].add(dcAttr);
       }
     } else {
       Attr attr = attrSet.getAttribute(aName);
       if (attr != null) {
         attrArray[1].add(attr);
         attrArray[0].remove(aName);
       }
     }
   }
   if (debug.messageEnabled()) {
     debug.message(
         "DCTreeServicesImpl.splitAttrSet: " + "domain attrset = " + attrArray[1].toString());
     debug.message(
         "DCTreeServicesImpl.splitAttrSet: " + "non-domain attrset = " + attrArray[0].toString());
   }
   return attrArray;
 }