Source Code Cross Referenced for CVSPass.java in  » Build » ANT » org » apache » tools » ant » taskdefs » 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 » Build » ANT » org.apache.tools.ant.taskdefs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        package org.apache.tools.ant.taskdefs;
020:
021:        import java.io.BufferedReader;
022:        import java.io.File;
023:        import java.io.FileReader;
024:        import java.io.FileWriter;
025:        import java.io.IOException;
026:        import java.io.PrintWriter;
027:        import org.apache.tools.ant.BuildException;
028:        import org.apache.tools.ant.Project;
029:        import org.apache.tools.ant.Task;
030:        import org.apache.tools.ant.util.StringUtils;
031:
032:        /**
033:         * Adds an new entry to a CVS password file.
034:         *
035:         *
036:         * @since Ant 1.4
037:         *
038:         * @ant.task category="scm"
039:         */
040:        public class CVSPass extends Task {
041:            /** CVS Root */
042:            private String cvsRoot = null;
043:            /** Password file to add password to */
044:            private File passFile = null;
045:            /** Password to add to file */
046:            private String password = null;
047:
048:            /** Array contain char conversion data */
049:            private final char[] shifts = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
050:                    11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
051:                    26, 27, 28, 29, 30, 31, 114, 120, 53, 79, 96, 109, 72, 108,
052:                    70, 64, 76, 67, 116, 74, 68, 87, 111, 52, 75, 119, 49, 34,
053:                    82, 81, 95, 65, 112, 86, 118, 110, 122, 105, 41, 57, 83,
054:                    43, 46, 102, 40, 89, 38, 103, 45, 50, 42, 123, 91, 35, 125,
055:                    55, 54, 66, 124, 126, 59, 47, 92, 71, 115, 78, 88, 107,
056:                    106, 56, 36, 121, 117, 104, 101, 100, 69, 73, 99, 63, 94,
057:                    93, 39, 37, 61, 48, 58, 113, 32, 90, 44, 98, 60, 51, 33,
058:                    97, 62, 77, 84, 80, 85, 223, 225, 216, 187, 166, 229, 189,
059:                    222, 188, 141, 249, 148, 200, 184, 136, 248, 190, 199, 170,
060:                    181, 204, 138, 232, 218, 183, 255, 234, 220, 247, 213, 203,
061:                    226, 193, 174, 172, 228, 252, 217, 201, 131, 230, 197, 211,
062:                    145, 238, 161, 179, 160, 212, 207, 221, 254, 173, 202, 146,
063:                    224, 151, 140, 196, 205, 130, 135, 133, 143, 246, 192, 159,
064:                    244, 239, 185, 168, 215, 144, 139, 165, 180, 157, 147, 186,
065:                    214, 176, 227, 231, 219, 169, 175, 156, 206, 198, 129, 164,
066:                    150, 210, 154, 177, 134, 127, 182, 128, 158, 208, 162, 132,
067:                    167, 209, 149, 241, 153, 251, 237, 236, 171, 195, 243, 233,
068:                    253, 240, 194, 250, 191, 155, 142, 137, 245, 235, 163, 242,
069:                    178, 152 };
070:
071:            /**
072:             * Create a CVS task using the default cvspass file location.
073:             */
074:            public CVSPass() {
075:                passFile = new File(System.getProperty("cygwin.user.home",
076:                        System.getProperty("user.home"))
077:                        + File.separatorChar + ".cvspass");
078:            }
079:
080:            /**
081:             * Does the work.
082:             *
083:             * @exception BuildException if something goes wrong with the build
084:             */
085:            public final void execute() throws BuildException {
086:                if (cvsRoot == null) {
087:                    throw new BuildException("cvsroot is required");
088:                }
089:                if (password == null) {
090:                    throw new BuildException("password is required");
091:                }
092:
093:                log("cvsRoot: " + cvsRoot, Project.MSG_DEBUG);
094:                log("password: " + password, Project.MSG_DEBUG);
095:                log("passFile: " + passFile, Project.MSG_DEBUG);
096:
097:                BufferedReader reader = null;
098:                PrintWriter writer = null;
099:                try {
100:                    StringBuffer buf = new StringBuffer();
101:
102:                    if (passFile.exists()) {
103:                        reader = new BufferedReader(new FileReader(passFile));
104:
105:                        String line = null;
106:
107:                        while ((line = reader.readLine()) != null) {
108:                            if (!line.startsWith(cvsRoot)) {
109:                                buf.append(line).append(StringUtils.LINE_SEP);
110:                            }
111:                        }
112:                    }
113:
114:                    String pwdfile = buf.toString() + cvsRoot + " A"
115:                            + mangle(password);
116:
117:                    log("Writing -> " + pwdfile, Project.MSG_DEBUG);
118:
119:                    writer = new PrintWriter(new FileWriter(passFile));
120:
121:                    writer.println(pwdfile);
122:                } catch (IOException e) {
123:                    throw new BuildException(e);
124:                } finally {
125:                    if (reader != null) {
126:                        try {
127:                            reader.close();
128:                        } catch (IOException e) {
129:                            // ignore
130:                        }
131:                    }
132:                    if (writer != null) {
133:                        writer.close();
134:                    }
135:                }
136:            }
137:
138:            private final String mangle(String password) {
139:                StringBuffer buf = new StringBuffer();
140:                for (int i = 0; i < password.length(); i++) {
141:                    buf.append(shifts[password.charAt(i)]);
142:                }
143:                return buf.toString();
144:            }
145:
146:            /**
147:             * The CVS repository to add an entry for.
148:             *
149:             * @param cvsRoot the CVS repository
150:             */
151:            public void setCvsroot(String cvsRoot) {
152:                this .cvsRoot = cvsRoot;
153:            }
154:
155:            /**
156:             * Password file to add the entry to.
157:             *
158:             * @param passFile the password file.
159:             */
160:            public void setPassfile(File passFile) {
161:                this .passFile = passFile;
162:            }
163:
164:            /**
165:             * Password to be added to the password file.
166:             *
167:             * @param password the password.
168:             */
169:            public void setPassword(String password) {
170:                this.password = password;
171:            }
172:
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.