Source Code Cross Referenced for Component.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) 


0001:        package migration.modules.ldap;
0002:
0003:        //import com.sun.portal.psadmin.*;
0004:
0005:        import java.util.*;
0006:        import java.net.URL;
0007:        import java.io.PrintStream;
0008:        import java.io.InputStreamReader;
0009:        import java.io.OutputStreamWriter;
0010:        import java.io.FileWriter;
0011:        import java.io.FileOutputStream;
0012:        import java.io.FileInputStream;
0013:        import java.io.IOException;
0014:        import com.iplanet.portalserver.parser.ParseOutput;
0015:        import com.iplanet.portalserver.parser.GenericNode; //import com.sun.portal.profile.service.*;
0016:        import com.iplanet.portalserver.profile.impl.*;
0017:        import com.iplanet.portalserver.profile.share.ProfileBundle;
0018:        import netscape.ldap.*;
0019:
0020:        public class Component extends Element implements  ParseOutput {
0021:            String _compname;
0022:            String _rawcompname;
0023:            Hashtable _configdata;
0024:            Vector _attributes = new Vector();
0025:            Vector _privileges = new Vector();
0026:            final static String INITIAL = "java.naming.factory.initial";
0027:            final static String URL = "java.naming.provider.url";
0028:            final static String PRINCIPAL = "java.naming.security.principal";
0029:            final static String CREDENTIALS = "java.naming.security.credentials";
0030:            final static String PROPFILE = "/etc/opt/SUNWportal/properties.file";
0031:            //	final static String iPSPROPFILE = "/etc/opt/SUNWdpro/psDPro";
0032:            final static String iPSPROPFILE = "/etc/opt/SUNWportal/psDPro";
0033:            final static String BASEDIR = "baseDir";
0034:            String baseDir = null;
0035:            boolean needtoaddattr = false;
0036:            PrintStream ldifout = null;
0037:
0038:            FileWriter outFile;
0039:            boolean _chkschema;
0040:            boolean _debug = false;
0041:            boolean _debugConvert = false; // one to change back to false
0042:            boolean _debugGC = false; // for getComponents()
0043:            boolean _debugGCh = false; // for getChildren()
0044:            static int numTabs = 0;
0045:
0046:            public void process(String name, Vector elems, Hashtable atts,
0047:                    String pcdata) {
0048:                int numElems = elems.size();
0049:
0050:                //    System.out.println("process: of component");
0051:                for (int i = 0; i < numElems; i++) {
0052:                    Element gn = (Element) elems.elementAt(i);
0053:                    if (gn.type == Element.ATTRIBUTE_I)
0054:                        _attributes.addElement(gn);
0055:                    else
0056:                        _privileges.addElement(gn);
0057:                }
0058:                _configdata = atts;
0059:                _compname = (String) atts.get(Element.NAME);
0060:            }
0061:
0062:            public String toString() {
0063:                return "Name=" + _compname + " _configdata=" + _configdata
0064:                        + " Attrs=" + _attributes.toString() + " Privs="
0065:                        + _privileges.toString();
0066:            }
0067:
0068:            public void createStubFile(String stubfile) throws Exception {
0069:                PrintStream of = new PrintStream(new FileOutputStream(stubfile));
0070:                int numAttrs = _attributes.size();
0071:                System.out.println("createStubFile: of component");
0072:                for (int i = 0; i < numAttrs; i++) {
0073:                    Attribute att = (Attribute) _attributes.elementAt(i);
0074:                    String name = att.name;
0075:                    StringBuffer outstr = new StringBuffer(200);
0076:                    Object val = att._atts.get(Element.VALUE);
0077:                    if (val.getClass().getName().indexOf("Vector") > 0) {
0078:                        Enumeration en = (Enumeration) val;
0079:                        outstr.append(name).append("=");
0080:                        boolean fst = true;
0081:                        while (en.hasMoreElements()) {
0082:                            if (fst)
0083:                                outstr.append(en.nextElement());
0084:                            else
0085:                                outstr.append(",").append(en.nextElement());
0086:                            fst = false;
0087:                        }
0088:                    } else
0089:                        outstr.append(name).append("=").append(val);
0090:                    of.println(outstr.toString());
0091:                }
0092:                of.flush();
0093:                of.close();
0094:            }
0095:
0096:            public String getCompName() {
0097:                return _compname;
0098:
0099:            }
0100:
0101:            public Vector getAttributes() {
0102:
0103:                return _attributes;
0104:            }
0105:
0106:            public void printContents(Object obj) {
0107:                String objClass = obj.getClass().getName();
0108:
0109:                try {
0110:                    //	System.out.println ("printContents:class=" + objClass);
0111:                    if (objClass.equals("java.lang.String")) {
0112:                        //System.out.print (obj);
0113:                        outFile.write(obj.toString());
0114:                    } else if (objClass.indexOf("Vector") > 0) {
0115:                        Enumeration en = (Enumeration) obj;
0116:                        boolean fst = true;
0117:                        while (en.hasMoreElements()) {
0118:                            if (fst) {
0119:                                outFile.write((en.nextElement()).toString()
0120:                                        + "\n");
0121:                            } else {
0122:                                outFile.write(", " + en.nextElement() + "\n");
0123:                            }
0124:                        }
0125:                    } else {
0126:                        outFile.write("object class = " + objClass + "\n");
0127:                    }
0128:                } catch (IOException ie) {
0129:                    System.out.println("Error writing to file specified");
0130:                    ie.printStackTrace();
0131:
0132:                }
0133:            }
0134:
0135:            public void createProfile(String intype, String inname,
0136:                    boolean ldifwanted, String ldiffilename, boolean chkschema)
0137:                    throws Exception {
0138:
0139:                if (_debug) {
0140:                    System.out.println("Component:createProfile:intype="
0141:                            + intype + ", inname=" + inname + ", ldifwanted="
0142:                            + ldifwanted + ", ldiffilename=" + ldiffilename
0143:                            + ", chkschema=" + chkschema);
0144:                }
0145:
0146:                try {
0147:                    _chkschema = chkschema;
0148:                    // Make sure ldiffile can be created
0149:                    if (ldifwanted) {
0150:                        ldifout = new PrintStream(new FileOutputStream(
0151:                                ldiffilename));
0152:                    }
0153:
0154:                    String pparent = null, pname = null, ptype = intype;
0155:
0156:                    if (ptype.equals("component")) {
0157:                        pname = inname;
0158:                        ptype = "application";
0159:                        pparent = "component";
0160:                        needtoaddattr = true;
0161:                    } else if (ptype.equals("user")) {
0162:                        StringTokenizer tk = new StringTokenizer(inname, "/");
0163:                        pparent = tk.nextToken();
0164:                        pname = tk.nextToken();
0165:                        if (tk.hasMoreTokens())
0166:                            throw new Exception(bundle.getString("invusername"));
0167:                        ptype = intype;
0168:                    } else if (ptype.equals("role")) {
0169:                        ptype = intype;
0170:                        int last = inname.lastIndexOf("/");
0171:                        pparent = inname.substring(0, last);
0172:                        pname = inname.substring(last + 1, inname.length());
0173:                    } else if (ptype.equals("domain")) {
0174:                        ptype = intype;
0175:                        pparent = null;
0176:                        pname = inname;
0177:                    }
0178:                    Hashtable ht = new Hashtable();
0179:                    int numAttrs = _attributes.size();
0180:                    for (int i = 0; i < numAttrs; i++) {
0181:
0182:                        System.out.println("Processing....Attributes..."
0183:                                + numAttrs);
0184:                        Attribute att = (Attribute) _attributes.elementAt(i);
0185:                        Object val;
0186:                        String name = att.name;
0187:
0188:                        if (_debug) {
0189:                            System.out
0190:                                    .println("Component:createProfile:att.name="
0191:                                            + name);
0192:                        }
0193:
0194:                        addAttrToSchema(name);
0195:                        Enumeration keys = att._atts.keys();
0196:                        while (keys.hasMoreElements()) {
0197:                            String key = (String) keys.nextElement();
0198:
0199:                            if (_debug) {
0200:                                System.out
0201:                                        .println("Component:createProfile:attr.key="
0202:                                                + key);
0203:                            }
0204:
0205:                            if (Element.mapper.get(key) != null) {
0206:                                ht.put(name + Element.ATTPREFIX
0207:                                        + Element.mapper.get(key), att._atts
0208:                                        .get(key));
0209:
0210:                                if (_debug) {
0211:                                    System.out
0212:                                            .print("Component:createProfile:put("
0213:                                                    + name
0214:                                                    + Element.ATTPREFIX
0215:                                                    + Element.mapper.get(key)
0216:                                                    + ", ");
0217:                                    printContents(att._atts.get(key));
0218:                                    System.out.println(")");
0219:                                    //				    att._atts.get(key) + "), key obj class = " +
0220:                                    //				    (Object)(att._atts.get(key)).getClass().getName());
0221:                                }
0222:
0223:                            } else
0224:                                throw new Exception(bundle.getString("invxml")
0225:                                        + name + " " + key);
0226:                        }
0227:                    }
0228:                    int numPrivs = _privileges.size();
0229:
0230:                    if (_debug) {
0231:                        System.out.println("Component:createProfile:numPrivs="
0232:                                + numPrivs);
0233:                    }
0234:
0235:                    for (int i = 0; i < numPrivs; i++) {
0236:                        System.out.println("Processing....previlieges..."
0237:                                + numPrivs);
0238:                        Privilege att = (Privilege) _privileges.elementAt(i);
0239:                        Object val;
0240:                        String name = att.name;
0241:
0242:                        if (_debug) {
0243:                            System.out
0244:                                    .println("Component:createProfile:priv.name="
0245:                                            + name);
0246:                        }
0247:
0248:                        addPrivToSchema(name);
0249:                        Enumeration keys = att._atts.keys();
0250:                        while (keys.hasMoreElements()) {
0251:                            String key = (String) keys.nextElement();
0252:
0253:                            if (_debug) {
0254:                                System.out
0255:                                        .println("Component:createProfile:priv.key="
0256:                                                + key);
0257:                            }
0258:
0259:                            if (Element.mapper.get(key) != null)
0260:                                ht.put(name + Element.PRIVPREFIX
0261:                                        + Element.mapper.get(key), att._atts
0262:                                        .get(key));
0263:                            else
0264:                                throw new Exception(bundle.getString("invxml")
0265:                                        + name + " " + key);
0266:                        }
0267:                    }
0268:
0269:                    // Handle special cases of Description,ResourceBundle and DescIndex
0270:                    if (_configdata.get(DESC) != null) {
0271:                        String attname = _compname + "-description" + ATTPREFIX;
0272:
0273:                        if (_debug) {
0274:                            System.out.println("Component:createProfile:add '"
0275:                                    + attname + "'");
0276:                        }
0277:
0278:                        addAttrToSchema(_compname + "-description");
0279:                        ht.put(attname, _configdata.get(DESC));
0280:
0281:                        if (_debug) {
0282:                            //			System.out.println ("Component:createProfile:put(" + attname + ", " +
0283:                            //			    _configdata.get(DESC) + ")");
0284:                            System.out.print("Component:createProfile:put("
0285:                                    + attname + ", ");
0286:                            printContents(_configdata.get(DESC));
0287:                            System.out.println(")");
0288:                        }
0289:
0290:                        ht.put(attname + mapper.get(READPERM), admin_owner
0291:                                .elements());
0292:
0293:                        if (_debug) {
0294:                            //			System.out.println ("Component:createProfile:put(" +
0295:                            //			    attname+mapper.get(READPERM) + ", " + admin_owner.elements() + ")");
0296:                            System.out.print("Component:createProfile:put("
0297:                                    + attname + mapper.get(READPERM) + ", ");
0298:                            printContents(admin_owner.elements());
0299:                            System.out.println(")");
0300:                        }
0301:
0302:                        if (_configdata.get(INDEX) != null)
0303:                            ht.put(attname + mapper.get(INDEX), _configdata
0304:                                    .get(INDEX));
0305:                        ht.put(attname + mapper.get(TYPE), "string");
0306:
0307:                        if (_debug) {
0308:                            System.out.println("Component:createProfile:put("
0309:                                    + attname + mapper.get(TYPE) + ", string)");
0310:                        }
0311:
0312:                        ht.put(attname + mapper.get(USERCONFIGURABLE), "false");
0313:
0314:                        if (_debug) {
0315:                            System.out.println("Component:createProfile:put("
0316:                                    + attname + mapper.get(USERCONFIGURABLE)
0317:                                    + ", false)");
0318:                        }
0319:
0320:                    }
0321:                    if (_configdata.get(RESOURCEBUNDLE) != null) {
0322:                        String attname = _compname + "-resourceBundle"
0323:                                + ATTPREFIX;
0324:
0325:                        if (_debug) {
0326:                            System.out.println("Component:createProfile:add '"
0327:                                    + attname + "'");
0328:                        }
0329:
0330:                        addAttrToSchema(_compname + "-resourceBundle");
0331:                        ht.put(attname, _configdata.get(RESOURCEBUNDLE));
0332:
0333:                        if (_debug) {
0334:                            System.out.println("Component:createProfile:put("
0335:                                    + attname + ", "
0336:                                    + _configdata.get(RESOURCEBUNDLE) + ")");
0337:                        }
0338:
0339:                        ht.put(attname + mapper.get(READPERM), admin_owner
0340:                                .elements());
0341:
0342:                        if (_debug) {
0343:                            System.out.println("Component:createProfile:put("
0344:                                    + attname + mapper.get(READPERM) + ", "
0345:                                    + admin_owner.elements() + ")");
0346:                        }
0347:
0348:                        if (_configdata.get(INDEX) != null) {
0349:                            ht.put(attname + mapper.get(INDEX), _configdata
0350:                                    .get(INDEX));
0351:
0352:                            if (_debug) {
0353:                                System.out
0354:                                        .println("Component:createProfile:put("
0355:                                                + attname + mapper.get(INDEX)
0356:                                                + ", " + _configdata.get(INDEX)
0357:                                                + ")");
0358:                            }
0359:                        }
0360:                        ht.put(attname + mapper.get(TYPE), "string");
0361:
0362:                        if (_debug) {
0363:                            System.out.println("Component:createProfile:put("
0364:                                    + attname + mapper.get(TYPE) + ", string");
0365:                        }
0366:
0367:                        ht.put(attname + mapper.get(USERCONFIGURABLE), "false");
0368:
0369:                        if (_debug) {
0370:                            System.out.println("Component:createProfile:put("
0371:                                    + attname + mapper.get(USERCONFIGURABLE)
0372:                                    + ", false");
0373:                        }
0374:
0375:                    }
0376:                    // Setup adminRoles as a empty list
0377:                    if (ptype.equals("domain")
0378:                            && ht.get("iwtPlatform-adminRoles" + ATTPREFIX) == null) {
0379:                        Vector tmp = new Vector();
0380:                        ht.put("iwtPlatform-adminRoles" + ATTPREFIX, tmp
0381:                                .elements());
0382:                        if (_debug) {
0383:                            System.out
0384:                                    .println("Component:createProfile:add 'iwtPlatform-adminRoles"
0385:                                            + ATTPREFIX
0386:                                            + "', tmp.elements="
0387:                                            + tmp.elements());
0388:                        }
0389:
0390:                    }
0391:                    //if (needtoaddattr)
0392:                    //addAttrToSchema(ht);
0393:                    if (ptype.equals("user")
0394:                            && ht.get("iwtUser-role-at") == null)
0395:                        System.err.println(bundle.getString("rolewarning"));
0396:                    if (!ldifwanted) {
0397:                        // initialize ProfileServiceManager & create teh profile
0398:                        ProfileServiceManager psm = new ProfileServiceManager(1);
0399:
0400:                        //		    if (_debug) {
0401:                        //			System.out.println ("Component:createProfile:calling newProfile with pnam=" +
0402:                        //			    pname + ", ptype=" + ptype + ", ht=" + ht + ", pparent=" + pparent);
0403:                        //		    }
0404:
0405:                        psm.newProfile(pname, ptype, ht, pparent, null);
0406:
0407:                        //		    if (_debug) {
0408:                        //			System.out.println ("Component:createProfile:return from newProfile");
0409:                        //		    }
0410:
0411:                        psm.close();
0412:                    }
0413:                    if (ldifwanted) {
0414:                        ldifout.flush();
0415:                        ldifout.close();
0416:                    }
0417:                } catch (Exception e) {
0418:                    throw new Exception(bundle.getString("createfail")
0419:                            + getProfileBundle(e.getMessage()));
0420:                }
0421:            }
0422:
0423:            private void doIndent() {
0424:                if (numTabs == 0)
0425:                    return;
0426:                try {
0427:                    for (int i = 0; i < numTabs; i++) {
0428:                        outFile.write("    ");
0429:                    }
0430:                } catch (IOException ie) {
0431:                    System.out.println("Error writing to file specified");
0432:                    ie.printStackTrace();
0433:                }
0434:            }
0435:
0436:            private void getBaseDir() {
0437:                Properties prop = System.getProperties();
0438:
0439:                try {
0440:                    //  load properties from file
0441:                    //   prop.load (new FileInputStream(iPSPROPFILE));
0442:                    baseDir = prop.getProperty("BASEDIR");
0443:                } catch (Exception e) {
0444:                    //  e.printStackTrace();
0445:                    // System.err.println("Error reading properties file, " + PROPFILE + ".  " + e);
0446:                    baseDir = "/opt"; // default
0447:                }
0448:            }
0449:
0450:            private void printFrontStuff(String compName) {
0451:
0452:                getBaseDir();
0453:
0454:                String lineOne = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
0455:                String lineDocType = "<!DOCTYPE ServicesConfiguration";
0456:                String linePublic = "PUBLIC \"-//Sun ONE//Service Management Services (SMS) 1.0 DTD//EN\"";
0457:                String lineFile = "\"file:" + baseDir
0458:                        + "/SUNWam/dtd/sms.dtd\">";
0459:                String lineSvcsConf = "<ServicesConfiguration version=\"1.0\">";
0460:                String lineSvcName = "<Service name=\"" + compName + "\">";
0461:                String lineSvcSchema = "<Schema";
0462:
0463:                numTabs = 0;
0464:                /*	System.out.println (lineOne);
0465:                 System.out.println("");
0466:                 System.out.println (lineDocType); */
0467:
0468:                try {
0469:                    outFile.write(lineOne);
0470:                    outFile.write("\n");
0471:                    outFile.write(lineDocType + "\n");
0472:                    numTabs = 1;
0473:                    doIndent();
0474:                    //System.out.println (linePublic);
0475:                    outFile.write(linePublic + "\n");
0476:                    doIndent();
0477:                    /*	System.out.println (lineFile);
0478:                     System.out.println(""); */
0479:
0480:                    outFile.write(lineFile + "\n");
0481:                    outFile.write("\n");
0482:
0483:                    //	numTabs = 0;
0484:                    //	doIndent();
0485:
0486:                    /*	System.out.println (lineSvcsConf);
0487:                     */
0488:
0489:                    outFile.write(lineSvcsConf + "\n");
0490:                    /*	numTabs = 1;
0491:                     doIndent();
0492:
0493:                     outFile.write(lineSvcName+"\n");
0494:                     numTabs = 2;
0495:                     doIndent();
0496:                     outFile.write(lineSvcSchema); */
0497:                } catch (IOException ie) {
0498:                    System.out.println("Problem writing to file specified ");
0499:                    ie.printStackTrace();
0500:                }
0501:            }
0502:
0503:            private void processPrivilege(Privilege att) {
0504:
0505:                try {
0506:                    if (att._atts.containsKey("type")) {
0507:                        if (Element.mapper.get("type") != null) {
0508:                            String tstr = (String) att._atts.get("type");
0509:                            String type = null;
0510:                            String syntax = null;
0511:                            String any = null;
0512:
0513:                            if (tstr.equalsIgnoreCase("boolean")) {
0514:                                type = "single";
0515:                                syntax = "boolean";
0516:                            } else if (tstr.equalsIgnoreCase("list")) {
0517:                                type = "list";
0518:                                syntax = "string";
0519:                            }
0520:                            doIndent();
0521:                            outFile.write("type=\"" + type + "\"\n");
0522:                            doIndent();
0523:                            outFile.write("syntax=\"" + syntax + "\"\n");
0524:                            if (any != null) {
0525:                                doIndent();
0526:                                outFile.write("any=\"" + any + "\"\n");
0527:                            }
0528:
0529:                        }
0530:
0531:                        if (att._atts.containsKey("idx")) {
0532:                            if (Element.mapper.get("idx") != null) {
0533:                                String tstr = (String) att._atts.get("idx");
0534:
0535:                                doIndent();
0536:                                outFile.write("i18nKey=\"" + tstr + "\"\n");
0537:                            }
0538:                        } else {
0539:                            //System.out.println("Hey, no 'idx'!");
0540:                        }
0541:                        doIndent();
0542:                        outFile.write(">"); // end the descI18Nkey
0543:
0544:                        //
0545:                        //  if there are ChoiceValues (key = "CVal"), then
0546:                        //  don't end this attribute, else put a "/>" on a
0547:                        //  new line.
0548:                        //
0549:
0550:                        if (att._atts.containsKey("CVal")) {
0551:                            //doIndent();
0552:                            //outFile.write(">");  // end the descI18Nkey
0553:                            if (Element.mapper.get("CVal") != null) {
0554:                                Object obj = (Object) att._atts.get("CVal");
0555:                                String objClass = obj.getClass().getName();
0556:
0557:                                if (objClass.equals("java.lang.String")) {
0558:                                    outFile.write(obj.toString());
0559:                                } else if (objClass.indexOf("Vector") > 0) {
0560:                                    Enumeration en = (Enumeration) obj;
0561:                                    outFile.write("\n");
0562:                                    doIndent();
0563:                                    outFile.write("<ChoiceValues>\n");
0564:                                    numTabs += 1;
0565:                                    while (en.hasMoreElements()) {
0566:                                        doIndent();
0567:                                        outFile.write("<ChoiceValue>"
0568:                                                + en.nextElement()
0569:                                                + "</ChoiceValue>\n");
0570:
0571:                                    }
0572:                                    numTabs -= 1;
0573:                                    doIndent();
0574:                                    outFile.write("</ChoiceValues>\n");
0575:                                    numTabs -= 1;
0576:                                    doIndent();
0577:                                    outFile.write("</AttributeSchema>\n");
0578:                                } else {
0579:                                    outFile.write("object class = " + objClass);
0580:                                }
0581:                            }
0582:
0583:                        } else {
0584:                            outFile.write("\n");
0585:                            numTabs -= 1;
0586:                            doIndent();
0587:                            outFile.write("</AttributeSchema>\n");
0588:                            //outFile.write("/>\n");numTabs +=1;
0589:                        }
0590:                    } else {
0591:                        // System.out.println("Hey, no 'type'!");
0592:                    }
0593:                } catch (IOException ie) {
0594:                    System.out.println("Error writing to specified file");
0595:                    ie.printStackTrace();
0596:
0597:                }
0598:            }
0599:
0600:            private void processAttribute(Attribute att) {
0601:
0602:                try {
0603:                    if (att._atts.containsKey("type")) {
0604:                        if (Element.mapper.get("type") != null) {
0605:                            String tstr = (String) att._atts.get("type");
0606:                            String type = null;
0607:                            String syntax = null;
0608:                            String any = null;
0609:                            if (tstr.equalsIgnoreCase("string")) {
0610:                                type = "single";
0611:                                syntax = "string";
0612:                            } else if (tstr.equalsIgnoreCase("number")) {
0613:                                type = "single";
0614:                                syntax = "number";
0615:                            } else if (tstr.equalsIgnoreCase("boolean")) {
0616:                                type = "single";
0617:                                syntax = "boolean";
0618:                            } else if (tstr.equalsIgnoreCase("singlechoice")) {
0619:                                type = "single_choice";
0620:                                syntax = "string";
0621:                            } else if (tstr.equalsIgnoreCase("multichoice")) {
0622:                                type = "multiple_choice";
0623:                                syntax = "string";
0624:                            } else if (tstr.equalsIgnoreCase("protected")) {
0625:                                type = "single";
0626:                                syntax = "string";
0627:                                any = "protected";
0628:                            } else if (tstr.equalsIgnoreCase("stringlist")) {
0629:                                type = "list";
0630:                                syntax = "string";
0631:                            } else if (tstr.equalsIgnoreCase("numberlist")) {
0632:                                type = "list";
0633:                                syntax = "number";
0634:                            } else if (tstr.equalsIgnoreCase("binary")) {
0635:                                type = "single";
0636:                                syntax = "string";
0637:                                any = "binary";
0638:                            }
0639:
0640:                            doIndent();
0641:                            outFile.write("type=\"" + type + "\"\n");
0642:                            doIndent();
0643:                            outFile.write("syntax=\"" + syntax + "\"\n");
0644:                            if (any != null) {
0645:                                doIndent();
0646:                                outFile.write("any=\"" + any + "\"\n");
0647:                            }
0648:
0649:                        }
0650:
0651:                        if (att._atts.containsKey("idx")) {
0652:                            if (Element.mapper.get("idx") != null) {
0653:                                String tstr = (String) att._atts.get("idx");
0654:
0655:                                doIndent();
0656:                                outFile.write("i18nKey=\"" + tstr + "\">");
0657:                            }
0658:                        } else {
0659:                            //System.out.println("Hey, no 'idx'!");
0660:                        }
0661:
0662:                        //
0663:                        //  if there are ChoiceValues (key = "CVal"), then
0664:                        //  don't end this attribute, else put a "/>" on a
0665:                        //  new line.
0666:                        //
0667:
0668:                        if (att._atts.containsKey("CVal")) {
0669:                            /* doIndent();
0670:                            outFile.write(">"); */// end the descI18Nkey
0671:                            if (Element.mapper.get("CVal") != null) {
0672:                                Object obj = (Object) att._atts.get("CVal");
0673:                                String objClass = obj.getClass().getName();
0674:
0675:                                if (objClass.equals("java.lang.String")) {
0676:                                    outFile.write(obj.toString());
0677:                                } else if (objClass.indexOf("Vector") > 0) {
0678:                                    Enumeration en = (Enumeration) obj;
0679:                                    outFile.write("\n");
0680:                                    doIndent();
0681:                                    outFile.write("<ChoiceValues>\n");
0682:                                    numTabs += 1;
0683:                                    while (en.hasMoreElements()) {
0684:                                        doIndent();
0685:                                        outFile.write("<ChoiceValue>"
0686:                                                + en.nextElement()
0687:                                                + "</ChoiceValue>\n");
0688:                                    }
0689:                                    numTabs -= 1;
0690:                                    doIndent();
0691:                                    outFile.write("</ChoiceValues>");
0692:                                } else {
0693:                                    outFile.write("object class = " + objClass);
0694:                                }
0695:                            }
0696:
0697:                        }
0698:                        if (att._atts.containsKey("attval")) {
0699:                            if (Element.mapper.get("attval") != null) {
0700:                                Object obj = (Object) att._atts.get("attval");
0701:                                String objClass = obj.getClass().getName();
0702:
0703:                                if (objClass.equals("java.lang.String")) {
0704:                                    outFile.write("\n");
0705:                                    doIndent();
0706:                                    outFile.write("<DefaultValues>\n");
0707:                                    numTabs += 1;
0708:                                    doIndent();
0709:                                    outFile.write("<Value>" + obj.toString()
0710:                                            + "</Value>\n");
0711:                                    numTabs -= 1;
0712:                                    doIndent();
0713:                                    outFile.write("</DefaultValues>\n");
0714:                                    numTabs -= 1;
0715:                                    doIndent();
0716:                                    outFile.write("</AttributeSchema>\n");
0717:                                } else if (objClass.indexOf("Vector") > 0) {
0718:                                    Enumeration en = (Enumeration) obj;
0719:                                    outFile.write("\n");
0720:                                    doIndent();
0721:                                    outFile.write("<DefaultValues>\n");
0722:                                    numTabs += 1;
0723:                                    while (en.hasMoreElements()) {
0724:                                        doIndent();
0725:                                        outFile.write("<Value>"
0726:                                                + en.nextElement()
0727:                                                + "</Value>\n");
0728:                                    }
0729:                                    numTabs -= 1;
0730:                                    doIndent();
0731:                                    outFile.write("</DefaultValues>");
0732:                                } else {
0733:                                    outFile.write("object class = " + objClass);
0734:                                }
0735:                            }
0736:
0737:                            //	outFile.write("\n");
0738:                        }
0739:                        outFile.write("\n");
0740:                        numTabs -= 1;
0741:                        doIndent();
0742:                        outFile.write("</AttributeSchema>\n");
0743:                        /*numTabs -= 1;
0744:                        doIndent();
0745:                        outFile.write("/>\n");
0746:                         */
0747:                    } else {
0748:                        //System.out.println("Hey, no 'type'!");
0749:                    }
0750:                } catch (IOException ie) {
0751:                    System.out.println("Error writing to specified file");
0752:                    ie.printStackTrace();
0753:
0754:                }
0755:            }
0756:
0757:            public void ProcessAuthModule(String outfilename) throws Exception {
0758:
0759:                outFile = new FileWriter(outfilename);
0760:                Hashtable ht = new Hashtable();
0761:                int numAttrs = _attributes.size();
0762:                int numPrivs = _privileges.size();
0763:
0764:                if (numAttrs > 0) {
0765:                    String lineSvcName = "<Service name=\"" + _compname
0766:                            + "\" version=\"" + _configdata.get(VERSION)
0767:                            + "\">";
0768:                    String lineSvcSchema = "<Schema serviceHierarchy=\"/ps.configuration/"
0769:                            + _compname + "\"";
0770:                    printFrontStuff(_compname);
0771:                    numTabs = 1;
0772:                    doIndent();
0773:
0774:                    outFile.write(lineSvcName + "\n");
0775:                    numTabs = 2;
0776:                    doIndent();
0777:                    outFile.write(lineSvcSchema);
0778:                }
0779:
0780:                numTabs += 1;
0781:                outFile.write("\n");
0782:                doIndent();
0783:                if (_configdata.get(RESOURCEBUNDLE) != null) {
0784:                    outFile.write("i18nFileName=\"");
0785:                    printContents(_configdata.get(RESOURCEBUNDLE));
0786:                    outFile.write("\" \n");
0787:
0788:                    doIndent();
0789:                    outFile.write("i18nKey=\"");
0790:                    if (_configdata.get(INDEX) != null) {
0791:                        printContents(_configdata.get(INDEX));
0792:                    } else {
0793:                        outFile.write(_compname + "-description");
0794:                    }
0795:                    outFile.write("\">\n");
0796:                }
0797:
0798:                int attrsToAdd = 0;
0799:                for (int i = 0; i < numAttrs; i++) {
0800:                    if ((((Attribute) _attributes.elementAt(i))._atts)
0801:                            .containsKey("userConfigurable"))
0802:                        if (((String) ((((Attribute) _attributes.elementAt(i))._atts)
0803:                                .get("userConfigurable")))
0804:                                .equalsIgnoreCase("FALSE")) {
0805:                            attrsToAdd++;
0806:                            break;
0807:                        }
0808:
0809:                }
0810:
0811:                if (attrsToAdd != 0) {
0812:                    numTabs++;
0813:                    doIndent();
0814:                    outFile.write("<Global>\n");
0815:                    numTabs++;
0816:                    for (int i = 0; i < numAttrs; i++) {
0817:                        Attribute att = (Attribute) _attributes.elementAt(i);
0818:                        Object val;
0819:                        String name = att.name;
0820:
0821:                        if (att._atts.containsKey("userConfigurable")) {
0822:                            String xstr = (String) att._atts
0823:                                    .get("userConfigurable");
0824:                            if (xstr.equalsIgnoreCase("FALSE")) { // did the others above
0825:                                doIndent();
0826:                                outFile.write("<AttributeSchema name=\"" + name
0827:                                        + "\"\n");
0828:                                numTabs += 1;
0829:
0830:                                processAttribute(att);
0831:                            }
0832:                        }
0833:
0834:                    }
0835:                    numTabs -= 1;
0836:                    doIndent();
0837:                    outFile.write("</Global>\n");
0838:                }
0839:
0840:                attrsToAdd = 0;
0841:                for (int i = 0; i < numAttrs; i++) {
0842:                    if ((((Attribute) _attributes.elementAt(i))._atts)
0843:                            .containsKey("userConfigurable"))
0844:                        if (((String) ((((Attribute) _attributes.elementAt(i))._atts)
0845:                                .get("userConfigurable")))
0846:                                .equalsIgnoreCase("TRUE")) {
0847:                            attrsToAdd++;
0848:                            break;
0849:                        }
0850:
0851:                }
0852:
0853:                if (attrsToAdd != 0) {
0854:                    doIndent();
0855:                    outFile.write("<Organization>\n");
0856:                    numTabs++;
0857:                    for (int i = 0; i < numAttrs; i++) {
0858:                        Attribute att = (Attribute) _attributes.elementAt(i);
0859:                        Object val;
0860:                        String name = att.name;
0861:
0862:                        if (att._atts.containsKey("userConfigurable")) {
0863:                            String xstr = (String) att._atts
0864:                                    .get("userConfigurable");
0865:                            if (xstr.equalsIgnoreCase("TRUE")) { // did the others above
0866:                                doIndent();
0867:                                outFile.write("<AttributeSchema name=\"" + name
0868:                                        + "\"\n");
0869:                                numTabs += 1;
0870:
0871:                                processAttribute(att);
0872:                            }
0873:                        }
0874:
0875:                    }
0876:                    numTabs -= 1;
0877:                    doIndent();
0878:                    outFile.write("</Organization>\n");
0879:                }
0880:                numTabs -= 1;
0881:                doIndent();
0882:                outFile.write("</Schema>\n");
0883:                numTabs -= 1;
0884:                doIndent();
0885:                outFile.write("</Service>\n");
0886:                numTabs -= 1;
0887:                doIndent();
0888:                outFile.write("</ServicesConfiguration>\n");
0889:                outFile.close();
0890:            }
0891:
0892:            public void convertProfile(String intype, String outfilename)
0893:                    throws Exception {
0894:                String ptype = intype;
0895:
0896:                outFile = new FileWriter(outfilename);
0897:                if (_debugConvert) {
0898:                    System.out.println("Component:convertProfile, intype="
0899:                            + intype);
0900:                }
0901:
0902:                try {
0903:                    Hashtable ht = new Hashtable();
0904:                    int numAttrs = _attributes.size();
0905:                    int numPrivs = _privileges.size();
0906:
0907:                    if (_debugConvert) {
0908:                        System.out.println("Component:convertProfile:numAttrs="
0909:                                + numAttrs);
0910:                    }
0911:
0912:                    if (numAttrs > 0) {
0913:                        String lineSvcName = "<Service name=\"" + _compname
0914:                                + "\" version=\"" + _configdata.get(VERSION)
0915:                                + "\">";
0916:                        String lineSvcSchema = "<Schema serviceHierarchy=\"/ps.configuration/"
0917:                                + _compname + "\"";
0918:                        printFrontStuff(_compname);
0919:                        numTabs = 1;
0920:                        doIndent();
0921:
0922:                        outFile.write(lineSvcName + "\n");
0923:                        numTabs = 2;
0924:                        doIndent();
0925:                        outFile.write(lineSvcSchema);
0926:                    }
0927:
0928:                    //
0929:                    //  next is the "i18nFileName" parameter, which corresponds to the
0930:                    //  iPS "resB" parameter.
0931:                    //
0932:
0933:                    numTabs += 1;
0934:                    outFile.write("\n");
0935:                    doIndent();
0936:                    if (_configdata.get(RESOURCEBUNDLE) != null) {
0937:                        //System.out.print ("i18nFileName=\"");
0938:                        outFile.write("i18nFileName=\"");
0939:                        printContents(_configdata.get(RESOURCEBUNDLE));
0940:                        outFile.write("\" \n");
0941:
0942:                        doIndent();
0943:                        outFile.write("i18nKey=\"");
0944:                        if (_configdata.get(INDEX) != null) {
0945:                            //printContents(_configdata.get(INDEX));
0946:                            outFile.write(_compname + "-description");
0947:                        } else {
0948:                            outFile.write(_compname + "-description");
0949:                        }
0950:                        outFile.write("\">\n");
0951:                    }
0952:
0953:                    //
0954:                    //  now the one-per-installation stuff
0955:                    //
0956:
0957:                    int attrsToAdd = 0;
0958:                    for (int i = 0; i < numAttrs; i++) {
0959:                        if ((((Attribute) _attributes.elementAt(i))._atts)
0960:                                .containsKey("userConfigurable"))
0961:                            if (((String) ((((Attribute) _attributes
0962:                                    .elementAt(i))._atts)
0963:                                    .get("userConfigurable")))
0964:                                    .equalsIgnoreCase("FALSE")) {
0965:                                attrsToAdd++;
0966:                                break;
0967:                            }
0968:
0969:                    }
0970:                    if (attrsToAdd != 0) {
0971:                        doIndent();
0972:                        outFile.write("<Global>\n");
0973:                        /*numTabs += 1;
0974:                        doIndent();
0975:                         outFile.write("<AttributeSchema name=\"serviceObjectClasses\" \n");
0976:                        numTabs += 1;
0977:                        doIndent();
0978:                        outFile.write("type=\"list\"\n");
0979:                        doIndent();
0980:                        outFile.write("syntax=\"string\"\n");
0981:                        doIndent();
0982:                        outFile.write(">\n");
0983:                        doIndent();
0984:                        outFile.write("<DefaultValues>\n");
0985:                        numTabs += 1;doIndent();
0986:                        outFile.write("<Value>"+_compname+"-service</Value>\n");
0987:                        numTabs -=1; doIndent();
0988:                        outFile.write("</DefaultValues>\n");
0989:                        numTabs -=1; doIndent();
0990:                        outFile.write("</AttributeSchema>\n");
0991:                         */
0992:                        for (int i = 0; i < numAttrs; i++) {
0993:                            Attribute att = (Attribute) _attributes
0994:                                    .elementAt(i);
0995:                            Object val;
0996:                            String name = att.name;
0997:
0998:                            //
0999:                            //  att._atts is a Hashtable.  don't really want to spin through
1000:                            //  all the keys, rather want to see if specific ones are there.
1001:                            //
1002:
1003:                            if ((name.toLowerCase()).indexOf("resourcebundle") < 0
1004:                                    && (name.toLowerCase())
1005:                                            .indexOf("description") < 0) {
1006:                                if (att._atts.containsKey("userConfigurable")) {
1007:                                    String xstr = (String) att._atts
1008:                                            .get("userConfigurable");
1009:                                    if (xstr.equalsIgnoreCase("FALSE")) { // did the others above
1010:                                        doIndent();
1011:                                        outFile
1012:                                                .write("<AttributeSchema name=\""
1013:                                                        + name + "\"\n");
1014:                                        numTabs += 1;
1015:
1016:                                        processAttribute(att);
1017:                                    }
1018:                                } else {
1019:                                    // System.out.println("Hey, no 'userConfigurable'!");
1020:                                }
1021:                            }
1022:
1023:                        }
1024:
1025:                        numTabs -= 1;
1026:                        doIndent();
1027:                        outFile.write("</Global>\n");
1028:
1029:                    }
1030:
1031:                    //
1032:                    //  now the ServiceSubSchema sections.  'name="Dynamic"' is iDSAME's
1033:                    //  way of indicating per org or per role attributes, as opposed to
1034:                    //  'name="Global"', which indicates one-instance-per-installation
1035:                    //  attributes.  the way to distinguish which iPS attributes go where
1036:                    //  depends on the userConfigurable setting; 'false' means it's
1037:                    //  "Global".
1038:                    //
1039:                    attrsToAdd = 0;
1040:                    for (int i = 0; i < numAttrs; i++) {
1041:                        if ((((Attribute) _attributes.elementAt(i))._atts)
1042:                                .containsKey("userConfigurable"))
1043:                            if (((String) ((((Attribute) _attributes
1044:                                    .elementAt(i))._atts)
1045:                                    .get("userConfigurable")))
1046:                                    .equalsIgnoreCase("TRUE")) {
1047:                                attrsToAdd++;
1048:                                break;
1049:                            }
1050:
1051:                    }
1052:
1053:                    if (attrsToAdd != 0) {
1054:
1055:                        doIndent();
1056:                        outFile.write("<Dynamic>\n");
1057:                        numTabs += 1;
1058:                        /*	    	doIndent();
1059:                         outFile.write("<SchemaType type=\"Global\"/>\n");
1060:                         numTabs += 1;
1061:                         */
1062:                        for (int i = 0; i < numAttrs; i++) {
1063:                            Attribute att = (Attribute) _attributes
1064:                                    .elementAt(i);
1065:                            Object val;
1066:                            String name = att.name;
1067:
1068:                            //		System.out.println("att.name=" + att.name);
1069:
1070:                            //
1071:                            //  att._atts is a Hashtable.  don't really want to spin through
1072:                            //  all the keys, rather want to see if specific ones are there.
1073:                            //
1074:
1075:                            if (att._atts.containsKey("userConfigurable")) {
1076:                                String xstr = (String) att._atts
1077:                                        .get("userConfigurable");
1078:                                if (xstr.equalsIgnoreCase("TRUE")) { // else forget about this one for now
1079:                                    doIndent();
1080:                                    outFile.write("<AttributeSchema name=\""
1081:                                            + name + "\"\n");
1082:                                    numTabs += 1;
1083:
1084:                                    processAttribute(att);
1085:                                }
1086:                            } else {
1087:                                //System.out.println("Hey, no 'userConfigurable'!");
1088:                            }
1089:                        }
1090:
1091:                        numTabs -= 1;
1092:                        doIndent();
1093:                        outFile.write("</Dynamic>\n");
1094:
1095:                    }
1096:
1097:                    if (numPrivs != 0) {
1098:                        doIndent();
1099:                        outFile.write("<Policy>\n");
1100:                        numTabs += 1;
1101:                        /*	doIndent();
1102:                        outFile.write("<SchemaType type=\"Policy\"/>\n");
1103:                        numTabs += 1; */
1104:
1105:                        for (int i = 0; i < numPrivs; i++) {
1106:                            Privilege att = (Privilege) _privileges
1107:                                    .elementAt(i);
1108:                            Object val;
1109:                            String name = att.name;
1110:
1111:                            if (_debugConvert) {
1112:                                System.out
1113:                                        .println("Component:convertProfile:priv.name="
1114:                                                + name);
1115:                            }
1116:
1117:                            //
1118:                            //  don't want to add privs to LDAP, either
1119:                            //
1120:                            //              addPrivToSchema(name);
1121:                            //		if (att._atts.containsKey("userConfigurable")) {
1122:                            //	    String xstr = (String)att._atts.get("userConfigurable");
1123:                            //	    if (xstr.equalsIgnoreCase ("TRUE")) {  // did the others above
1124:                            doIndent();
1125:                            outFile.write("<AttributeSchema name=\"" + name
1126:                                    + "\"\n");
1127:                            numTabs += 1;
1128:
1129:                            processPrivilege(att);
1130:                            /*    	    }
1131:                            } else {
1132:                               System.out.println("Hey, no 'userConfigurable'!");
1133:                            } */
1134:
1135:                        }
1136:                        numTabs -= 1; //  no matching </SchemaType>
1137:                        doIndent();
1138:                        outFile.write("</Policy>\n");
1139:                        numTabs -= 1;
1140:
1141:                    }
1142:                    //
1143:                    //  now the data part
1144:                    //
1145:
1146:                    doIndent();
1147:                    outFile.write("</Schema>\n");
1148:                    /*	    doIndent();
1149:                     outFile.write("<Configuration>\n");
1150:
1151:                     //
1152:                     //  not sure where the "serviceObjectClasses" attribute comes from,
1153:                     //  or its value.  for now, fake it?
1154:                     //
1155:
1156:                     numTabs += 1;
1157:                     doIndent();
1158:                     outFile.write("<AttributeValuePair>\n");
1159:                     numTabs += 1;
1160:                     doIndent();
1161:                     outFile.write("<Attribute name=\"serviceObjectClasses\"/>\n");
1162:                     doIndent();
1163:                     outFile.write("<Value>" + _compname + "-service" + "</Value>\n");
1164:                     numTabs -= 1;
1165:                     doIndent();
1166:                     outFile.write("</AttributeValuePair>\n");
1167:                     doIndent();
1168:                     outFile.write("<ServiceSubConfig name=\"Dynamic\"> \n");
1169:                     numTabs += 1;
1170:
1171:
1172:                     numTabs += 1;
1173:                     doIndent();
1174:
1175:                     outFile.write("<OrganizationConfiguration>");
1176:                     //
1177:                     //  do the dynamic attrs here
1178:                     //
1179:
1180:                     for (int i=0; i< numAttrs; i++) {
1181:                     Attribute att = (Attribute) _attributes.elementAt(i);
1182:                     Object val;
1183:                     String name = att.name;
1184:
1185:                     //
1186:                     //  att._atts is a Hashtable.  don't really want to spin through
1187:                     //  all the keys, rather want to see if specific ones are there.
1188:                     //
1189:
1190:                     if (att._atts.containsKey("userConfigurable")) {
1191:                     String xstr = (String)att._atts.get("userConfigurable");
1192:                     if (xstr.equalsIgnoreCase ("TRUE")) {  // did the others below
1193:
1194:                     if (att._atts.containsKey("attval")) {
1195:                     if (Element.mapper.get("attval") != null) {
1196:                     Object obj = (Object)att._atts.get("attval");
1197:                     String objClass = obj.getClass().getName();
1198:
1199:                     doIndent();
1200:                     outFile.write("<AttributeValuePair>\n");
1201:                     numTabs += 1;
1202:
1203:                     if (objClass.equals("java.lang.String")) {
1204:                     doIndent();
1205:                     outFile.write("<Attribute name=\"" + name + "\"/>\n");
1206:                     doIndent();
1207:                     outFile.write("<Value>" + obj + "</Value>\n");
1208:                     } else if (objClass.indexOf("Vector") > 0) {  // can have >1 value?
1209:                     doIndent();
1210:                     outFile.write("<Attribute name=\"" + name + "\"/>\n");
1211:                     Enumeration en = (Enumeration) obj;
1212:                     while (en.hasMoreElements()) {
1213:                     doIndent();
1214:                     outFile.write("<Value>" + en.nextElement() +
1215:                     "</Value>\n");
1216:                     }
1217:                     }
1218:                     numTabs -= 1;
1219:                     doIndent();
1220:                     outFile.write("</AttributeValuePair>\n");
1221:                     }
1222:                     } else {
1223:                     //
1224:                     //  should the attribute name be put here, without a <Value>?
1225:
1226:
1227:                     //  Note by Sailaja: The dtd definition itself sort of states Value*
1228:                     //  Does it not indicate that at times 0 occurences of Value also is valid...
1229:                     //
1230:
1231:                     //System.out.println ("Hey, " + name + " doesn't have a default value");
1232:                     }
1233:                     }
1234:                     } else {
1235:                     //System.out.println("Hey, no 'userConfigurable'!");
1236:                     }
1237:                     }
1238:                     numTabs -= 1;
1239:                     doIndent();
1240:                     outFile.write("</ServiceSubConfig>\n");
1241:
1242:                     numTabs += 1;
1243:                     doIndent();
1244:                     outFile.write("<GlobalConfiguration>\n");
1245:                     numTabs += 1;
1246:
1247:                     //
1248:                     //  do the global attrs here
1249:                     //
1250:
1251:                     for (int i=0; i< numAttrs; i++) {
1252:                     Attribute att = (Attribute) _attributes.elementAt(i);
1253:                     Object val;
1254:                     String name = att.name;
1255:
1256:                     //
1257:                     //  att._atts is a Hashtable.  don't really want to spin through
1258:                     //  all the keys, rather want to see if specific ones are there.
1259:                     //
1260:
1261:                     if (att._atts.containsKey("userConfigurable")) {
1262:                     String xstr = (String)att._atts.get("userConfigurable");
1263:                     if (xstr.equalsIgnoreCase ("FALSE")) {  // did the others above
1264:
1265:                     if (att._atts.containsKey("attval")) {
1266:                     if (Element.mapper.get("attval") != null) {
1267:                     Object obj = (Object)att._atts.get("attval");
1268:                     String objClass = obj.getClass().getName();
1269:
1270:                     doIndent();
1271:                     outFile.write("<AttributeValuePair>\n");
1272:                     numTabs += 1;
1273:
1274:                     if (objClass.equals("java.lang.String")) {
1275:                     doIndent();
1276:                     outFile.write("<Attribute name=\"" + name + "\"/>\n");
1277:                     doIndent();
1278:                     outFile.write("<Value>" + obj + "</Value>\n");
1279:                     } else if (objClass.indexOf("Vector") > 0) {  // can have >1 value?
1280:                     doIndent();
1281:                     outFile.write("<Attribute name=\"" + name + "\"/>\n");
1282:                     Enumeration en = (Enumeration) obj;
1283:                     while (en.hasMoreElements()) {
1284:                     doIndent();
1285:                     outFile.write("<Value>" + en.nextElement() +
1286:                     "</Value>\n");
1287:                     }
1288:                     }
1289:                     numTabs -= 1;
1290:                     doIndent();
1291:                     outFile.write("</AttributeValuePair>\n");
1292:                     }
1293:                     } else {
1294:                     //
1295:                     //  should the attribute name be put here, without a <Value>?
1296:                     //
1297:                     //System.out.println ("Hey, " + name + " doesn't have a default value");
1298:                     }
1299:                     }
1300:                     } else {
1301:                     //System.out.println("Hey, no 'userConfigurable'!");
1302:                     }
1303:                     }
1304:
1305:                     numTabs -= 1;
1306:                     doIndent();
1307:                     outFile.write("</GlobalConfiguration>\n");
1308:
1309:                     numTabs -= 1;
1310:                     doIndent();
1311:                     outFile.write("</Configuration>\n"); */
1312:                    numTabs -= 1;
1313:                    doIndent();
1314:                    outFile.write("</Service>\n");
1315:                    numTabs -= 1;
1316:                    doIndent();
1317:                    outFile.write("</ServicesConfiguration>\n");
1318:
1319:                    /*	    for (int i=0; i< numAttrs; i++) {
1320:                     Attribute att = (Attribute) _attributes.elementAt(i);
1321:                     Object val;
1322:                     String name = att.name;
1323:
1324:                     if (_debugConvert) {
1325:                     System.out.println ("Component:convertProfile:att.name=" + name);
1326:                     }
1327:                     */
1328:                    //
1329:                    //  don't want to add attributes to LDAP!
1330:                    //
1331:                    //		addAttrToSchema(name);
1332:                    /*		Enumeration keys = att._atts.keys();
1333:                     while (keys.hasMoreElements()) {
1334:                     String key = (String) keys.nextElement();
1335:
1336:                     if (_debugConvert) {
1337:                     System.out.println ("Component:convertProfile:attr.key=" + key);
1338:                     }
1339:
1340:                     if (Element.mapper.get(key) != null) {
1341:                     ht.put(name+Element.ATTPREFIX+Element.mapper.get(key), att._atts.get(key));
1342:
1343:                     if (_debugConvert) {
1344:                     System.out.print ("Component:convertProfile:put(" +
1345:                     name+Element.ATTPREFIX+Element.mapper.get(key) + ", ");
1346:                     printContents (att._atts.get(key));
1347:                     System.out.println (")");
1348:                     }
1349:
1350:                     } else {
1351:                     throw new Exception(bundle.getString("invxml")+name+" "+key);
1352:                     }
1353:                     }
1354:                     }
1355:                     int numPrivs = _privileges.size();
1356:
1357:                     System.out.println("NUmber of privilges:"+numPrivs+"::::");
1358:                     if (_debugConvert) {
1359:                     System.out.println ("Component:convertProfile:numPrivs=" + numPrivs);
1360:                     }
1361:
1362:                     for (int i=0; i< numPrivs; i++) {
1363:                     Privilege att = (Privilege) _privileges.elementAt(i);
1364:                     Object val;
1365:                     String name = att.name;
1366:
1367:                     if (_debugConvert) {
1368:                     System.out.println ("Component:convertProfile:priv.name=" + name);
1369:                     }
1370:                     */
1371:                    //
1372:                    //  don't want to add privs to LDAP, either
1373:                    //
1374:                    //		addPrivToSchema(name);
1375:                    /*		Enumeration keys = att._atts.keys();
1376:                     while (keys.hasMoreElements()) {
1377:                     String key = (String) keys.nextElement();
1378:
1379:                     if (_debugConvert) {
1380:                     System.out.println ("Component:convertProfile:priv.key=" + key);
1381:                     }
1382:
1383:                     if (Element.mapper.get(key) != null) {
1384:                     ht.put(name+Element.PRIVPREFIX+Element.mapper.get(key), att._atts.get(key));
1385:                     if (_debugConvert) {
1386:                     System.out.print ("Component:convertProfile:put(" +
1387:                     name+Element.PRIVPREFIX+Element.mapper.get(key) + ", ");
1388:                     printContents (att._atts.get(key));
1389:                     System.out.println (")");
1390:                     }
1391:                     } else {
1392:                     throw new Exception(bundle.getString("invxml")+name+" "+key);
1393:                     }
1394:                     }
1395:                     }
1396:                     */
1397:                    // Handle special cases of Description,ResourceBundle and DescIndex
1398:                    /*	    if (_configdata.get(DESC) != null) {
1399:                     String attname = _compname+"-description"+ATTPREFIX;
1400:
1401:                     if (_debugConvert) {
1402:                     System.out.println ("Component:convertProfile:add '" + attname + "'");
1403:                     }
1404:                     */
1405:                    //		addAttrToSchema(_compname+"-description");
1406:                    /*		ht.put(attname, _configdata.get(DESC));
1407:
1408:                     if (_debugConvert) {
1409:                     System.out.print ("Component:convertProfile:put(" + attname + ", ");
1410:                     printContents(_configdata.get(DESC));
1411:                     System.out.println (")");
1412:                     }
1413:
1414:                     ht.put(attname+mapper.get(READPERM), admin_owner.elements());
1415:
1416:                     if (_debugConvert) {
1417:                     System.out.print ("Component:convertProfile:put(" +
1418:                     attname+mapper.get(READPERM) + ", ");
1419:                     printContents (admin_owner.elements());
1420:                     System.out.println (")");
1421:                     }
1422:
1423:                     if (_configdata.get(INDEX) != null) {
1424:                     ht.put(attname+mapper.get(INDEX), _configdata.get(INDEX));
1425:                     }
1426:                     ht.put(attname+mapper.get(TYPE), "string");
1427:
1428:                     if (_debugConvert) {
1429:                     System.out.println ("Component:convertProfile:put(" +
1430:                     attname+mapper.get(TYPE) + ", string)");
1431:                     }
1432:
1433:                     ht.put(attname+mapper.get(USERCONFIGURABLE), "false");
1434:
1435:                     if (_debugConvert) {
1436:                     System.out.println ("Component:convertProfile:put(" +
1437:                     attname+mapper.get(USERCONFIGURABLE) + ", false)");
1438:                     }
1439:
1440:                     }
1441:
1442:                     if (_configdata.get(RESOURCEBUNDLE) != null) {
1443:                     String attname = _compname+"-resourceBundle"+ATTPREFIX;
1444:
1445:                     if (_debugConvert) {
1446:                     System.out.println ("Component:convertProfile:add '" + attname + "'");
1447:                     }
1448:                     */
1449:                    //		addAttrToSchema(_compname+"-resourceBundle");
1450:                    /*		ht.put(attname, _configdata.get(RESOURCEBUNDLE));
1451:
1452:                     if (_debugConvert) {
1453:                     System.out.print("Component:convertProfile:put(" + attname +
1454:                     ", ");
1455:                     printContents(_configdata.get(RESOURCEBUNDLE));
1456:                     System.out.println(")");
1457:                     }
1458:
1459:                     ht.put(attname+mapper.get(READPERM), admin_owner.elements());
1460:
1461:                     if (_debugConvert) {
1462:                     System.out.print("Component:convertProfile:put(" +
1463:                     attname+mapper.get(READPERM) + ", ");
1464:                     printContents(admin_owner.elements());
1465:                     System.out.println(")");
1466:                     }
1467:
1468:                     if (_configdata.get(INDEX) != null) {
1469:                     ht.put(attname+mapper.get(INDEX), _configdata.get(INDEX));
1470:
1471:                     if (_debugConvert) {
1472:                     System.out.println("Component:convertProfile:put(" +
1473:                     attname+mapper.get(INDEX) + ", " + _configdata.get(INDEX)+ ")");
1474:                     }
1475:                     }
1476:
1477:                     ht.put(attname+mapper.get(TYPE), "string");
1478:
1479:                     if (_debugConvert) {
1480:                     System.out.println ("Component:convertProfile:put(" + attname+mapper.get(TYPE)
1481:                     + ", string)");
1482:                     }
1483:
1484:                     ht.put(attname+mapper.get(USERCONFIGURABLE), "false");
1485:
1486:                     if (_debugConvert) {
1487:                     System.out.println ("Component:convertProfile:put(" +
1488:                     attname+mapper.get(USERCONFIGURABLE) + ", false)");
1489:                     }
1490:
1491:                     }
1492:                     */
1493:                    // Setup adminRoles as a empty list
1494:                    /*	    if (ptype.equals("domain") && ht.get("iwtPlatform-adminRoles"+ATTPREFIX) == null) {
1495:                     Vector tmp = new Vector();
1496:                     ht.put("iwtPlatform-adminRoles"+ATTPREFIX, tmp.elements());
1497:                     if (_debugConvert) {
1498:                     System.out.println ("Component:convertProfile:add 'iwtPlatform-adminRoles" +
1499:                     ATTPREFIX + "', tmp.elements=" +  tmp.elements());
1500:                     }
1501:
1502:                     }
1503:
1504:                     if (ptype.equals("user") && ht.get("iwtUser-role-at") == null) {
1505:                     System.err.println(bundle.getString("rolewarning"));
1506:                     }
1507:                     */
1508:
1509:                    outFile.close();
1510:                } catch (Exception e) {
1511:                    throw new Exception(bundle.getString("createfail")
1512:                            + getProfileBundle(e.getMessage()));
1513:                }
1514:            }
1515:
1516:            public void deleteProfile(String intype, String profilename)
1517:                    throws Exception {
1518:                try {
1519:                    if (intype.equals("component")) {
1520:                        profilename = "/" + intype + "/" + profilename;
1521:                    } else if (intype.equals("domain")) {
1522:                        if (!profilename.startsWith("/")) {
1523:                            profilename = "/" + profilename;
1524:                        }
1525:                    }
1526:                    // initialize ProfileServiceManager
1527:                    ProfileServiceManager psm = new ProfileServiceManager(1);
1528:                    psm.removeProfile(profilename, true);
1529:                    psm.close();
1530:                } catch (Exception e) {
1531:                    throw new Exception(bundle.getString("deletefail")
1532:                            + getProfileBundle(e.getMessage()));
1533:                }
1534:            }
1535:
1536:            public void changeProfile(String intype, String profilename)
1537:                    throws Exception {
1538:
1539:                try {
1540:                    if (intype.equals("component")) {
1541:                        profilename = "/" + intype + "/" + profilename;
1542:                    }
1543:                    // initialize ProfileServiceManager
1544:                    ProfileServiceManager psm = new ProfileServiceManager(1);
1545:                    //ProfileInstance ppe = (ProfileInstance) psm.getProfileInstance("sun.com/qcheng");
1546:                    ProfileInstance ppe = (ProfileInstance) psm
1547:                            .getProfileInstance(profilename);
1548:                    if (ppe == null)
1549:                        throw new Exception(bundle.getString("notfound"));
1550:                    _compname = profilename;
1551:                    Hashtable ht = new Hashtable();
1552:                    int numAttrs = _attributes.size();
1553:                    for (int i = 0; i < numAttrs; i++) {
1554:                        Attribute att = (Attribute) _attributes.elementAt(i);
1555:                        Object val;
1556:                        String name = att.name;
1557:
1558:                        Enumeration keys = att._atts.keys();
1559:                        while (keys.hasMoreElements()) {
1560:                            String key = (String) keys.nextElement();
1561:                            if (Element.mapper.get(key) != null)
1562:                                ht.put(name + Element.ATTPREFIX
1563:                                        + Element.mapper.get(key), att._atts
1564:                                        .get(key));
1565:                            else
1566:                                throw new Exception(bundle.getString("invxml")
1567:                                        + name + " " + key);
1568:                        }
1569:                    }
1570:                    int numPrivs = _privileges.size();
1571:                    for (int i = 0; i < numPrivs; i++) {
1572:                        Privilege att = (Privilege) _privileges.elementAt(i);
1573:                        Object val;
1574:                        String name = att.name;
1575:                        Enumeration keys = att._atts.keys();
1576:                        while (keys.hasMoreElements()) {
1577:                            String key = (String) keys.nextElement();
1578:                            if (Element.mapper.get(key) != null)
1579:                                ht.put(name + Element.PRIVPREFIX
1580:                                        + Element.mapper.get(key), att._atts
1581:                                        .get(key));
1582:                            else
1583:                                throw new Exception(bundle.getString("invxml")
1584:                                        + name + " " + key);
1585:                        }
1586:                    }
1587:                    // Handle special cases of description,ResourceBundle and DescIndex
1588:                    if (_configdata.get(DESC) != null) {
1589:                        String attname = _compname + "-description" + ATTPREFIX;
1590:                        ht.put(attname, _configdata.get(DESC));
1591:                        ht.put(attname + mapper.get(READPERM), admin_owner
1592:                                .elements());
1593:                        if (_configdata.get(INDEX) != null)
1594:                            ht.put(attname + mapper.get(INDEX), _configdata
1595:                                    .get(INDEX));
1596:                        ht.put(attname + mapper.get(TYPE), "string");
1597:                        ht.put(attname + mapper.get(USERCONFIGURABLE), "false");
1598:                    }
1599:                    if (_configdata.get(RESOURCEBUNDLE) != null) {
1600:                        String attname = _compname + "-resourceBundle"
1601:                                + ATTPREFIX;
1602:                        ht.put(attname, _configdata.get(RESOURCEBUNDLE));
1603:                        ht.put(attname + mapper.get(READPERM), admin_owner
1604:                                .elements());
1605:                        if (_configdata.get(INDEX) != null)
1606:                            ht.put(attname + mapper.get(INDEX), _configdata
1607:                                    .get(INDEX));
1608:                        ht.put(attname + mapper.get(TYPE), "string");
1609:                        ht.put(attname + mapper.get(USERCONFIGURABLE), "false");
1610:                    }
1611:                    // Okay, now start updating...
1612:                    Enumeration en = ht.keys();
1613:                    while (en.hasMoreElements()) {
1614:                        String key = (String) en.nextElement();
1615:                        ppe.setAttrib(key, ht.get(key), true);
1616:                    }
1617:                    psm.close();
1618:                } catch (Exception e) {
1619:                    throw new Exception(bundle.getString("changefail")
1620:                            + getProfileBundle(e.getMessage()));
1621:                }
1622:            }
1623:
1624:            public void getProfile(String intype, String profilename)
1625:                    throws Exception {
1626:
1627:                try {
1628:                    if (intype.equals("component")) {
1629:                        profilename = "/" + intype + "/" + profilename;
1630:                    }
1631:
1632:                    if (_debug) {
1633:                        System.out.println("Component:getProfile:intype="
1634:                                + intype + ", profilename=" + profilename);
1635:                        System.out.println("Component:getProfile:profilename="
1636:                                + profilename);
1637:                    }
1638:
1639:                    // initialize ProfileServiceManager
1640:                    ProfileServiceManager psm = new ProfileServiceManager(1);
1641:                    //ProfileInstance ppe = (ProfileInstance) psm.getProfileInstance("sun.com/qcheng");
1642:
1643:                    //
1644:                    //  for components, profilename = "/component/<theComponentName>"
1645:                    //
1646:                    ProfileInstance ppe = (ProfileInstance) psm
1647:                            .getProfileInstance(profilename);
1648:                    if (ppe == null)
1649:                        throw new Exception(bundle.getString("notfound"));
1650:                    _compname = profilename;
1651:                    Enumeration em0 = ppe.getAttrib("*");
1652:                    while (em0.hasMoreElements()) {
1653:                        Object ob = em0.nextElement();
1654:                        if (ob
1655:                                .getClass()
1656:                                .getName()
1657:                                .equals(
1658:                                        "com.iplanet.portalserver.profile.impl.ProfileAttribute")) {
1659:                            ProfileAttribute pa0 = (ProfileAttribute) ob;
1660:                            Attribute at = new Attribute();
1661:                            Enumeration en;
1662:                            if (pa0.getName() != null) {
1663:                                String tmp = pa0.getName();
1664:                                if (!tmp.endsWith(ATTPREFIX))
1665:                                    continue;
1666:                                at.name = tmp.substring(0, tmp.length() - 3);
1667:                            }
1668:
1669:                            if (_debug) {
1670:                                System.out
1671:                                        .println("Component:getProfile:at.name="
1672:                                                + at.name);
1673:                            }
1674:
1675:                            if (pa0.getDescription() != null) {
1676:                                if (_debug) {
1677:                                    System.out
1678:                                            .println("Component:getProfile:description="
1679:                                                    + pa0.getDescription());
1680:                                }
1681:                                at.addAttribute(DESC, pa0.getDescription());
1682:                            }
1683:                            if (pa0.getCatalogID() != null) {
1684:                                at.addAttribute(INDEX, pa0.getCatalogID());
1685:                                if (_debug) {
1686:                                    System.out
1687:                                            .println("Component:getProfile:catalogid="
1688:                                                    + pa0.getCatalogID());
1689:                                }
1690:                            }
1691:                            if ((en = pa0.getValue()) != null) {
1692:                                at.setValues(en);
1693:                                if (_debug) {
1694:                                    for (Enumeration temp_en = en; temp_en
1695:                                            .hasMoreElements();) {
1696:                                        System.out
1697:                                                .println("Component:getProfile:getValues:"
1698:                                                        + temp_en.nextElement());
1699:                                    }
1700:                                }
1701:                                //			String defval = (String)at._atts.get("defaultValue");
1702:                                //			if (defval != null) {
1703:                                //			    System.out.println("Component:getProfile:defVal=" + defval);
1704:                                //			} else {
1705:                                //			    System.out.println("Component:getProfile:defVal=null");
1706:                                //			}
1707:                            }
1708:                            // TODO if (pa0.getRemoteFlag() != null)
1709:                            // TODO if (pa0.getInherit() != null)
1710:                            if (pa0.getOverrideFlag()) {
1711:                                at.addAttribute(USERCONFIGURABLE, "true");
1712:                                if (_debug) {
1713:                                    System.out
1714:                                            .println("Component:getProfile:Override=true");
1715:                                }
1716:                            } else {
1717:                                at.addAttribute(USERCONFIGURABLE, "false");
1718:                                if (_debug) {
1719:                                    System.out
1720:                                            .println("Component:getProfile:Override=false");
1721:                                }
1722:                            }
1723:                            if ((en = pa0.getReadPermission()) != null) {
1724:                                at.setRPermListAttribute(en);
1725:                                if (_debug) {
1726:                                    for (Enumeration e1 = at.rpermlist
1727:                                            .elements(); e1.hasMoreElements();) {
1728:                                        System.out
1729:                                                .println("Component:getProfile:getReadPermission:"
1730:                                                        + e1.nextElement());
1731:                                    }
1732:                                }
1733:                                ////			for (Enumeration temp_en = en; temp_en.hasMoreElements();) {
1734:                                ////		    	    System.out.println ("Component:getProfile:getReadPermission:" +
1735:                                ////				temp_en.nextElement());
1736:                                ////			}
1737:                                //			String tperm = (String)at._atts.get("readPermission");
1738:                                //			    if (tperm != null) {
1739:                                //				if (tperm.equals("ADMIN")) {
1740:                                //		    	    	    System.out.println ("Component:getProfile:readPerm:ADMIN");
1741:                                //				} else if (tperm.equals("OWNER")) {
1742:                                //		    	    	    System.out.println ("Component:getProfile:readPerm:OWNER");
1743:                                //				} else {
1744:                                //		    	    	    System.out.println ("Component:getProfile:readPerm:ADMIN/OWNER");
1745:                                //				}
1746:                                //			    } else {
1747:                                //		    	    	System.out.println ("Component:getProfile:readPerm:null");
1748:                                //			    }
1749:                            }
1750:                            if ((en = pa0.getWritePermission()) != null) {
1751:                                at.setWPermListAttribute(en);
1752:
1753:                                if (_debug) {
1754:                                    for (Enumeration e1 = at.wpermlist
1755:                                            .elements(); e1.hasMoreElements();) {
1756:                                        System.out
1757:                                                .println("Component:getProfile:getWritePermission:"
1758:                                                        + e1.nextElement());
1759:                                    }
1760:                                }
1761:
1762:                                ////			for (Enumeration temp_en = en; temp_en.hasMoreElements();) {
1763:                                ////		    	    System.out.println ("Component:getProfile:getWritePermission:" +
1764:                                ////				temp_en.nextElement());
1765:                                ////			}
1766:                                //			String tperm = (String)at._atts.get("writePermission");
1767:                                //			    if (tperm != null) {
1768:                                //				if (tperm.equals("ADMIN")) {
1769:                                //		    	    	    System.out.println ("Component:getProfile:writePerm:ADMIN");
1770:                                //				} else if (tperm.equals("OWNER")) {
1771:                                //		    	    	    System.out.println ("Component:getProfile:writePerm:OWNER");
1772:                                //				} else {
1773:                                //		    	    	    System.out.println ("Component:getProfile:writePerm:ADMIN/OWNER");
1774:                                //				}
1775:                                //			    } else {
1776:                                //		    	    	System.out.println ("Component:getProfile:writePerm:null");
1777:                                //			    }
1778:                            }
1779:                            if ((en = pa0.getChoices()) != null) {
1780:                                at.setChoiceListAttribute(en);
1781:                                if (_debug) {
1782:                                    for (Enumeration temp_en = en; temp_en
1783:                                            .hasMoreElements();) {
1784:                                        System.out
1785:                                                .println("Component:getProfile:getChoices:"
1786:                                                        + temp_en.nextElement());
1787:                                    }
1788:                                }
1789:                            }
1790:                            if (pa0.getType() != null) {
1791:                                if (_debug) {
1792:                                    System.out
1793:                                            .println("Component:getProfile:getType="
1794:                                                    + pa0.getType());
1795:                                }
1796:                                at.addAttribute(Element.TYPE, pa0.getType());
1797:                            }
1798:
1799:                            if (_debug) {
1800:                                System.out.println("Component:getProfile:at="
1801:                                        + at);
1802:                            }
1803:
1804:                            _attributes.addElement(at);
1805:                        } else {
1806:                            ProfilePrivilege pa0 = (ProfilePrivilege) ob;
1807:                            Privilege pr = new Privilege();
1808:                            Enumeration en;
1809:                            if (pa0.getName() != null) {
1810:                                String tmp = pa0.getName();
1811:                                if (!tmp.endsWith(PRIVPREFIX))
1812:                                    continue;
1813:                                pr.name = tmp.substring(0, tmp.length() - 3);
1814:                            }
1815:
1816:                            if (_debug) {
1817:                                System.out
1818:                                        .println("Component:getProfile:pr.name="
1819:                                                + pr.name);
1820:                            }
1821:
1822:                            // TODO if (pa0.getRemoteFlag() != null)
1823:
1824:                            if ((en = pa0.getReadPermission()) != null) {
1825:                                pr.setRPermListAttribute(en);
1826:                                if (_debug) {
1827:                                    for (Enumeration temp_en = en; temp_en
1828:                                            .hasMoreElements();) {
1829:                                        System.out
1830:                                                .println("Component:getProfile:getReadPermission:"
1831:                                                        + temp_en.nextElement());
1832:                                    }
1833:                                }
1834:                                //			String tperm = (String)pr._atts.get(Element.READPERM);
1835:                                //			    if (tperm != null) {
1836:                                //				if (tperm.equals("ADMIN")) {
1837:                                //		    	    	    System.out.println ("Component:getProfile:readPerm:ADMIN");
1838:                                //				} else if (tperm.equals("OWNER")) {
1839:                                //		    	    	    System.out.println ("Component:getProfile:readPerm:OWNER");
1840:                                //				} else {
1841:                                //		    	    	    System.out.println ("Component:getProfile:readPerm:ADMIN/OWNER");
1842:                                //				}
1843:                                //			    } else {
1844:                                //		    	    	System.out.println ("Component:getProfile:readPerm:null");
1845:                                //			    }
1846:                            }
1847:                            if ((en = pa0.getWritePermission()) != null) {
1848:                                pr.setWPermListAttribute(en);
1849:                                if (_debug) {
1850:                                    for (Enumeration temp_en = en; temp_en
1851:                                            .hasMoreElements();) {
1852:                                        System.out
1853:                                                .println("Component:getProfile:getWritePermission:"
1854:                                                        + temp_en.nextElement());
1855:                                    }
1856:                                }
1857:                                //			String tperm = (String)pr._atts.get(Element.WRITEPERM);
1858:                                //			    if (tperm != null) {
1859:                                //				if (tperm.equals("ADMIN")) {
1860:                                //		    	    	    System.out.println ("Component:getProfile:writePerm:ADMIN");
1861:                                //				} else if (tperm.equals("OWNER")) {
1862:                                //		    	    	    System.out.println ("Component:getProfile:writePerm:OWNER");
1863:                                //				} else {
1864:                                //		    	    	    System.out.println ("Component:getProfile:writePerm:ADMIN/OWNER");
1865:                                //				}
1866:                                //			    } else {
1867:                                //		    	    	System.out.println ("Component:getProfile:writePerm:null");
1868:                                //			    }
1869:                            }
1870:
1871:                            int typ = pa0.getType();
1872:
1873:                            if (_debug) {
1874:                                System.out.println("Component:getProfile:typ"
1875:                                        + typ);
1876:                            }
1877:
1878:                            if (typ != 2) {
1879:                                if (typ == 0) {
1880:                                    pr.addAttribute(Element.TYPE, "boolean");
1881:                                    if (_debug) {
1882:                                        System.out
1883:                                                .println("Component:getProfile:typ = boolean");
1884:                                    }
1885:                                } else {
1886:                                    pr.addAttribute(Element.TYPE, "list");
1887:                                    if (_debug) {
1888:                                        System.out
1889:                                                .println("Component:getProfile:typ = list");
1890:                                    }
1891:                                }
1892:                            }
1893:                            if (pa0.doSetAccessRight())
1894:                                if (pa0.getAccessRight()) {
1895:                                    pr.booleanval = "true";
1896:                                    if (_debug) {
1897:                                        System.out
1898:                                                .println("Component:getProfile:accessRight = true");
1899:                                    }
1900:                                } else {
1901:                                    pr.booleanval = "false";
1902:                                    if (_debug) {
1903:                                        System.out
1904:                                                .println("Component:getProfile:accessRight = false");
1905:                                    }
1906:                                }
1907:                            if ((en = pa0.getAllowList()) != null) {
1908:                                pr.setAllowListAttribute(en);
1909:                                if (_debug) {
1910:                                    for (Enumeration temp_en = en; temp_en
1911:                                            .hasMoreElements();) {
1912:                                        System.out
1913:                                                .println("Component:getProfile:getAllowList:"
1914:                                                        + temp_en.nextElement());
1915:                                    }
1916:                                }
1917:                            }
1918:                            if ((en = pa0.getDenyList()) != null) {
1919:                                pr.setDenyListAttribute(en);
1920:
1921:                                if (_debug) {
1922:                                    for (Enumeration temp_en = en; temp_en
1923:                                            .hasMoreElements();) {
1924:                                        System.out
1925:                                                .println("Component:getProfile:getDenyList:"
1926:                                                        + temp_en.nextElement());
1927:                                    }
1928:                                }
1929:                            }
1930:                            if (pa0.getDescription() != null) {
1931:                                pr.addAttribute(DESC, pa0.getDescription());
1932:                                if (_debug) {
1933:                                    System.out
1934:                                            .println("Component:getProfile:getDescription"
1935:                                                    + pa0.getDescription());
1936:                                }
1937:                            }
1938:                            if (pa0.getCatalogID() != null) {
1939:                                pr.addAttribute(INDEX, pa0.getCatalogID());
1940:                                if (_debug) {
1941:                                    System.out
1942:                                            .println("Component:getProfile:getCatalogID"
1943:                                                    + pa0.getCatalogID());
1944:                                }
1945:                            }
1946:                            // TODO if (choicelist != null)
1947:                            _privileges.addElement(pr);
1948:                        }
1949:                    }
1950:                    psm.close();
1951:                } catch (Exception e) {
1952:                    throw new Exception(bundle.getString("getfail")
1953:                            + getProfileBundle(e.getMessage()));
1954:                }
1955:            }
1956:
1957:            public void getComponents() throws Exception {
1958:
1959:                String profilename = "/component";
1960:                try {
1961:                    if (_debugGC) {
1962:                        System.out.println("Component:getComponents");
1963:                    }
1964:
1965:                    // initialize ProfileServiceManager
1966:                    ProfileServiceManager psm = new ProfileServiceManager(1);
1967:
1968:                    Enumeration em0 = psm.getChildren(profilename);
1969:
1970:                    while (em0.hasMoreElements()) {
1971:                        Object ob = em0.nextElement();
1972:                        if (ob.getClass().getName().equals("java.lang.String")) {
1973:                            System.out.print("Child = " + ob);
1974:                            String compStr = (String) ob;
1975:                            String componentName = null;
1976:                            if (compStr.startsWith("/component/")) {
1977:                                int i = compStr.indexOf("/", 1);
1978:                                if (i > -1) {
1979:                                    componentName = compStr.substring(i + 1);
1980:                                    System.out.println(", Component Name = "
1981:                                            + componentName);
1982:                                } else {
1983:                                    System.out
1984:                                            .println("; Didn't find second slash (/)");
1985:                                }
1986:                            } else {
1987:                                System.out
1988:                                        .println("; Didn't find '/component/'");
1989:                            }
1990:                        } else {
1991:                            System.out.println("Object class = "
1992:                                    + ob.getClass().getName());
1993:                        }
1994:                    }
1995:
1996:                    psm.close();
1997:                } catch (Exception e) {
1998:                    throw new Exception(bundle.getString("getfail")
1999:                            + getProfileBundle(e.getMessage()));
2000:                }
2001:            }
2002:
2003:            public void getChildren(String nodeName) throws Exception {
2004:
2005:                try {
2006:                    if (_debugGCh) {
2007:                        System.out.println("Component:getChildren");
2008:                    }
2009:
2010:                    // initialize ProfileServiceManager
2011:                    ProfileServiceManager psm = new ProfileServiceManager(1);
2012:
2013:                    Enumeration em0 = psm.getChildren(nodeName);
2014:
2015:                    while (em0.hasMoreElements()) {
2016:                        Object ob = em0.nextElement();
2017:                        if (ob.getClass().getName().equals("java.lang.String")) {
2018:                            System.out.println("Child = " + ob);
2019:                        } else {
2020:                            System.out.println("Object class = "
2021:                                    + ob.getClass().getName());
2022:                        }
2023:                    }
2024:
2025:                    psm.close();
2026:                } catch (Exception e) {
2027:                    throw new Exception(bundle.getString("getfail")
2028:                            + getProfileBundle(e.getMessage()));
2029:                }
2030:            }
2031:
2032:            public void getIChildren(String prfName, String prfType)
2033:                    throws Exception {
2034:                String profType = null;
2035:
2036:                if (prfType.equals("user")) {
2037:                    profType = ProfileUtil.PROFILE_USER_TYPE;
2038:                } else if (prfType.equals("role")) {
2039:                    profType = ProfileUtil.PROFILE_ROLE_TYPE;
2040:                } else if (prfType.equals("domain")) {
2041:                    //
2042:                    //  should have done "psadmin getchildren /", since that's
2043:                    //  the only place that has domains.
2044:                    //
2045:                    try {
2046:                        getChildren("/");
2047:                    } catch (Exception e) {
2048:                        throw new Exception(bundle.getString("getfail")
2049:                                + getProfileBundle(e.getMessage()));
2050:                    }
2051:                }
2052:
2053:                try {
2054:                    if (_debugGCh) {
2055:                        System.out.println("Component:getIChildren");
2056:                    }
2057:
2058:                    // initialize ProfileServiceManager
2059:
2060:                    ProfileServiceManager psm = new ProfileServiceManager(1);
2061:
2062:                    Enumeration em0 = psm.getImmediateChildren(prfName,
2063:                            profType);
2064:
2065:                    while (em0.hasMoreElements()) {
2066:                        Object ob = em0.nextElement();
2067:                        if (ob.getClass().getName().equals("java.lang.String")) {
2068:                            System.out.println("  Child = " + ob);
2069:                        } else {
2070:                            System.out.println("  Object class = "
2071:                                    + ob.getClass().getName());
2072:                        }
2073:                    }
2074:
2075:                    psm.close();
2076:
2077:                } catch (Exception e) {
2078:                    throw new Exception(bundle.getString("getfail")
2079:                            + getProfileBundle(e.getMessage()));
2080:                }
2081:            }
2082:
2083:            public void getAllUsers() throws Exception {
2084:
2085:                try {
2086:                    if (_debugGCh) {
2087:                        System.out.println("Component:getAllUsers");
2088:                    }
2089:
2090:                    // initialize ProfileServiceManager
2091:                    ProfileServiceManager psm = new ProfileServiceManager(1);
2092:
2093:                    Enumeration em0 = psm.getChildren("/");
2094:
2095:                    while (em0.hasMoreElements()) {
2096:                        Object ob = em0.nextElement();
2097:                        if (ob.getClass().getName().equals("java.lang.String")) {
2098:                            System.out.println("Domain = " + ob + "; Users:");
2099:                            String compStr = (String) ob;
2100:                            getIChildren(compStr, "user");
2101:                        } else {
2102:                            System.out.println("Object class = "
2103:                                    + ob.getClass().getName());
2104:                        }
2105:                    }
2106:
2107:                    psm.close();
2108:                } catch (Exception e) {
2109:                    throw new Exception(bundle.getString("getfail")
2110:                            + getProfileBundle(e.getMessage()));
2111:                }
2112:            }
2113:
2114:            public void getAllRoles() throws Exception {
2115:
2116:                try {
2117:                    if (_debugGCh) {
2118:                        System.out.println("Component:getAllRoles");
2119:                    }
2120:
2121:                    // initialize ProfileServiceManager
2122:                    ProfileServiceManager psm = new ProfileServiceManager(1);
2123:
2124:                    Enumeration em0 = psm.getChildren("/");
2125:
2126:                    while (em0.hasMoreElements()) {
2127:                        Object ob = em0.nextElement();
2128:                        if (ob.getClass().getName().equals("java.lang.String")) {
2129:                            System.out.println("Domain = " + ob + "; Roles:");
2130:                            String compStr = (String) ob;
2131:                            getIChildren(compStr, "role");
2132:                        } else {
2133:                            System.out.println("Object class = "
2134:                                    + ob.getClass().getName());
2135:                        }
2136:                    }
2137:
2138:                    psm.close();
2139:                } catch (Exception e) {
2140:                    throw new Exception(bundle.getString("getfail")
2141:                            + getProfileBundle(e.getMessage()));
2142:                }
2143:            }
2144:
2145:            public void getAll(String prfType) throws Exception {
2146:                String profType = null;
2147:
2148:                try {
2149:                    if (prfType.equals("user")) {
2150:                        getAllUsers();
2151:                    } else if (prfType.equals("role")) {
2152:                        getAllRoles();
2153:                    } else if (prfType.equals("domain")) {
2154:                        //
2155:                        //  should have done "psadmin getchildren /", since that's
2156:                        //  the only place that has domains.
2157:                        //
2158:                        try {
2159:                            getChildren("/");
2160:                        } catch (Exception e) {
2161:                            throw new Exception(bundle.getString("getfail")
2162:                                    + getProfileBundle(e.getMessage()));
2163:                        }
2164:                    } else if (prfType.equals("component")) {
2165:                        getComponents();
2166:                    }
2167:                } catch (Exception e) {
2168:                    throw new Exception(bundle.getString("getfail")
2169:                            + getProfileBundle(e.getMessage()));
2170:                }
2171:            }
2172:
2173:            //    //
2174:            //    //  this one uses a new ProfileServiceManager method
2175:            //    //
2176:            //
2177:            //    public void getRoles2(String domainName) throws Exception
2178:            //    {
2179:            //
2180:            //	try {
2181:            //	    if (_debugGCh) {
2182:            //		System.out.println ("Component:getRoles");
2183:            //	    }
2184:            //
2185:            //	    // initialize ProfileServiceManager
2186:            //	    ProfileServiceManager psm = new ProfileServiceManager(1);
2187:            //
2188:            //	    Enumeration em0 = psm.getAllChildren(domainName, ProfileUtil.PROFILE_ROLE_TYPE);
2189:            //
2190:            //	    while (em0.hasMoreElements()) {
2191:            //		Object ob = em0.nextElement();
2192:            ////		System.out.println ("Object class = " + ob.getClass().getName());
2193:            //		if (ob.getClass().getName().equals("java.lang.String")) {
2194:            //		    System.out.println ("Child = " + ob);
2195:            //		} else {
2196:            //		    System.out.println ("Object class = " + ob.getClass().getName());
2197:            //		}
2198:            //	    }
2199:            //	    psm.close();
2200:            //	} catch (Exception e) {
2201:            //	    throw new Exception(bundle.getString("getfail")
2202:            //		+ getProfileBundle(e.getMessage()));
2203:            //	}
2204:            //    }
2205:            //
2206:
2207:            private boolean get_roles(String domainName,
2208:                    ProfileServiceManager psm, int indent) throws Exception {
2209:                boolean b1 = true;
2210:
2211:                try {
2212:                    while (b1) {
2213:                        Enumeration em0 = psm.getImmediateChildren(domainName,
2214:                                ProfileUtil.PROFILE_ROLE_TYPE);
2215:
2216:                        if (em0.hasMoreElements()) {
2217:                            while (em0.hasMoreElements()) {
2218:                                Object ob = em0.nextElement();
2219:                                if (ob.getClass().getName().equals(
2220:                                        "java.lang.String")) {
2221:                                    String role_str = null;
2222:                                    if (indent > 0) {
2223:                                        for (int i = 0; i < indent; i++) {
2224:                                            System.out.print("  ");
2225:                                        }
2226:                                        role_str = "subRole = ";
2227:                                    } else {
2228:                                        role_str = "Role = ";
2229:                                    }
2230:                                    System.out.println(role_str + ob);
2231:                                    b1 = get_roles((String) ob, psm, indent + 1);
2232:                                } else {
2233:                                    System.out.println("Object class = "
2234:                                            + ob.getClass().getName());
2235:                                }
2236:                            }
2237:                        } else {
2238:                            b1 = false;
2239:                        }
2240:                    }
2241:
2242:                } catch (Exception e) {
2243:                    throw new Exception(bundle.getString("getfail")
2244:                            + getProfileBundle(e.getMessage()));
2245:                }
2246:
2247:                return (b1);
2248:            }
2249:
2250:            public void getRoles(String domainName) throws Exception {
2251:                try {
2252:                    if (_debugGCh) {
2253:                        System.out.println("Component:getRoles");
2254:                    }
2255:
2256:                    // initialize ProfileServiceManager
2257:
2258:                    ProfileServiceManager psm = new ProfileServiceManager(1);
2259:
2260:                    boolean b = get_roles(domainName, psm, 0);
2261:
2262:                    psm.close();
2263:
2264:                } catch (Exception e) {
2265:                    throw new Exception(bundle.getString("getfail")
2266:                            + getProfileBundle(e.getMessage()));
2267:                }
2268:            }
2269:
2270:            //zzzzzzzz
2271:            private boolean get_roles_and_users(String nodeName,
2272:                    ProfileServiceManager psm, String domainName)
2273:                    throws Exception {
2274:                boolean b1 = true;
2275:
2276:                try {
2277:                    while (b1) {
2278:                        Enumeration em0 = psm.getImmediateChildren(nodeName,
2279:                                ProfileUtil.PROFILE_ROLE_TYPE);
2280:
2281:                        if (em0.hasMoreElements()) { // any roles?
2282:                            while (em0.hasMoreElements()) {
2283:                                Object ob = em0.nextElement();
2284:                                if (ob.getClass().getName().equals(
2285:                                        "java.lang.String")) {
2286:                                    String role_str = (String) ob;
2287:                                    System.out.println("  Role = " + role_str);
2288:                                    //
2289:                                    //  get the users in this role
2290:                                    //
2291:                                    Enumeration em2 = psm.getImmediateChildren(
2292:                                            domainName,
2293:                                            ProfileUtil.PROFILE_USER_TYPE);
2294:
2295:                                    if (em2.hasMoreElements()) {
2296:                                        while (em2.hasMoreElements()) {
2297:                                            Object ob2 = em2.nextElement();
2298:                                            if (ob2.getClass().getName()
2299:                                                    .equals("java.lang.String")) {
2300:                                                String user_str = (String) ob2;
2301:                                                ProfileInstance ppe = (ProfileInstance) psm
2302:                                                        .getProfileInstance(user_str);
2303:                                                if (ppe != null) {
2304:                                                    Enumeration em3 = ppe
2305:                                                            .getAttrib("iwtUser-role-at");
2306:
2307:                                                    while (em3
2308:                                                            .hasMoreElements()) {
2309:                                                        Object ob3 = em3
2310:                                                                .nextElement();
2311:                                                        //System.out.println (" x2.5");
2312:                                                        if (ob3
2313:                                                                .getClass()
2314:                                                                .getName()
2315:                                                                .equals(
2316:                                                                        "com.iplanet.portalserver.profile.impl.ProfileAttribute")) {
2317:                                                            ProfileAttribute pa0 = (ProfileAttribute) ob3;
2318:                                                            String tmp = pa0
2319:                                                                    .getName();
2320:                                                            Enumeration em4 = pa0
2321:                                                                    .getValue();
2322:
2323:                                                            while (em4
2324:                                                                    .hasMoreElements()) {
2325:                                                                String rstr = (String) em4
2326:                                                                        .nextElement();
2327:                                                                if (rstr
2328:                                                                        .equals(role_str)) {
2329:                                                                    System.out
2330:                                                                            .println("    User = "
2331:                                                                                    + user_str);
2332:                                                                }
2333:                                                            }
2334:                                                        } else {
2335:                                                            System.out
2336:                                                                    .println("'s class is "
2337:                                                                            + ob3
2338:                                                                                    .getClass()
2339:                                                                                    .getName());
2340:                                                        }
2341:                                                    }
2342:                                                } else {
2343:                                                    // default role?
2344:                                                    System.out
2345:                                                            .println(" has no attributes");
2346:                                                }
2347:                                            }
2348:                                        }
2349:                                    } else {
2350:                                        System.out.println("    No Users");
2351:                                    }
2352:
2353:                                    //
2354:                                    //  see if any subroles
2355:                                    //
2356:                                    b1 = get_roles_and_users(role_str, psm,
2357:                                            domainName);
2358:                                } else {
2359:                                    System.out.println("Object class = "
2360:                                            + ob.getClass().getName());
2361:                                }
2362:                            }
2363:                        } else {
2364:                            b1 = false;
2365:                        }
2366:                    }
2367:
2368:                } catch (Exception e) {
2369:                    throw new Exception(bundle.getString("getfail")
2370:                            + getProfileBundle(e.getMessage()));
2371:                }
2372:
2373:                return (b1);
2374:            }
2375:
2376:            public void getAllUsersByRole() throws Exception {
2377:                String platformDefaultRole = "";
2378:
2379:                try {
2380:                    if (_debugGCh) {
2381:                        System.out.println("Component:getAllUsersByRole");
2382:                    }
2383:
2384:                    // initialize ProfileServiceManager
2385:                    ProfileServiceManager psm = new ProfileServiceManager(1);
2386:
2387:                    Enumeration em0 = psm.getChildren("/"); // get all domains
2388:                    ProfileInstance ppp = (ProfileInstance) psm
2389:                            .getProfileInstance("/component/iwtAuth");
2390:
2391:                    try {
2392:                        Enumeration pme = ppp
2393:                                .getAttrib("iwtAuth-defaultRole-at");
2394:                        //Enumeration pme = ppp.getAttrib("*");
2395:                        while (pme.hasMoreElements()) {
2396:                            Object pmo = pme.nextElement();
2397:                            if (pmo
2398:                                    .getClass()
2399:                                    .getName()
2400:                                    .equals(
2401:                                            "com.iplanet.portalserver.profile.impl.ProfileAttribute")) {
2402:                                ProfileAttribute pp0 = (ProfileAttribute) pmo;
2403:                                String nnn = pp0.getName();
2404:                                Enumeration eee = pp0.getValue();
2405:                                if (eee != null) {
2406:                                    while (eee.hasMoreElements()) {
2407:                                        String sss = (String) eee.nextElement();
2408:                                        //System.out.println("platform profile attr '" + nnn +
2409:                                        //    "' = " + sss);
2410:                                        platformDefaultRole = sss;
2411:                                    }
2412:                                } else { // null value is not uncommon; skip them
2413:                                    //System.out.println("null getValue for " + nnn);
2414:                                }
2415:                            }
2416:                        }
2417:                    } catch (Exception e) {
2418:                        //System.out.println ("first catch");
2419:                        throw new Exception(bundle.getString("getfail")
2420:                                + getProfileBundle(e.getMessage()));
2421:                    }
2422:
2423:                    while (em0.hasMoreElements()) {
2424:                        Object ob = em0.nextElement();
2425:                        if (ob.getClass().getName().equals("java.lang.String")) {
2426:                            String domain_str = (String) ob;
2427:                            System.out.print("Domain = " + domain_str
2428:                                    + ", defaultRole = ");
2429:
2430:                            //
2431:                            //  get defaultRole name
2432:                            //
2433:                            String this DomainsDefaultRole = null;
2434:
2435:                            ProfileInstance ppe = (ProfileInstance) psm
2436:                                    .getProfileInstance(domain_str);
2437:                            if (ppe != null) {
2438:                                try {
2439:                                    Enumeration dme = ppe
2440:                                            .getAttrib("iwtAuth-defaultRole-at");
2441:                                    //Enumeration dme = ppe.getAttrib("*");
2442:                                    while (dme.hasMoreElements()) {
2443:                                        Object dmo = dme.nextElement();
2444:                                        if (dmo
2445:                                                .getClass()
2446:                                                .getName()
2447:                                                .equals(
2448:                                                        "com.iplanet.portalserver.profile.impl.ProfileAttribute")) {
2449:                                            ProfileAttribute pa0 = (ProfileAttribute) dmo;
2450:                                            String atstr = pa0.getName();
2451:                                            Enumeration aten = pa0.getValue();
2452:                                            while (aten.hasMoreElements()) {
2453:                                                String rstr = (String) aten
2454:                                                        .nextElement();
2455:                                                this DomainsDefaultRole = rstr;
2456:                                                System.out.print(rstr);
2457:                                                //System.out.println ("(" + atstr + ") = " + rstr);
2458:                                            }
2459:                                        } else {
2460:                                            System.out.println("'s class is "
2461:                                                    + dmo.getClass().getName());
2462:                                        }
2463:                                    }
2464:                                } catch (Exception e) { //  no default role in domain; use platform's
2465:                                    this DomainsDefaultRole = platformDefaultRole;
2466:                                    System.out.print(this DomainsDefaultRole);
2467:                                }
2468:                            } else {
2469:                                // default role?
2470:                                System.out.print("**NONE**");
2471:                            }
2472:                            System.out.println("");
2473:
2474:                            boolean b = get_roles_and_users(domain_str, psm,
2475:                                    domain_str);
2476:
2477:                            //		    Enumeration em1 = psm.getImmediateChildren(domain_str,
2478:                            //					ProfileUtil.PROFILE_ROLE_TYPE);
2479:                            //
2480:                            //		    if (em1.hasMoreElements()) {
2481:                            //			while (em1.hasMoreElements()) {
2482:                            //			    Object ob1 = em1.nextElement();
2483:                            //			    if (ob1.getClass().getName().equals("java.lang.String")) {
2484:                            //				String role_str = (String)ob1;
2485:                            //				System.out.println ("  Role = " + role_str);
2486:                            //
2487:                            //		    		Enumeration em2 = psm.getImmediateChildren(domain_str,
2488:                            //					ProfileUtil.PROFILE_USER_TYPE);
2489:                            //
2490:                            //				if (em2.hasMoreElements()) {
2491:                            //				    while (em2.hasMoreElements()) {
2492:                            //					Object ob2 = em2.nextElement();
2493:                            //					if (ob2.getClass().getName().equals("java.lang.String")) {
2494:                            //					    String user_str = (String)ob2;
2495:                            //					    //System.out.print ("    (checking)User = " + user_str);
2496:                            //					    ProfileInstance ppe =
2497:                            //						(ProfileInstance) psm.getProfileInstance(user_str);
2498:                            //					    //System.out.println (" x1");
2499:                            //					    if (ppe != null) {
2500:                            //						Enumeration em3 = ppe.getAttrib("iwtUser-role-at");
2501:                            //						//Enumeration em3 = ppe.getAttrib("*");
2502:                            //						//System.out.println (" x2");
2503:                            //
2504:                            //						while (em3.hasMoreElements()) {
2505:                            //						    Object ob3 = em3.nextElement();
2506:                            //						    //System.out.println (" x2.5");
2507:                            //						    if (ob3.getClass().getName().equals("com.iplanet.portalserver.profile.impl.ProfileAttribute")) {
2508:                            //							ProfileAttribute pa0 = (ProfileAttribute)ob3;
2509:                            //							//System.out.println (" x3");
2510:                            //							String tmp = pa0.getName();
2511:                            //							Enumeration em4 = pa0.getValue();
2512:                            //							//System.out.println (" x4");
2513:                            //
2514:                            //							while (em4.hasMoreElements()) {
2515:                            //							    String rstr = (String)em4.nextElement();
2516:                            //							    if (rstr.equals(role_str)) {
2517:                            //								System.out.println ("    User = " +
2518:                            //								    user_str);
2519:                            //								//System.out.println (" is in role " +
2520:                            //								//    rstr);
2521:                            //							    }
2522:                            //							    //System.out.println("attr " + tmp +
2523:                            //								//" = " + rstr);
2524:                            //							}
2525:                            //						    } else {
2526:                            //							System.out.println ("'s class is " +
2527:                            //							    ob3.getClass().getName());
2528:                            //						    }
2529:                            //						}
2530:                            //					    } else {
2531:                            //						// default role?
2532:                            //						System.out.println (" has no attributes");
2533:                            //					    }
2534:                            //					}
2535:                            //				    }
2536:                            //				} else {
2537:                            //				    System.out.println ("    No Users");
2538:                            //				}
2539:                            //			    }
2540:                            //			}
2541:                            //		    }
2542:                        } else {
2543:                            System.out.println("Object class = "
2544:                                    + ob.getClass().getName());
2545:                        }
2546:                    }
2547:
2548:                    psm.close();
2549:                } catch (Exception e) {
2550:                    //System.out.println ("outside catch");
2551:                    throw new Exception(bundle.getString("getfail")
2552:                            + getProfileBundle(e.getMessage()));
2553:                }
2554:            }
2555:
2556:            public void getCompProfile(String intype, String profilename)
2557:                    throws Exception {
2558:
2559:                //
2560:                //  at least initially, get a component profile and reconstruct the original
2561:                //  XML.
2562:                //
2563:
2564:                _rawcompname = profilename;
2565:
2566:                try {
2567:                    if (intype.equals("component")) {
2568:                        profilename = "/" + intype + "/" + profilename;
2569:                    }
2570:
2571:                    if (_debug) {
2572:                        System.out.println("Component:getCompProfile:intype="
2573:                                + intype + ", profilename=" + profilename);
2574:                        System.out
2575:                                .println("Component:getCompProfile:profilename="
2576:                                        + profilename);
2577:                    }
2578:
2579:                    ProfileServiceManager psm = new ProfileServiceManager(1);
2580:
2581:                    //
2582:                    //  for components, profilename = "/component/<theComponentName>"
2583:                    //
2584:                    ProfileInstance ppe = (ProfileInstance) psm
2585:                            .getProfileInstance(profilename);
2586:                    if (ppe == null)
2587:                        throw new Exception(bundle.getString("notfound"));
2588:                    _compname = profilename;
2589:
2590:                    Hashtable ht = new Hashtable();
2591:                    int numAttrs = _attributes.size();
2592:
2593:                    if (_debug) {
2594:                        System.out.println("getCompProfile:numAttrs="
2595:                                + numAttrs);
2596:                    }
2597:
2598:                    Enumeration em0 = ppe.getAttrib("*");
2599:                    while (em0.hasMoreElements()) {
2600:                        Object ob = em0.nextElement();
2601:                        if (ob
2602:                                .getClass()
2603:                                .getName()
2604:                                .equals(
2605:                                        "com.iplanet.portalserver.profile.impl.ProfileAttribute")) {
2606:                            ProfileAttribute pa0 = (ProfileAttribute) ob;
2607:                            Attribute at = new Attribute();
2608:                            Enumeration en;
2609:                            if (pa0.getName() != null) {
2610:                                String tmp = pa0.getName();
2611:                                if (!tmp.endsWith(ATTPREFIX))
2612:                                    continue;
2613:                                at.name = tmp.substring(0, tmp.length() - 3);
2614:                            }
2615:
2616:                            if (_debug) {
2617:                                System.out
2618:                                        .println("Component:getCompProfile:at.name="
2619:                                                + at.name);
2620:                            }
2621:
2622:                            if (at.name
2623:                                    .equals(_rawcompname + "-resourceBundle")) {
2624:                                if (_configdata == null) {
2625:                                    _configdata = new Hashtable();
2626:                                }
2627:                                Enumeration tempEnum = pa0.getValue();
2628:
2629:                                if (_debug) {
2630:                                    System.out
2631:                                            .println("Component:getCompProfile:found "
2632:                                                    + _rawcompname
2633:                                                    + "-resourceBundle");
2634:                                }
2635:
2636:                                String tmpStr = null;
2637:                                for (Enumeration temp_en = tempEnum; temp_en
2638:                                        .hasMoreElements();) {
2639:                                    tmpStr = (String) temp_en.nextElement();
2640:
2641:                                    if (_debug) {
2642:                                        System.out
2643:                                                .println("Component:getCompProfile:getValues:"
2644:                                                        + tmpStr);
2645:                                    }
2646:                                }
2647:                                //
2648:                                //  assuming there's only one value...  if not, it'll just get the last one
2649:                                //
2650:                                _configdata.put(VERSION, "1.0"); // always
2651:                                _configdata.put(RESOURCEBUNDLE, tmpStr);
2652:                                _configdata.put(INDEX, pa0.getCatalogID());
2653:                            } else if (at.name.equals(_rawcompname
2654:                                    + "-description")) {
2655:                                if (_configdata == null) {
2656:                                    _configdata = new Hashtable();
2657:                                }
2658:                                Enumeration tempEnum = pa0.getValue();
2659:
2660:                                if (_debug) {
2661:                                    System.out
2662:                                            .println("Component:getCompProfile:found "
2663:                                                    + _rawcompname
2664:                                                    + "-description");
2665:                                }
2666:
2667:                                String tmpStr = null;
2668:                                for (Enumeration temp_en = tempEnum; temp_en
2669:                                        .hasMoreElements();) {
2670:                                    tmpStr = (String) temp_en.nextElement();
2671:
2672:                                    if (_debug) {
2673:                                        System.out
2674:                                                .println("Component:getCompProfile:getValues:"
2675:                                                        + tmpStr);
2676:                                    }
2677:                                }
2678:                                //
2679:                                //  assuming there's only one value...  if not, it'll just get the last one
2680:                                //
2681:                                _configdata.put(DESC, tmpStr);
2682:                            } else {
2683:
2684:                                if (pa0.getDescription() != null) {
2685:
2686:                                    if (_debug) {
2687:                                        System.out
2688:                                                .println("Component:getProfile:description="
2689:                                                        + pa0.getDescription());
2690:                                    }
2691:
2692:                                    at.addAttribute(DESC, pa0.getDescription());
2693:                                }
2694:                                if (pa0.getCatalogID() != null) {
2695:                                    at.addAttribute(INDEX, pa0.getCatalogID());
2696:
2697:                                    if (_debug) {
2698:                                        System.out
2699:                                                .println("Component:getProfile:catalogid="
2700:                                                        + pa0.getCatalogID());
2701:                                    }
2702:                                }
2703:                                if ((en = pa0.getValue()) != null) {
2704:                                    at.setValues(en);
2705:
2706:                                    //
2707:                                    //  don't seem to get this
2708:                                    //
2709:                                    //			for (Enumeration temp_en = en; temp_en.hasMoreElements();) {
2710:                                    //		    	    System.out.println ("Component:getCompProfile:getValues:" +
2711:                                    //				temp_en.nextElement());
2712:                                    //			}
2713:
2714:                                    //			String defval = (String)at._atts.get("defaultValue");
2715:                                    //			if (defval != null) {
2716:                                    //			    System.out.println("Component:getProfile:defVal=" + defval);
2717:                                    //			} else {
2718:                                    //			    System.out.println("Component:getProfile:defVal=null");
2719:                                    //			}
2720:                                }
2721:                                // TODO if (pa0.getRemoteFlag() != null)
2722:                                // TODO if (pa0.getInherit() != null)
2723:                                if (pa0.getOverrideFlag()) {
2724:                                    at.addAttribute(USERCONFIGURABLE, "true");
2725:                                    if (_debug) {
2726:                                        System.out
2727:                                                .println("Component:getCompProfile:Override=true");
2728:                                    }
2729:                                } else {
2730:                                    at.addAttribute(USERCONFIGURABLE, "false");
2731:                                    if (_debug) {
2732:                                        System.out
2733:                                                .println("Component:getCompProfile:Override=false");
2734:                                    }
2735:                                }
2736:                                if ((en = pa0.getReadPermission()) != null) {
2737:                                    at.setRPermListAttribute(en);
2738:                                    if (_debug) {
2739:                                        for (Enumeration e1 = at.rpermlist
2740:                                                .elements(); e1
2741:                                                .hasMoreElements();) {
2742:                                            System.out
2743:                                                    .println("Component:getCompProfile:getReadPermission:"
2744:                                                            + e1.nextElement());
2745:                                        }
2746:                                    }
2747:                                    ////			for (Enumeration temp_en = en; temp_en.hasMoreElements();) {
2748:                                    ////		    	    System.out.println ("Component:getProfile:getReadPermission:" +
2749:                                    ////				temp_en.nextElement());
2750:                                    ////			}
2751:                                    //			String tperm = (String)at._atts.get("readPermission");
2752:                                    //			    if (tperm != null) {
2753:                                    //				if (tperm.equals("ADMIN")) {
2754:                                    //		    	    	    System.out.println ("Component:getProfile:readPerm:ADMIN");
2755:                                    //				} else if (tperm.equals("OWNER")) {
2756:                                    //		    	    	    System.out.println ("Component:getProfile:readPerm:OWNER");
2757:                                    //				} else {
2758:                                    //		    	    	    System.out.println ("Component:getProfile:readPerm:ADMIN/OWNER");
2759:                                    //				}
2760:                                    //			    } else {
2761:                                    //		    	    	System.out.println ("Component:getProfile:readPerm:null");
2762:                                    //			    }
2763:                                }
2764:                                if ((en = pa0.getWritePermission()) != null) {
2765:                                    at.setWPermListAttribute(en);
2766:                                    if (_debug) {
2767:                                        for (Enumeration e1 = at.wpermlist
2768:                                                .elements(); e1
2769:                                                .hasMoreElements();) {
2770:                                            System.out
2771:                                                    .println("Component:getCompProfile:getWritePermission:"
2772:                                                            + e1.nextElement());
2773:                                        }
2774:                                    }
2775:                                    ////			for (Enumeration temp_en = en; temp_en.hasMoreElements();) {
2776:                                    ////		    	    System.out.println ("Component:getProfile:getWritePermission:" +
2777:                                    ////				temp_en.nextElement());
2778:                                    ////			}
2779:                                    //			String tperm = (String)at._atts.get("writePermission");
2780:                                    //			    if (tperm != null) {
2781:                                    //				if (tperm.equals("ADMIN")) {
2782:                                    //		    	    	    System.out.println ("Component:getProfile:writePerm:ADMIN");
2783:                                    //				} else if (tperm.equals("OWNER")) {
2784:                                    //		    	    	    System.out.println ("Component:getProfile:writePerm:OWNER");
2785:                                    //				} else {
2786:                                    //		    	    	    System.out.println ("Component:getProfile:writePerm:ADMIN/OWNER");
2787:                                    //				}
2788:                                    //			    } else {
2789:                                    //		    	    	System.out.println ("Component:getProfile:writePerm:null");
2790:                                    //			    }
2791:                                }
2792:                                if ((en = pa0.getChoices()) != null) {
2793:                                    at.setChoiceListAttribute(en);
2794:                                    if (_debug) {
2795:                                        for (Enumeration temp_en = en; temp_en
2796:                                                .hasMoreElements();) {
2797:                                            System.out
2798:                                                    .println("Component:getCompProfile:getChoices:"
2799:                                                            + temp_en
2800:                                                                    .nextElement());
2801:                                        }
2802:                                    }
2803:                                }
2804:                                if (pa0.getType() != null) {
2805:                                    if (_debug) {
2806:                                        System.out
2807:                                                .println("Component:getCompProfile:getType="
2808:                                                        + pa0.getType());
2809:                                    }
2810:                                    at
2811:                                            .addAttribute(Element.TYPE, pa0
2812:                                                    .getType());
2813:                                }
2814:
2815:                                if (_debug) {
2816:                                    System.out
2817:                                            .println("Component:getCompProfile:at="
2818:                                                    + at);
2819:                                }
2820:
2821:                                _attributes.addElement(at);
2822:                            } // end check for "-resourceBundle" and "-description"
2823:
2824:                        } else {
2825:                            ProfilePrivilege pa0 = (ProfilePrivilege) ob;
2826:                            Privilege pr = new Privilege();
2827:                            Enumeration en;
2828:                            if (pa0.getName() != null) {
2829:                                String tmp = pa0.getName();
2830:                                if (!tmp.endsWith(PRIVPREFIX))
2831:                                    continue;
2832:                                pr.name = tmp.substring(0, tmp.length() - 3);
2833:                            }
2834:
2835:                            if (_debug) {
2836:                                System.out
2837:                                        .println("Component:getCompProfile:pr.name="
2838:                                                + pr.name);
2839:                            }
2840:
2841:                            // TODO if (pa0.getRemoteFlag() != null)
2842:
2843:                            if ((en = pa0.getReadPermission()) != null) {
2844:                                pr.setRPermListAttribute(en);
2845:                                if (_debug) {
2846:                                    for (Enumeration temp_en = en; temp_en
2847:                                            .hasMoreElements();) {
2848:                                        System.out
2849:                                                .println("Component:getCompProfile:getReadPermission:"
2850:                                                        + temp_en.nextElement());
2851:                                    }
2852:                                }
2853:                                //			String tperm = (String)pr._atts.get(Element.READPERM);
2854:                                //			    if (tperm != null) {
2855:                                //				if (tperm.equals("ADMIN")) {
2856:                                //		    	    	    System.out.println ("Component:getProfile:readPerm:ADMIN");
2857:                                //				} else if (tperm.equals("OWNER")) {
2858:                                //		    	    	    System.out.println ("Component:getProfile:readPerm:OWNER");
2859:                                //				} else {
2860:                                //		    	    	    System.out.println ("Component:getProfile:readPerm:ADMIN/OWNER");
2861:                                //				}
2862:                                //			    } else {
2863:                                //		    	    	System.out.println ("Component:getProfile:readPerm:null");
2864:                                //			    }
2865:                            }
2866:                            if ((en = pa0.getWritePermission()) != null) {
2867:                                pr.setWPermListAttribute(en);
2868:                                if (_debug) {
2869:                                    for (Enumeration temp_en = en; temp_en
2870:                                            .hasMoreElements();) {
2871:                                        System.out
2872:                                                .println("Component:getCompProfile:getWritePermission:"
2873:                                                        + temp_en.nextElement());
2874:                                    }
2875:                                }
2876:                                //			String tperm = (String)pr._atts.get(Element.WRITEPERM);
2877:                                //			    if (tperm != null) {
2878:                                //				if (tperm.equals("ADMIN")) {
2879:                                //		    	    	    System.out.println ("Component:getProfile:writePerm:ADMIN");
2880:                                //				} else if (tperm.equals("OWNER")) {
2881:                                //		    	    	    System.out.println ("Component:getProfile:writePerm:OWNER");
2882:                                //				} else {
2883:                                //		    	    	    System.out.println ("Component:getProfile:writePerm:ADMIN/OWNER");
2884:                                //				}
2885:                                //			    } else {
2886:                                //		    	    	System.out.println ("Component:getProfile:writePerm:null");
2887:                                //			    }
2888:                            }
2889:
2890:                            int typ = pa0.getType();
2891:
2892:                            if (_debug) {
2893:                                System.out
2894:                                        .println("Component:getCompProfile:typ"
2895:                                                + typ);
2896:                            }
2897:
2898:                            if (typ != 2) {
2899:                                if (typ == 0) {
2900:                                    pr.addAttribute(Element.TYPE, "boolean");
2901:                                    if (_debug) {
2902:                                        System.out
2903:                                                .println("Component:getCompProfile:typ = boolean");
2904:                                    }
2905:                                } else {
2906:                                    pr.addAttribute(Element.TYPE, "list");
2907:                                    if (_debug) {
2908:                                        System.out
2909:                                                .println("Component:getCompProfile:typ = list");
2910:                                    }
2911:                                }
2912:                            }
2913:                            if (pa0.doSetAccessRight())
2914:                                if (pa0.getAccessRight()) {
2915:                                    pr.booleanval = "true";
2916:                                    if (_debug) {
2917:                                        System.out
2918:                                                .println("Component:getCompProfile:accessRight = true");
2919:                                    }
2920:                                } else {
2921:                                    pr.booleanval = "false";
2922:                                    if (_debug) {
2923:                                        System.out
2924:                                                .println("Component:getCompProfile:accessRight = false");
2925:                                    }
2926:                                }
2927:                            if ((en = pa0.getAllowList()) != null) {
2928:                                pr.setAllowListAttribute(en);
2929:                                if (_debug) {
2930:                                    for (Enumeration temp_en = en; temp_en
2931:                                            .hasMoreElements();) {
2932:                                        System.out
2933:                                                .println("Component:getCompProfile:getAllowList:"
2934:                                                        + temp_en.nextElement());
2935:                                    }
2936:                                }
2937:                            }
2938:                            if ((en = pa0.getDenyList()) != null) {
2939:                                pr.setDenyListAttribute(en);
2940:                                if (_debug) {
2941:                                    for (Enumeration temp_en = en; temp_en
2942:                                            .hasMoreElements();) {
2943:                                        System.out
2944:                                                .println("Component:getCompProfile:getDenyList:"
2945:                                                        + temp_en.nextElement());
2946:                                    }
2947:                                }
2948:                            }
2949:                            if (pa0.getDescription() != null) {
2950:                                pr.addAttribute(DESC, pa0.getDescription());
2951:                                if (_debug) {
2952:                                    System.out
2953:                                            .println("Component:getCompProfile:getDescription"
2954:                                                    + pa0.getDescription());
2955:                                }
2956:                            }
2957:                            if (pa0.getCatalogID() != null) {
2958:                                pr.addAttribute(INDEX, pa0.getCatalogID());
2959:                                if (_debug) {
2960:                                    System.out
2961:                                            .println("Component:getCompProfile:getCatalogID"
2962:                                                    + pa0.getCatalogID());
2963:                                }
2964:                            }
2965:                            // TODO if (choicelist != null)
2966:                            _privileges.addElement(pr);
2967:                        }
2968:                    }
2969:                    psm.close();
2970:                } catch (Exception e) {
2971:                    throw new Exception(bundle.getString("getfail")
2972:                            + getProfileBundle(e.getMessage()));
2973:                }
2974:            }
2975:
2976:            public String toXML() {
2977:                return toXML(true);
2978:            }
2979:
2980:            public String toXML(boolean comptag) {
2981:                try {
2982:                    StringBuffer xml = new StringBuffer(200);
2983:                    if (comptag) {
2984:                        xml.append("<").append(COMPONENT_E).append(" name=\"")
2985:                                .append(_rawcompname).append("\"\n");
2986:                        xml.append(hashToXML(_configdata)).append(">\n");
2987:                    }
2988:                    int numAttrs = _attributes.size();
2989:                    for (int i = 0; i < numAttrs; i++) {
2990:                        xml.append(((Attribute) _attributes.elementAt(i))
2991:                                .toXML());
2992:                    }
2993:                    int numPrivileges = _privileges.size();
2994:                    for (int i = 0; i < numPrivileges; i++) {
2995:                        xml.append(((Privilege) _privileges.elementAt(i))
2996:                                .toXML());
2997:                    }
2998:                    if (comptag)
2999:                        xml.append("</").append(COMPONENT_E).append(">\n");
3000:
3001:                    return xml.toString();
3002:                } catch (Exception e) {
3003:                    e.printStackTrace();
3004:                }
3005:                return "oops";
3006:            }
3007:
3008:            LDAPConnection ld = null;
3009:
3010:            void connectLDAP() throws Exception {
3011:                Properties prop = new Properties();
3012:                ld = new LDAPConnection();
3013:                // load properties from file
3014:                prop.load(new FileInputStream(PROPFILE));
3015:                String urlstr = prop.getProperty(URL);
3016:                urlstr = "http" + urlstr.substring(4, urlstr.length()); // remove "ldap"
3017:                URL url = new URL(urlstr);
3018:                String hostname = url.getHost();
3019:                int portnumber = url.getPort(); //LDAPv2.DEFAULT_PORT;
3020:                String bindDN = prop.getProperty(PRINCIPAL);
3021:                String bindPW = prop.getProperty(CREDENTIALS);
3022:                ld.connect(hostname, portnumber, bindDN, bindPW);
3023:            }
3024:
3025:            void addLDAPAttr(String attr) throws Exception {
3026:                try {
3027:                    if (ldifout == null && _chkschema) {
3028:                        LDAPAttributeSchema newAttrType = new LDAPAttributeSchema(
3029:                                attr, attr + "-oid", "",
3030:                                LDAPAttributeSchema.ces, false);
3031:                        newAttrType.add(ld);
3032:                    } else if (ldifout != null)
3033:                        ldifout.println("attribute " + attr + "    " + attr
3034:                                + "-oid ces");
3035:                } catch (Exception e) {
3036:                    System.err.println(attr + ": "
3037:                            + bundle.getString("schemawarn"));
3038:                }
3039:            }
3040:
3041:            void addAttrToSchema(String inatname) throws Exception {
3042:                if (needtoaddattr == false)
3043:                    return;
3044:                // Connect to LDAP only if ldif option is off
3045:                if (ld == null && ldifout == null)
3046:                    connectLDAP();
3047:                String attr = null;
3048:                String atname = inatname + ATTPREFIX;
3049:                addLDAPAttr(atname);
3050:                attr = atname + mapper.get(WRITEPERM);
3051:                addLDAPAttr(attr);
3052:                attr = atname + mapper.get(READPERM);
3053:                addLDAPAttr(attr);
3054:                attr = atname + mapper.get(DESC);
3055:                addLDAPAttr(attr);
3056:                attr = atname + mapper.get(TYPE);
3057:                addLDAPAttr(attr);
3058:                attr = atname + mapper.get(USERCONFIGURABLE);
3059:                addLDAPAttr(attr);
3060:                attr = atname + mapper.get(INDEX);
3061:                addLDAPAttr(attr);
3062:                attr = atname + mapper.get(CHOICEVALUE);
3063:                addLDAPAttr(attr);
3064:                attr = atname + mapper.get(REMOTEFLAG);
3065:                addLDAPAttr(attr);
3066:            }
3067:
3068:            void addPrivToSchema(String inatname) throws Exception {
3069:                if (needtoaddattr == false)
3070:                    return;
3071:                if (ld == null && ldifout == null)
3072:                    connectLDAP();
3073:                String attr = null;
3074:                String atname = inatname + PRIVPREFIX;
3075:                attr = atname + mapper.get(WRITEPERM);
3076:                addLDAPAttr(attr);
3077:                attr = atname + mapper.get(READPERM);
3078:                addLDAPAttr(attr);
3079:                attr = atname + mapper.get(DESC);
3080:                addLDAPAttr(attr);
3081:                attr = atname + mapper.get(TYPE);
3082:                addLDAPAttr(attr);
3083:                attr = atname + mapper.get(INDEX);
3084:                addLDAPAttr(attr);
3085:                attr = atname + mapper.get(DENYLIST);
3086:                addLDAPAttr(attr);
3087:                attr = atname + mapper.get(ALLOWLIST);
3088:                addLDAPAttr(attr);
3089:                attr = atname + mapper.get(ACVALUE);
3090:                addLDAPAttr(attr);
3091:                attr = atname + mapper.get(USERCONFIGURABLE);
3092:                addLDAPAttr(attr);
3093:                attr = atname + mapper.get(REMOTEFLAG);
3094:                addLDAPAttr(attr);
3095:            }
3096:
3097:            void addAttrToSchema(Hashtable ht) throws Exception {
3098:                Properties prop = new Properties();
3099:
3100:                try {
3101:                    // load properties from file
3102:                    prop.load(new FileInputStream(PROPFILE));
3103:                } catch (Exception e) {
3104:                    System.err.println("Error reading properties file");
3105:                }
3106:
3107:                String attr = "";
3108:                try {
3109:                    LDAPConnection ld = new LDAPConnection();
3110:                    String urlstr = prop.getProperty(URL);
3111:                    urlstr = "http" + urlstr.substring(4, urlstr.length()); // remove "ldap"
3112:                    URL url = new URL(urlstr);
3113:                    String hostname = url.getHost();
3114:                    int portnumber = url.getPort(); //LDAPv2.DEFAULT_PORT;
3115:                    String bindDN = prop.getProperty(PRINCIPAL);
3116:                    String bindPW = prop.getProperty(CREDENTIALS);
3117:                    ld.connect(hostname, portnumber, bindDN, bindPW);
3118:                    Enumeration en = ht.keys();
3119:                    while (en.hasMoreElements()) {
3120:                        attr = (String) en.nextElement();
3121:                        try {
3122:                            LDAPAttributeSchema newAttrType = new LDAPAttributeSchema(
3123:                                    attr, attr + "-oid", "",
3124:                                    LDAPAttributeSchema.ces, false);
3125:                            newAttrType.add(ld);
3126:                        } catch (Exception e) {
3127:                            System.err.println(attr + ": "
3128:                                    + bundle.getString("schemawarn"));
3129:                        }
3130:                    }
3131:                } catch (Exception e) {
3132:                    System.err.println(attr + ": "
3133:                            + bundle.getString("schemaerr") + e);
3134:                }
3135:            }
3136:
3137:            private String getProfileBundle(String msg) {
3138:                if (msg == null || msg.equals("")) {
3139:                    return msg;
3140:                }
3141:
3142:                StringTokenizer st = new StringTokenizer(msg, "^");
3143:                if (st.hasMoreTokens()) {
3144:                    try {
3145:                        return ProfileBundle.getString(st.nextToken());
3146:                    } catch (Exception e) {
3147:                        return msg;
3148:                    }
3149:                }
3150:
3151:                return msg;
3152:            }
3153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.