Source Code Cross Referenced for RoleConvert.java in  » Portal » Open-Portal » migration » modules » ldap » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » migration.modules.ldap 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package migration.modules.ldap;
002:
003:        import java.util.*;
004:        import java.io.*;
005:        import org.xml.sax.SAXException;
006:
007:        import com.iplanet.portalserver.parser.*; //import com.sun.portal.profile.service.*;
008:        import com.iplanet.portalserver.profile.impl.*;
009:        import com.iplanet.portalserver.profile.share.ProfileBundle;
010:        import netscape.ldap.*;
011:
012:        public class RoleConvert extends CommonXml {
013:            private static ResourceBundle bundle = null;
014:            private static String DeployUri = "/portal";
015:
016:            /* General syntax:
017:
018:            This module is necessary in the event of having to create suborganizations corresponding to each role.
019:            The design decision has been taken given the issue of subroles.
020:
021:             */
022:            static public void main(String[] args) {
023:                String ptypeToConvert, fromFile, outFile, dirname;
024:                String localeString = new String();
025:                Locale locale;
026:
027:                localeString = null;
028:                if (System.getProperty("LOCALE_STRING") != null)
029:                    localeString = System.getProperty("LOCALE_STRING");
030:
031:                if (localeString == null)
032:                    locale = Locale.getDefault();
033:                else
034:                    locale = getLocale(localeString);
035:
036:                bundle = ResourceBundle.getBundle("psMigrationLdap", locale);
037:
038:                ptypeToConvert = args[0];
039:                fromFile = args[1];
040:                outFile = args[2];
041:
042:                getNamingAttributes(System.getProperty("IMPORT_DIR"));
043:                getAMConfigProperties();
044:
045:                //System.out.println("Conversion from  "+fromFile+" to file "+outFile);
046:                if (ptypeToConvert.equalsIgnoreCase("allRoles")) {
047:                    dirname = args[1];
048:                    convertAllRoles(dirname, outFile);
049:                }
050:
051:                try {
052:                    if (ptypeToConvert.equalsIgnoreCase("role"))
053:                        convertRole(fromFile, outFile);
054:                } catch (Exception e) {
055:                    System.out.println("Error occured in conversion of role:"
056:                            + fromFile);
057:                    e.printStackTrace();
058:                    System.exit(1);
059:                }
060:
061:            }
062:
063:            static void convertRole(String infile, String outfile)
064:                    throws Exception {
065:                File roleFile = new File(infile);
066:                OutputStreamWriter toWriteTo;
067:
068:                String rolename, dn;
069:                int indent = 1;
070:                if (roleFile.isFile() == false) {
071:                    System.out.println("Specific role filename to be given.");
072:                    System.exit(1);
073:                }
074:                //System.out.println("outfile.."+outfile);
075:                try {
076:                    toWriteTo = new OutputStreamWriter(new FileOutputStream(
077:                            outfile), "UTF-8");
078:                } catch (FileNotFoundException fe) {
079:
080:                    //System.out.println("Is this the directory..."+outfile.substring(0,outfile.lastIndexOf("/")));
081:                    try {
082:                        File fl1 = new File(outfile.substring(0, outfile
083:                                .lastIndexOf("/")));
084:                        fl1.mkdirs();
085:                        toWriteTo = new OutputStreamWriter(
086:                                new FileOutputStream(outfile), "UTF-8");
087:                    } catch (Exception ee) {
088:                        ee.printStackTrace();
089:                    }
090:                    toWriteTo = new OutputStreamWriter(new FileOutputStream(
091:                            outfile), "UTF-8");
092:                }
093:                printHeader(toWriteTo);
094:                toWriteTo.write("\n<Requests>");
095:
096:                indent++;
097:                doIndent(toWriteTo, indent);
098:                toWriteTo.write("<OrganizationRequests DN=\"" + rootsuffix
099:                        + "\">");
100:                //System.out.println("Rolename..."+roleList[i]);
101:                String roleFileName = roleFile.toString();
102:                //String trueOrgName = orgName.substring(orgName.lastIndexOf("/")+1,orgName.length());
103:                indent = 2;
104:                doIndent(toWriteTo, indent);
105:
106:                rolename = roleFileName.substring(
107:                        roleFileName.lastIndexOf("/") + 1, roleFileName
108:                                .length() - 4);
109:
110:                //System.out.println("looking at:"+rolename+"in ..."+roleFileName);
111:                dn = ConstructDN(roleFileName);
112:                //System.out.println("This is the dn..."+dn);
113:                toWriteTo.write("<CreateSubOrganization createDN=\"" + dn
114:                        + "\">");
115:
116:                Component comp = GetComponent(roleFileName);
117:                comp._compname = rolename;
118:
119:                /*Privilege tmpPr;
120:                Vector tmpValues;
121:                Enumeration keys;
122:                Hashtable ht=new Hashtable();
123:                for(int j=0; j<(comp._privileges).size();++j){
124:                	tmpPr=(Privilege)((comp._privileges).elementAt(j));
125:                	//System.out.println("Name is:"+tmpPr.name);
126:                	if((tmpPr.name).startsWith("iwt"))
127:                		 break; // Ignoring attributes as in iwtPlatform
128:                						// as they don't have equiv in hana...
129:                	keys= tmpPr._atts.keys();
130:                	while (keys.hasMoreElements()) {
131:
132:                		String key = (String) keys.nextElement();
133:                		if (Element.mapper.get(key) != null){
134:                			indent++;doIndent(toWriteTo,indent);
135:                			ht.put(tmpPr.name+Element.PRIVPREFIX+Element.mapper.get(key),tmpPr._atts.get(key));
136:                			toWriteTo.write("<AttributeValuePair>");
137:                			indent++;doIndent(toWriteTo,indent);
138:                			toWriteTo.write("<Attribute name=\""+tmpPr.name+"\"/>");
139:                			toWriteTo.write("<Value>");
140:                			//tmpValues=(Vector)tmpPr._atts.get(key);
141:                			//System.out.println("Size is:"+(tmpPr._atts.get(key)).getClass());
142:
143:                			if(((tmpPr._atts.get(key)).getClass())==(new String()).getClass())
144:                				toWriteTo.write(tmpPr._atts.get(key).toString());
145:
146:                			else {
147:                 *//* System.out.println((tmpPr._atts.get(key)).getClass());
148:                		 for(int m=0;m<((Vector)(tmpPr._atts.get(key))).size();++m)
149:                			System.out.print(((Vector)(tmpPr._atts.get(key))).elementAt(m));*/
150:
151:                /*		}
152:                		toWriteTo.write("</Value>");
153:                		indent--;doIndent(toWriteTo,indent);
154:                		toWriteTo.write("</AttributeValuePair>");
155:                		indent--;doIndent(toWriteTo,indent);
156:                	}
157:                }
158:                }
159:                indent--;*/
160:                doIndent(toWriteTo, indent);
161:                toWriteTo.write("</CreateSubOrganization>");
162:
163:                indent--;
164:                doIndent(toWriteTo, indent);
165:                toWriteTo.write("</OrganizationRequests>");
166:                doIndent(toWriteTo, indent);
167:                dn = ConstructDN(roleFileName);
168:                appendDesktopService(toWriteTo, dn);
169:                toWriteTo.write(SetServiceValues.setAuthAttrs(comp, dn,
170:                        rootsuffix));
171:                toWriteTo.write(SetServiceValues.setLdapAuthAttrs(hostname,
172:                        comp, dn, rootsuffix));
173:                toWriteTo.write(SetServiceValues.setRadiusAuthAttrs(comp, dn,
174:                        rootsuffix));
175:                toWriteTo.write(SetServiceValues.setSafewordAuth(comp, dn,
176:                        rootsuffix));
177:                toWriteTo.write(SetServiceValues.setAnonymousAuth(comp, dn,
178:                        rootsuffix));
179:                toWriteTo.write(SetServiceValues.setAuthMembershipAttrs(comp,
180:                        dn, rootsuffix));
181:                toWriteTo.write(SetServiceValues.setAuthCertAttrs(comp, dn,
182:                        rootsuffix));
183:                toWriteTo.write(SetServiceValues.setAuthUnixAttrs(comp, dn,
184:                        rootsuffix));
185:                toWriteTo.write(SetServiceValues.createAuthAdminModule(dn,
186:                        rootsuffix));
187:
188:                SetServiceValues.initHashTable(outfile.substring(0, outfile
189:                        .indexOf("xml/role"))
190:                        + "xml/org/.desktypes_orgs");
191:                toWriteTo.write(SetServiceValues.setDesktopTypeAttrs(comp, dn,
192:                        rootsuffix));
193:
194:                SetServiceValues.writeHashTable(outfile.substring(0, outfile
195:                        .indexOf("xml/role"))
196:                        + "xml/org/.desktypes_orgs");
197:                indent--;
198:                doIndent(toWriteTo, indent);
199:                toWriteTo.write("</Requests>\n");
200:                toWriteTo.close();
201:
202:            }
203:
204:            static void convertAllRoles(String dir, String outfile) {
205:                File currDir = new File(dir);
206:                OutputStreamWriter toWriteTo;
207:                int indent = 0;
208:
209:                String[] orgsList1, orgsList2;
210:
211:                if (currDir.isDirectory() == false) {
212:                    System.out
213:                            .println("Error: File name specified. Need to specify the name of the directory where the role files are located");
214:                    System.exit(1);
215:                }
216:                try {
217:                    //System.out.println("outfile.."+outfile);
218:                    try {
219:                        toWriteTo = new OutputStreamWriter(
220:                                new FileOutputStream(outfile), "UTF-8");
221:                    } catch (FileNotFoundException fe) {
222:
223:                        //System.out.println("Is this the directory..."+outfile.substring(0,outfile.lastIndexOf("/")));
224:                        try {
225:                            File fl1 = new File(outfile.substring(0, outfile
226:                                    .lastIndexOf("/")));
227:                            fl1.mkdirs();
228:                            toWriteTo = new OutputStreamWriter(
229:                                    new FileOutputStream(outfile), "UTF-8");
230:                        } catch (Exception ee) {
231:                            ee.printStackTrace();
232:                        }
233:                        toWriteTo = new OutputStreamWriter(
234:                                new FileOutputStream(outfile), "UTF-8");
235:                    }
236:                    printHeader(toWriteTo);
237:                    toWriteTo.write("\n<Requests>");
238:
239:                    indent++;
240:                    doIndent(toWriteTo, indent);
241:                    toWriteTo.write("<OrganizationRequests DN=\"" + rootsuffix
242:                            + "\">");
243:                    //orgsList=currDir.list();
244:                    //System.out.println("This is the file.."+dir);
245:                    orgsList1 = (new File(dir)).list();
246:                    for (int i = 0; i < orgsList1.length; i++) {
247:                        //System.out.println("value..."+orgsList1[i]);
248:                        //if((new File(orgsList1[i])).isFile()){
249:                        //System.out.println("Filename:"+orgsList1[i]);
250:                        indent++;
251:                        doIndent(toWriteTo, indent);
252:                        WriteRolesToFile(dir + "/" + orgsList1[i], toWriteTo);
253:                        //}
254:                    }
255:                    /* orgsList2=(new File(dir)).list();
256:                    for(int i=0;i<orgsList2.length;i++){
257:                    	System.out.println("value..."+orgsList2[i]);
258:                    	if((new File(orgsList2[i])).isDirectory()){
259:                    		//System.out.println("Filename:"+orgsList2[i]);
260:                    		indent++;doIndent(toWriteTo,indent);
261:                    		WriteRolesToFile(dir+"/"+orgsList2[i],toWriteTo);
262:                    	}
263:                    }*/
264:                    indent--;
265:                    indent--;
266:                    doIndent(toWriteTo, indent);
267:                    toWriteTo.write("</OrganizationRequests>");
268:                    doIndent(toWriteTo, indent);
269:                    for (int i = 0; i < orgsList1.length; ++i) {
270:                        //indent++;doIndent(toWriteTo,indent);
271:                        createRoleTemplates(dir + "/" + orgsList1[i], toWriteTo);
272:                        //indent--;doIndent(toWriteTo,indent);
273:                    }
274:                    indent--;
275:                    doIndent(toWriteTo, indent);
276:                    toWriteTo.write("</Requests>\n");
277:                    toWriteTo.close();
278:                } catch (Exception e) {
279:                    System.out.println("Error listing the directory!");
280:                    e.printStackTrace();
281:                }
282:                /* catch(IOException ie){
283:                System.out.println("Error opening file :"+outfile);
284:                ie.printStackTrace();
285:                }*/
286:
287:            }
288:
289:            static void createRoleTemplates(String orgName,
290:                    OutputStreamWriter toWriteTo) throws Exception {
291:                Object[] roleList;
292:                File currOrg;
293:                int indent;
294:                String rolename;
295:
296:                currOrg = new File(orgName);
297:
298:                if (currOrg.isDirectory() == false) {
299:                    System.out.println("Ignoring " + orgName
300:                            + ": Not a directory");
301:                    return;
302:                }
303:
304:                roleList = getRecursiveFilelist(currOrg).toArray();
305:
306:                for (int i = 0; i < roleList.length; i++) {
307:                    File roleFile = (File) roleList[i];
308:                    String roleFileName = roleFile.toString();
309:
310:                    String dn;
311:
312:                    dn = ConstructDN(roleFileName);
313:                    appendDesktopService(toWriteTo, dn);
314:
315:                }
316:
317:            }
318:
319:            static void WriteRolesToFile(String orgName,
320:                    OutputStreamWriter toWriteTo) {
321:                Object[] roleList;
322:                File currOrg;
323:                int indent;
324:                String rolename;
325:                String dn;
326:
327:                currOrg = new File(orgName);
328:
329:                if (currOrg.isDirectory() == false) {
330:                    System.out.println("Ignoring " + orgName
331:                            + ": Not a directory");
332:                    return;
333:                }
334:
335:                roleList = getRecursiveFilelist(currOrg).toArray();
336:                try {
337:                    for (int i = 0; i < roleList.length; i++) {
338:                        File roleFile = (File) roleList[i];
339:                        //System.out.println("Rolename..."+roleList[i]);
340:                        String roleFileName = roleFile.toString();
341:                        String trueOrgName = orgName.substring(orgName
342:                                .lastIndexOf("/") + 1, orgName.length());
343:                        indent = 2;
344:                        doIndent(toWriteTo, indent);
345:
346:                        rolename = roleFileName.substring(roleFileName
347:                                .lastIndexOf("/") + 1,
348:                                roleFileName.length() - 4);
349:
350:                        //System.out.println("looking at:"+rolename+"in ..."+roleFileName);
351:                        dn = ConstructDN(roleFileName);
352:                        //System.out.println("This is the dn..."+dn);
353:                        toWriteTo.write("<CreateSubOrganization createDN=\""
354:                                + dn + "\">");
355:
356:                        Component comp = GetComponent(roleFileName);
357:                        comp._compname = rolename;
358:
359:                        /*Privilege tmpPr;
360:                        Vector tmpValues;
361:                        Enumeration keys;
362:                        Hashtable ht=new Hashtable();
363:                        for(int j=0; j<(comp._privileges).size();++j){
364:                        	tmpPr=(Privilege)((comp._privileges).elementAt(j));
365:                        	//System.out.println("Name is:"+tmpPr.name);
366:                        	if((tmpPr.name).startsWith("iwt"))
367:                        		 break; // Ignoring attributes as in iwtPlatform
368:                        						// as they don't have equiv in hana...
369:                        	keys= tmpPr._atts.keys();
370:                        	while (keys.hasMoreElements()) {
371:
372:                        		String key = (String) keys.nextElement();
373:                        		if (Element.mapper.get(key) != null){
374:                        			indent++;doIndent(toWriteTo,indent);
375:                        			ht.put(tmpPr.name+Element.PRIVPREFIX+Element.mapper.get(key),tmpPr._atts.get(key));
376:                        			toWriteTo.write("<AttributeValuePair>");
377:                        			indent++;doIndent(toWriteTo,indent);
378:                        			toWriteTo.write("<Attribute name=\""+tmpPr.name+"\"/>");
379:                        			toWriteTo.write("<Value>");
380:                        			//tmpValues=(Vector)tmpPr._atts.get(key);
381:                        			//System.out.println("Size is:"+(tmpPr._atts.get(key)).getClass());
382:
383:                        			if(((tmpPr._atts.get(key)).getClass())==(new String()).getClass())
384:                        				toWriteTo.write(tmpPr._atts.get(key).toString());
385:
386:                        			else {
387:                         *//* System.out.println((tmpPr._atts.get(key)).getClass());
388:                        		 for(int m=0;m<((Vector)(tmpPr._atts.get(key))).size();++m)
389:                        			System.out.print(((Vector)(tmpPr._atts.get(key))).elementAt(m));*/
390:
391:                        /*		}
392:                        		toWriteTo.write("</Value>");
393:                        		indent--;doIndent(toWriteTo,indent);
394:                        		toWriteTo.write("</AttributeValuePair>");
395:                        		indent--;doIndent(toWriteTo,indent);
396:                        	}
397:                        }
398:                        }
399:                        indent--;*/
400:                        doIndent(toWriteTo, indent);
401:                        toWriteTo.write("</CreateSubOrganization>");
402:
403:                    }
404:                } catch (Exception e) {
405:                    e.printStackTrace();
406:                }
407:
408:                return;
409:            }
410:
411:            static String ConstructDN(String roleFileName) {
412:                String rolename;
413:                String tmp;
414:                String dnToRet;//The DN to be returned
415:
416:                // Given the relative path of the current file. This function constructs the DN of the required Role i.e SUbORganization..*
417:
418:                //System.out.println("PAth:"+roleFileName);
419:                rolename = roleFileName.substring(
420:                        roleFileName.lastIndexOf("/") + 1, roleFileName
421:                                .length() - 4);
422:                dnToRet = rolename;
423:                tmp = roleFileName.substring(roleFileName.indexOf("role") + 4,
424:                        roleFileName.lastIndexOf("/"));
425:                //System.out.println("Temp:"+tmp);
426:                while (tmp.indexOf("/") >= 0) {
427:                    //System.out.println("Temp:"+tmp);
428:                    dnToRet += "," + orgNaming
429:                            + tmp.substring(tmp.lastIndexOf("/") + 1);
430:                    tmp = tmp.substring(0, tmp.lastIndexOf("/"));
431:                }
432:
433:                //System.out.println("To return:"+dnToRet);
434:                return dnToRet;
435:            }
436:
437:            public static Component GetComponent(String filename)
438:                    throws Exception {
439:                WebtopParser wp = new WebtopParser();
440:                wp.register(Element.COMPONENT_E,
441:                        "migration.modules.ldap.Component");
442:
443:                wp.register(Element.ATT_E, "migration.modules.ldap.Attribute");
444:                wp.register(Element.PRIV_E, "migration.modules.ldap.Privilege");
445:                wp.register(Element.VALUELIST, "migration.modules.ldap.List");
446:                wp.register(Element.DENYLIST, "migration.modules.ldap.List");
447:                wp.register(Element.ALLOWLIST, "migration.modules.ldap.List");
448:                wp.register(Element.CHOICEVALUE, "migration.modules.ldap.List");
449:                wp.register(Element.READPERM, "migration.modules.ldap.List");
450:                wp.register(Element.WRITEPERM, "migration.modules.ldap.List");
451:                wp.register(Element.VALUELISTN, "migration.modules.ldap.List");
452:                wp.register(Element.DENYLISTN, "migration.modules.ldap.List");
453:                wp.register(Element.ALLOWLISTN, "migration.modules.ldap.List");
454:                wp
455:                        .register(Element.CHOICEVALUEN,
456:                                "migration.modules.ldap.List");
457:                wp.register(Element.READPERMN, "migration.modules.ldap.List");
458:                wp.register(Element.WRITEPERMN, "migration.modules.ldap.List");
459:                wp.register("Component", "com.sun.portal.psadmin.AppComponent");
460:                wp.register("Attributes",
461:                        "com.iplanet.portalserver.parser.GenericNode");
462:                wp.register("Privileges",
463:                        "com.iplanet.portalserver.parser.GenericNode");
464:                wp.register("Attribute", "com.sun.portal.psadmin.AppAttribute");
465:                wp.register("Privilege", "com.sun.portal.psadmin.AppPrivilege");
466:                return (Component) wp.parse(createTmpWithComponent(filename));
467:            }
468:
469:            public static void printHeader(OutputStreamWriter fw)
470:                    throws IOException {
471:
472:                if (System.getProperty("DEPLOY_URI") != null)
473:                    DeployUri = System.getProperty("DEPLOY_URI");
474:
475:                fw.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
476:                fw
477:                        .write("\n<!--  PROPRIETARY/CONFIDENTIAL/ Use of this product is subject");
478:                fw
479:                        .write("\n to license terms. Copyright 2001 Sun Microsystems Inc.");
480:                fw.write("Some preexisting portions Copyright 2001 Netscape");
481:                fw.write("Communications Corp. All rights reserved. -->");
482:                fw
483:                        .write("\n<!DOCTYPE Requests PUBLIC \"-//Sun ONE//iDSAME 5.0 Admin CLI DTD//EN \" ");
484:                fw.write("\"file:" + IDSAMEBaseDir + "/dtd/amAdmin.dtd\">");
485:
486:                return;
487:            }
488:
489:            static void doIndent(OutputStreamWriter fw, int count)
490:                    throws IOException {
491:
492:                fw.write("\n");
493:                for (int i = 0; i < count; ++i)
494:                    fw.write("  ");
495:            }
496:
497:            static FileInputStream createTmpWithComponent(String infile)
498:                    throws Exception {
499:                try {
500:                    FileInputStream in = new FileInputStream(infile);
501:                    File tmp = File.createTempFile("wt1234", "xml", new File(
502:                            "/tmp"));
503:                    tmp.deleteOnExit();
504:                    FileOutputStream out = new FileOutputStream(tmp);
505:                    String compstuff = "<iwt:Component name=\"" + infile
506:                            + "\" >\n";
507:                    out.write(compstuff.getBytes());
508:                    byte[] bb = new byte[100];
509:                    int len = 0;
510:                    while ((len = in.read(bb)) != -1) {
511:                        out.write(bb, 0, len);
512:                    }
513:                    compstuff = "</iwt:Component>\n";
514:                    out.write("</iwt:Component>".getBytes());
515:                    in.close();
516:                    out.flush();
517:                    out.close();
518:                    return new FileInputStream(tmp);
519:                } catch (Exception e) {
520:                    throw (e);
521:                }
522:            }
523:
524:            /* Returns a vector of File objects which are all the files under the directory
525:             passed into the method. */
526:            static Vector getRecursiveFilelist(File directory) {
527:                Vector returnList = new Vector();
528:                try {
529:                    File[] currentList = directory.listFiles();
530:                    /* for (int i=0;i<currentList.length;i++) {
531:                      if (currentList[i].isDirectory() == true) {
532:                    //            System.out.println("Getting recursive directory "+currentList[i].toString());
533:                        returnList.addAll(getRecursiveFilelist(currentList[i]));
534:                      } else if (currentList[i].isFile()) {
535:                    //            System.out.println("Adding file "+currentList[i].toString());
536:                        returnList.add(currentList[i]);
537:                      } else {
538:                    //            System.out.println("Unknown item "+currentList[i].toString());
539:                      }
540:                    }*/
541:                    for (int i = 0; i < currentList.length; i++) {
542:                        if (currentList[i].isFile())
543:                            returnList.add(currentList[i]);
544:                    }
545:                    for (int i = 0; i < currentList.length; i++) {
546:                        if (currentList[i].isDirectory())
547:                            returnList
548:                                    .addAll(getRecursiveFilelist(currentList[i]));
549:                    }
550:
551:                } catch (SecurityException se) {
552:                    System.err.println("Unable to access directory within "
553:                            + directory.toString() + "\n");
554:                    se.printStackTrace();
555:                }
556:                return returnList;
557:            }
558:
559:            static void appendDesktopService(OutputStreamWriter o, String org)
560:                    throws IOException {
561:                int indent;
562:                int MAX_POSSIBLE_COS = 100;
563:
564:                indent = 2;
565:                doIndent(o, indent);
566:                o.write("<OrganizationRequests DN=\""
567:                        + constructOrgDN(org, rootsuffix) + "\">");
568:                indent++;
569:                doIndent(o, indent);
570:                o.write("<RegisterServices>");
571:                indent++;
572:                doIndent(o, indent);
573:                o.write("<Service_Name>SunPortalDesktopService</Service_Name>");
574:                doIndent(o, indent);
575:                o.write("<Service_Name>SunPortalNetMailService</Service_Name>");
576:                doIndent(o, indent);
577:                o.write("<Service_Name>iPlanetAMAuthService</Service_Name>");
578:                doIndent(o, indent);
579:                o.write("<Service_Name>iPlanetAMUserService</Service_Name>");
580:                /* o.write("<Service_Name>iPlanetAMAuthAnonymousService</Service_Name>");
581:                doIndent(o,indent);
582:                o.write("<Service_Name>iPlanetAMAuthMembershipService</Service_Name>");
583:                doIndent(o,indent);*/
584:                /*o.write("<Service_Name>iPlanetAMAuthLDAPService</Service_Name>");
585:                indent--;doIndent(o,indent);*/
586:
587:                o.write("</RegisterServices>");
588:                indent--;
589:                doIndent(o, indent);
590:                o.write("</OrganizationRequests>");
591:
592:                doIndent(o, indent);
593:                o.write("<OrganizationRequests DN=\""
594:                        + constructOrgDN(org, rootsuffix) + "\">");
595:                indent++;
596:                doIndent(o, indent);
597:                o.write(getCreateServiceTemplate("SunPortalDesktopService"));
598:                indent--;
599:                doIndent(o, indent);
600:                o.write("</OrganizationRequests>");
601:                doIndent(o, indent);
602:                o.write("<OrganizationRequests DN=\""
603:                        + constructOrgDN(org, rootsuffix) + "\">");
604:                indent++;
605:                doIndent(o, indent);
606:                o.write(getCreateServiceTemplate("SunPortalNetMailService"));
607:                indent--;
608:                doIndent(o, indent);
609:                o.write("</OrganizationRequests>");
610:                doIndent(o, indent);
611:                o.write("<OrganizationRequests DN=\""
612:                        + constructOrgDN(org, rootsuffix) + "\">");
613:                indent++;
614:                doIndent(o, indent);
615:                o.write(getCreateServiceTemplate("iPlanetAMAuthService"));
616:                indent--;
617:                doIndent(o, indent);
618:                o.write("</OrganizationRequests>");
619:                doIndent(o, indent);
620:                o.write("<OrganizationRequests DN=\""
621:                        + constructOrgDN(org, rootsuffix) + "\">");
622:                indent++;
623:                doIndent(o, indent);
624:                o.write(getCreateServiceTemplate("iPlanetAMUserService"));
625:                indent--;
626:                doIndent(o, indent);
627:                o.write("</OrganizationRequests>");
628:
629:                //o.write("<RoleRequests DN=\"" + constructRoleDN("ContainerDefaultTemplateRole", org, rootsuffix) + "\">");
630:                o.write("<OrganizationRequests DN=\""
631:                        + constructOrgDN(org, rootsuffix) + "\">");
632:                indent++;
633:                doIndent(o, indent);
634:                o
635:                        .write("<ModifyServiceTemplate serviceName=\"SunPortalDesktopService\" schemaType=\"Dynamic\">");
636:                indent++;
637:                doIndent(o, indent);
638:                o.write("<AttributeValuePair>");
639:                indent++;
640:                doIndent(o, indent);
641:                o
642:                        .write("<Attribute name=\"sunPortalDesktopDefaultChannelName\"/>");
643:                doIndent(o, indent);
644:                o.write("<Value>TemplateTableContainer</Value>");
645:                indent--;
646:                doIndent(o, indent);
647:                o.write("</AttributeValuePair>");
648:                doIndent(o, indent);
649:                o.write("<AttributeValuePair>");
650:                indent++;
651:                doIndent(o, indent);
652:                o
653:                        .write("<Attribute name=\"sunPortalDesktopEditProviderContainerName\"/>");
654:                doIndent(o, indent);
655:                o.write("<Value>TemplateEditContainer</Value>");
656:                indent--;
657:                doIndent(o, indent);
658:                o.write("</AttributeValuePair>");
659:
660:                /*doIndent(o,indent);
661:                o.write("<AttributeValuePair>");
662:                indent++;doIndent(o,indent);
663:                o.write("<Attribute name=\"cospriority\"/>");
664:                doIndent(o,indent);*/
665:
666:                /* This part of the code generates the cospriority for the DESKTOP SERVICE TEMPLATE.
667:                The service template of the organization at a higher level in the hierarchy will recieve a greate COS Priority so
668:                that the user inherits from the suborganization at lower level, which would have lower value of cos priority and
669:                hence would take precedance. */
670:
671:                /*int prev,Idx,orgAtLevel;
672:                Idx=0;orgAtLevel=0;
673:                while(Idx < org.length() && org.indexOf(orgNaming,Idx) != -1){
674:                	orgAtLevel++;
675:                	prev=Idx;
676:                	Idx=org.indexOf(orgNaming,prev+1);
677:                	if(Idx==-1) break;
678:                }
679:                o.write("<Value>"+(MAX_POSSIBLE_COS-orgAtLevel)+"</Value>");
680:                indent--;doIndent(o,indent);
681:                o.write("</AttributeValuePair>");
682:                 */
683:
684:                indent--;
685:                doIndent(o, indent);
686:                o.write("</ModifyServiceTemplate>");
687:                indent--;
688:                doIndent(o, indent);
689:                o.write("</OrganizationRequests>");
690:
691:                doIndent(o, indent);
692:                o.write("<OrganizationRequests DN=\""
693:                        + constructOrgDN(org, rootsuffix) + "\">");
694:                indent++;
695:                doIndent(o, indent);
696:                o
697:                        .write("<ModifyServiceTemplate serviceName=\"iPlanetAMAuthService\" schemaType=\"Organization\">");
698:                indent++;
699:                doIndent(o, indent);
700:                o.write("<AttributeValuePair>");
701:                indent++;
702:                doIndent(o, indent);
703:                o
704:                        .write("<Attribute name=\"iplanet-am-auth-login-success-url\"/>");
705:                doIndent(o, indent);
706:                o.write("<Value>" + DeployUri + "/dt</Value>");
707:                indent--;
708:                doIndent(o, indent);
709:                o.write("</AttributeValuePair>");
710:                doIndent(o, indent);
711:                o.write("<AttributeValuePair>");
712:                indent++;
713:                doIndent(o, indent);
714:                o.write("<Attribute name=\"iplanet-am-auth-user-container\"/>");
715:                doIndent(o, indent);
716:                o.write("<Value>ou=People," + constructOrgDN(org, rootsuffix)
717:                        + "</Value>");
718:                indent--;
719:                doIndent(o, indent);
720:                o.write("</AttributeValuePair>");
721:
722:                /*doIndent(o,indent);
723:                o.write("<AttributeValuePair>");
724:                indent++;doIndent(o,indent);
725:                o.write("<Attribute name=\"iplanet-am-auth-menu\"/>");
726:                doIndent(o,indent);
727:                o.write("<Value>LDAP</Value>");
728:                doIndent(o,indent);
729:                o.write("<Value>Anonymous</Value>");
730:                doIndent(o,indent);
731:                o.write("<Value>Membership</Value>");
732:                indent--;doIndent(o,indent);
733:                o.write("</AttributeValuePair>");*/
734:
735:                indent--;
736:                doIndent(o, indent);
737:                o.write("</ModifyServiceTemplate>");
738:                indent--;
739:                doIndent(o, indent);
740:                o.write("</OrganizationRequests>");
741:                doIndent(o, indent);
742:
743:                /* o.write("<OrganizationRequests DN=\"" + constructOrgDN(org, rootsuffix) + "\">");
744:                indent++;doIndent(o,indent);
745:                o.write(getCreateServiceTemplate("iPlanetAMAuthAnonymousService"));
746:                indent--;doIndent(o,indent);
747:                o.write("</OrganizationRequests>");
748:                doIndent(o,indent);
749:                o.write("<OrganizationRequests DN=\"" + constructOrgDN(org, rootsuffix) + "\">");
750:                indent++;doIndent(o,indent);
751:                o.write(getCreateServiceTemplate("iPlanetAMAuthMembershipService"));
752:                indent--;doIndent(o,indent);
753:                o.write("</OrganizationRequests>");*/
754:
755:                /*o.write("<OrganizationRequests DN=\"" + constructOrgDN(org, rootsuffix) + "\">");
756:                indent++;doIndent(o,indent);
757:                o.write(getCreateServiceTemplate("iPlanetAMAuthLDAPService"));
758:                indent--;doIndent(o,indent);
759:                o.write("</OrganizationRequests>");
760:                doIndent(o,indent);
761:
762:                doIndent(o,indent);
763:                o.write("<OrganizationRequests DN=\"" + constructOrgDN(org, rootsuffix) + "\">");
764:                indent++;doIndent(o,indent);
765:                o.write("<ModifyServiceTemplate serviceName=\"iPlanetAMAuthLDAPService\" schemaType=\"Organization\">");
766:                indent++;doIndent(o,indent);
767:                o.write("<AttributeValuePair>");
768:                indent++;doIndent(o,indent);
769:                o.write("<Attribute name=\"iplanet-am-auth-ldap-base-dn\"/>");
770:                doIndent(o,indent);
771:                o.write("<Value>" + constructOrgDN(org, rootsuffix) + "</Value>");
772:                indent--;doIndent(o,indent);
773:                o.write("</AttributeValuePair>");
774:                indent--;doIndent(o,indent);
775:                o.write("</ModifyServiceTemplate>");
776:                indent--;doIndent(o,indent);
777:                o.write("</OrganizationRequests>");
778:                doIndent(o,indent); */
779:
780:                /*	o.write("<OrganizationRequests DN=\"" + constructOrgDN(org, rootsuffix) + "\">");
781:                 indent++;doIndent(o,indent);
782:                 o.write("<CreatePolicy createDN=\"" + constructOrgDN(org, rootsuffix) + "\">");
783:                 indent++;doIndent(o,indent);
784:                 o.write("<Policy name=\"Ability to execute Portal Server Desktop\" serviceName=\"SunPortalDesktopService\">");
785:                 indent++;doIndent(o,indent);
786:                 o.write("<Rule name=\"Ability to execute Portal Server Desktop\">");
787:                 indent++;doIndent(o,indent);
788:                 o.write("<ServiceName name=\"SunPortalDesktopService\"/>");
789:                 o.write("<AttributeValuePair>");
790:                 indent++;doIndent(o,indent);
791:                 o.write("<Attribute name=\"sunPortalDesktopExecutable\"/>");
792:                 o.write("<Value>true</Value>");
793:                 indent--;doIndent(o,indent);
794:                 o.write("</AttributeValuePair>");
795:                 indent--;doIndent(o,indent);
796:                 o.write("</Rule>");
797:                 indent--;doIndent(o,indent);
798:                 o.write("</Policy>");
799:                 o.write("<Policy name=\"Ability to execute Portal Server Netmail\" serviceName=\"SunPortalNetMailService\">");
800:                 indent++;doIndent(o,indent);
801:                 o.write("<Rule name=\"Ability to execute Portal Server Netmail\">");
802:                 indent++;doIndent(o,indent);
803:                 o.write("<ServiceName name=\"SunPortalNetMailService\"/>");
804:                 o.write("<AttributeValuePair>");
805:                 indent++;doIndent(o,indent);
806:                 o.write("<Attribute name=\"sunPortalNetmailExecutable\"/>");
807:                 o.write("<Value>true</Value>");
808:                 indent--;doIndent(o,indent);
809:                 o.write("</AttributeValuePair>");
810:                 indent--;doIndent(o,indent);
811:                 o.write("</Rule>");
812:                 indent--;doIndent(o,indent);
813:                 o.write("</Policy>");
814:                 indent--;doIndent(o,indent);
815:                 o.write("</CreatePolicy>");
816:                 indent--;doIndent(o,indent);
817:                 o.write("</OrganizationRequests>");doIndent(o,indent);
818:                 o.write("<OrganizationRequests DN=\"" + constructOrgDN(org, rootsuffix) + "\">");
819:                 indent++;doIndent(o,indent);
820:                 o.write("<AssignPolicy policyDN=\"" + constructOrgDN(org, rootsuffix) + "\">");
821:                 indent++;doIndent(o,indent);
822:                 o.write("<PolicyName name=\"Ability to execute Portal Server Desktop\"/>");
823:                 doIndent(o,indent);
824:                 o.write("<PolicyName name=\"Ability to execute Portal Server Netmail\"/>");
825:                 indent--;doIndent(o,indent);
826:                 o.write("</AssignPolicy>");
827:                 indent--;doIndent(o,indent);
828:                 o.write("</OrganizationRequests>");
829:                 */
830:                doIndent(o, indent);
831:                o.write("<!--OrganizationRequests DN=\""
832:                        + constructOrgDN(org, rootsuffix) + "\">");
833:                indent++;
834:                doIndent(o, indent);
835:                o.write("<CreatePolicy createDN=\""
836:                        + constructOrgDN(org, rootsuffix) + "\">");
837:                indent++;
838:                doIndent(o, indent);
839:                o
840:                        .write("<Policy name=\"Ability to execute Portal Server Desktop\" referralPolicy=\"false\">");
841:                indent++;
842:                doIndent(o, indent);
843:                o.write("<Rule name=\"ExecuteDesktop\">");
844:                indent++;
845:                doIndent(o, indent);
846:                o.write("<ServiceName name=\"SunPortalDesktopService\"/>");
847:                o.write("<AttributeValuePair>");
848:                indent++;
849:                doIndent(o, indent);
850:                o.write("<Attribute name=\"sunPortalDesktopExecutable\"/>");
851:                o.write("<Value>true</Value>");
852:                indent--;
853:                doIndent(o, indent);
854:                o.write("</AttributeValuePair>");
855:                indent--;
856:                doIndent(o, indent);
857:                o.write("</Rule>");
858:                doIndent(o, indent);
859:                o.write("<Subjects name=\"OrgExecDesktop\" description=\"\">");
860:                indent++;
861:                doIndent(o, indent);
862:                o
863:                        .write("<Subject name=\"OrgExecuteDesktop\" type=\"Organization\">");
864:                indent++;
865:                doIndent(o, indent);
866:                o.write("<AttributeValuePair>");
867:                indent++;
868:                doIndent(o, indent);
869:                o.write("<Attribute name=\"Values\"/>");
870:                doIndent(o, indent);
871:                o.write("<Value>" + constructOrgDN(org, rootsuffix)
872:                        + "</Value>");
873:                indent--;
874:                doIndent(o, indent);
875:                o.write("</AttributeValuePair>");
876:                indent--;
877:                doIndent(o, indent);
878:                o.write("</Subject>");
879:                indent--;
880:                doIndent(o, indent);
881:                o.write("</Subjects>");
882:                indent--;
883:                doIndent(o, indent);
884:                o.write("</Policy>");
885:                o
886:                        .write("<Policy name=\"Ability to execute Portal Server Netmail\" referralPolicy=\"false\">");
887:                indent++;
888:                doIndent(o, indent);
889:                o.write("<Rule name=\"ExecuteNetmail\">");
890:                indent++;
891:                doIndent(o, indent);
892:                o.write("<ServiceName name=\"SunPortalNetMailService\"/>");
893:                o.write("<AttributeValuePair>");
894:                indent++;
895:                doIndent(o, indent);
896:                o.write("<Attribute name=\"sunPortalNetmailExecutable\"/>");
897:                o.write("<Value>true</Value>");
898:                indent--;
899:                doIndent(o, indent);
900:                o.write("</AttributeValuePair>");
901:                indent--;
902:                doIndent(o, indent);
903:                o.write("</Rule>");
904:                doIndent(o, indent);
905:                o.write("<Subjects name=\"OrgExecNetmail\" description=\"\">");
906:                indent++;
907:                doIndent(o, indent);
908:                o
909:                        .write("<Subject name=\"OrgExecuteNetmail\" type=\"Organization\">");
910:                indent++;
911:                doIndent(o, indent);
912:                o.write("<AttributeValuePair>");
913:                indent++;
914:                doIndent(o, indent);
915:                o.write("<Attribute name=\"Values\"/>");
916:                doIndent(o, indent);
917:                o.write("<Value>" + constructOrgDN(org, rootsuffix)
918:                        + "</Value>");
919:                indent--;
920:                doIndent(o, indent);
921:                o.write("</AttributeValuePair>");
922:                indent--;
923:                doIndent(o, indent);
924:                o.write("</Subject>");
925:                indent--;
926:                doIndent(o, indent);
927:                o.write("</Subjects>");
928:                indent--;
929:                doIndent(o, indent);
930:                o.write("</Policy>");
931:                indent--;
932:                doIndent(o, indent);
933:                o.write("</CreatePolicy>");
934:                indent--;
935:                doIndent(o, indent);
936:                o.write("</OrganizationRequests-->");
937:                doIndent(o, indent);
938:                o.write("<!--OrganizationRequests DN=\""
939:                        + constructOrgDN(org, rootsuffix) + "\">");
940:                indent++;
941:                doIndent(o, indent);
942:                o.write("<AssignPolicy policyDN=\""
943:                        + constructOrgDN(org, rootsuffix) + "\">");
944:                indent++;
945:                doIndent(o, indent);
946:                o
947:                        .write("<PolicyName name=\"Ability to execute Portal Server Desktop\"/>");
948:                doIndent(o, indent);
949:                o
950:                        .write("<PolicyName name=\"Ability to execute Portal Server Netmail\"/>");
951:                indent--;
952:                doIndent(o, indent);
953:                o.write("</AssignPolicy>");
954:                indent--;
955:                doIndent(o, indent);
956:                o.write("</OrganizationRequests-->");
957:            }
958:
959:            static java.util.Locale getLocale(String stringformat) {
960:                if (stringformat == null)
961:                    return java.util.Locale.getDefault();
962:
963:                StringTokenizer tk = new StringTokenizer(stringformat, "_");
964:                String lang = "";
965:                String country = "";
966:                String variant = "";
967:
968:                if (tk.hasMoreTokens())
969:                    lang = tk.nextToken();
970:                if (tk.hasMoreTokens())
971:                    country = tk.nextToken();
972:                if (tk.hasMoreTokens())
973:                    variant = tk.nextToken();
974:
975:                return new java.util.Locale(lang, country, variant);
976:            }
977:
978:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.