0001: package migration.modules.ldap;
0002:
0003: import java.util.*;
0004: import java.io.*;
0005: import org.xml.sax.SAXException;
0006:
0007: import com.iplanet.portalserver.parser.*;
0008: import com.iplanet.portalserver.profile.impl.*;
0009: import com.iplanet.portalserver.profile.share.ProfileBundle;
0010: import netscape.ldap.*;
0011:
0012: public class SetServiceValues extends CommonXml {
0013:
0014: public static String adminModuleToSet = "";
0015:
0016: static Map DesktopTypes = new HashMap();
0017:
0018: public static void initHashTable(String fileName) {
0019:
0020: try {
0021: DesktopTypes = new HashMap();
0022:
0023: InputStreamReader fr = new InputStreamReader(
0024: new FileInputStream(fileName), "UTF-8");
0025: BufferedReader desktopTypes_Orgs = new BufferedReader(fr);
0026: String currLine, key, val;
0027: key = "";
0028: val = "";
0029: while ((currLine = desktopTypes_Orgs.readLine()) != null) {
0030: currLine = (currLine.trim());
0031: StringTokenizer tk = new StringTokenizer(currLine, " ");
0032: while (tk.hasMoreTokens()) {
0033: key = tk.nextToken();
0034: val = tk.nextToken();
0035: }
0036: DesktopTypes.put(key, val);
0037: }
0038: fr.close();
0039: desktopTypes_Orgs.close();
0040: } catch (Exception e) {
0041:
0042: }
0043:
0044: return;
0045: }
0046:
0047: public static void writeHashTable(String fileName) {
0048: /* Writes the organization name and the desktop Type into the file*/
0049:
0050: try {
0051: OutputStreamWriter desktopTypes_Orgs = new OutputStreamWriter(
0052: new FileOutputStream(fileName), "UTF-8");
0053:
0054: Iterator keysList;
0055: Object keyVal;
0056:
0057: keysList = (DesktopTypes.keySet()).iterator();
0058: while (keysList.hasNext()) {
0059: keyVal = (keysList.next());
0060: desktopTypes_Orgs.write("\n" + keyVal.toString() + " "
0061: + (DesktopTypes.get(keyVal)).toString());
0062: }
0063:
0064: desktopTypes_Orgs.close();
0065: } catch (Exception e) {
0066:
0067: }
0068: }
0069:
0070: public static String setRadiusAuthAttrs(Component comp, String org,
0071: String rootsuffix) throws IOException {
0072:
0073: boolean radiusToSet = false;
0074: Attribute tmpAttr;
0075: Hashtable ht = new Hashtable();
0076: Enumeration keys;
0077: StringBuffer toWriteTo = new StringBuffer();
0078:
0079: for (int i = 0; i < (comp._attributes).size(); ++i) {
0080: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0081: if (((tmpAttr.name).indexOf("iwtAuthRadius")) != -1)
0082: radiusToSet = true;
0083: }
0084:
0085: if (radiusToSet) {
0086: if (adminModuleToSet.equalsIgnoreCase("Radius"))
0087: adminModuleToSet = "";
0088:
0089: toWriteTo.append("\n <OrganizationRequests DN=\""
0090: + constructOrgDN(org, rootsuffix) + "\">");
0091: toWriteTo.append("\n <RegisterServices>");
0092: toWriteTo
0093: .append("\n <Service_Name>iPlanetAMAuthRadiusService</Service_Name>");
0094: toWriteTo.append("\n </RegisterServices>");
0095: toWriteTo.append("\n</OrganizationRequests>");
0096:
0097: toWriteTo.append("\n<OrganizationRequests DN=\""
0098: + constructOrgDN(org, rootsuffix) + "\">");
0099: toWriteTo
0100: .append(getCreateServiceTemplate("iPlanetAMAuthRadiusService"));
0101: toWriteTo.append("\n</OrganizationRequests>");
0102:
0103: toWriteTo.append("\n<OrganizationRequests DN=\""
0104: + constructOrgDN(org, rootsuffix) + "\">");
0105: toWriteTo
0106: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
0107: toWriteTo.append("\n <AttributeValuePair>");
0108: toWriteTo
0109: .append("\n <Attribute name=\"iplanet-am-auth-dynamic-profile-creation\"/>");
0110: toWriteTo
0111: .append("\n <Value>" + true + "</Value>");
0112: toWriteTo.append("\n </AttributeValuePair>");
0113: toWriteTo.append("\n </ModifyServiceTemplate>");
0114: toWriteTo.append("\n</OrganizationRequests>");
0115:
0116: toWriteTo.append("\n<OrganizationRequests DN=\""
0117: + constructOrgDN(org, rootsuffix) + "\">");
0118: toWriteTo
0119: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthRadiusService\" schemaType=\"Organization\">");
0120: for (int i = 0; i < (comp._attributes).size(); ++i) {
0121: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0122:
0123: if ((tmpAttr.name)
0124: .equalsIgnoreCase("iwtAuthRadius-server1")) {
0125: String val = (String) (tmpAttr.vallist)
0126: .elementAt(0);
0127: toWriteTo.append("\n <AttributeValuePair>");
0128: toWriteTo
0129: .append("\n <Attribute name=\"iplanet-am-auth-radius-server1\"/>");
0130: toWriteTo.append("\n <Value>");
0131: toWriteTo.append(val);
0132: toWriteTo.append("</Value>");
0133: toWriteTo.append("\n </AttributeValuePair>");
0134: }
0135: if ((tmpAttr.name)
0136: .equalsIgnoreCase("iwtAuthRadius-server2")) {
0137: String val = (String) (tmpAttr.vallist)
0138: .elementAt(0);
0139: toWriteTo.append("\n <AttributeValuePair>");
0140: toWriteTo
0141: .append("\n <Attribute name=\"iplanet-am-auth-radius-server2\"/>");
0142: toWriteTo.append("\n <Value>");
0143: toWriteTo.append(val);
0144: toWriteTo.append("</Value>");
0145: toWriteTo.append("\n </AttributeValuePair>");
0146: }
0147: if ((tmpAttr.name)
0148: .equalsIgnoreCase("iwtAuthRadius-serverPort")) {
0149: String val = (String) (tmpAttr.vallist)
0150: .elementAt(0);
0151: toWriteTo.append("\n <AttributeValuePair>");
0152: toWriteTo
0153: .append("\n <Attribute name=\"iplanet-am-auth-radius-server-port\"/>");
0154: toWriteTo.append("\n <Value>");
0155: toWriteTo.append(val);
0156: toWriteTo.append("</Value>");
0157: toWriteTo.append("\n </AttributeValuePair>");
0158: }
0159: if ((tmpAttr.name)
0160: .equalsIgnoreCase("iwtAuthRadius-maxAuthLevel")) {
0161: String val = (String) (tmpAttr.vallist)
0162: .elementAt(0);
0163: toWriteTo.append("\n <AttributeValuePair>");
0164: toWriteTo
0165: .append("\n <Attribute name=\"iplanet-am-auth-radius-auth-level\"/>");
0166: toWriteTo.append("\n <Value>");
0167: toWriteTo.append(val);
0168: toWriteTo.append("</Value>");
0169: toWriteTo.append("\n </AttributeValuePair>");
0170: }
0171: if ((tmpAttr.name)
0172: .equalsIgnoreCase("iwtAuthRadius-secret")) {
0173: String val = (String) (tmpAttr.vallist)
0174: .elementAt(0);
0175: toWriteTo.append("\n <AttributeValuePair>");
0176: toWriteTo
0177: .append("\n <Attribute name=\"iplanet-am-auth-radius-secret\"/>");
0178: toWriteTo.append("\n <Value>" + val
0179: + "</Value>");
0180: toWriteTo.append("\n </AttributeValuePair>");
0181: }
0182: }
0183: toWriteTo.append("\n </ModifyServiceTemplate>");
0184: toWriteTo.append("\n</OrganizationRequests>");
0185: }
0186: return toWriteTo.toString();
0187:
0188: }
0189:
0190: public static String setLdapAuthAttrs(String hostname,
0191: Component comp, String org, String rootsuffix)
0192: throws IOException {
0193:
0194: boolean LdapToSet = false;
0195: Attribute tmpAttr;
0196: Hashtable ht = new Hashtable();
0197: Enumeration keys;
0198: String serverName = new String();
0199: String tempServerName = new String();
0200: StringBuffer toWriteTo = new StringBuffer();
0201:
0202: for (int i = 0; i < (comp._attributes).size(); ++i) {
0203: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0204: if (((tmpAttr.name).indexOf("iwtAuthLdap")) != -1)
0205: LdapToSet = true;
0206: if ((tmpAttr.name).equalsIgnoreCase("iwtAuthLdap-server")) {
0207: serverName = (String) (tmpAttr.vallist).elementAt(0);
0208: }
0209: }
0210:
0211: if (LdapToSet) {
0212:
0213: if (adminModuleToSet.equalsIgnoreCase("Ldap"))
0214: adminModuleToSet = "";
0215:
0216: toWriteTo.append("\n<OrganizationRequests DN=\""
0217: + constructOrgDN(org, rootsuffix) + "\">");
0218: toWriteTo
0219: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
0220: toWriteTo.append("\n <AttributeValuePair>");
0221: toWriteTo
0222: .append("\n <Attribute name=\"iplanet-am-auth-dynamic-profile-creation\"/>");
0223: toWriteTo
0224: .append("\n <Value>" + true + "</Value>");
0225: toWriteTo.append("\n </AttributeValuePair>");
0226: toWriteTo.append("\n </ModifyServiceTemplate>");
0227: toWriteTo.append("\n</OrganizationRequests>");
0228:
0229: toWriteTo.append("\n <OrganizationRequests DN=\""
0230: + constructOrgDN(org, rootsuffix) + "\">");
0231: toWriteTo.append("\n <RegisterServices>");
0232: toWriteTo
0233: .append("\n <Service_Name>iPlanetAMAuthLDAPService</Service_Name>");
0234: toWriteTo.append("\n </RegisterServices>");
0235: toWriteTo.append("\n</OrganizationRequests>");
0236:
0237: toWriteTo.append("\n<OrganizationRequests DN=\""
0238: + constructOrgDN(org, rootsuffix) + "\">");
0239: toWriteTo
0240: .append(getCreateServiceTemplate("iPlanetAMAuthLDAPService"));
0241: toWriteTo.append("\n</OrganizationRequests>");
0242:
0243: if (serverName.indexOf(":") > 0)
0244: tempServerName = serverName.substring(0, serverName
0245: .indexOf(":"));
0246: else
0247: tempServerName = serverName;
0248: if (tempServerName.equalsIgnoreCase(hostname)) {
0249: //Internal Server hence nothing to be done, Service template will take care
0250: //Just set the base dn
0251:
0252: toWriteTo.append("\n<OrganizationRequests DN=\""
0253: + constructOrgDN(org, rootsuffix) + "\">");
0254: toWriteTo
0255: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthLDAPService\" schemaType=\"Organization\">");
0256: toWriteTo.append("\n <AttributeValuePair>");
0257: toWriteTo
0258: .append("\n <Attribute name=\"iplanet-am-auth-ldap-base-dn\"/>");
0259: toWriteTo.append("\n <Value>"
0260: + constructOrgDN(org, rootsuffix) + "</Value>");
0261: toWriteTo.append("\n </AttributeValuePair>");
0262: toWriteTo.append("\n </ModifyServiceTemplate>");
0263: toWriteTo.append("\n </OrganizationRequests>");
0264:
0265: } else {
0266: toWriteTo.append("\n<OrganizationRequests DN=\""
0267: + constructOrgDN(org, rootsuffix) + "\">");
0268: toWriteTo
0269: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthLDAPService\" schemaType=\"Organization\">");
0270: toWriteTo.append("\n <AttributeValuePair>");
0271: toWriteTo
0272: .append("\n <Attribute name=\"iplanet-am-auth-ldap-return-user-dn\"/>");
0273: toWriteTo.append("\n <Value>" + false
0274: + "</Value>");
0275: toWriteTo.append("\n </AttributeValuePair>");
0276:
0277: /* To take care of External LDAP....If one of them is not specified, then not to take the default
0278: * From the Settings of the Service TEmplate.
0279: * In case anonymous auth is specified,
0280: *
0281: * + Need to clear the bind-dn and bind-password of the default service template.
0282: * + The later step will populate values if there is a specified value for bind-dn or password
0283: * + Otherwise, the blank values will be retained to make sure that anonymous works.
0284: **/
0285:
0286: toWriteTo.append("\n <AttributeValuePair>");
0287: toWriteTo
0288: .append("\n <Attribute name=\"iplanet-am-auth-ldap-bind-dn\"/>");
0289: toWriteTo.append("\n <Value> </Value>");
0290: toWriteTo.append("\n </AttributeValuePair>");
0291:
0292: toWriteTo.append("\n <AttributeValuePair>");
0293: toWriteTo
0294: .append("\n <Attribute name=\"iplanet-am-auth-ldap-bind-passwd\"/>");
0295: toWriteTo.append("\n <Value> </Value>");
0296: toWriteTo.append("\n </AttributeValuePair>");
0297:
0298: toWriteTo.append("\n </ModifyServiceTemplate>");
0299: toWriteTo.append("\n </OrganizationRequests>");
0300:
0301: toWriteTo.append("\n<OrganizationRequests DN=\""
0302: + constructOrgDN(org, rootsuffix) + "\">");
0303: toWriteTo
0304: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthLDAPService\" schemaType=\"Organization\">");
0305: for (int i = 0; i < (comp._attributes).size(); ++i) {
0306: tmpAttr = (Attribute) ((comp._attributes)
0307: .elementAt(i));
0308:
0309: if ((tmpAttr.name)
0310: .equalsIgnoreCase("iwtAuthLdap-baseDN")) {
0311:
0312: String val = (String) (tmpAttr.vallist)
0313: .elementAt(0);
0314: toWriteTo
0315: .append("\n <AttributeValuePair>");
0316: toWriteTo
0317: .append("\n <Attribute name=\"iplanet-am-auth-ldap-base-dn\"/>");
0318: toWriteTo.append("\n <Value>" + val
0319: + "</Value>");
0320: toWriteTo
0321: .append("\n </AttributeValuePair>");
0322:
0323: }
0324: if ((tmpAttr.name)
0325: .equalsIgnoreCase("iwtAuthLdap-bindDN")) {
0326: String val = (String) (tmpAttr.vallist)
0327: .elementAt(0);
0328: toWriteTo
0329: .append("\n <AttributeValuePair>");
0330: toWriteTo
0331: .append("\n <Attribute name=\"iplanet-am-auth-ldap-bind-dn\"/>");
0332: toWriteTo.append("\n <Value>" + val
0333: + "</Value>");
0334: toWriteTo
0335: .append("\n </AttributeValuePair>");
0336:
0337: }
0338: if ((tmpAttr.name)
0339: .equalsIgnoreCase("iwtAuthLdap-server")) {
0340: String val = (String) (tmpAttr.vallist)
0341: .elementAt(0);
0342: toWriteTo
0343: .append("\n <AttributeValuePair>");
0344: toWriteTo
0345: .append("\n <Attribute name=\"iplanet-am-auth-ldap-server\"/>");
0346: toWriteTo.append("\n <Value>" + val
0347: + "</Value>");
0348: toWriteTo
0349: .append("\n </AttributeValuePair>");
0350:
0351: }
0352: if ((tmpAttr.name)
0353: .equalsIgnoreCase("iwtAuthLdap-bindPasswd")) {
0354: String val = (String) (tmpAttr.vallist)
0355: .elementAt(0);
0356: toWriteTo
0357: .append("\n <AttributeValuePair>");
0358: toWriteTo
0359: .append("\n <Attribute name=\"iplanet-am-auth-ldap-bind-passwd\"/>");
0360: toWriteTo.append("\n <Value>" + val
0361: + "</Value>");
0362: toWriteTo
0363: .append("\n </AttributeValuePair>");
0364: }
0365:
0366: if ((tmpAttr.name)
0367: .equalsIgnoreCase("iwtAuthLdap-sslEnabled")) {
0368: String val = (String) (tmpAttr.vallist)
0369: .elementAt(0);
0370: toWriteTo
0371: .append("\n <AttributeValuePair>");
0372: toWriteTo
0373: .append("\n <Attribute name=\"iplanet-am-auth-ldap-ssl-enabled\"/>");
0374: toWriteTo.append("\n <Value>" + val
0375: + "</Value>");
0376: toWriteTo
0377: .append("\n </AttributeValuePair>");
0378: }
0379:
0380: }
0381: toWriteTo.append("\n </ModifyServiceTemplate>");
0382: toWriteTo.append("\n</OrganizationRequests>");
0383: }
0384: }
0385: return toWriteTo.toString();
0386:
0387: }
0388:
0389: public static String setSafewordAuth(Component comp, String org,
0390: String rootsuffix) throws IOException {
0391:
0392: boolean safewordToSet = false;
0393: Attribute tmpAttr;
0394: Hashtable ht = new Hashtable();
0395: Enumeration keys;
0396: StringBuffer toWriteTo = new StringBuffer();
0397: String sPort = new String();
0398:
0399: for (int i = 0; i < (comp._attributes).size(); ++i) {
0400: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0401: if (((tmpAttr.name).indexOf("iwtAuthSafeword")) != -1)
0402: safewordToSet = true;
0403: if ((tmpAttr.name).indexOf("iwtAuthSafeword-serverPort") != -1)
0404: sPort = (String) (tmpAttr.vallist).elementAt(0);
0405: }
0406:
0407: if (safewordToSet) {
0408: if (adminModuleToSet.equalsIgnoreCase("SafeWord"))
0409: adminModuleToSet = "";
0410:
0411: toWriteTo.append("\n <OrganizationRequests DN=\""
0412: + constructOrgDN(org, rootsuffix) + "\">");
0413: toWriteTo.append("\n <RegisterServices>");
0414: toWriteTo
0415: .append("\n <Service_Name>iPlanetAMAuthSafeWordService</Service_Name>");
0416: toWriteTo.append("\n </RegisterServices>");
0417: toWriteTo.append("\n</OrganizationRequests>");
0418:
0419: toWriteTo.append("\n<OrganizationRequests DN=\""
0420: + constructOrgDN(org, rootsuffix) + "\">");
0421: toWriteTo
0422: .append(getCreateServiceTemplate("iPlanetAMAuthSafeWordService"));
0423: toWriteTo.append("\n</OrganizationRequests>");
0424:
0425: toWriteTo.append("\n<OrganizationRequests DN=\""
0426: + constructOrgDN(org, rootsuffix) + "\">");
0427: toWriteTo
0428: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthSafeWordService\" schemaType=\"Organization\">");
0429: for (int i = 0; i < (comp._attributes).size(); ++i) {
0430: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0431:
0432: if ((tmpAttr.name)
0433: .equalsIgnoreCase("iwtAuthSafeWord-logLevel")) {
0434: String val = (String) (tmpAttr.vallist)
0435: .elementAt(0);
0436: toWriteTo.append("\n <AttributeValuePair>");
0437: toWriteTo
0438: .append("\n <Attribute name=\"iplanet-am-auth-safeword-log-level\"/>");
0439: toWriteTo.append("\n <Value>");
0440: toWriteTo.append(val);
0441: toWriteTo.append("</Value>");
0442: toWriteTo.append("\n </AttributeValuePair>");
0443: }
0444: if ((tmpAttr.name)
0445: .equalsIgnoreCase("iwtAuthSafeWord-logPath")) {
0446: String val = (String) (tmpAttr.vallist)
0447: .elementAt(0);
0448: toWriteTo.append("\n <AttributeValuePair>");
0449: toWriteTo
0450: .append("\n <Attribute name=\"iplanet-am-auth-safeword-log-path\"/>");
0451: toWriteTo.append("\n <Value>");
0452: toWriteTo.append(val);
0453: toWriteTo.append("</Value>");
0454: toWriteTo.append("\n </AttributeValuePair>");
0455: }
0456:
0457: if ((tmpAttr.name)
0458: .equalsIgnoreCase("iwtAuthSafeWord-maxAuthLevel")) {
0459: String val = (String) (tmpAttr.vallist)
0460: .elementAt(0);
0461: toWriteTo.append("\n <AttributeValuePair>");
0462: toWriteTo
0463: .append("\n <Attribute name=\"iplanet-am-auth-safeword-auth-level\"/>");
0464: toWriteTo.append("\n <Value>");
0465: toWriteTo.append(val);
0466: toWriteTo.append("</Value>");
0467: toWriteTo.append("\n </AttributeValuePair>");
0468: }
0469: if ((tmpAttr.name)
0470: .equalsIgnoreCase("iwtAuthSafeWord-systemName")) {
0471: String val = (String) (tmpAttr.vallist)
0472: .elementAt(0);
0473: toWriteTo.append("\n <AttributeValuePair>");
0474: toWriteTo
0475: .append("\n <Attribute name=\"iplanet-am-auth-safeword-system-name\"/>");
0476: toWriteTo.append("\n <Value>");
0477: toWriteTo.append(val);
0478: toWriteTo.append("</Value>");
0479: toWriteTo.append("\n </AttributeValuePair>");
0480: }
0481: if ((tmpAttr.name)
0482: .equalsIgnoreCase("iwtAuthSafeWord-serverName")) {
0483: String val = (String) (tmpAttr.vallist)
0484: .elementAt(0);
0485: toWriteTo.append("\n <AttributeValuePair>");
0486: toWriteTo
0487: .append("\n <Attribute name=\"iplanet-am-auth-safeword-server-specification\"/>");
0488: toWriteTo.append("\n <Value>");
0489: toWriteTo.append(val + " " + sPort);
0490: toWriteTo.append("</Value>");
0491: toWriteTo.append("\n </AttributeValuePair>");
0492: }
0493:
0494: }
0495: toWriteTo.append("\n </ModifyServiceTemplate>");
0496: toWriteTo.append("\n</OrganizationRequests>");
0497: }
0498:
0499: return toWriteTo.toString();
0500: }
0501:
0502: public static String setAuthAttrs(Component comp, String org,
0503: String rootsuffix) throws IOException {
0504:
0505: Attribute tmpAttr;
0506: Hashtable ht = new Hashtable();
0507: Enumeration keys;
0508: StringBuffer toWriteTo = new StringBuffer();
0509:
0510: for (int i = 0; i < (comp._attributes).size(); ++i) {
0511: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0512:
0513: /* if((tmpAttr.name).equalsIgnoreCase("iwtAuth-domainURL")){
0514: toWriteTo.append("\n<OrganizationRequests DN=\"" + constructOrgDN(org, rootsuffix) + "\">");
0515: toWriteTo.append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
0516: String val= (String)(tmpAttr.vallist).elementAt(0);
0517: toWriteTo.append("\n <AttributeValuePair>");
0518: toWriteTo.append("\n <Attribute name=\"iplanet-am-auth-domain-urls\"/>");
0519: for(int jk=0;jk<(tmpAttr.vallist).size();++jk){
0520: toWriteTo.append("\n <Value>");
0521: toWriteTo.append((String)(tmpAttr.vallist).elementAt(jk));
0522: toWriteTo.append("</Value>");
0523: }
0524: toWriteTo.append("\n </AttributeValuePair>");
0525: toWriteTo.append("\n </ModifyServiceTemplate>");
0526: toWriteTo.append("\n</OrganizationRequests>");
0527: } */
0528: if ((tmpAttr.name)
0529: .equalsIgnoreCase("iwtAuth-nonInteractiveModules")) {
0530: toWriteTo.append("\n<OrganizationRequests DN=\""
0531: + constructOrgDN(org, rootsuffix) + "\">");
0532: toWriteTo
0533: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
0534: String val = (String) (tmpAttr.vallist).elementAt(0);
0535: toWriteTo.append("\n <AttributeValuePair>");
0536: toWriteTo
0537: .append("\n <Attribute name=\"iplanet-am-auth-non-interactive-modules\"/>");
0538: for (int jk = 0; jk < (tmpAttr.vallist).size(); ++jk) {
0539:
0540: if (ValidValue((String) (tmpAttr.vallist)
0541: .elementAt(jk))) {
0542: toWriteTo.append("\n <Value>");
0543: toWriteTo
0544: .append(AuthEquivalent((String) (tmpAttr.vallist)
0545: .elementAt(jk)));
0546: toWriteTo.append("</Value>");
0547: }
0548: }
0549: toWriteTo.append("\n </AttributeValuePair>");
0550: toWriteTo.append("\n </ModifyServiceTemplate>");
0551: toWriteTo.append("\n</OrganizationRequests>");
0552:
0553: // Register Auth Services for Non-Interactive Modules, based on
0554: // auth common name
0555: //
0556: for (int jk = 1; jk < (tmpAttr.vallist).size(); jk = jk + 2) {
0557: String commonName = (String) (tmpAttr.vallist)
0558: .elementAt(jk);
0559:
0560: try {
0561: String propsVal = authProperties
0562: .getString(commonName);
0563: toWriteTo.append(getRegisterService(propsVal,
0564: org, rootsuffix));
0565: toWriteTo
0566: .append("\n<OrganizationRequests DN=\""
0567: + constructOrgDN(org,
0568: rootsuffix) + "\">");
0569: toWriteTo
0570: .append(getCreateServiceTemplate(propsVal));
0571: toWriteTo.append("\n</OrganizationRequests>");
0572: } catch (Exception e) {
0573: continue;
0574: }
0575:
0576: }
0577:
0578: }
0579:
0580: if ((tmpAttr.name)
0581: .equalsIgnoreCase("iwtAuth-chainingModules")) {
0582: toWriteTo.append("\n<OrganizationRequests DN=\""
0583: + constructOrgDN(org, rootsuffix) + "\">");
0584: toWriteTo
0585: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
0586: String val = (String) (tmpAttr.vallist).elementAt(0);
0587: toWriteTo.append("\n <AttributeValuePair>");
0588: toWriteTo
0589: .append("\n <Attribute name=\"iplanet-am-auth-chaining-modules\"/>");
0590: toWriteTo.append("\n <Value>");
0591: toWriteTo.append(val);
0592: toWriteTo.append("</Value>");
0593: toWriteTo.append("\n </AttributeValuePair>");
0594: toWriteTo.append("\n </ModifyServiceTemplate>");
0595: toWriteTo.append("\n</OrganizationRequests>");
0596: }
0597: if ((tmpAttr.name)
0598: .equalsIgnoreCase("iwtAuth-adminAuthModule")) {
0599: toWriteTo.append("\n<OrganizationRequests DN=\""
0600: + constructOrgDN(org, rootsuffix) + "\">");
0601: toWriteTo
0602: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
0603: String val = (String) (tmpAttr.vallist).elementAt(0);
0604: if (val.equalsIgnoreCase("Ldap"))
0605: val = "LDAP";
0606: if (val.equalsIgnoreCase("Radius"))
0607: val = "RADIUS";
0608: toWriteTo.append("\n <AttributeValuePair>");
0609: toWriteTo
0610: .append("\n <Attribute name=\"iplanet-am-auth-admin-auth-module\"/>");
0611: toWriteTo.append("\n <Value>");
0612: toWriteTo.append(val);
0613: toWriteTo.append("</Value>");
0614: adminModuleToSet = val;
0615: toWriteTo.append("\n </AttributeValuePair>");
0616: toWriteTo.append("\n </ModifyServiceTemplate>");
0617: toWriteTo.append("\n</OrganizationRequests>");
0618: }
0619:
0620: if ((tmpAttr.name)
0621: .equalsIgnoreCase("iwtAuth-persistentCookieMode")) {
0622: toWriteTo.append("\n<OrganizationRequests DN=\""
0623: + constructOrgDN(org, rootsuffix) + "\">");
0624: toWriteTo
0625: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
0626: String val = (String) (tmpAttr.vallist).elementAt(0);
0627: toWriteTo.append("\n <AttributeValuePair>");
0628: toWriteTo
0629: .append("\n <Attribute name=\"iplanet-am-auth-persistent-cookie-mode\"/>");
0630: toWriteTo.append("\n <Value>");
0631: toWriteTo.append(val);
0632: toWriteTo.append("</Value>");
0633: toWriteTo.append("\n </AttributeValuePair>");
0634: toWriteTo.append("\n </ModifyServiceTemplate>");
0635: toWriteTo.append("\n</OrganizationRequests>");
0636: }
0637: if ((tmpAttr.name)
0638: .equalsIgnoreCase("iwtAuth-persistentCookieTime")) {
0639: toWriteTo.append("\n<OrganizationRequests DN=\""
0640: + constructOrgDN(org, rootsuffix) + "\">");
0641: toWriteTo
0642: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
0643: String val = (String) (tmpAttr.vallist).elementAt(0);
0644: toWriteTo.append("\n <AttributeValuePair>");
0645: toWriteTo
0646: .append("\n <Attribute name=\"iplanet-am-auth-persistent-cookie-time\"/>");
0647: toWriteTo.append("\n <Value>");
0648: toWriteTo.append(val);
0649: toWriteTo.append("</Value>");
0650: toWriteTo.append("\n </AttributeValuePair>");
0651: toWriteTo.append("\n </ModifyServiceTemplate>");
0652: toWriteTo.append("\n</OrganizationRequests>");
0653: }
0654:
0655: if ((tmpAttr.name)
0656: .equalsIgnoreCase("iwtAuth-chainingEnabled")) {
0657: toWriteTo.append("\n<OrganizationRequests DN=\""
0658: + constructOrgDN(org, rootsuffix) + "\">");
0659: toWriteTo
0660: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
0661: String val = (String) (tmpAttr.vallist).elementAt(0);
0662: toWriteTo.append("\n <AttributeValuePair>");
0663: toWriteTo
0664: .append("\n <Attribute name=\"iplanet-am-auth-chaining-enabled\"/>");
0665: toWriteTo.append("\n <Value>");
0666: toWriteTo.append(val);
0667: toWriteTo.append("</Value>");
0668: toWriteTo.append("\n </AttributeValuePair>");
0669: toWriteTo.append("\n </ModifyServiceTemplate>");
0670: toWriteTo.append("\n</OrganizationRequests>");
0671: }
0672: }
0673:
0674: return toWriteTo.toString();
0675:
0676: }
0677:
0678: static String AuthEquivalent(String val) {
0679:
0680: String authValue = new String();
0681:
0682: if (val.equalsIgnoreCase("LDAP"))
0683: authValue = "LDAP";
0684: if (val.equalsIgnoreCase("Membership"))
0685: authValue = "Membership";
0686: if (val.equalsIgnoreCase("Anonymous"))
0687: authValue = "Anonymous";
0688: if (val.equalsIgnoreCase("Cert"))
0689: authValue = "Cert";
0690: if (val.equalsIgnoreCase("RADIUS"))
0691: authValue = "RADIUS";
0692: if (val.equalsIgnoreCase("SafeWord"))
0693: authValue = "SafeWord";
0694: if (val.equalsIgnoreCase("Unix"))
0695: authValue = "Unix";
0696:
0697: return authValue;
0698: }
0699:
0700: static boolean ValidValue(String val) {
0701:
0702: boolean validAuthValue = false;
0703:
0704: if (val.equalsIgnoreCase("LDAP"))
0705: validAuthValue = true;
0706: if (val.equalsIgnoreCase("Membership"))
0707: validAuthValue = true;
0708: if (val.equalsIgnoreCase("Anonymous"))
0709: validAuthValue = true;
0710: if (val.equalsIgnoreCase("Cert"))
0711: validAuthValue = true;
0712: if (val.equalsIgnoreCase("RADIUS"))
0713: validAuthValue = true;
0714: if (val.equalsIgnoreCase("SafeWord"))
0715: validAuthValue = true;
0716: if (val.equalsIgnoreCase("Unix"))
0717: validAuthValue = true;
0718:
0719: return validAuthValue;
0720: }
0721:
0722: public static String setAnonymousAuth(Component comp, String org,
0723: String rootsuffix) throws IOException {
0724:
0725: boolean anonymousToSet = false;
0726: Attribute tmpAttr;
0727: Hashtable ht = new Hashtable();
0728: Enumeration keys;
0729: StringBuffer toWriteTo = new StringBuffer();
0730:
0731: for (int i = 0; i < (comp._attributes).size(); ++i) {
0732: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0733: if (((tmpAttr.name).indexOf("iwtAuthAnonymous")) != -1)
0734: anonymousToSet = true;
0735: }
0736:
0737: if (anonymousToSet) {
0738: toWriteTo.append("\n <OrganizationRequests DN=\""
0739: + constructOrgDN(org, rootsuffix) + "\">");
0740: toWriteTo.append("\n <RegisterServices>");
0741: toWriteTo
0742: .append("\n <Service_Name>iPlanetAMAuthAnonymousService</Service_Name>");
0743: toWriteTo.append("\n </RegisterServices>");
0744: toWriteTo.append("\n</OrganizationRequests>");
0745:
0746: toWriteTo.append("\n<OrganizationRequests DN=\""
0747: + constructOrgDN(org, rootsuffix) + "\">");
0748: toWriteTo
0749: .append(getCreateServiceTemplate("iPlanetAMAuthAnonymousService"));
0750: toWriteTo.append("\n</OrganizationRequests>");
0751:
0752: toWriteTo.append("\n<OrganizationRequests DN=\""
0753: + constructOrgDN(org, rootsuffix) + "\">");
0754: toWriteTo
0755: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthAnonymousService\" schemaType=\"Organization\">");
0756: for (int i = 0; i < (comp._attributes).size(); ++i) {
0757: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0758:
0759: if ((tmpAttr.name)
0760: .equalsIgnoreCase("iwtAuthAnonymous-maxAuthLevel")) {
0761: String val = (String) (tmpAttr.vallist)
0762: .elementAt(0);
0763: toWriteTo.append("\n <AttributeValuePair>");
0764: toWriteTo
0765: .append("\n <Attribute name=\"iplanet-am-auth-anonymous-auth-level\"/>");
0766: toWriteTo.append("\n <Value>");
0767: toWriteTo.append("\n " + val);
0768: toWriteTo.append("\n </Value>");
0769: toWriteTo.append("\n </AttributeValuePair>");
0770: }
0771: if ((tmpAttr.name)
0772: .equalsIgnoreCase("iwtAuthAnonymous-anonymousDefaultUsername")) {
0773: String val = (String) (tmpAttr.vallist)
0774: .elementAt(0);
0775: toWriteTo.append("\n <AttributeValuePair>");
0776: toWriteTo
0777: .append("\n <Attribute name=\"iplanet-am-auth-anonymous-default-user-name\"/>");
0778: toWriteTo.append("\n <Value>");
0779: toWriteTo.append("\n " + val);
0780: toWriteTo.append("\n </Value>");
0781: toWriteTo.append("\n </AttributeValuePair>");
0782: }
0783: if ((tmpAttr.name)
0784: .equalsIgnoreCase("iwtAuthAnonymous-anonymousUsers")) {
0785: String val = (String) (tmpAttr.vallist)
0786: .elementAt(0);
0787: toWriteTo.append("\n <AttributeValuePair>");
0788: toWriteTo
0789: .append("\n <Attribute name=\"iplanet-am-auth-anonymous-users-list\"/>");
0790: toWriteTo.append("\n <Value>");
0791: toWriteTo.append("\n " + val);//TO DO: Make it a list of values
0792: toWriteTo.append("\n </Value>");
0793: toWriteTo.append("\n </AttributeValuePair>");
0794: }
0795: }
0796: toWriteTo.append("\n </ModifyServiceTemplate>");
0797: toWriteTo.append("\n</OrganizationRequests>");
0798: }
0799:
0800: return toWriteTo.toString();
0801: }
0802:
0803: public static String setAuthMembershipAttrs(Component comp,
0804: String org, String rootsuffix) throws IOException {
0805:
0806: boolean membershipToSet = false;
0807: Attribute tmpAttr;
0808: Hashtable ht = new Hashtable();
0809: Enumeration keys;
0810: StringBuffer toWriteTo = new StringBuffer();
0811:
0812: for (int i = 0; i < (comp._attributes).size(); ++i) {
0813: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0814: if (((tmpAttr.name)
0815: .indexOf("iwtAuthMembership-maxAuthLevel")) != -1)
0816: membershipToSet = true;
0817: if (((tmpAttr.name).indexOf("iwtAuthMembership-password")) != -1)
0818: membershipToSet = true;
0819: }
0820:
0821: if (membershipToSet) {
0822:
0823: toWriteTo.append("\n <OrganizationRequests DN=\""
0824: + constructOrgDN(org, rootsuffix) + "\">");
0825: toWriteTo.append("\n <RegisterServices>");
0826: toWriteTo
0827: .append("\n <Service_Name>iPlanetAMAuthMembershipService</Service_Name>");
0828: toWriteTo.append("\n </RegisterServices>");
0829: toWriteTo.append("\n</OrganizationRequests>");
0830:
0831: toWriteTo.append("\n<OrganizationRequests DN=\""
0832: + constructOrgDN(org, rootsuffix) + "\">");
0833: toWriteTo
0834: .append(getCreateServiceTemplate("iPlanetAMAuthMembershipService"));
0835: toWriteTo.append("\n</OrganizationRequests>");
0836:
0837: toWriteTo.append("\n<OrganizationRequests DN=\""
0838: + constructOrgDN(org, rootsuffix) + "\">");
0839: toWriteTo
0840: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthMembershipService\" schemaType=\"Organization\">");
0841: toWriteTo.append("\n <AttributeValuePair>");
0842: toWriteTo
0843: .append("\n <Attribute name=\"iplanet-am-auth-membership-base-dn\"/>");
0844: toWriteTo.append("\n <Value>"
0845: + constructOrgDN(org, rootsuffix) + "</Value>");
0846: toWriteTo.append("\n </AttributeValuePair>");
0847:
0848: for (int i = 0; i < (comp._attributes).size(); ++i) {
0849: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0850:
0851: if ((tmpAttr.name)
0852: .equalsIgnoreCase("iwtAuthMembership-passwordLength")) {
0853: String val = (String) (tmpAttr.vallist)
0854: .elementAt(0);
0855: toWriteTo.append("\n <AttributeValuePair>");
0856: toWriteTo
0857: .append("\n <Attribute name=\"iplanet-am-auth-membership-min-password-length\"/>");
0858: toWriteTo.append("\n <Value>");
0859: toWriteTo.append(val);
0860: toWriteTo.append("</Value>");
0861: toWriteTo.append("\n </AttributeValuePair>");
0862:
0863: }
0864: if ((tmpAttr.name)
0865: .equalsIgnoreCase("iwtAuthMemberhip-maxAuthLevel")) {
0866: String val = (String) (tmpAttr.vallist)
0867: .elementAt(0);
0868: toWriteTo.append("\n <AttributeValuePair>");
0869: toWriteTo
0870: .append("\n <Attribute name=\"iplanet-am-auth-membership-auth-level\"/>");
0871: toWriteTo.append("\n <Value>");
0872: toWriteTo.append(val);
0873: toWriteTo.append("</Value>");
0874: toWriteTo.append("\n </AttributeValuePair>");
0875:
0876: }
0877:
0878: }
0879: toWriteTo.append("\n </ModifyServiceTemplate>");
0880: toWriteTo.append("\n</OrganizationRequests>");
0881: }
0882: return toWriteTo.toString();
0883:
0884: }
0885:
0886: public static String setAuthUnixAttrs(Component comp, String org,
0887: String rootsuffix) throws IOException {
0888:
0889: boolean unixToSet = false;
0890:
0891: Attribute tmpAttr;
0892: Hashtable ht = new Hashtable();
0893: Enumeration keys;
0894: StringBuffer toWriteTo = new StringBuffer();
0895:
0896: for (int i = 0; i < (comp._attributes).size(); ++i) {
0897: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0898: if (((tmpAttr.name).indexOf("iwtAuthUnix-maxAuthLevel")) != -1)
0899: unixToSet = true;
0900: }
0901:
0902: if (unixToSet) {
0903: if (adminModuleToSet.equalsIgnoreCase("unix"))
0904: adminModuleToSet = "";
0905:
0906: toWriteTo.append("\n<OrganizationRequests DN=\""
0907: + constructOrgDN(org, rootsuffix) + "\">");
0908: toWriteTo
0909: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
0910: toWriteTo.append("\n <AttributeValuePair>");
0911: toWriteTo
0912: .append("\n <Attribute name=\"iplanet-am-auth-dynamic-profile-creation\"/>");
0913: toWriteTo
0914: .append("\n <Value>" + true + "</Value>");
0915: toWriteTo.append("\n </AttributeValuePair>");
0916: toWriteTo.append("\n </ModifyServiceTemplate>");
0917: toWriteTo.append("\n</OrganizationRequests>");
0918:
0919: toWriteTo.append("\n <OrganizationRequests DN=\""
0920: + constructOrgDN(org, rootsuffix) + "\">");
0921: toWriteTo.append("\n <RegisterServices>");
0922: toWriteTo
0923: .append("\n <Service_Name>iPlanetAMAuthUnixService</Service_Name>");
0924: toWriteTo.append("\n </RegisterServices>");
0925: toWriteTo.append("\n</OrganizationRequests>");
0926:
0927: toWriteTo.append("\n<OrganizationRequests DN=\""
0928: + constructOrgDN(org, rootsuffix) + "\">");
0929: toWriteTo
0930: .append(getCreateServiceTemplate("iPlanetAMAuthUnixService"));
0931: toWriteTo.append("\n</OrganizationRequests>");
0932:
0933: toWriteTo.append("\n<OrganizationRequests DN=\""
0934: + constructOrgDN(org, rootsuffix) + "\">");
0935: toWriteTo
0936: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthUnixService\" schemaType=\"Organization\">");
0937: for (int i = 0; i < (comp._attributes).size(); ++i) {
0938: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0939:
0940: if ((tmpAttr.name)
0941: .equalsIgnoreCase("iwtAuthUnix-maxAuthLevel")) {
0942: String val = (String) (tmpAttr.vallist)
0943: .elementAt(0);
0944: toWriteTo.append("\n <AttributeValuePair>");
0945: toWriteTo
0946: .append("\n <Attribute name=\"iplanet-am-auth-unix-auth-level\"/>");
0947: toWriteTo.append("\n <Value>");
0948: toWriteTo.append(val);
0949: toWriteTo.append("</Value>");
0950: toWriteTo.append("\n </AttributeValuePair>");
0951:
0952: }
0953:
0954: }
0955: toWriteTo.append("\n </ModifyServiceTemplate>");
0956: toWriteTo.append("\n</OrganizationRequests>");
0957: }
0958:
0959: return toWriteTo.toString();
0960: }
0961:
0962: public static String setDesktopTypeAttrs(Component comp,
0963: String org, String rootsuffix) throws IOException {
0964:
0965: boolean desktopSet = false;
0966: Attribute tmpAttr;
0967: String val = "";
0968: String roleDN = "";
0969: String parentRoleDN = "";
0970:
0971: StringBuffer toWriteTo = new StringBuffer();
0972:
0973: for (int i = 0; i < (comp._attributes).size(); ++i) {
0974: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
0975:
0976: if ((tmpAttr.name).indexOf("iwtDesktop-type") >= 0) {
0977: desktopSet = true;
0978: val = (String) (tmpAttr.vallist).elementAt(0);
0979: }
0980: }
0981:
0982: if (desktopSet) {
0983:
0984: roleDN = constructRoleDN("ContainerDefaultTemplateRole",
0985: org, rootsuffix);
0986: toWriteTo.append("\n<RoleRequests DN=\""
0987: + constructRoleDN("ContainerDefaultTemplateRole",
0988: org, rootsuffix) + "\">");
0989: toWriteTo
0990: .append("\n <ModifyServiceTemplate serviceName=\"SunPortalDesktopService\" schemaType=\"Dynamic\">");
0991: toWriteTo.append("\n <AttributeValuePair>");
0992: toWriteTo
0993: .append("\n <Attribute name=\"sunPortalDesktopType\"/>");
0994: toWriteTo.append("<Value>" + val + "</Value>");
0995: toWriteTo.append("\n </AttributeValuePair>");
0996: toWriteTo.append("\n </ModifyServiceTemplate>");
0997: toWriteTo.append("\n</RoleRequests>");
0998: DesktopTypes.put(roleDN, val);
0999: } else {
1000: parentRoleDN = getParentRoleDN(org + "," + rootsuffix);
1001: if (parentRoleDN != null
1002: && DesktopTypes.containsKey(parentRoleDN)) {
1003: val = (DesktopTypes.get(parentRoleDN)).toString();
1004: roleDN = constructRoleDN(
1005: "ContainerDefaultTemplateRole", org, rootsuffix);
1006: toWriteTo.append("\n<RoleRequests DN=\""
1007: + constructRoleDN(
1008: "ContainerDefaultTemplateRole", org,
1009: rootsuffix) + "\">");
1010: toWriteTo
1011: .append("\n <ModifyServiceTemplate serviceName=\"SunPortalDesktopService\" schemaType=\"Dynamic\">");
1012: toWriteTo.append("\n <AttributeValuePair>");
1013: toWriteTo
1014: .append("\n <Attribute name=\"sunPortalDesktopType\"/>");
1015: toWriteTo.append("<Value>" + val + "</Value>");
1016: toWriteTo.append("\n </AttributeValuePair>");
1017: toWriteTo.append("\n </ModifyServiceTemplate>");
1018: toWriteTo.append("\n</RoleRequests>");
1019: DesktopTypes.put(roleDN, val);
1020: }
1021: }
1022:
1023: return toWriteTo.toString();
1024: }
1025:
1026: static String getParentRoleDN(String orgdn) {
1027:
1028: if (orgdn.indexOf(orgNaming) < 0)
1029: return null;
1030: else
1031: return new String(roleNaming
1032: + "ContainerDefaultTemplateRole"
1033: + orgdn.substring(orgdn.indexOf(orgNaming) + 2));
1034: //Returning the parent Org's dn prefixed by the Container DefaultRole
1035:
1036: }
1037:
1038: public static String setDesktopAttrs(Component comp, String org,
1039: String rootsuffix) throws IOException {
1040:
1041: /* This method basically sets the CosPriority to inherit attribute values from the Organization, in case there
1042: are no customizations at this suborg Level */
1043:
1044: boolean desktopContainer = false;
1045: int MAX_POSSIBLE_COS = 100;
1046: Attribute tmpAttr;
1047:
1048: StringBuffer toWriteTo = new StringBuffer();
1049: int prev, Idx, orgAtLevel;
1050: Idx = 0;
1051: orgAtLevel = 0;
1052:
1053: for (int i = 0; i < (comp._attributes).size(); ++i) {
1054: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
1055:
1056: if ((tmpAttr.name)
1057: .indexOf("iwtDesktop-userSelectedProviders") >= 0) {
1058: desktopContainer = true;
1059: }
1060: }
1061:
1062: if (!desktopContainer) {
1063:
1064: toWriteTo.append("\n<RoleRequests DN=\""
1065: + constructRoleDN("ContainerDefaultTemplateRole",
1066: org, rootsuffix) + "\">");
1067: toWriteTo
1068: .append("\n <ModifyServiceTemplate serviceName=\"SunPortalDesktopService\" schemaType=\"Dynamic\">");
1069: toWriteTo.append("\n <AttributeValuePair>");
1070: toWriteTo
1071: .append("\n <Attribute name=\"cospriority\"/>");
1072: while (Idx < org.length()
1073: && org.indexOf(orgNaming, Idx) != -1) {
1074: orgAtLevel++;
1075: prev = Idx;
1076: Idx = org.indexOf(orgNaming, prev + 1);
1077: if (Idx == -1)
1078: break;
1079: }
1080: toWriteTo.append("<Value>"
1081: + (MAX_POSSIBLE_COS + orgAtLevel) + "</Value>");
1082: toWriteTo.append("\n </AttributeValuePair>");
1083:
1084: toWriteTo.append("\n </ModifyServiceTemplate>");
1085: toWriteTo.append("\n</RoleRequests>");
1086: }
1087:
1088: return toWriteTo.toString();
1089: }
1090:
1091: public static String setAuthCertAttrs(Component comp, String org,
1092: String rootsuffix) throws IOException {
1093:
1094: boolean certToSet = false;
1095: Attribute tmpAttr;
1096: Hashtable ht = new Hashtable();
1097: Enumeration keys;
1098: StringBuffer toWriteTo = new StringBuffer();
1099:
1100: for (int i = 0; i < (comp._attributes).size(); ++i) {
1101: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
1102: if (((tmpAttr.name).indexOf("iwtAuthCert")) != -1)
1103: certToSet = true;
1104: }
1105:
1106: if (certToSet) {
1107: toWriteTo.append("\n <OrganizationRequests DN=\""
1108: + constructOrgDN(org, rootsuffix) + "\">");
1109: toWriteTo.append("\n <RegisterServices>");
1110: toWriteTo
1111: .append("\n <Service_Name>iPlanetAMAuthCertService</Service_Name>");
1112: toWriteTo.append("\n </RegisterServices>");
1113: toWriteTo.append("\n</OrganizationRequests>");
1114:
1115: toWriteTo.append("\n<OrganizationRequests DN=\""
1116: + constructOrgDN(org, rootsuffix) + "\">");
1117: toWriteTo
1118: .append(getCreateServiceTemplate("iPlanetAMAuthCertService"));
1119: toWriteTo.append("\n</OrganizationRequests>");
1120:
1121: toWriteTo.append("\n<OrganizationRequests DN=\""
1122: + constructOrgDN(org, rootsuffix) + "\">");
1123: toWriteTo
1124: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthCertService\" schemaType=\"Organization\">");
1125:
1126: for (int i = 0; i < (comp._attributes).size(); ++i) {
1127: tmpAttr = (Attribute) ((comp._attributes).elementAt(i));
1128:
1129: if ((tmpAttr.name)
1130: .equalsIgnoreCase("iwtAuthCert-securityType")) {
1131: String val = (String) (tmpAttr.vallist)
1132: .elementAt(0);
1133: toWriteTo.append("\n <AttributeValuePair>");
1134: toWriteTo
1135: .append("\n <Attribute name=\"iplanet-am-auth-cert-security-type\"/>");
1136: toWriteTo.append("\n <Value>");
1137: toWriteTo.append(val);
1138: toWriteTo.append("</Value>");
1139: toWriteTo.append("\n </AttributeValuePair>");
1140: }
1141: if ((tmpAttr.name)
1142: .equalsIgnoreCase("iwtAuthCert-principleUser")) {
1143: String val = (String) (tmpAttr.vallist)
1144: .elementAt(0);
1145: toWriteTo.append("\n <AttributeValuePair>");
1146: toWriteTo
1147: .append("\n <Attribute name=\"iplanet-am-auth-cert-principal-user\"/>");
1148: toWriteTo.append("\n <Value>");
1149: toWriteTo.append(val);
1150: toWriteTo.append("</Value>");
1151: toWriteTo.append("\n </AttributeValuePair>");
1152: }
1153: if ((tmpAttr.name)
1154: .equalsIgnoreCase("iwtAuthCert-useSSL")) {
1155: String val = (String) (tmpAttr.vallist)
1156: .elementAt(0);
1157: toWriteTo.append("\n <AttributeValuePair>");
1158: toWriteTo
1159: .append("\n <Attribute name=\"iplanet-am-auth-cert-use-ssl\"/>");
1160: toWriteTo.append("\n <Value>");
1161: toWriteTo.append(val);
1162: toWriteTo.append("</Value>");
1163: toWriteTo.append("\n </AttributeValuePair>");
1164: }
1165: if ((tmpAttr.name)
1166: .equalsIgnoreCase("iwtAuthCert-chkCertInLDAP")) {
1167: String val = (String) (tmpAttr.vallist)
1168: .elementAt(0);
1169: toWriteTo.append("\n <AttributeValuePair>");
1170: toWriteTo
1171: .append("\n <Attribute name=\"iplanet-am-auth-cert-check-cert-in-ldap\"/>");
1172: toWriteTo.append("\n <Value>");
1173: toWriteTo.append(val);
1174: toWriteTo.append("</Value>");
1175: toWriteTo.append("\n </AttributeValuePair>");
1176: }
1177: if ((tmpAttr.name)
1178: .equalsIgnoreCase("iwtAuthCert-ldapProviderUrl")) {
1179: String val = (String) (tmpAttr.vallist)
1180: .elementAt(0);
1181: /* ips3.0 lets prefixing of the protocol along with the server name.
1182: * On the other hand, 6.x which relies on DSAME 6.1, expects only server:host for the
1183: * Cert ldap server name.
1184: * Hence, the protocol when present needs to be trimmed off.
1185: * This is undertaken by the TrimProtocol method
1186: * */
1187: if (val != null) {
1188: val = trimProtocol(val);
1189:
1190: toWriteTo
1191: .append("\n <AttributeValuePair>");
1192: toWriteTo
1193: .append("\n <Attribute name=\"iplanet-am-auth-cert-ldap-provider-url\"/>");
1194: toWriteTo.append("\n <Value>");
1195: toWriteTo.append(val);
1196: toWriteTo.append("</Value>");
1197: toWriteTo
1198: .append("\n </AttributeValuePair>");
1199: }
1200: }
1201: if ((tmpAttr.name)
1202: .equalsIgnoreCase("iwtAuthCert-chkCRL")) {
1203: String val = (String) (tmpAttr.vallist)
1204: .elementAt(0);
1205: toWriteTo.append("\n <AttributeValuePair>");
1206: toWriteTo
1207: .append("\n <Attribute name=\"iplanet-am-auth-cert-check-crl\"/>");
1208: toWriteTo.append("\n <Value>");
1209: toWriteTo.append(val);
1210: toWriteTo.append("</Value>");
1211: toWriteTo.append("\n </AttributeValuePair>");
1212: }
1213: if ((tmpAttr.name)
1214: .equalsIgnoreCase("iwtAuthCert-startSearchLoc")) {
1215: String val = (String) (tmpAttr.vallist)
1216: .elementAt(0);
1217: toWriteTo.append("\n <AttributeValuePair>");
1218: toWriteTo
1219: .append("\n <Attribute name=\"iplanet-am-auth-cert-start-search-loc\"/>");
1220: toWriteTo.append("\n <Value>");
1221: toWriteTo.append(val);
1222: toWriteTo.append("</Value>");
1223: toWriteTo.append("\n </AttributeValuePair>");
1224: }
1225: if ((tmpAttr.name)
1226: .equalsIgnoreCase("iwtAuthCert-userProfileMapper")) {
1227: String val = (String) (tmpAttr.vallist)
1228: .elementAt(0);
1229: toWriteTo.append("\n <AttributeValuePair>");
1230: toWriteTo
1231: .append("\n <Attribute name=\"iplanet-am-auth-cert-user-profile-mapper\"/>");
1232: toWriteTo.append("\n <Value>");
1233: toWriteTo.append(val);
1234: toWriteTo.append("</Value>");
1235: toWriteTo.append("\n </AttributeValuePair>");
1236: }
1237: if ((tmpAttr.name)
1238: .equalsIgnoreCase("iwtAuthCert-ldapProfileID")) {
1239: String val = (String) (tmpAttr.vallist)
1240: .elementAt(0);
1241: toWriteTo.append("\n <AttributeValuePair>");
1242: toWriteTo
1243: .append("\n <Attribute name=\"iplanet-am-auth-cert-ldap-profile-id\"/>");
1244: toWriteTo.append("\n <Value>");
1245: toWriteTo.append(val);
1246: toWriteTo.append("</Value>");
1247: toWriteTo.append("\n </AttributeValuePair>");
1248: }
1249: if ((tmpAttr.name)
1250: .equalsIgnoreCase("iwtAuthCert-authLevelList")) {
1251: String val = (String) (tmpAttr.vallist)
1252: .elementAt(0);
1253: toWriteTo.append("\n <AttributeValuePair>");
1254: toWriteTo
1255: .append("\n <Attribute name=\"iplanet-am-auth-cert-auth-level\"/>");
1256: toWriteTo.append("\n <Value>");
1257: toWriteTo.append(val);
1258: toWriteTo.append("</Value>");
1259: toWriteTo.append("\n </AttributeValuePair>");
1260: }
1261: if ((tmpAttr.name)
1262: .equalsIgnoreCase("iwtAuthCert-principlePasswd")) {
1263: String val = (String) (tmpAttr.vallist)
1264: .elementAt(0);
1265: toWriteTo.append("\n <AttributeValuePair>");
1266: toWriteTo
1267: .append("\n <Attribute name=\"iplanet-am-auth-cert-principal-passwd\"/>");
1268: toWriteTo.append("\n <Value>");
1269: toWriteTo.append(val);
1270: toWriteTo.append("</Value>");
1271: toWriteTo.append("\n </AttributeValuePair>");
1272: }
1273:
1274: }
1275: toWriteTo.append("\n </ModifyServiceTemplate>");
1276: toWriteTo.append("\n</OrganizationRequests>");
1277: }
1278:
1279: return toWriteTo.toString();
1280: }
1281:
1282: public static String trimProtocol(String serverInfo) {
1283:
1284: if (serverInfo.indexOf("//") < 0)
1285: return serverInfo;
1286: else
1287: return serverInfo.substring(serverInfo.indexOf("//") + 2);
1288: }
1289:
1290: public static String createAuthAdminModule(String org,
1291: String rootsuffix) throws IOException {
1292:
1293: StringBuffer toWriteTo = new StringBuffer();
1294:
1295: if (adminModuleToSet.equalsIgnoreCase(""))
1296: return toWriteTo.toString();
1297: if (adminModuleToSet.equalsIgnoreCase("unix")) {
1298: toWriteTo.append("\n<OrganizationRequests DN=\""
1299: + constructOrgDN(org, rootsuffix) + "\">");
1300: toWriteTo
1301: .append("\n <ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
1302: toWriteTo.append("\n <AttributeValuePair>");
1303: toWriteTo
1304: .append("\n <Attribute name=\"iplanet-am-auth-dynamic-profile-creation\"/>");
1305: toWriteTo
1306: .append("\n <Value>" + true + "</Value>");
1307: toWriteTo.append("\n </AttributeValuePair>");
1308: toWriteTo.append("\n </ModifyServiceTemplate>");
1309: toWriteTo.append("\n</OrganizationRequests>");
1310:
1311: toWriteTo.append("\n <OrganizationRequests DN=\""
1312: + constructOrgDN(org, rootsuffix) + "\">");
1313: toWriteTo.append("\n <RegisterServices>");
1314: toWriteTo
1315: .append("\n <Service_Name>iPlanetAMAuthUnixService</Service_Name>");
1316: toWriteTo.append("\n </RegisterServices>");
1317: toWriteTo.append("\n</OrganizationRequests>");
1318:
1319: toWriteTo.append("\n<OrganizationRequests DN=\""
1320: + constructOrgDN(org, rootsuffix) + "\">");
1321: toWriteTo
1322: .append(getCreateServiceTemplate("iPlanetAMAuthUnixService"));
1323: toWriteTo.append("\n</OrganizationRequests>");
1324: }
1325:
1326: adminModuleToSet = "";
1327: return toWriteTo.toString();
1328: }
1329: }
|