001: /*
002: * $Id: NetletConvert.java,v 1.12 2003/07/04 09:20:59 mm132998 Exp $
003: * $Source: /m/portal/ps/srap/src/migration/modules/srap/ldap/Attic/NetletConvert.java,v $
004: * $Log: NetletConvert.java,v $
005: * Revision 1.12 2003/07/04 09:20:59 mm132998
006: * 3.0 -> 6.2 migration changes
007: *
008: * Revision 1.11 2003/06/20 11:39:57 mm132998
009: * Initial changes for 6.2
010: *
011: * Revision 1.8.2.2.6.2 2003/04/10 14:35:09 mm132998
012: * Bug ID : 4845550
013: *
014: * Revision 1.8.2.2.6.1 2003/04/04 09:49:12 mm132998
015: * Migration changes for 3.0 -> 6.0.1
016: *
017: * Revision 1.8.2.2 2002/11/19 11:01:47 bv131302
018: * CRT#2047 - looking for installdir
019: *
020: * Revision 1.8.2.1 2002/09/30 10:48:25 bv131302
021: * LihueRtm_branch changes
022: *
023: * Revision 1.7.2.2 2002/09/23 19:46:13 mm132998
024: * CRT #1987
025: *
026: * Revision 1.9 2002/09/23 19:44:00 mm132998
027: * CRT #1987
028: *
029: * Revision 1.8 2002/09/16 17:54:12 mm132998
030: * CRT 1972
031: *
032: * Revision 1.7.2.1 2002/09/16 17:41:43 mm132998
033: * CRT 1972
034: *
035: * Revision 1.7 2002/08/14 04:38:32 mm132998
036: * CRT : 1868 , Bugs : 4730677 ,4730681 , 4730685
037: *
038: * Revision 1.6 2002/08/13 18:25:52 mm132998
039: * CRT : 1868 , Bugs : 4730677 ,4730681 , 4730685
040: *
041: * Revision 1.5 2002/08/12 15:13:14 mm132998
042: * Bug 4719627 , 4728392
043: *
044: * Revision 1.4 2002/07/31 02:29:39 mm132998
045: * Bug fixes
046: *
047: * Revision 1.3 2002/07/29 13:00:13 mm132998
048: * Bug fixes
049: *
050: * Revision 1.2 2002/07/22 08:47:29 mm132998
051: * Bug ID - 4718198 , Desc - Initial code changes
052: *
053: *
054: */
055: /**
056: * $Id: NetletConvert.java,v 1.12 2003/07/04 09:20:59 mm132998 Exp $
057: * Copyright 2002 Sun Microsystems, Inc. All
058: * rights reserved. Use of this product is subject
059: * to license terms. Federal Acquisitions:
060: * Commercial Software -- Government Users
061: * Subject to Standard License Terms and
062: * Conditions.
063: *
064: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
065: * are trademarks or registered trademarks of Sun Microsystems,
066: * Inc. in the United States and other countries.
067: */package migration.modules.srap.ldap;
068:
069: import netscape.ldap.util.*;
070:
071: import netscape.ldap.LDAPAttribute;
072: import netscape.ldap.LDAPAttributeSet;
073:
074: import java.util.*;
075: import java.io.*;
076:
077: public class NetletConvert {
078:
079: static FileWriter outFile;
080: static String rootsuffix;
081: static LinkedList orgList = new LinkedList();
082:
083: static LinkedList defaultRules = null;
084:
085: private static final int ROLE_PROFILE = 1;
086: private static final int DOMAIN_PROFILE = 2;
087:
088: public static void main(String args[]) {
089:
090: String outputDir, ldifDir;
091:
092: ldifDir = new String();// Input file, the LDIF file to be converted....
093: outputDir = new String();
094: if (args.length == 3) {
095: // defaultRulesFile also specified.
096: loadDefaultRules(args[2]);
097: outputDir = args[1];
098: ldifDir = args[0];
099: } else if (args.length == 2) {
100: outputDir = args[1];
101: ldifDir = args[0];
102: } else if (args.length == 1) {
103: outputDir = new String("/tmp/xml");
104: ldifDir = args[0];
105: } else if (args.length == 0) {
106: System.out
107: .println("Input file to be converted not specified!");
108: System.out
109: .println("Invokation Format is:java NetletConvert ldif_directory output_dir");
110: System.exit(1);
111: }
112:
113: doConvert(ldifDir + "/domain.ldif", outputDir
114: + "/NetletOrgAttrs.xml");
115: doConvert(ldifDir + "/role.ldif", outputDir
116: + "/NetletRoleAttrs.xml");
117: dumpOrganizationList(outputDir + "/orgList");
118: dumpPolicyList(outputDir + "/NetletPolicies.xml");
119: System.exit(0);
120: }
121:
122: private static void dumpPolicyList(String fileName) {
123: try {
124: outFile = new FileWriter(fileName);
125: printHeader();
126:
127: List orgContainerList = OrgContainerParser.parse(orgList,
128: rootsuffix);
129: Iterator iter = orgContainerList.iterator();
130:
131: while (iter.hasNext()) {
132: OrgContainer org = (OrgContainer) iter.next();
133:
134: OrgContainerParser.writeReferalPolicy(outFile, org,
135: "srapNetletService", "Netlet");
136: if (!org.isDummyOrg()) {
137: // This is not a dummy root org that we added for populating referal policies.
138: // So assign the policies.
139: writePolicies(org);
140: }
141: }
142:
143: outFile.write("\n</Requests>");
144: outFile.close();
145: } catch (Exception ex) {
146: System.out
147: .println("Exception while dumping policies xml file.\n");
148: ex.printStackTrace();
149: }
150: }
151:
152: private static void writePolicies(OrgContainer org)
153: throws IOException {
154: // To create and assign the policy
155: outFile.write("<OrganizationRequests DN=\"" + org.getOrgName()
156: + "\">\n");
157: outFile.write("<CreatePolicy createDN=\"" + org.getOrgName()
158: + "\">\n");
159:
160: outFile
161: .write(" <Policy name=\"Ability to Execute SRAP Netlet\" referralPolicy=\"false\">\n");
162: outFile
163: .write(" <Rule name=\"Ability to Execute SRAP Netlet\">\n");
164: outFile
165: .write(" <ServiceName name=\"srapNetletService\"/>\n");
166: outFile.write(" <AttributeValuePair>\n");
167: outFile
168: .write(" <Attribute name=\"sunPortalNetletExecute\"/>\n");
169: outFile.write(" <Value>true</Value>\n");
170: outFile.write(" </AttributeValuePair>\n");
171: outFile.write(" </Rule>\n");
172: outFile
173: .write(" <Subjects name=\"OrgEnableNetlet\" description=\"\">\n");
174: outFile
175: .write(" <Subject name=\"OrgEnableNetlet\" type=\"Organization\">\n");
176: outFile.write(" <AttributeValuePair>\n");
177: outFile.write(" <Attribute name=\"Values\"/>\n");
178: outFile.write(" <Value>" + org.getOrgName()
179: + "</Value>\n");
180: outFile.write(" </AttributeValuePair>\n");
181: outFile.write(" </Subject>\n");
182: outFile.write(" </Subjects>\n");
183: outFile.write(" </Policy>\n");
184: outFile.write("</CreatePolicy>\n");
185: outFile.write("</OrganizationRequests>\n");
186:
187: // Create policy "Cannot Execute SRAP Netlet" - which denies users access to Netlet.
188: // Create Role which has "Cannot Execute SRAP Netlet" Policy assigned to it.
189:
190: outFile.write("\n <OrganizationRequests DN=\""
191: + org.getOrgName() + "\">\n");
192:
193: outFile
194: .write(" <CreateRole createDN=\"Netlet Denied User Role\">\n");
195: outFile.write(" <AttributeValuePair>\n");
196: outFile
197: .write(" <Attribute name=\"iplanet-am-role-description\"/>\n");
198: outFile
199: .write(" <Value>Netlet Denied User Role</Value>\n");
200: outFile.write(" </AttributeValuePair>\n");
201: outFile.write(" </CreateRole>\n");
202: outFile.write("</OrganizationRequests>\n");
203:
204: outFile.write("\n <OrganizationRequests DN=\""
205: + org.getOrgName() + "\">\n");
206: outFile.write("<CreatePolicy createDN=\"" + org.getOrgName()
207: + "\">\n");
208:
209: outFile
210: .write(" <Policy name=\"Cannot Execute SRAP Netlet\" referralPolicy=\"false\">\n");
211: outFile
212: .write(" <Rule name=\"Ability to Execute SRAP Netlet\">\n");
213: outFile
214: .write(" <ServiceName name=\"srapNetletService\"/>\n");
215: outFile.write(" <AttributeValuePair>\n");
216: outFile
217: .write(" <Attribute name=\"sunPortalNetletExecute\"/>\n");
218: outFile.write(" <Value>false</Value>\n");
219: outFile.write(" </AttributeValuePair>\n");
220: outFile.write(" </Rule>\n");
221: outFile
222: .write(" <Subjects name=\"OrgEnableNetlet\" description=\"\">\n");
223: outFile
224: .write(" <Subject name=\"OrgEnableNetlet\" type=\"Organization\">\n");
225: outFile.write(" <AttributeValuePair>\n");
226: outFile.write(" <Attribute name=\"Values\"/>\n");
227: outFile.write(" <Value>");
228: outFile.write("\"cn=Netlet Denied User Role,"
229: + org.getOrgName() + "\"");
230: outFile.write("</Value>\n");
231: outFile.write(" </AttributeValuePair>\n");
232: outFile.write(" </Subject>\n");
233: outFile.write(" </Subjects>\n");
234: outFile.write(" </Policy>\n");
235: outFile.write("</CreatePolicy>\n");
236: outFile.write("</OrganizationRequests>\n");
237: }
238:
239: private static void dumpOrganizationList(String fileName) {
240: try {
241: Iterator iter = orgList.iterator();
242: String org;
243: FileWriter orgListFile = new FileWriter(fileName);
244:
245: while (iter.hasNext()) {
246: orgListFile.write(iter.next().toString());
247: orgListFile.write("\n");
248: }
249: orgListFile.close();
250: } catch (IOException ioex) {
251: ioex.printStackTrace();
252: } catch (Exception ex) {
253: ex.printStackTrace();
254: }
255: }
256:
257: private static void loadDefaultRules(String fileName) {
258:
259: defaultRules = null;
260:
261: try {
262: LDIF l1 = new LDIF(fileName);
263:
264: LDIFRecord tmp = l1.nextRecord();
265: LDIFAttributeContent con;
266: LDAPAttribute[] attrList;
267: LDAPAttributeSet theAttrSet = null;
268:
269: while (tmp != null) {
270: if (tmp.getDN().trim().toLowerCase().indexOf(
271: "iwtnetlet") != -1) {
272: con = (LDIFAttributeContent) tmp.getContent();
273: attrList = con.getAttributes();
274: theAttrSet = new LDAPAttributeSet(attrList);
275: for (int i = 0; i < attrList.length; ++i) {
276: if (attrList[i].getName().equalsIgnoreCase(
277: "iwtNetlet-rules-at")) {
278: String[] allAttrs = (((LDAPAttribute) (theAttrSet
279: .getAttribute(attrList[i].getName())))
280: .getStringValueArray());
281: if (allAttrs.length > 1) {
282: defaultRules = new LinkedList();
283: for (int j = 1; j < allAttrs.length; j++) {
284: defaultRules.add(allAttrs[j]);
285: }
286: }
287: // Validate these entries - Basically see whether it is not empty :)
288: if (defaultRules.size() == 0) {
289: defaultRules = null;
290: } else if (defaultRules.size() == 1) {
291: if (defaultRules.iterator().next()
292: .toString().trim().length() == 0) {
293: defaultRules = null;
294: }
295: }
296: return;
297: }
298: }
299: }
300: tmp = l1.nextRecord();
301: }
302: } catch (Exception ex) {
303: }
304: }
305:
306: public static void doConvert(String ldiffile, String outputfile) {
307: LDIFRecord out;
308: int count = 0;
309: LDIF l1;
310:
311: try {
312: l1 = new LDIF(ldiffile);
313:
314: outFile = new FileWriter(outputfile);
315:
316: System.out
317: .println("Converting LDIF entries corr. to users from file:"
318: + ldiffile + ".....\n");
319:
320: LDIFRecord tmp = l1.nextRecord();
321:
322: printHeader();
323: while (tmp != null) {
324: ProcessRecord(tmp);
325: tmp = l1.nextRecord();
326: }
327: outFile.write("\n</Requests>");
328: outFile.close();
329: //System.out.println("Processed "+count+" entries");
330: System.out
331: .println("Output available in file " + outputfile);
332: } catch (Exception e) {
333: System.out.println("Error:" + e.toString());
334: e.printStackTrace();
335: }
336: }
337:
338: static void printHeader() throws Exception {
339:
340: Locale locale = Locale.getDefault();
341: ResourceBundle ambundle;
342: ambundle = ResourceBundle.getBundle("AMConfig");
343: String IDSAMEBaseDir = new String();
344:
345: if (ambundle.getObject("com.iplanet.am.rootsuffix") != null)
346: rootsuffix = (String) (ambundle
347: .getObject("com.iplanet.am.rootsuffix"));
348: if (ambundle.getObject("com.iplanet.am.installdir") != null) {
349: IDSAMEBaseDir = (String) (ambundle
350: .getObject("com.iplanet.am.installdir"));
351: IDSAMEBaseDir = IDSAMEBaseDir.substring(0, IDSAMEBaseDir
352: .indexOf("SUNWam"));
353: }
354: outFile
355: .write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
356: outFile
357: .write("\n<!-- PROPRIETARY/CONFIDENTIAL/ Use of this product is subject");
358: outFile
359: .write("\n to license terms. Copyright 2001 Sun Microsystems Inc.");
360: outFile
361: .write("Some preexisting portions Copyright 2001 Netscape");
362: outFile.write("Communications Corp. All rights reserved. -->");
363: outFile
364: .write("\n<!DOCTYPE Requests PUBLIC \"-//iPlanet//iDSAME 5.0 Admin CLI DTD//EN \" ");
365: outFile.write("\"file:" + IDSAMEBaseDir
366: + "SUNWam/dtd/amAdmin.dtd\">");
367:
368: outFile.write("\n<Requests>");
369: return;
370: }
371:
372: static void ProcessRecord(LDIFRecord toConvert) throws Exception {
373: LDIFAttributeContent con;
374: LDAPAttributeSet theAttrSet;
375: String[] allAttrs;
376: String attrName;
377: String org, profiletype, rolename, parent, dn, profileid;
378: boolean tabContainerFound = false;
379: boolean authModulesToAdd = false;
380: int count;
381:
382: boolean defaultRulesDone = false;
383:
384: String[] hostAccessAllow = null;
385: String[] hostAccessDeny = null;
386: String[] domainAccessAllow = null;
387: String[] domainAccessDeny = null;
388:
389: int profileTypeId;
390:
391: LDAPAttribute[] attrList;
392:
393: profiletype = parent = rolename = profileid = null;
394: org = getOrgName(toConvert.getDN());
395: dn = new String();
396:
397: con = (LDIFAttributeContent) toConvert.getContent();
398: attrList = con.getAttributes();
399: theAttrSet = new LDAPAttributeSet(attrList);
400:
401: for (int i = 0; i < attrList.length; ++i) {
402: if ((attrList[i].getName()).equalsIgnoreCase("profiletype")) {
403: allAttrs = (((LDAPAttribute) (theAttrSet
404: .getAttribute(attrList[i].getName())))
405: .getStringValueArray());
406: profiletype = allAttrs[0];
407: }
408: if ((attrList[i].getName()).equalsIgnoreCase("profileid")) {
409: allAttrs = (((LDAPAttribute) (theAttrSet
410: .getAttribute(attrList[i].getName())))
411: .getStringValueArray());
412: profileid = allAttrs[0];
413: }
414: if ((attrList[i].getName()).equalsIgnoreCase("cn")) {
415: allAttrs = (((LDAPAttribute) (theAttrSet
416: .getAttribute(attrList[i].getName())))
417: .getStringValueArray());
418: rolename = allAttrs[0];
419: }
420: if ((attrList[i].getName()).equalsIgnoreCase("parent")) {
421: allAttrs = (((LDAPAttribute) (theAttrSet
422: .getAttribute(attrList[i].getName())))
423: .getStringValueArray());
424: parent = allAttrs[0];
425: }
426: }
427: if (profiletype.equalsIgnoreCase("role"))
428: profileTypeId = ROLE_PROFILE;
429: else
430: profileTypeId = DOMAIN_PROFILE;
431:
432: if (profileTypeId == ROLE_PROFILE)
433: dn = ConstructDN(profileid);
434:
435: if (profileTypeId == DOMAIN_PROFILE)
436: outFile.write("\n <OrganizationRequests DN=\"o=" + org
437: + "," + rootsuffix + "\">");
438: if (profileTypeId == ROLE_PROFILE)
439: outFile.write("\n <OrganizationRequests DN=\""
440: + dn.substring(1) + "," + rootsuffix + "\">");
441: outFile.write("\n <RegisterServices>");
442: outFile
443: .write("\n <Service_Name>srapNetletService</Service_Name>");
444: outFile.write("\n </RegisterServices>");
445: outFile.write("\n </OrganizationRequests>");
446:
447: /* Creating the Service template stuff..*/
448: if (profileTypeId == DOMAIN_PROFILE)
449: outFile.write("\n <OrganizationRequests DN=\"o=" + org
450: + "," + rootsuffix + "\">");
451: if (profileTypeId == ROLE_PROFILE)
452: outFile.write("\n <OrganizationRequests DN=\""
453: + dn.substring(1) + "," + rootsuffix + "\">");
454:
455: String fqOrgDN = null;
456: if (profileTypeId == DOMAIN_PROFILE) {
457: fqOrgDN = "o=" + org + "," + rootsuffix;
458: }
459: if (profileTypeId == ROLE_PROFILE) {
460: fqOrgDN = dn.substring(1) + "," + rootsuffix;
461: }
462:
463: if (fqOrgDN != null && !orgList.contains(fqOrgDN)) {
464: orgList.add(fqOrgDN);
465: }
466:
467: //outFile.write("<CreateServiceTemplate serviceName=\"srapNetletService\"/>");
468: outFile.write("<CreateServiceTemplate>\n");
469: outFile
470: .write(" <Service_Name>srapNetletService</Service_Name>");
471: outFile.write("</CreateServiceTemplate>");
472: outFile.write("\n </OrganizationRequests>\n");
473:
474: for (int i = 0; i < attrList.length; ++i) {
475: attrName = attrList[i].getName();
476: allAttrs = (((LDAPAttribute) (theAttrSet
477: .getAttribute(attrList[i].getName())))
478: .getStringValueArray());
479:
480: /* Setting the dynamic attributes of iwtNetlet
481: * The following attributes are taken into consideration:
482: * - iwtNetlet-clientLoopbackport
483: * - iwtNetlet-portWarn
484: * - iwtNetlet-Rules
485: * - iwtNetlet-debug
486: * - iwtNetlet-access
487: * - iwtNetlet-hostAccess
488: * - iwtNetlet-domainAccess
489: * */
490:
491: if (attrName
492: .equalsIgnoreCase("iwtNetlet-clientLoopbackPort-at")) {
493: if (allAttrs.length > 1
494: && allAttrs[1].trim().length() != 0) {
495: if (profileTypeId == DOMAIN_PROFILE)
496: outFile
497: .write("\n <OrganizationRequests DN=\"o="
498: + org
499: + ","
500: + rootsuffix
501: + "\">");
502: if (profileTypeId == ROLE_PROFILE)
503: //outFile.write("\n <RoleRequests DN=\"cn="+rolename+",o="+parent.substring(1,parent.length())+","+rootsuffix+"\">");
504: outFile.write("\n <OrganizationRequests DN=\""
505: + dn.substring(1) + "," + rootsuffix
506: + "\">");
507: outFile
508: .write("\n <ModifyServiceTemplate serviceName=\"srapNetletService\" schemaType=\"Dynamic\">");
509: outFile.write("\n <AttributeValuePair>");
510: outFile
511: .write("\n <Attribute name=\"sunPortalNetletClientLoopbackPort\"/>");
512: outFile.write("\n <Value>" + allAttrs[1]);
513: outFile.write("</Value>");
514: outFile.write("\n </AttributeValuePair>");
515: outFile.write("\n </ModifyServiceTemplate>");
516: outFile.write("\n </OrganizationRequests>");
517: }
518: }
519: if (attrName.equalsIgnoreCase("iwtNetlet-portWarn-at")) {
520: if (allAttrs.length > 1
521: && allAttrs[1].trim().length() != 0) {
522: if (profileTypeId == DOMAIN_PROFILE)
523: outFile
524: .write("\n <OrganizationRequests DN=\"o="
525: + org
526: + ","
527: + rootsuffix
528: + "\">");
529: if (profileTypeId == ROLE_PROFILE)
530: //outFile.write("\n <RoleRequests DN=\"cn="+rolename+",o="+parent.substring(1,parent.length())+","+rootsuffix+"\">");
531: outFile.write("\n <OrganizationRequests DN=\""
532: + dn.substring(1) + "," + rootsuffix
533: + "\">");
534: outFile
535: .write("\n <ModifyServiceTemplate serviceName=\"srapNetletService\" schemaType=\"Dynamic\">");
536: outFile.write("\n <AttributeValuePair>");
537: outFile
538: .write("\n <Attribute name=\"sunPortalNetletPortWarn\"/>");
539: outFile.write("\n <Value>" + allAttrs[1]);
540: outFile.write("</Value>");
541: outFile.write("\n </AttributeValuePair>");
542: outFile.write("\n </ModifyServiceTemplate>");
543: outFile.write("\n </OrganizationRequests>");
544: }
545: }
546: if (attrName.equalsIgnoreCase("iwtNetlet-Rules-at")) {
547: if (allAttrs.length == 1
548: || (allAttrs.length == 2 && allAttrs[1].trim()
549: .length() == 0)) {
550: // Ignore this entry.
551: ;
552: } else {
553: if (profileTypeId == DOMAIN_PROFILE)
554: outFile
555: .write("\n <OrganizationRequests DN=\"o="
556: + org
557: + ","
558: + rootsuffix
559: + "\">");
560: if (profileTypeId == ROLE_PROFILE)
561: //outFile.write("\n <RoleRequests DN=\"cn="+rolename+",o="+parent.substring(1,parent.length())+","+rootsuffix+"\">");
562: outFile.write("\n <OrganizationRequests DN=\""
563: + dn.substring(1) + "," + rootsuffix
564: + "\">");
565: outFile
566: .write("\n <ModifyServiceTemplate serviceName=\"srapNetletService\" schemaType=\"Dynamic\">");
567: outFile.write("\n <AttributeValuePair>");
568: outFile
569: .write("\n <Attribute name=\"sunPortalNetletRules\"/>");
570: count = 1;
571: while (count < allAttrs.length) {
572: outFile.write("\n <Value>"
573: + allAttrs[count] + "</Value>");
574: count++;
575: }
576: if (defaultRules != null) {
577: Iterator iter = defaultRules.iterator();
578: defaultRulesDone = true;
579: while (iter.hasNext()) {
580: outFile.write("\n <Value>"
581: + iter.next().toString()
582: + "</Value>");
583: }
584: }
585: outFile.write("\n </AttributeValuePair>");
586: outFile.write("\n </ModifyServiceTemplate>");
587: outFile.write("\n </OrganizationRequests>");
588: }
589: }
590: if (attrName.equalsIgnoreCase("iwtNetlet-access-pv-de-")) {
591: if (allAttrs.length == 1
592: && allAttrs[0].trim().length() == 0) {
593: // Ignore entry.
594: ;
595: } else {
596: if (profileTypeId == DOMAIN_PROFILE)
597: outFile
598: .write("\n <OrganizationRequests DN=\"o="
599: + org
600: + ","
601: + rootsuffix
602: + "\">");
603: if (profileTypeId == ROLE_PROFILE)
604: //outFile.write("\n <RoleRequests DN=\"cn="+rolename+",o="+parent.substring(1,parent.length())+","+rootsuffix+"\">");
605: outFile.write("\n <OrganizationRequests DN=\""
606: + dn.substring(1) + "," + rootsuffix
607: + "\">");
608: outFile
609: .write("\n <ModifyServiceTemplate serviceName=\"srapNetletService\" schemaType=\"Dynamic\">");
610: outFile.write("\n <AttributeValuePair>");
611: outFile
612: .write("\n <Attribute name=\"sunPortalNetletDenyRules\"/>");
613: count = 0;
614: while (count < allAttrs.length) {
615: outFile.write("\n <Value>"
616: + allAttrs[count] + "</Value>");
617: count++;
618: }
619: outFile.write("\n </AttributeValuePair>");
620: outFile.write("\n </ModifyServiceTemplate>");
621: outFile.write("\n </OrganizationRequests>");
622: }
623: }
624: if (attrName.equalsIgnoreCase("iwtNetlet-access-pv-al-")) {
625: if (allAttrs.length == 1
626: && allAttrs[0].trim().length() == 0) {
627: // Ignore entry.
628: ;
629: } else {
630: if (profileTypeId == DOMAIN_PROFILE)
631: outFile
632: .write("\n <OrganizationRequests DN=\"o="
633: + org
634: + ","
635: + rootsuffix
636: + "\">");
637: if (profileTypeId == ROLE_PROFILE)
638: //outFile.write("\n <RoleRequests DN=\"cn="+rolename+",o="+parent.substring(1,parent.length())+","+rootsuffix+"\">");
639: outFile.write("\n <OrganizationRequests DN=\""
640: + dn.substring(1) + "," + rootsuffix
641: + "\">");
642: outFile
643: .write("\n <ModifyServiceTemplate serviceName=\"srapNetletService\" schemaType=\"Dynamic\">");
644: outFile.write("\n <AttributeValuePair>");
645: outFile
646: .write("\n <Attribute name=\"sunPortalNetletAccessRules\"/>");
647: count = 0;
648: while (count < allAttrs.length) {
649: outFile.write("\n <Value>"
650: + allAttrs[count] + "</Value>");
651: count++;
652: }
653: outFile.write("\n </AttributeValuePair>");
654: outFile.write("\n </ModifyServiceTemplate>");
655: outFile.write("\n </OrganizationRequests>");
656: }
657: }
658: /*
659: if(attrName.equalsIgnoreCase("iwtNetlet-hostAccess-at")){
660: if (allAttrs.length == 1 || (allAttrs.length == 2 && allAttrs[0].trim().length() == 0)){
661: // Ignore entry.
662: ;
663: }
664: else{
665: if(profileTypeId == DOMAIN_PROFILE)
666: outFile.write("\n <RoleRequests DN=\"cn=ContainerDefaultTemplateRole,o="+org+","+rootsuffix+"\">");
667: if(profileTypeId == ROLE_PROFILE)
668: //outFile.write("\n <RoleRequests DN=\"cn="+rolename+",o="+parent.substring(1,parent.length())+","+rootsuffix+"\">");
669: outFile.write("\n <RoleRequests DN=\"cn=ContainerDefaultTemplateRole"+dn+","+rootsuffix+"\">");
670: outFile.write("\n <ModifyServiceTemplate serviceName=\"srapNetletService\" schemaType=\"Dynamic\">");
671: outFile.write("\n <AttributeValuePair>");
672: outFile.write("\n <Attribute name=\"iplanet-srap-netlet-host-access\"/>");
673: outFile.write("\n <Value>"+allAttrs[1]);
674: outFile.write("</Value>");
675: outFile.write("\n </AttributeValuePair>");
676: outFile.write("\n </ModifyServiceTemplate>");
677: outFile.write("\n </RoleRequests>");
678: }
679: }
680: */
681: if (attrName
682: .equalsIgnoreCase("iwtNetlet-hostAccess-pv-al-")) {
683: hostAccessAllow = allAttrs;
684: }
685: if (attrName
686: .equalsIgnoreCase("iwtNetlet-hostAccess-pv-de-")) {
687: hostAccessDeny = allAttrs;
688: }
689: /*
690: if(attrName.equalsIgnoreCase("iwtNetlet-domainAccess-at")){
691: if (allAttrs.length == 1 && allAttrs[0].trim().length() == 0){
692: // Ignore entry.
693: ;
694: }
695: else{
696: if(profileTypeId == DOMAIN_PROFILE)
697: outFile.write("\n <RoleRequests DN=\"cn=ContainerDefaultTemplateRole,o="+org+","+rootsuffix+"\">");
698: if(profileTypeId == ROLE_PROFILE)
699: //outFile.write("\n <RoleRequests DN=\"cn="+rolename+",o="+parent.substring(1,parent.length())+","+rootsuffix+"\">");
700: outFile.write("\n <RoleRequests DN=\"cn=ContainerDefaultTemplateRole"+dn+","+rootsuffix+"\">");
701: outFile.write("\n <ModifyServiceTemplate serviceName=\"srapNetletService\" schemaType=\"Dynamic\">");
702: outFile.write("\n <AttributeValuePair>");
703: outFile.write("\n <Attribute name=\"iplanet-srap-netlet-domain-access\"/>");
704: outFile.write("\n <Value>"+allAttrs[1]);
705: outFile.write("</Value>");
706: outFile.write("\n </AttributeValuePair>");
707: outFile.write("\n </ModifyServiceTemplate>");
708: outFile.write("\n </RoleRequests>");
709: }
710: }
711: */
712: if (attrName
713: .equalsIgnoreCase("iwtNetlet-domainAccess-pv-al-")) {
714: domainAccessAllow = allAttrs;
715: }
716:
717: if (attrName
718: .equalsIgnoreCase("iwtNetlet-domainAccess-pv-de-")) {
719: domainAccessDeny = allAttrs;
720: }
721: /*
722: if(attrName.equalsIgnoreCase("iwtNetlet-debug-at")){
723: if (allAttrs.length == 1 && allAttrs[0].trim().length() == 0){
724: // Ignore entry.
725: ;
726: }
727: else{
728: if(profileTypeId == DOMAIN_PROFILE)
729: outFile.write("\n <RoleRequests DN=\"cn=ContainerDefaultTemplateRole,o="+org+","+rootsuffix+"\">");
730: if(profileTypeId == ROLE_PROFILE)
731: //outFile.write("\n <RoleRequests DN=\"cn="+rolename+",o="+parent.substring(1,parent.length())+","+rootsuffix+"\">");
732: outFile.write("\n <RoleRequests DN=\"cn=ContainerDefaultTemplateRole"+dn+","+rootsuffix+"\">");
733: outFile.write("\n <ModifyServiceTemplate serviceName=\"srapNetletService\" schemaType=\"Dynamic\">");
734: outFile.write("\n <AttributeValuePair>");
735: outFile.write("\n <Attribute name=\"iplanet-srap-netlet-debug\"/>");
736: outFile.write("\n <Value>"+allAttrs[1]);
737: outFile.write("</Value>");
738: outFile.write("\n </AttributeValuePair>");
739: outFile.write("\n </ModifyServiceTemplate>");
740: outFile.write("\n </RoleRequests>");
741: }
742: }
743: */
744: }
745: // Now combine the domainAccess and hostAccess attributes into the new
746: // sunPortalNetletAccessHosts attribute
747: if (hostAccessAllow != null && hostAccessAllow.length == 1) {
748: if (hostAccessAllow[0].trim().length() == 0) {
749: hostAccessAllow = null;
750: }
751: }
752: if (domainAccessAllow != null && domainAccessAllow.length == 1) {
753: if (domainAccessAllow[0].trim().length() == 0) {
754: domainAccessAllow = null;
755: }
756: }
757: if (hostAccessDeny != null && hostAccessDeny.length == 1) {
758: if (hostAccessDeny[0].trim().length() == 0) {
759: hostAccessDeny = null;
760: }
761: }
762: if (domainAccessDeny != null && domainAccessDeny.length == 1) {
763: if (domainAccessDeny[0].trim().length() == 0) {
764: domainAccessDeny = null;
765: }
766: }
767: if (hostAccessAllow != null || domainAccessAllow != null) {
768: if (profileTypeId == DOMAIN_PROFILE)
769: outFile.write("\n <OrganizationRequests DN=\"o=" + org
770: + "," + rootsuffix + "\">");
771: if (profileTypeId == ROLE_PROFILE)
772: //outFile.write("\n <RoleRequests DN=\"cn="+rolename+",o="+parent.substring(1,parent.length())+","+rootsuffix+"\">");
773: outFile.write("\n <OrganizationRequests DN=\""
774: + dn.substring(1) + "," + rootsuffix + "\">");
775: outFile
776: .write("\n <ModifyServiceTemplate serviceName=\"srapNetletService\" schemaType=\"Dynamic\">");
777: outFile.write("\n <AttributeValuePair>");
778: outFile
779: .write("\n <Attribute name=\"sunPortalNetletAccessHosts\"/>");
780: if (hostAccessAllow != null) {
781: count = 0;
782: while (count < hostAccessAllow.length) {
783: outFile.write("\n <Value>"
784: + hostAccessAllow[count] + "</Value>");
785: count++;
786: }
787: }
788: if (domainAccessAllow != null) {
789: count = 0;
790: while (count < domainAccessAllow.length) {
791: outFile.write("\n <Value>*."
792: + domainAccessAllow[count] + "</Value>");
793: count++;
794: }
795: }
796: outFile.write("\n </AttributeValuePair>");
797: outFile.write("\n </ModifyServiceTemplate>");
798: outFile.write("\n </OrganizationRequests>");
799: }
800: if (hostAccessDeny != null || domainAccessDeny != null) {
801: if (profileTypeId == DOMAIN_PROFILE)
802: outFile.write("\n <OrganizationRequests DN=\"o=" + org
803: + "," + rootsuffix + "\">");
804: if (profileTypeId == ROLE_PROFILE)
805: //outFile.write("\n <RoleRequests DN=\"cn="+rolename+",o="+parent.substring(1,parent.length())+","+rootsuffix+"\">");
806: outFile.write("\n <OrganizationRequests DN=\""
807: + dn.substring(1) + "," + rootsuffix + "\">");
808: outFile
809: .write("\n <ModifyServiceTemplate serviceName=\"srapNetletService\" schemaType=\"Dynamic\">");
810: outFile.write("\n <AttributeValuePair>");
811: outFile
812: .write("\n <Attribute name=\"sunPortalNetletDenyHosts\"/>");
813: if (hostAccessDeny != null) {
814: count = 0;
815: while (count < hostAccessDeny.length) {
816: outFile.write("\n <Value>"
817: + hostAccessDeny[count] + "</Value>");
818: count++;
819: }
820: }
821: if (domainAccessDeny != null) {
822: count = 0;
823: while (count < domainAccessDeny.length) {
824: outFile.write("\n <Value>*."
825: + domainAccessDeny[count] + "</Value>");
826: count++;
827: }
828: }
829: outFile.write("\n </AttributeValuePair>");
830: outFile.write("\n </ModifyServiceTemplate>");
831: outFile.write("\n </OrganizationRequests>");
832: }
833: if (!defaultRulesDone && defaultRules != null) {
834: if (profileTypeId == DOMAIN_PROFILE)
835: outFile.write("\n <OrganizationRequests DN=\"o=" + org
836: + "," + rootsuffix + "\">");
837: if (profileTypeId == ROLE_PROFILE)
838: //outFile.write("\n <RoleRequests DN=\"cn="+rolename+",o="+parent.substring(1,parent.length())+","+rootsuffix+"\">");
839: outFile.write("\n <OrganizationRequests DN=\""
840: + dn.substring(1) + "," + rootsuffix + "\">");
841: outFile
842: .write("\n <ModifyServiceTemplate serviceName=\"srapNetletService\" schemaType=\"Dynamic\">");
843: outFile.write("\n <AttributeValuePair>");
844: outFile
845: .write("\n <Attribute name=\"sunPortalNetletRules\"/>");
846:
847: Iterator iter = defaultRules.iterator();
848: while (iter.hasNext()) {
849: outFile.write("\n <Value>"
850: + iter.next().toString() + "</Value>");
851: }
852: outFile.write("\n </AttributeValuePair>");
853: outFile.write("\n </ModifyServiceTemplate>");
854: outFile.write("\n </OrganizationRequests>");
855: }
856: return;
857: }
858:
859: static String getOrgName(String dn) {
860: String orgName = new String();
861:
862: orgName = dn.substring(3, dn.indexOf(","));
863: return orgName;
864: }
865:
866: static String ConstructDN(String roleFileName) {
867: String rolename;
868: String tmp;
869: String dnToRet;//The DN to be returned
870:
871: // Given the relative path of the current file. This function constructs the DN of the required Role i.e SUbORganization..*
872:
873: dnToRet = new String();
874: tmp = roleFileName;
875: while (tmp.indexOf("/") >= 0) {
876: dnToRet += ",o=" + tmp.substring(tmp.lastIndexOf("/") + 1);
877: tmp = tmp.substring(0, tmp.lastIndexOf("/"));
878: }
879:
880: return dnToRet;
881: }
882: }
|