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

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


001:        package migration.modules.ldap;
002:
003:        import netscape.ldap.util.*;
004:
005:        import netscape.ldap.LDAPAttribute;
006:        import netscape.ldap.LDAPAttributeSet;
007:
008:        import java.util.*;
009:        import java.io.*;
010:
011:        import com.iplanet.portalserver.util.Password;
012:
013:        public class DecryptPassword {
014:            public static void main(String args[]) {
015:
016:                String outputfile, ldiffile;
017:
018:                ldiffile = new String();// Input file, the LDIF file to be converted....
019:                outputfile = new String();
020:                if (args.length == 2) {
021:                    outputfile = args[1];
022:                    ldiffile = args[0];
023:                } else if (args.length == 1) {
024:                    outputfile = new String("default.ldif");
025:                    ldiffile = args[0];
026:                } else if (args.length == 0) {
027:                    System.out
028:                            .println("Input file to be converted not specified!");
029:                    System.out
030:                            .println("Invokation Format is:java UsersConvert infile outfile");
031:                    System.exit(1);
032:                }
033:
034:                doConvert(ldiffile, outputfile);
035:            }
036:
037:            public static void doConvert(String ldiffile, String outputfile) {
038:                LDIFRecord out;
039:                OutputStreamWriter outFile;
040:                int count = 0;
041:                LDIF l1;
042:
043:                try {
044:
045:                    l1 = new LDIF(ldiffile);
046:
047:                    //outFile=new FileWriter(outputfile);
048:                    outFile = new OutputStreamWriter(new FileOutputStream(
049:                            outputfile), "UTF-8");
050:
051:                    LDIFRecord tmp = l1.nextRecord();
052:
053:                    while (tmp != null) {
054:                        out = ConvertRecord(tmp, count++);
055:                        try {
056:                            OutputRecord(outFile, out);
057:                        } catch (Exception e) {
058:                            System.out.println("Error writing to output file:"
059:                                    + outputfile);
060:                            e.printStackTrace();
061:                        }
062:                        tmp = l1.nextRecord();
063:                    }
064:                    outFile.close();
065:                    //System.out.println("Processed "+count+" entries");
066:                    //System.out.println("Output available in file "+outputfile);
067:                } catch (IOException e) {
068:                    System.out.println("Error:" + e.toString());
069:                    e.printStackTrace();
070:                }
071:            }
072:
073:            static String processNLines(String inName) {
074:
075:                String toRet;
076:                int index, tmp;
077:
078:                index = inName.indexOf("\n");
079:                if (index < 0)
080:                    return inName;
081:                toRet = inName.substring(0, index);
082:                while (index >= 0 && index < inName.length()) {
083:                    tmp = inName.indexOf("\n", index + 1);
084:                    if (tmp != -1)
085:                        toRet += "\n " + inName.substring(index + 1, tmp);
086:                    else
087:                        toRet += "\n " + inName.substring(index + 1);
088:                    index = tmp;
089:                }
090:
091:                return toRet;
092:
093:            }
094:
095:            static LDIFRecord ConvertRecord(LDIFRecord toConvert, int count) {
096:                LDIFAttributeContent con, converted;
097:                LDAPAttribute tmp;
098:                LDAPAttributeSet theAttrSet;
099:
100:                MimeBase64Encoder MBE = new MimeBase64Encoder();
101:
102:                String attrVal, firstname;
103:                String[] allAttrs;
104:                String[] listAllAttrs;
105:                Vector dispProf = new Vector();
106:                String lastname = new String();
107:                boolean cnValuetobeSet = false;
108:                String dn;
109:                firstname = new String();
110:
111:                LDAPAttribute[] attrList;
112:                int i, typeAttr;
113:
114:                ByteBuf tmpBuf;
115:
116:                con = (LDIFAttributeContent) toConvert.getContent();
117:                converted = new LDIFAttributeContent();
118:                attrList = con.getAttributes();
119:                theAttrSet = new LDAPAttributeSet(attrList);
120:
121:                converted.setControls(con.getControls());
122:
123:                for (i = 0; i < attrList.length; ++i) {
124:                    if ((attrList[i].getName())
125:                            .equalsIgnoreCase("iwtAuthMembership-password-at")) {
126:                        allAttrs = (((LDAPAttribute) (theAttrSet
127:                                .getAttribute(attrList[i].getName())))
128:                                .getStringValueArray());
129:                        attrVal = allAttrs[1];
130:                        tmpBuf = new ByteBuf();
131:                        tmpBuf.setLength(0);
132:                        //System.out.println("attrName:"+attrList[i].getName());
133:                        attrVal = Password.decrypt(attrVal);
134:                        MBE.translate(new ByteBuf(attrVal), tmpBuf);
135:                        allAttrs[1] = tmpBuf.toString();
136:                        //allAttrs[1]=attrVal;
137:                        converted.addElement(new LDAPAttribute(
138:                                "iwtAuthMembership-password-at", allAttrs));
139:                    } else {
140:                        if ((attrList[i].getName())
141:                                .equalsIgnoreCase("iwtUser-IMAPPassword-at")) {
142:                            allAttrs = (((LDAPAttribute) (theAttrSet
143:                                    .getAttribute(attrList[i].getName())))
144:                                    .getStringValueArray());
145:                            attrVal = allAttrs[1];
146:                            tmpBuf = new ByteBuf();
147:                            tmpBuf.setLength(0);
148:                            //System.out.println("attrName:"+attrList[i].getName());
149:                            attrVal = Password.decrypt(attrVal);
150:                            MBE.translate(new ByteBuf(attrVal), tmpBuf);
151:                            allAttrs[1] = tmpBuf.toString();
152:                            //allAttrs[1]=attrVal;
153:                            converted.addElement(new LDAPAttribute(
154:                                    "iwtUser-IMAPPassword-at", allAttrs));
155:                        } else {
156:                            if ((attrList[i].getName())
157:                                    .equalsIgnoreCase("iwtNetMail-Signature-at")) {
158:                                allAttrs = (((LDAPAttribute) (theAttrSet
159:                                        .getAttribute(attrList[i].getName())))
160:                                        .getStringValueArray());
161:                                attrVal = allAttrs[1];
162:                                tmpBuf = new ByteBuf();
163:                                MBE.translate(new ByteBuf(attrVal), tmpBuf);
164:                                allAttrs[1] = tmpBuf.toString();
165:                                converted.addElement(new LDAPAttribute(
166:                                        "iwtNetMail-Signature-at", allAttrs));
167:                            } else {
168:
169:                                allAttrs = (((LDAPAttribute) (theAttrSet
170:                                        .getAttribute(attrList[i].getName())))
171:                                        .getStringValueArray());
172:                                for (int kk = 0; kk < allAttrs.length; ++kk) {
173:                                    allAttrs[kk] = processNLines(allAttrs[kk]);
174:                                }
175:
176:                                converted.addElement(new LDAPAttribute(
177:                                        attrList[i].getName(), allAttrs));
178:                            }
179:                        }
180:                    }
181:                }
182:
183:                return new LDIFRecord(toConvert.getDN(), converted);
184:            }
185:
186:            static void OutputRecord(OutputStreamWriter fw, LDIFRecord toOutput)
187:                    throws Exception {
188:                LDIFAttributeContent con;
189:                LDAPAttribute[] list;
190:                LDAPAttributeSet theAttrSet;
191:                String[] values;
192:                String dnVal = new String();
193:                boolean snExists = false;
194:                boolean cnExists = false;
195:
196:                con = (LDIFAttributeContent) toOutput.getContent();
197:                list = con.getAttributes();
198:                theAttrSet = new LDAPAttributeSet(list);
199:                //System.out.println("\ndn:"+toOutput.getDN());
200:                //dnVal=processDN(toOutput.getDN());
201:                fw.write("\ndn: " + toOutput.getDN());
202:                for (int i = 0; i < theAttrSet.size(); ++i) {
203:                    values = (String[]) (theAttrSet.elementAt(i))
204:                            .getStringValueArray();
205:                    for (int j = 0; j < values.length; ++j) {
206:                        /* System.out.print((theAttrSet.elementAt(i)).getName());
207:                        System.out.println(":"+values[j]+"  ");	*/
208:                        fw.write("\n" + (theAttrSet.elementAt(i)).getName());
209:                        fw.write(": " + values[j]);
210:                    }
211:                    if (((theAttrSet.elementAt(i)).getName()).equals("cn"))
212:                        cnExists = true;
213:                    if (((theAttrSet.elementAt(i)).getName()).equals("sn"))
214:                        snExists = true;
215:                }
216:
217:                fw.write("\n");
218:                //System.out.print("\n OUTPUTTING....dn: "+toOutput.getDN()+"\n");
219:
220:                return;
221:            }
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.