Source Code Cross Referenced for Users.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 netscape.ldap.util.*;
0004:
0005:        import netscape.ldap.LDAPAttribute;
0006:        import netscape.ldap.LDAPAttributeSet;
0007:        import com.sun.identity.security.EncryptAction;
0008:        import java.security.AccessController;
0009:        import java.util.*;
0010:        import java.io.*;
0011:        import java.net.URLDecoder;
0012:
0013:        //import com.iplanet.portalserver.util.Password;
0014:        //import com.iplanet.services.util.Crypt;
0015:        public class Users extends Common {
0016:
0017:            static final int FIRSTNAME = 7;
0018:            static final int LASTNAME = 8;
0019:            static final int UID = 9;
0020:            static final int PHONE_NUMBER = 10;
0021:            static final int PASSWORD = 11;
0022:            static final int CREATORSNAME = 12;
0023:            static final int CREATETIMESTAMP = 13;
0024:            static final int MODIFIERSNAME = 14;
0025:            static final int MODIFYTIMESTAMP = 15;
0026:            static final int OBJECTCLASS = 16;
0027:            static final int PARENT = 17;
0028:            static final int ROLE_AT = 18;
0029:            static final int EMAIL = 19;
0030:            static final int USERNAME = 20;
0031:            static final int CN = 21;
0032:            static final int PROFILE_TYPE = 22;
0033:            static final int PROFILE_ID = 23;
0034:
0035:            /* Netmail related properties...*/
0036:            static final int NETMAIL_USER_SMTP_ID = 31;
0037:            static final int NETMAIL_USER_SMTP_SERVER = 32;
0038:            static final int NETMAIL_USER_IMAP_ID = 33;
0039:            static final int NETMAIL_USER_IMAP_PASSWD = 34;
0040:            static final int NETMAIL_USER_IMAP_SERVER = 35;
0041:            static final int NETMAIL_USER_DEFAULTMAILDOMAIN = 36;
0042:            static final int NETMAIL_ROOT_FOLDER = 37;
0043:            static final int NETMAIL_SENT_FOLDER = 38;
0044:            static final int NETMAIL_REPLY_WITHAUTHOR = 39;
0045:            static final int NETMAIL_REPLY_WITHBODY = 40;
0046:            static final int NETMAIL_REPLY_WITHDATE = 41;
0047:            static final int NETMAIL_INDENT_PREFIX = 42;
0048:            static final int NETMAIL_ADD_SIGNATURE = 43;
0049:            static final int NETMAIL_INITIAL_HDRS = 44;
0050:            static final int NETMAIL_INACTIVITY_INTERVAL = 45;
0051:            static final int NETMAIL_MAX_ATTACH_LEN = 46;
0052:            static final int NETMAIL_AUTOLOAD = 47;
0053:            static final int NETMAIL_AUTOSAVE = 48;
0054:            static final int NETMAIL_AUTOPURGE = 49;
0055:            static final int NETMAIL_AUTOFOLDERLOAD = 50;
0056:            static final int NETMAIL_MULTIPLE_RDW = 51;//Multiple Read Windows
0057:            static final int NETMAIL_SORTKEY = 52;
0058:            static final int NETMAIL_VIEWKEY = 53;
0059:            static final int NETMAIL_COMPOSE_WINBOUNDS = 54;
0060:            static final int NETMAIL_FOLDER_WINBOUNDS = 55;
0061:            static final int NETMAIL_READ_WINBOUNDS = 56;
0062:            static final int NETMAIL_GRID_HEIGHT = 57;
0063:            static final int NETMAIL_GRID_COLWIDTHS = 58;
0064:            static final int NETMAIL_TEXT_COLOR = 59;
0065:            static final int NETMAIL_BGCOLOR = 60;
0066:            static final int NETMAIL_TEXTSIZE = 61;
0067:            static final int NETMAIL_TEXTSTYLE = 62;
0068:            static final int NETMAIL_HEADERS_PAGE = 63;
0069:            static final int NETMAIL_NEWEST_FIRST = 64;
0070:            static final int NETMAIL_LOGMSSGS = 65;
0071:            static final int NETMAIL_USER_REPLYTOADDRESS = 66;
0072:            static final int NETMAIL_SIGNATURE = 67;
0073:            static final int NETMAIL_CHAR_SET = 68;
0074:            static final int NETMAIL_PERSONAL_ADDRBOOK = 69;
0075:            static final int NETMAIL_EXEC_PV = 70;
0076:            static final int NETMAIL_EXEC_CAT = 71;
0077:            static final int NETMAIL_FAVORITE_FOLDER = 72;
0078:
0079:            static final int DESKTOP_PROVIDERS = 73;
0080:            static final int USER_LOCALE = 74;
0081:            static final int USER_AUTHMODULES = 75;
0082:            static final int USER_TIMEZONE = 76;
0083:            static final int USER_LOGINSTATE = 77;
0084:
0085:            static Map ATTRIBUTES = new HashMap();
0086:
0087:            static String RoleValue = new String();
0088:            static String currOrgName = new String();
0089:            static String isFlat = new String("n");
0090:
0091:            static OutputStreamWriter uidsToModify;//To handle the internal LDAP Server case
0092:            static Map LISTOFORGS = new HashMap();
0093:            static ArrayList adminRoles = new ArrayList();
0094:
0095:            // authmap handles mapping of authentication handles to class names
0096:            static AuthMap authmap = new AuthMap();
0097:
0098:            public static void main(String args[]) {
0099:
0100:                String outputfile, ldiffile, rolefile;
0101:
0102:                ldiffile = new String();// Input file, the LDIF file to be converted....
0103:                outputfile = new String();
0104:                rolefile = null;
0105:
0106:                // arg[0] = exported user ldif file
0107:                // arg[1] = converted user ldif file (outfile)
0108:                // arg[2] = exorted role ldif file - used for delegated admin convert
0109:                //
0110:                if (args.length == 3) {
0111:                    ldiffile = args[0];
0112:                    outputfile = args[1];
0113:                    rolefile = args[2];
0114:
0115:                    getAdminRoles(rolefile);
0116:                } else if (args.length == 2) {
0117:                    outputfile = args[1];
0118:                    ldiffile = args[0];
0119:                } else if (args.length == 1) {
0120:                    outputfile = new String("default.ldif");
0121:                    ldiffile = args[0];
0122:                } else if (args.length == 0) {
0123:                    System.out
0124:                            .println("Input file to be converted not specified!");
0125:                    System.out
0126:                            .println("Invokation Format is:java UsersConvert infile outfile");
0127:                    System.exit(1);
0128:                }
0129:                doConvert(ldiffile, outputfile);
0130:            }
0131:
0132:            public static void doConvertWithDelegatedAdmin(String ldiffile,
0133:                    String outputfile, String rolefile) {
0134:                getAdminRoles(rolefile);
0135:                doConvert(ldiffile, outputfile);
0136:            }
0137:
0138:            public static void doConvert(String ldiffile, String outputfile) {
0139:                LDIFRecord out;
0140:                OutputStreamWriter outFile;
0141:                int count = 0;
0142:                LDIF l1;
0143:
0144:                try {
0145:                    InitHashMap(); // Populate the hash map.
0146:                    String LDIFDIR = System.getProperty("LDIFDIR");
0147:                    String OUTPUTDIR = System.getProperty("OUTPUTDIR");
0148:                    String localeString = null;
0149:
0150:                    PopulateOrgsMap(OUTPUTDIR);
0151:                    File userDN = new File(LDIFDIR + "/userDNs.ldif");
0152:                    if (!userDN.exists()) {
0153:                        userDN.createNewFile();
0154:                    }
0155:                    uidsToModify = new OutputStreamWriter(new FileOutputStream(
0156:                            userDN), "UTF-8");
0157:                    DataInputStream ldifFile = new DataInputStream(
0158:                            new FileInputStream(ldiffile));
0159:                    l1 = new LDIF(ldifFile);
0160:                    outFile = new OutputStreamWriter(new FileOutputStream(
0161:                            outputfile), "UTF-8");
0162:                    ;
0163:
0164:                    //System.out.println("Converting LDIF entries corr. to users from file:"+ldiffile+".....\n");
0165:
0166:                    LDIFRecord tmp = l1.nextRecord();
0167:                    Locale locale = Locale.getDefault();
0168:                    if (System.getProperty("LOCALE_STRING") != null)
0169:                        localeString = System.getProperty("LOCALE_STRING");
0170:
0171:                    if (localeString == null)
0172:                        locale = Locale.getDefault();
0173:                    else
0174:                        locale = getLocale(localeString);
0175:
0176:                    if (System.getProperty("FLAT") != null)
0177:                        isFlat = System.getProperty("FLAT");
0178:
0179:                    ResourceBundle ambundle;
0180:                    ambundle = ResourceBundle.getBundle("AMConfig", locale);
0181:
0182:                    if (ambundle.getObject("com.iplanet.am.rootsuffix") != null)
0183:                        rootsuffix = (String) (ambundle
0184:                                .getObject("com.iplanet.am.rootsuffix"));
0185:                    while (tmp != null) {
0186:
0187:                        //OutputRecord(tmp);
0188:
0189:                        RoleValue = "";
0190:                        out = ConvertRecord(tmp, count);
0191:
0192:                        if (out != null) {
0193:                            count++;
0194:                            outFile.write("\n# Entry id:" + count + "\n");
0195:                            try {
0196:                                OutputRecord(outFile, out);
0197:                            } catch (Exception e) {
0198:                                System.out
0199:                                        .println("Error writing to output file:"
0200:                                                + outputfile);
0201:                                e.printStackTrace();
0202:                            }
0203:                        }
0204:                        tmp = l1.nextRecord();
0205:                    }
0206:                    outFile.close();
0207:                    uidsToModify.close();
0208:                    System.out.println("\tprocessed " + count + " entries");
0209:                    //System.out.println("Output available in file "+outputfile);
0210:                } catch (IOException e) {
0211:                    System.out.println("Error:" + e.toString());
0212:                    e.printStackTrace();
0213:                }
0214:            }
0215:
0216:            static void PopulateOrgsMap(String outDir) {
0217:                try {
0218:                    InputStreamReader fr = new InputStreamReader(
0219:                            new FileInputStream(outDir + "/.orgslist"), "UTF-8");
0220:                    BufferedReader buffRead = new BufferedReader(fr);
0221:                    String currLine;
0222:                    int i = 0;
0223:                    while ((currLine = buffRead.readLine()) != null) {
0224:                        currLine = (currLine.trim()).toLowerCase();
0225:                        LISTOFORGS.put(currLine, new Integer(i));
0226:                        i++;
0227:                    }
0228:                    fr.close();
0229:                } catch (IOException fnfe) {
0230:                    return;
0231:                }
0232:            }
0233:
0234:            static void InitHashMap() {
0235:                /* Populate hash map to have the list of attributest that need to be processed....
0236:                Attributes in the display profile stored in LDAP are not put in Hash Table.
0237:                They are handled differently....*/
0238:
0239:                ATTRIBUTES.put((new String("iwtAuthMembership-phoneNumber-at"))
0240:                        .toLowerCase(), new Integer(PHONE_NUMBER));
0241:                ATTRIBUTES.put((new String("iwtAuthMembership-password-at"))
0242:                        .toLowerCase(), new Integer(PASSWORD));
0243:                ATTRIBUTES.put((new String("iwtAuthMembership-email-at"))
0244:                        .toLowerCase(), new Integer(EMAIL));
0245:                ATTRIBUTES.put((new String("iwtAuthMembership-userName-at"))
0246:                        .toLowerCase(), new Integer(USERNAME));
0247:                ATTRIBUTES.put((new String("iwtUserInfoProvider-firstName-at"))
0248:                        .toLowerCase(), new Integer(FIRSTNAME));
0249:                ATTRIBUTES.put((new String("iwtUserInfoProvider-lastName-at"))
0250:                        .toLowerCase(), new Integer(LASTNAME));
0251:                ATTRIBUTES.put((new String("uid")).toLowerCase(), new Integer(
0252:                        UID));
0253:                ATTRIBUTES.put((new String("creatorsname")).toLowerCase(),
0254:                        new Integer(CREATORSNAME));
0255:                ATTRIBUTES.put((new String("createtimestamp")).toLowerCase(),
0256:                        new Integer(CREATETIMESTAMP));
0257:                ATTRIBUTES.put((new String("modifiersname")).toLowerCase(),
0258:                        new Integer(MODIFIERSNAME));
0259:                ATTRIBUTES.put((new String("modifytimestamp")).toLowerCase(),
0260:                        new Integer(MODIFYTIMESTAMP));
0261:                ATTRIBUTES.put((new String("parent")).toLowerCase(),
0262:                        new Integer(PARENT));
0263:                ATTRIBUTES.put((new String("iwtUser-role-at")).toLowerCase(),
0264:                        new Integer(ROLE_AT));
0265:                ATTRIBUTES.put((new String("objectclass")).toLowerCase(),
0266:                        new Integer(OBJECTCLASS));
0267:                ATTRIBUTES.put((new String("cn")).toLowerCase(),
0268:                        new Integer(CN));
0269:                ATTRIBUTES.put((new String("profileid")).toLowerCase(),
0270:                        new Integer(PROFILE_ID));
0271:                ATTRIBUTES.put((new String("profiletype")).toLowerCase(),
0272:                        new Integer(PROFILE_TYPE));
0273:
0274:                ATTRIBUTES.put((new String("iwtUser-locale-at")).toLowerCase(),
0275:                        new Integer(USER_LOCALE));
0276:                ATTRIBUTES.put((new String("iwtUser-authModules-at"))
0277:                        .toLowerCase(), new Integer(USER_AUTHMODULES));
0278:                ATTRIBUTES.put((new String("iwtUser-SMTPServerName-at"))
0279:                        .toLowerCase(), new Integer(NETMAIL_USER_SMTP_SERVER));
0280:                ATTRIBUTES.put((new String("iwtUser-IMAPServerName-at"))
0281:                        .toLowerCase(), new Integer(NETMAIL_USER_IMAP_SERVER));
0282:                ATTRIBUTES.put((new String("iwtUser-IMAPUserId-at"))
0283:                        .toLowerCase(), new Integer(NETMAIL_USER_IMAP_ID));
0284:                ATTRIBUTES.put((new String("iwtUser-IMAPPassword-at"))
0285:                        .toLowerCase(), new Integer(NETMAIL_USER_IMAP_PASSWD));
0286:                ATTRIBUTES.put((new String("iwtUser-defaultMailDomain-at"))
0287:                        .toLowerCase(), new Integer(
0288:                        NETMAIL_USER_DEFAULTMAILDOMAIN));
0289:                ATTRIBUTES.put((new String("iwtUser-replyToAddress-at"))
0290:                        .toLowerCase(),
0291:                        new Integer(NETMAIL_USER_REPLYTOADDRESS));
0292:                ATTRIBUTES.put((new String("iwtNetMail-rootFolder-at"))
0293:                        .toLowerCase(), new Integer(NETMAIL_ROOT_FOLDER));
0294:                ATTRIBUTES.put((new String("iwtNetMail-sentMessagesFolder-at"))
0295:                        .toLowerCase(), new Integer(NETMAIL_SENT_FOLDER));
0296:                ATTRIBUTES.put((new String("iwtNetMail-replyWithAuthor-at"))
0297:                        .toLowerCase(), new Integer(NETMAIL_REPLY_WITHAUTHOR));
0298:                ATTRIBUTES.put((new String("iwtNetMail-replyWithDate-at"))
0299:                        .toLowerCase(), new Integer(NETMAIL_REPLY_WITHDATE));
0300:                ATTRIBUTES.put((new String("iwtNetMail-replyWithBody-at"))
0301:                        .toLowerCase(), new Integer(NETMAIL_REPLY_WITHBODY));
0302:                ATTRIBUTES.put((new String("iwtNetMail-indentPrefix-at"))
0303:                        .toLowerCase(), new Integer(NETMAIL_INDENT_PREFIX));
0304:                ATTRIBUTES.put((new String("iwtNetMail-addSignature-at"))
0305:                        .toLowerCase(), new Integer(NETMAIL_ADD_SIGNATURE));
0306:                ATTRIBUTES.put((new String("iwtNetMail-initialHeaders-at"))
0307:                        .toLowerCase(), new Integer(NETMAIL_INITIAL_HDRS));
0308:                ATTRIBUTES.put((new String("iwtNetMail-inactivityInterval-at"))
0309:                        .toLowerCase(),
0310:                        new Integer(NETMAIL_INACTIVITY_INTERVAL));
0311:                ATTRIBUTES.put((new String("iwtNetMail-maxAttachLen-at"))
0312:                        .toLowerCase(), new Integer(NETMAIL_MAX_ATTACH_LEN));
0313:                ATTRIBUTES.put((new String("iwtNetMail-autoload-at"))
0314:                        .toLowerCase(), new Integer(NETMAIL_AUTOLOAD));
0315:                ATTRIBUTES.put((new String("iwtNetMail-autosave-at"))
0316:                        .toLowerCase(), new Integer(NETMAIL_AUTOSAVE));
0317:                ATTRIBUTES.put((new String("iwtNetMail-autopurge-at"))
0318:                        .toLowerCase(), new Integer(NETMAIL_AUTOPURGE));
0319:                ATTRIBUTES.put((new String("iwtNetMail-autoFolderload-at"))
0320:                        .toLowerCase(), new Integer(NETMAIL_AUTOFOLDERLOAD));
0321:                ATTRIBUTES.put(
0322:                        (new String("iwtNetMail-multipleReadWindows-at"))
0323:                                .toLowerCase(), new Integer(
0324:                                NETMAIL_MULTIPLE_RDW));
0325:                ATTRIBUTES.put((new String("iwtNetMail-sortKey-at"))
0326:                        .toLowerCase(), new Integer(NETMAIL_SORTKEY));
0327:                ATTRIBUTES.put((new String("iwtNetMail-viewKey-at"))
0328:                        .toLowerCase(), new Integer(NETMAIL_VIEWKEY));
0329:                ATTRIBUTES.put((new String("iwtNetMail-composeWinBounds-at"))
0330:                        .toLowerCase(), new Integer(NETMAIL_COMPOSE_WINBOUNDS));
0331:                ATTRIBUTES.put((new String("iwtNetMail-folderWinBounds-at"))
0332:                        .toLowerCase(), new Integer(NETMAIL_FOLDER_WINBOUNDS));
0333:                ATTRIBUTES.put((new String("iwtNetMail-readWinBounds-at"))
0334:                        .toLowerCase(), new Integer(NETMAIL_READ_WINBOUNDS));
0335:                ATTRIBUTES.put((new String("iwtNetMail-gridHeight-at"))
0336:                        .toLowerCase(), new Integer(NETMAIL_GRID_HEIGHT));
0337:                ATTRIBUTES.put((new String("iwtNetMail-gridColWidths-at"))
0338:                        .toLowerCase(), new Integer(NETMAIL_GRID_COLWIDTHS));
0339:                ATTRIBUTES.put((new String("iwtNetMail-textColor-at"))
0340:                        .toLowerCase(), new Integer(NETMAIL_TEXT_COLOR));
0341:                ATTRIBUTES.put((new String("iwtNetMail-textSize-at"))
0342:                        .toLowerCase(), new Integer(NETMAIL_TEXTSIZE));
0343:                ATTRIBUTES.put((new String("iwtNetMail-backgroundColor-at"))
0344:                        .toLowerCase(), new Integer(NETMAIL_BGCOLOR));
0345:                ATTRIBUTES.put((new String("iwtNetMail-textStyle-at"))
0346:                        .toLowerCase(), new Integer(NETMAIL_TEXTSTYLE));
0347:                ATTRIBUTES.put((new String("iwtNetMail-headersPerPage-at"))
0348:                        .toLowerCase(), new Integer(NETMAIL_HEADERS_PAGE));
0349:                ATTRIBUTES.put((new String("iwtNetMail-newestFirst-at"))
0350:                        .toLowerCase(), new Integer(NETMAIL_NEWEST_FIRST));
0351:                ATTRIBUTES.put((new String("iwtNetMail-logMessages-at"))
0352:                        .toLowerCase(), new Integer(NETMAIL_LOGMSSGS));
0353:                ATTRIBUTES.put((new String("iwtNetMail-signature-at"))
0354:                        .toLowerCase(), new Integer(NETMAIL_SIGNATURE));
0355:                ATTRIBUTES.put((new String("iwtNetMail-charset-at"))
0356:                        .toLowerCase(), new Integer(NETMAIL_CHAR_SET));
0357:                ATTRIBUTES.put(
0358:                        (new String("iwtNetMail-personaladdressbook-at"))
0359:                                .toLowerCase(), new Integer(
0360:                                NETMAIL_PERSONAL_ADDRBOOK));
0361:                ATTRIBUTES.put((new String("iwtNetMail-execute-pv-ac-"))
0362:                        .toLowerCase(), new Integer(NETMAIL_EXEC_PV));
0363:                ATTRIBUTES.put((new String("iwtNetMail-execute-pv-cat-"))
0364:                        .toLowerCase(), new Integer(NETMAIL_EXEC_CAT));
0365:                ATTRIBUTES.put((new String("iwtNetMail-favoriteFolders-at"))
0366:                        .toLowerCase(), new Integer(NETMAIL_FAVORITE_FOLDER));
0367:
0368:                ATTRIBUTES.put((new String(
0369:                        "iwtDesktop-userSelectedProviders-at")).toLowerCase(),
0370:                        new Integer(DESKTOP_PROVIDERS));
0371:                ATTRIBUTES.put((new String("iwtUser-timezone-at"))
0372:                        .toLowerCase(), new Integer(USER_TIMEZONE));
0373:                ATTRIBUTES.put((new String("iwtUser-loginState-at"))
0374:                        .toLowerCase(), new Integer(USER_LOGINSTATE));
0375:            }
0376:
0377:            static LDIFRecord ConvertRecord(LDIFRecord toConvert, int count) {
0378:                LDIFAttributeContent con, converted;
0379:                LDAPAttribute tmp;
0380:                LDAPAttributeSet theAttrSet;
0381:                String attrVal, firstname;
0382:                String[] allAttrs;
0383:                String[] listAllAttrs;
0384:                String[] allAttrsConv;
0385:                Vector dispProf = new Vector();
0386:                String lastname = new String();
0387:                boolean cnValuetobeSet = false;
0388:                String dn;
0389:                firstname = new String();
0390:                //DispProfile dp;
0391:
0392:                MimeBase64Decoder MBD = new MimeBase64Decoder();
0393:                ByteBuf tmpBuf;
0394:                /* NOTE: CHECK WITH HARRY, BEFORE ACTUALLY INCLUDING THIS......GET TO KNOW THE INTERFACE.....CHECK IF WHAT
0395:                	YOU DID IS CORRECT AND THEN INCLUDE......??? */
0396:
0397:                LDAPAttribute[] attrList;
0398:                int i, typeAttr;
0399:
0400:                con = (LDIFAttributeContent) toConvert.getContent();
0401:                converted = new LDIFAttributeContent();
0402:                attrList = con.getAttributes();
0403:                theAttrSet = new LDAPAttributeSet(attrList);
0404:
0405:                // Filter uids 'authentication' and starting with 'gateway-'
0406:                // per 3.x admin console code
0407:                //
0408:                String uid = ((String[]) theAttrSet.getAttribute("uid")
0409:                        .getStringValueArray())[0];
0410:
0411:                if (uid != null) {
0412:                    if ((uid.equals("authentication"))
0413:                            || (uid.startsWith("gateway-"))) {
0414:                        return null;
0415:                    }
0416:                }
0417:
0418:                converted.setControls(con.getControls());
0419:
0420:                for (i = 0; i < attrList.length; ++i) {
0421:                    typeAttr = attrType(attrList[i].getName());
0422:                    switch (typeAttr) {
0423:
0424:                    case -1:
0425:                        break;
0426:
0427:                    case PHONE_NUMBER:
0428:                        allAttrs = (((LDAPAttribute) (theAttrSet
0429:                                .getAttribute(attrList[i].getName())))
0430:                                .getStringValueArray());
0431:                        attrVal = allAttrs[1];
0432:                        converted.addElement(new LDAPAttribute(
0433:                                "telephoneNumber", attrVal));
0434:                        break;
0435:                    case PASSWORD:
0436:
0437:                        allAttrs = (((LDAPAttribute) (theAttrSet
0438:                                .getAttribute(attrList[i].getName())))
0439:                                .getStringValueArray());
0440:                        attrVal = allAttrs[1];
0441:                        tmpBuf = new ByteBuf("");
0442:                        MBD.translate(new ByteBuf(attrVal), tmpBuf);
0443:                        attrVal = tmpBuf.toString();
0444:                        //attrVal=Password.decrypt(attrVal);
0445:                        //fwp.write(attrVal);
0446:                        //attrVal=Crypt.encrypt(attrVal);
0447:                        //System.out.println("Encrypted...."+attrVal);
0448:                        converted.addElement(new LDAPAttribute("userPassword",
0449:                                attrVal));
0450:                        break;
0451:
0452:                    case EMAIL:
0453:                        allAttrs = (((LDAPAttribute) (theAttrSet
0454:                                .getAttribute(attrList[i].getName())))
0455:                                .getStringValueArray());
0456:                        attrVal = allAttrs[1];
0457:                        converted
0458:                                .addElement(new LDAPAttribute("mail", attrVal));
0459:                        break;
0460:
0461:                    case FIRSTNAME:
0462:                        allAttrs = (((LDAPAttribute) (theAttrSet
0463:                                .getAttribute(attrList[i].getName())))
0464:                                .getStringValueArray());
0465:                        attrVal = allAttrs[1];
0466:                        firstname = attrVal;
0467:                        cnValuetobeSet = true;
0468:                        converted.addElement(new LDAPAttribute("givenName",
0469:                                attrVal));
0470:                        break;
0471:
0472:                    case LASTNAME:
0473:                        allAttrs = (((LDAPAttribute) (theAttrSet
0474:                                .getAttribute(attrList[i].getName())))
0475:                                .getStringValueArray());
0476:                        attrVal = allAttrs[1];
0477:                        lastname = attrVal;
0478:                        cnValuetobeSet = false;
0479:                        converted.addElement(new LDAPAttribute("sn", attrVal));
0480:                        break;
0481:
0482:                    case USERNAME:
0483:                        allAttrs = (((LDAPAttribute) (theAttrSet
0484:                                .getAttribute(attrList[i].getName())))
0485:                                .getStringValueArray());
0486:                        attrVal = allAttrs[1];
0487:                        //converted.addElement(new LDAPAttribute("cn",attrVal));
0488:                        break;
0489:
0490:                    case UID:
0491:                        allAttrs = (((LDAPAttribute) (theAttrSet
0492:                                .getAttribute(attrList[i].getName())))
0493:                                .getStringValueArray());
0494:                        attrVal = allAttrs[0];
0495:                        converted.addElement(new LDAPAttribute("uid", attrVal));
0496:                        break;
0497:
0498:                    case CREATORSNAME:
0499:                        allAttrs = (((LDAPAttribute) (theAttrSet
0500:                                .getAttribute(attrList[i].getName())))
0501:                                .getStringValueArray());
0502:                        attrVal = allAttrs[0];
0503:                        converted.addElement(new LDAPAttribute("creatorsName",
0504:                                attrVal));
0505:                        break;
0506:
0507:                    case CREATETIMESTAMP:
0508:
0509:                        allAttrs = (((LDAPAttribute) (theAttrSet
0510:                                .getAttribute(attrList[i].getName())))
0511:                                .getStringValueArray());
0512:                        attrVal = allAttrs[0];
0513:                        converted.addElement(new LDAPAttribute(
0514:                                "createTimestamp", attrVal));
0515:                        break;
0516:                    case MODIFIERSNAME:
0517:
0518:                        allAttrs = (((LDAPAttribute) (theAttrSet
0519:                                .getAttribute(attrList[i].getName())))
0520:                                .getStringValueArray());
0521:                        attrVal = allAttrs[0];
0522:                        converted.addElement(new LDAPAttribute("modifiersName",
0523:                                attrVal));
0524:                        break;
0525:                    case MODIFYTIMESTAMP:
0526:
0527:                        allAttrs = (((LDAPAttribute) (theAttrSet
0528:                                .getAttribute(attrList[i].getName())))
0529:                                .getStringValueArray());
0530:                        attrVal = allAttrs[0];
0531:                        converted.addElement(new LDAPAttribute(
0532:                                "modifyTimeStamp", attrVal));
0533:                        break;
0534:                    case OBJECTCLASS:
0535:                        converted.addElement(new LDAPAttribute("objectclass",
0536:                                "sunPortalNetmailPerson"));
0537:                        converted.addElement(new LDAPAttribute("objectclass",
0538:                                "sunPortalDesktopPerson"));
0539:                        converted.addElement(new LDAPAttribute("objectclass",
0540:                                "iplanet-am-web-agent-service"));
0541:                        converted.addElement(new LDAPAttribute("objectclass",
0542:                                "inetuser"));
0543:                        converted.addElement(new LDAPAttribute("objectclass",
0544:                                "iplanet-am-managed-person"));
0545:                        converted.addElement(new LDAPAttribute("objectclass",
0546:                                "top"));
0547:                        converted.addElement(new LDAPAttribute("objectclass",
0548:                                "person"));
0549:                        converted.addElement(new LDAPAttribute("objectclass",
0550:                                "organizationalPerson"));
0551:                        converted.addElement(new LDAPAttribute("objectclass",
0552:                                "iPlanetPreferences"));
0553:                        converted.addElement(new LDAPAttribute("objectclass",
0554:                                "inetOrgPerson"));
0555:                        converted.addElement(new LDAPAttribute("objectclass",
0556:                                "iplanet-am-user-service"));
0557:                        break;
0558:
0559:                    case ROLE_AT:
0560:                        allAttrs = (((LDAPAttribute) (theAttrSet
0561:                                .getAttribute(attrList[i].getName())))
0562:                                .getStringValueArray());
0563:                        RoleValue = allAttrs[1];
0564:
0565:                        if (adminRoles.contains(allAttrs[1])) {
0566:                            String orgName = allAttrs[1].substring(1,
0567:                                    allAttrs[1].indexOf("/", 1));
0568:                            String orgAdmin = constructRoleDN(
0569:                                    "Organization Admin Role", orgName,
0570:                                    rootsuffix);
0571:                            converted.addElement(new LDAPAttribute("nsRoleDN",
0572:                                    orgAdmin));
0573:                        }
0574:
0575:                        if (isFlat.equalsIgnoreCase("y")) {
0576:                            allAttrsConv = getnsRoleDN(allAttrs[1]);
0577:                            converted.addElement(new LDAPAttribute("nsRoleDN",
0578:                                    allAttrsConv));
0579:                        }
0580:                        break;
0581:
0582:                    case PARENT:
0583:                        allAttrs = (((LDAPAttribute) (theAttrSet
0584:                                .getAttribute(attrList[i].getName())))
0585:                                .getStringValueArray());
0586:                        currOrgName = (allAttrs[0].trim()).substring(1);
0587:                        //attrVal=getMemberOfVal(allAttrs[0]);
0588:                        /* Member-of element in Hana only appears when there is people-groups.....Doesnot have equiv. in
0589:                        iPS3.0.....So can ignore */
0590:                        // converted.addElement(new LDAPAttribute("memberOf",attrVal));
0591:                        break;
0592:
0593:                    case NETMAIL_USER_IMAP_ID:
0594:                        allAttrs = (((LDAPAttribute) (theAttrSet
0595:                                .getAttribute(attrList[i].getName())))
0596:                                .getStringValueArray());
0597:                        attrVal = allAttrs[1];
0598:                        converted.addElement(new LDAPAttribute(
0599:                                "sunPortalNetmailIMAPUserid", attrVal));
0600:                        break;
0601:
0602:                    case NETMAIL_USER_IMAP_PASSWD:
0603:                        allAttrs = (((LDAPAttribute) (theAttrSet
0604:                                .getAttribute(attrList[i].getName())))
0605:                                .getStringValueArray());
0606:                        attrVal = allAttrs[1];
0607:                        tmpBuf = new ByteBuf("");
0608:                        MBD.translate(new ByteBuf(attrVal), tmpBuf);
0609:                        attrVal = tmpBuf.toString();
0610:                        //attrVal=Password.decrypt(attrVal);
0611:                        //fwp.write(attrVal);
0612:                        //attrVal=Crypt.encrypt(attrVal);
0613:                        //System.out.println("Encrypted...."+attrVal);
0614:                        //converted.addElement(new LDAPAttribute("userPassword",attrVal));
0615:                        String convertedPwd = (String) AccessController
0616:                                .doPrivileged(new EncryptAction(attrVal));
0617:                        converted.addElement(new LDAPAttribute(
0618:                                "sunPortalNetmailIMAPPassword", convertedPwd));
0619:                        break;
0620:
0621:                    case NETMAIL_USER_SMTP_SERVER:
0622:                        allAttrs = (((LDAPAttribute) (theAttrSet
0623:                                .getAttribute(attrList[i].getName())))
0624:                                .getStringValueArray());
0625:                        attrVal = allAttrs[1];
0626:                        converted.addElement(new LDAPAttribute(
0627:                                "sunPortalNetmailSMTPServerName", attrVal));
0628:                        break;
0629:
0630:                    case NETMAIL_USER_IMAP_SERVER:
0631:                        allAttrs = (((LDAPAttribute) (theAttrSet
0632:                                .getAttribute(attrList[i].getName())))
0633:                                .getStringValueArray());
0634:                        attrVal = allAttrs[1];
0635:                        converted.addElement(new LDAPAttribute(
0636:                                "sunPortalNetmailIMAPServerName", attrVal));
0637:                        break;
0638:
0639:                    case NETMAIL_USER_DEFAULTMAILDOMAIN:
0640:                        allAttrs = (((LDAPAttribute) (theAttrSet
0641:                                .getAttribute(attrList[i].getName())))
0642:                                .getStringValueArray());
0643:                        attrVal = allAttrs[1];
0644:                        converted.addElement(new LDAPAttribute(
0645:                                "sunPortalNetmailDefaultMailDomain", attrVal));
0646:                        break;
0647:
0648:                    case NETMAIL_ROOT_FOLDER:
0649:                        allAttrs = (((LDAPAttribute) (theAttrSet
0650:                                .getAttribute(attrList[i].getName())))
0651:                                .getStringValueArray());
0652:                        attrVal = allAttrs[1];
0653:                        converted.addElement(new LDAPAttribute(
0654:                                "sunPortalNetmailRootFolder", attrVal));
0655:                        break;
0656:
0657:                    case NETMAIL_SENT_FOLDER:
0658:                        allAttrs = (((LDAPAttribute) (theAttrSet
0659:                                .getAttribute(attrList[i].getName())))
0660:                                .getStringValueArray());
0661:                        attrVal = allAttrs[1];
0662:                        converted.addElement(new LDAPAttribute(
0663:                                "sunPortalNetmailSentMessagesFolder", attrVal));
0664:                        break;
0665:
0666:                    case NETMAIL_REPLY_WITHAUTHOR:
0667:                        allAttrs = (((LDAPAttribute) (theAttrSet
0668:                                .getAttribute(attrList[i].getName())))
0669:                                .getStringValueArray());
0670:                        attrVal = allAttrs[1];
0671:                        converted.addElement(new LDAPAttribute(
0672:                                "sunPortalNetmailReplyWithAuthor", attrVal));
0673:                        break;
0674:
0675:                    case NETMAIL_REPLY_WITHDATE:
0676:                        allAttrs = (((LDAPAttribute) (theAttrSet
0677:                                .getAttribute(attrList[i].getName())))
0678:                                .getStringValueArray());
0679:                        attrVal = allAttrs[1];
0680:                        converted.addElement(new LDAPAttribute(
0681:                                "sunPortalNetmailReplyWithDate", attrVal));
0682:                        break;
0683:
0684:                    case NETMAIL_REPLY_WITHBODY:
0685:                        allAttrs = (((LDAPAttribute) (theAttrSet
0686:                                .getAttribute(attrList[i].getName())))
0687:                                .getStringValueArray());
0688:                        attrVal = allAttrs[1];
0689:                        converted.addElement(new LDAPAttribute(
0690:                                "sunPortalNetmailReplyWithBody", attrVal));
0691:                        break;
0692:
0693:                    case NETMAIL_INDENT_PREFIX:
0694:                        allAttrs = (((LDAPAttribute) (theAttrSet
0695:                                .getAttribute(attrList[i].getName())))
0696:                                .getStringValueArray());
0697:                        attrVal = allAttrs[1];
0698:                        converted.addElement(new LDAPAttribute(
0699:                                "sunPortalNetmailIndentPrefix", attrVal));
0700:                        break;
0701:
0702:                    case NETMAIL_ADD_SIGNATURE:
0703:                        allAttrs = (((LDAPAttribute) (theAttrSet
0704:                                .getAttribute(attrList[i].getName())))
0705:                                .getStringValueArray());
0706:                        attrVal = allAttrs[1];
0707:                        converted.addElement(new LDAPAttribute(
0708:                                "sunPortalNetmailAddSignature", attrVal));
0709:                        break;
0710:
0711:                    case NETMAIL_INITIAL_HDRS:
0712:                        allAttrs = (((LDAPAttribute) (theAttrSet
0713:                                .getAttribute(attrList[i].getName())))
0714:                                .getStringValueArray());
0715:                        attrVal = allAttrs[1];
0716:                        converted.addElement(new LDAPAttribute(
0717:                                "sunPortalNetmailInitialHeaders", attrVal));
0718:                        break;
0719:
0720:                    case NETMAIL_INACTIVITY_INTERVAL:
0721:                        allAttrs = (((LDAPAttribute) (theAttrSet
0722:                                .getAttribute(attrList[i].getName())))
0723:                                .getStringValueArray());
0724:                        attrVal = allAttrs[1];
0725:                        converted.addElement(new LDAPAttribute(
0726:                                "sunPortalNetmailInactivityInterval", attrVal));
0727:                        break;
0728:
0729:                    case NETMAIL_MAX_ATTACH_LEN:
0730:                        allAttrs = (((LDAPAttribute) (theAttrSet
0731:                                .getAttribute(attrList[i].getName())))
0732:                                .getStringValueArray());
0733:                        attrVal = allAttrs[1];
0734:                        converted.addElement(new LDAPAttribute(
0735:                                "sunPortalNetmailMaxAttachLen", attrVal));
0736:                        break;
0737:
0738:                    case NETMAIL_AUTOLOAD:
0739:                        allAttrs = (((LDAPAttribute) (theAttrSet
0740:                                .getAttribute(attrList[i].getName())))
0741:                                .getStringValueArray());
0742:                        attrVal = allAttrs[1];
0743:                        converted.addElement(new LDAPAttribute(
0744:                                "sunPortalNetmailAutoload", attrVal));
0745:                        break;
0746:
0747:                    case NETMAIL_AUTOSAVE:
0748:                        allAttrs = (((LDAPAttribute) (theAttrSet
0749:                                .getAttribute(attrList[i].getName())))
0750:                                .getStringValueArray());
0751:                        attrVal = allAttrs[1];
0752:                        converted.addElement(new LDAPAttribute(
0753:                                "sunPortalNetmailAutosave", attrVal));
0754:                        break;
0755:
0756:                    case NETMAIL_AUTOPURGE:
0757:                        allAttrs = (((LDAPAttribute) (theAttrSet
0758:                                .getAttribute(attrList[i].getName())))
0759:                                .getStringValueArray());
0760:                        attrVal = allAttrs[1];
0761:                        converted.addElement(new LDAPAttribute(
0762:                                "sunPortalNetmailAutopurge", attrVal));
0763:                        break;
0764:
0765:                    case NETMAIL_AUTOFOLDERLOAD:
0766:                        allAttrs = (((LDAPAttribute) (theAttrSet
0767:                                .getAttribute(attrList[i].getName())))
0768:                                .getStringValueArray());
0769:                        attrVal = allAttrs[1];
0770:                        converted.addElement(new LDAPAttribute(
0771:                                "sunPortalNetmailAutoFolderLoad", attrVal));
0772:                        break;
0773:
0774:                    case NETMAIL_MULTIPLE_RDW:
0775:                        allAttrs = (((LDAPAttribute) (theAttrSet
0776:                                .getAttribute(attrList[i].getName())))
0777:                                .getStringValueArray());
0778:                        attrVal = allAttrs[1];
0779:                        converted
0780:                                .addElement(new LDAPAttribute(
0781:                                        "sunPortalNetmailMultipleReadWindows",
0782:                                        attrVal));
0783:                        break;
0784:
0785:                    case NETMAIL_SORTKEY:
0786:                        allAttrs = (((LDAPAttribute) (theAttrSet
0787:                                .getAttribute(attrList[i].getName())))
0788:                                .getStringValueArray());
0789:                        attrVal = allAttrs[1];
0790:                        converted.addElement(new LDAPAttribute(
0791:                                "sunPortalNetmailSortKey", attrVal));
0792:                        break;
0793:
0794:                    case NETMAIL_VIEWKEY:
0795:                        allAttrs = (((LDAPAttribute) (theAttrSet
0796:                                .getAttribute(attrList[i].getName())))
0797:                                .getStringValueArray());
0798:                        attrVal = allAttrs[1];
0799:                        converted.addElement(new LDAPAttribute(
0800:                                "sunPortalNetmailViewKey", attrVal));
0801:                        break;
0802:                    case NETMAIL_COMPOSE_WINBOUNDS:
0803:                        allAttrs = (((LDAPAttribute) (theAttrSet
0804:                                .getAttribute(attrList[i].getName())))
0805:                                .getStringValueArray());
0806:                        attrVal = allAttrs[1];
0807:                        converted.addElement(new LDAPAttribute(
0808:                                "sunPortalNetmailComposeWinBounds", attrVal));
0809:                        break;
0810:
0811:                    case NETMAIL_FOLDER_WINBOUNDS:
0812:                        allAttrs = (((LDAPAttribute) (theAttrSet
0813:                                .getAttribute(attrList[i].getName())))
0814:                                .getStringValueArray());
0815:                        attrVal = allAttrs[1];
0816:                        converted.addElement(new LDAPAttribute(
0817:                                "sunPortalNetmailFolderWinBounds", attrVal));
0818:                        break;
0819:
0820:                    case NETMAIL_READ_WINBOUNDS:
0821:                        allAttrs = (((LDAPAttribute) (theAttrSet
0822:                                .getAttribute(attrList[i].getName())))
0823:                                .getStringValueArray());
0824:                        attrVal = allAttrs[1];
0825:                        converted.addElement(new LDAPAttribute(
0826:                                "sunPortalNetmailReadWinBounds", attrVal));
0827:                        break;
0828:
0829:                    case NETMAIL_GRID_HEIGHT:
0830:                        allAttrs = (((LDAPAttribute) (theAttrSet
0831:                                .getAttribute(attrList[i].getName())))
0832:                                .getStringValueArray());
0833:                        attrVal = allAttrs[1];
0834:                        converted.addElement(new LDAPAttribute(
0835:                                "sunPortalNetmailGridHeight", attrVal));
0836:                        break;
0837:
0838:                    case NETMAIL_GRID_COLWIDTHS:
0839:                        allAttrs = (((LDAPAttribute) (theAttrSet
0840:                                .getAttribute(attrList[i].getName())))
0841:                                .getStringValueArray());
0842:                        try {
0843:                            attrVal = URLDecoder.decode(allAttrs[1]);
0844:                            converted.addElement(new LDAPAttribute(
0845:                                    "sunPortalNetmailGridColWidths", attrVal));
0846:                        } catch (Exception e) {
0847:
0848:                        }
0849:
0850:                        break;
0851:
0852:                    case NETMAIL_TEXT_COLOR:
0853:                        allAttrs = (((LDAPAttribute) (theAttrSet
0854:                                .getAttribute(attrList[i].getName())))
0855:                                .getStringValueArray());
0856:                        attrVal = allAttrs[1];
0857:                        converted.addElement(new LDAPAttribute(
0858:                                "sunPortalNetmailTextColor", attrVal));
0859:                        break;
0860:
0861:                    case NETMAIL_BGCOLOR:
0862:                        allAttrs = (((LDAPAttribute) (theAttrSet
0863:                                .getAttribute(attrList[i].getName())))
0864:                                .getStringValueArray());
0865:                        attrVal = allAttrs[1];
0866:                        converted.addElement(new LDAPAttribute(
0867:                                "sunPortalNetmailBackgroundColor", attrVal));
0868:                        break;
0869:
0870:                    case NETMAIL_TEXTSIZE:
0871:                        allAttrs = (((LDAPAttribute) (theAttrSet
0872:                                .getAttribute(attrList[i].getName())))
0873:                                .getStringValueArray());
0874:                        attrVal = allAttrs[1];
0875:                        converted.addElement(new LDAPAttribute(
0876:                                "sunPortalNetmailTextSize", attrVal));
0877:                        break;
0878:
0879:                    case NETMAIL_TEXTSTYLE:
0880:                        allAttrs = (((LDAPAttribute) (theAttrSet
0881:                                .getAttribute(attrList[i].getName())))
0882:                                .getStringValueArray());
0883:                        attrVal = allAttrs[1];
0884:                        converted.addElement(new LDAPAttribute(
0885:                                "sunPortalNetmailTextStyle", attrVal));
0886:                        break;
0887:
0888:                    case NETMAIL_HEADERS_PAGE:
0889:                        allAttrs = (((LDAPAttribute) (theAttrSet
0890:                                .getAttribute(attrList[i].getName())))
0891:                                .getStringValueArray());
0892:                        attrVal = allAttrs[1];
0893:                        converted.addElement(new LDAPAttribute(
0894:                                "sunPortalNetmailHeadersPerPage", attrVal));
0895:                        break;
0896:
0897:                    case NETMAIL_NEWEST_FIRST:
0898:                        allAttrs = (((LDAPAttribute) (theAttrSet
0899:                                .getAttribute(attrList[i].getName())))
0900:                                .getStringValueArray());
0901:                        attrVal = allAttrs[1];
0902:                        converted.addElement(new LDAPAttribute(
0903:                                "sunPortalNetmailNewestFirst", attrVal));
0904:                        break;
0905:
0906:                    case NETMAIL_LOGMSSGS:
0907:                        allAttrs = (((LDAPAttribute) (theAttrSet
0908:                                .getAttribute(attrList[i].getName())))
0909:                                .getStringValueArray());
0910:                        attrVal = allAttrs[1];
0911:                        converted.addElement(new LDAPAttribute(
0912:                                "sunPortalNetmailLogMessages", attrVal));
0913:                        break;
0914:
0915:                    case NETMAIL_USER_REPLYTOADDRESS:
0916:                        allAttrs = (((LDAPAttribute) (theAttrSet
0917:                                .getAttribute(attrList[i].getName())))
0918:                                .getStringValueArray());
0919:                        attrVal = allAttrs[1];
0920:                        converted.addElement(new LDAPAttribute(
0921:                                "sunPortalNetmailReplyToAddress", attrVal));
0922:                        break;
0923:
0924:                    case NETMAIL_SIGNATURE:
0925:
0926:                        allAttrs = (((LDAPAttribute) (theAttrSet
0927:                                .getAttribute(attrList[i].getName())))
0928:                                .getStringValueArray());
0929:                        attrVal = allAttrs[1];
0930:                        tmpBuf = new ByteBuf("");
0931:                        MBD.translate(new ByteBuf(attrVal), tmpBuf);
0932:                        attrVal = processNLines(tmpBuf.toString());
0933:
0934:                        converted.addElement(new LDAPAttribute(
0935:                                "sunPortalNetmailSignature", attrVal));
0936:                        break;
0937:                    case NETMAIL_CHAR_SET:
0938:                        break;
0939:                    case NETMAIL_PERSONAL_ADDRBOOK:
0940:                        allAttrs = (((LDAPAttribute) (theAttrSet
0941:                                .getAttribute(attrList[i].getName())))
0942:                                .getStringValueArray());
0943:                        if (allAttrs.length > 2) {
0944:                            int k = 0;
0945:
0946:                            /* In 6.x, each nickname, mailids is stored as pair of
0947:                            	nickname,mailid@domain1, mailid@domain2
0948:
0949:                               In 3.0, it was stored as
0950:                            	nickname
0951:                            	mailid@domain1,mailid@domain2
0952:                             */
0953:                            listAllAttrs = new String[(allAttrs.length - 1) / 2];
0954:                            for (int jk = 1; jk < allAttrs.length; jk = jk + 2) {
0955:                                listAllAttrs[k] = allAttrs[jk] + ","
0956:                                        + allAttrs[jk + 1];
0957:                                k++;
0958:                            }
0959:                            converted.addElement(new LDAPAttribute(
0960:                                    "sunPortalNetmailPersonalAddressBook",
0961:                                    listAllAttrs));
0962:                        }
0963:                        break;
0964:                    case NETMAIL_FAVORITE_FOLDER:
0965:                        allAttrs = (((LDAPAttribute) (theAttrSet
0966:                                .getAttribute(attrList[i].getName())))
0967:                                .getStringValueArray());
0968:                        if (allAttrs.length > 1) {
0969:                            listAllAttrs = new String[allAttrs.length - 1];
0970:                            for (int jk = 1; jk < allAttrs.length; ++jk)
0971:                                listAllAttrs[jk - 1] = allAttrs[jk];
0972:                            converted.addElement(new LDAPAttribute(
0973:                                    "sunPortalNetmailFavoriteFolders",
0974:                                    listAllAttrs));
0975:                        }
0976:                        break;
0977:
0978:                    case DESKTOP_PROVIDERS:
0979:                        boolean tabContainerFound = false;
0980:                        allAttrs = (((LDAPAttribute) (theAttrSet
0981:                                .getAttribute(attrList[i].getName())))
0982:                                .getStringValueArray());
0983:                        if (allAttrs.length > 1) {
0984:                            for (int jk = 1; jk < allAttrs.length; ++jk) {
0985:                                if (allAttrs[jk]
0986:                                        .equalsIgnoreCase("iwtTabProvider")) {
0987:                                    tabContainerFound = true;
0988:                                }
0989:                            }
0990:                        }
0991:                        if (tabContainerFound == true)
0992:                            converted.addElement(new LDAPAttribute(
0993:                                    "sunPortalDesktopDefaultChannelName",
0994:                                    "TemplateTabContainer"));
0995:                        else
0996:                            converted.addElement(new LDAPAttribute(
0997:                                    "sunPortalDesktopDefaultChannelName",
0998:                                    "TemplateTableContainer"));
0999:                        break;
1000:                    case USER_LOCALE:
1001:                        allAttrs = (((LDAPAttribute) (theAttrSet
1002:                                .getAttribute(attrList[i].getName())))
1003:                                .getStringValueArray());
1004:                        attrVal = allAttrs[1];
1005:                        converted.addElement(new LDAPAttribute(
1006:                                "preferredLocale", attrVal));
1007:                        converted.addElement(new LDAPAttribute(
1008:                                "preferredlanguage", getLanguage(attrVal)));
1009:                        break;
1010:
1011:                    case USER_AUTHMODULES:
1012:                        allAttrs = (((LDAPAttribute) (theAttrSet
1013:                                .getAttribute(attrList[i].getName())))
1014:                                .getStringValueArray());
1015:                        if (allAttrs.length > 1) {
1016:                            StringBuffer authModuleList = new StringBuffer();
1017:                            boolean authModuleListHasValue = false;
1018:                            authModuleList.append("<AttributeValuePair>");
1019:                            for (int jk = 1; jk < allAttrs.length; ++jk) {
1020:                                if (authmap.containsKeyIgnoreCase(allAttrs[jk])) {
1021:                                    authModuleList.append("<Value>");
1022:                                    authModuleList.append((String) authmap
1023:                                            .getIgnoreCase(allAttrs[jk]));
1024:                                    authModuleList.append(" REQUIRED </Value>");
1025:                                    authModuleListHasValue = true;
1026:                                }
1027:                            }
1028:                            authModuleList.append("</AttributeValuePair>");
1029:                            if (authModuleListHasValue) {
1030:                                converted.addElement(new LDAPAttribute(
1031:                                        "iplanet-am-user-auth-config",
1032:                                        authModuleList.toString()));
1033:                            }
1034:                        }
1035:                        break;
1036:
1037:                    case USER_TIMEZONE:
1038:                        allAttrs = (((LDAPAttribute) (theAttrSet
1039:                                .getAttribute(attrList[i].getName())))
1040:                                .getStringValueArray());
1041:                        attrVal = allAttrs[1];
1042:                        converted.addElement(new LDAPAttribute(
1043:                                "preferredtimezone", attrVal));
1044:
1045:                        break;
1046:                    case USER_LOGINSTATE:
1047:                        allAttrs = (((LDAPAttribute) (theAttrSet
1048:                                .getAttribute(attrList[i].getName())))
1049:                                .getStringValueArray());
1050:                        attrVal = allAttrs[1];
1051:                        if (!attrVal.equalsIgnoreCase("disabled"))
1052:                            converted.addElement(new LDAPAttribute(
1053:                                    "inetUserStatus", "Active"));
1054:                        else
1055:                            converted.addElement(new LDAPAttribute(
1056:                                    "inetUserStatus", "Inactive"));
1057:
1058:                        break;
1059:                    case CN:
1060:                        break;
1061:                    case PROFILE_ID:
1062:                        break;
1063:                    case PROFILE_TYPE:
1064:                        break;
1065:                    }
1066:                }
1067:                //System.out.println("Disp Prof:"+dispProf.toString());
1068:
1069:                if (cnValuetobeSet == true)
1070:                    converted.addElement(new LDAPAttribute("cn", firstname
1071:                            + " " + lastname));
1072:                if (dispProf.size() != 0) {
1073:                    //	dp=new DispProfile(dispProf);
1074:
1075:                    //	converted.addElement(new LDAPAttribute("sunPortalDesktopDpDocumentUser",dp.getDP()));
1076:                }
1077:                return new LDIFRecord(toConvert.getDN(), converted);
1078:            }
1079:
1080:            static String processNLines(String inName) {
1081:
1082:                String toRet;
1083:                int index, tmp;
1084:
1085:                index = inName.indexOf("\n");
1086:                if (index < 0)
1087:                    return inName;
1088:                toRet = inName.substring(0, index);
1089:                while (index >= 0 && index < inName.length()) {
1090:                    tmp = inName.indexOf("\n", index + 1);
1091:                    if (tmp != -1)
1092:                        toRet += "\n " + inName.substring(index + 1, tmp);
1093:                    else
1094:                        toRet += "\n " + inName.substring(index + 1);
1095:                    index = tmp;
1096:                }
1097:
1098:                return toRet;
1099:
1100:            }
1101:
1102:            static int attrType(String attrName) {
1103:                /* Returns the type of attribute that is being handled currently....*/
1104:
1105:                try {
1106:                    return ((Integer) ATTRIBUTES.get(attrName.toLowerCase()))
1107:                            .intValue();
1108:                } catch (Exception e) {
1109:                    return -1;
1110:                }
1111:
1112:            }
1113:
1114:            static int OrgPresent(String attrName) {
1115:
1116:                try {
1117:                    return ((Integer) LISTOFORGS.get(attrName.toLowerCase()))
1118:                            .intValue();
1119:                } catch (Exception e) {
1120:                    return -1;
1121:                }
1122:
1123:            }
1124:
1125:            /*static String getMemberOfVal(String parent){
1126:            	String toRet=new String("
1127:
1128:            } */
1129:            static String[] getnsRoleDN(String role) {
1130:
1131:                String orgName = new String();
1132:                String roleTemp = new String();
1133:                String temp;
1134:                int j = 0;
1135:                int count = 0;
1136:
1137:                orgName = role.substring(1, role.indexOf("/", 1));
1138:
1139:                if (role.indexOf("/", 1) >= 0)
1140:                    role = role.substring(role.indexOf("/", 1));
1141:
1142:                StringTokenizer strTok = new StringTokenizer(role, "/");
1143:                String[] rolesList = new String[strTok.countTokens()];
1144:                String concatRole = "";
1145:
1146:                while (strTok.hasMoreTokens()) {
1147:                    concatRole += "_" + strTok.nextToken();
1148:
1149:                    if (concatRole.startsWith("_")) {
1150:                        concatRole = concatRole.substring(1, concatRole
1151:                                .length());
1152:                    }
1153:
1154:                    temp = constructRoleDN(concatRole, orgName, rootsuffix);
1155:                    rolesList[j] = new String(temp);
1156:                    //System.out.println("RolesList.."+rolesList[j]);
1157:                    j++;
1158:                }
1159:
1160:                return rolesList;
1161:
1162:            }
1163:
1164:            static void OutputRecord(OutputStreamWriter fw, LDIFRecord toOutput)
1165:                    throws Exception {
1166:                LDIFAttributeContent con;
1167:                LDAPAttribute[] list;
1168:                LDAPAttributeSet theAttrSet;
1169:                String[] values;
1170:                String dnVal = new String();
1171:                String uid = new String();
1172:                boolean snExists = false;
1173:                boolean cnExists = false;
1174:                boolean userPasswordPresent = false;
1175:
1176:                con = (LDIFAttributeContent) toOutput.getContent();
1177:                list = con.getAttributes();
1178:                theAttrSet = new LDAPAttributeSet(list);
1179:                //System.out.println("\ndn:"+toOutput.getDN());
1180:
1181:                if (isFlat.equalsIgnoreCase("y"))
1182:                    dnVal = getDN(toOutput.getDN());
1183:                else
1184:                    dnVal = processDN(toOutput.getDN());
1185:                fw.write("\ndn:" + dnVal);
1186:                for (int i = 0; i < theAttrSet.size(); ++i) {
1187:                    values = (String[]) (theAttrSet.elementAt(i))
1188:                            .getStringValueArray();
1189:                    for (int j = 0; j < values.length; ++j) {
1190:                        /* System.out.print((theAttrSet.elementAt(i)).getName());
1191:                        System.out.println(":"+values[j]+"  ");	*/
1192:                        fw.write("\n" + (theAttrSet.elementAt(i)).getName());
1193:                        fw.write(":" + values[j]);
1194:                    }
1195:                    if (((theAttrSet.elementAt(i)).getName()).equals("cn"))
1196:                        cnExists = true;
1197:                    if (((theAttrSet.elementAt(i)).getName()).equals("sn"))
1198:                        snExists = true;
1199:                    if (((theAttrSet.elementAt(i)).getName()).equals("uid"))
1200:                        uid = values[0];
1201:                    if (((theAttrSet.elementAt(i)).getName())
1202:                            .equals("userPassword"))
1203:                        userPasswordPresent = true;
1204:                }
1205:
1206:                // if(cnExists != true) fw.write("\ncn: default");
1207:                if (cnExists != true)
1208:                    fw.write("\ncn: " + uid);
1209:                if (snExists != true)
1210:                    fw.write("\nsn: default");
1211:                fw.write("\n");
1212:                if (!userPasswordPresent) {
1213:                    if (OrgPresent(currOrgName.toLowerCase()) != -1
1214:                            && dnVal.length() > 1) {
1215:                        //LdapInternalServer() present...
1216:                        uidsToModify.write(dnVal + "\n");
1217:                    }
1218:                }
1219:                return;
1220:            }
1221:
1222:            static String getDN(String inDN) {
1223:                String toRet = new String("uid=");
1224:
1225:                toRet = toRet
1226:                        + inDN.substring(inDN.indexOf("=") + 1, inDN
1227:                                .indexOf(",")) + ",ou=People," + orgNaming
1228:                        + currOrgName;
1229:                toRet = toRet + "," + rootsuffix;
1230:
1231:                return toRet;
1232:            }
1233:
1234:            static String processDN(String inDN) {
1235:                String toRet = new String("uid=");
1236:                String tmp;
1237:
1238:                inDN = inDN.trim();
1239:                toRet = toRet
1240:                        + inDN.substring(inDN.indexOf("=") + 1, inDN
1241:                                .indexOf(",")) + ",ou=People";
1242:                if (RoleValue.equals("")) {
1243:                    //System.out.println("Returning DN:"+toRet);
1244:                } else {
1245:                    //System.out.println("RoleValue.."+RoleValue);
1246:                    tmp = RoleValue;
1247:                    while (tmp.indexOf("/") >= 0) {
1248:                        toRet += "," + orgNaming
1249:                                + tmp.substring(tmp.lastIndexOf("/") + 1);
1250:                        tmp = tmp.substring(0, tmp.lastIndexOf("/"));
1251:                    }
1252:
1253:                }
1254:                toRet = toRet + "," + rootsuffix;
1255:                return toRet;
1256:            }
1257:
1258:            static void DispContent(LDIFAttributeContent l) {
1259:                LDAPAttribute[] list;
1260:                LDAPAttributeSet theAttrSet;
1261:
1262:                System.out.println("*******DISPLAY**********");
1263:                list = l.getAttributes();
1264:                theAttrSet = new LDAPAttributeSet(list);
1265:                for (int i = 0; i < theAttrSet.size(); ++i)
1266:                    System.out.println("Attribute name:"
1267:                            + (theAttrSet.elementAt(i)).getName());
1268:
1269:            }
1270:
1271:            static java.util.Locale getLocale(String stringformat) {
1272:                if (stringformat == null)
1273:                    return java.util.Locale.getDefault();
1274:
1275:                StringTokenizer tk = new StringTokenizer(stringformat, "_");
1276:                String lang = "";
1277:                String country = "";
1278:                String variant = "";
1279:
1280:                if (tk.hasMoreTokens())
1281:                    lang = tk.nextToken();
1282:                if (tk.hasMoreTokens())
1283:                    country = tk.nextToken();
1284:                if (tk.hasMoreTokens())
1285:                    variant = tk.nextToken();
1286:
1287:                return new java.util.Locale(lang, country, variant);
1288:            }
1289:
1290:            static String getLanguage(String stringLocale) {
1291:
1292:                StringTokenizer tk = new StringTokenizer(stringLocale, "_");
1293:                String lang = "";
1294:
1295:                if (tk.hasMoreTokens())
1296:                    lang = tk.nextToken();
1297:
1298:                return lang;
1299:            }
1300:
1301:            /*
1302:             * Responsible for retrieving Admin Roles from exported role ldif and
1303:             * populating the AdminRoles ArrayList.
1304:             *
1305:             * Logic:
1306:             * - create LDIF based on $exportDir/ldif/role.ldif
1307:             * - get privilege iwtAdmin-execute-pv-ac- if found and true then
1308:             * - get attribute profileid
1309:             * - store profile id in delegated admin role list (adminRoles)
1310:             *
1311:             * The profileid value is in the same form as the value of iwtUser-role
1312:             *
1313:             * @param rolefile String representing the role .ldif file
1314:             */
1315:            public static void getAdminRoles(String rolefile) {
1316:                LDIFRecord lrecord = null;
1317:                LDIF ldif = null;
1318:
1319:                try {
1320:                    ldif = new LDIF(rolefile);
1321:
1322:                    while ((lrecord = ldif.nextRecord()) != null) {
1323:                        LDIFAttributeContent lattrContent = (LDIFAttributeContent) lrecord
1324:                                .getContent();
1325:                        LDAPAttributeSet lattrSet = new LDAPAttributeSet(
1326:                                lattrContent.getAttributes());
1327:
1328:                        if (lattrSet != null) {
1329:                            LDAPAttribute lattr = lattrSet
1330:                                    .getAttribute("iwtAdmin-execute-pv-ac-");
1331:
1332:                            if ((lattr != null)
1333:                                    && (Boolean.valueOf(lattr
1334:                                            .getStringValueArray()[0])
1335:                                            .booleanValue())) {
1336:                                lattr = lattrSet.getAttribute("profileid");
1337:
1338:                                if (lattr != null) {
1339:                                    adminRoles
1340:                                            .add(lattr.getStringValueArray()[0]);
1341:                                }
1342:
1343:                            }
1344:                        }
1345:                    }
1346:
1347:                } catch (IOException e) {
1348:                    System.out.println("Error:" + e.toString());
1349:                    e.printStackTrace();
1350:                }
1351:
1352:            }
1353:
1354:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.