Return-Path: Delivered-To: apmail-jakarta-ant-user-archive@jakarta.apache.org Received: (qmail 3487 invoked by uid 500); 23 Jul 2001 15:20:46 -0000 Mailing-List: contact ant-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: ant-user@jakarta.apache.org Delivered-To: mailing list ant-user@jakarta.apache.org Received: (qmail 3478 invoked from network); 23 Jul 2001 15:20:46 -0000 From: "Ingmar Stein" To: Subject: CVSPass Date: Mon, 23 Jul 2001 17:20:45 +0200 Message-ID: <001f01c1138b$0b94d650$3fbf6086@win.xtramind.dfki.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0020_01C1139B.CF1DA650" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2512.0001 Importance: Normal X-Virus-Scanned: by AMaViS with Sophos Sweep X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N This is a multi-part message in MIME format. ------=_NextPart_000_0020_01C1139B.CF1DA650 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi all, this is a corrected version of the CVSPass task. The old one did not include shifts for all ASCII characters. A diff is included. Cheers, Ingmar Stein ------=_NextPart_000_0020_01C1139B.CF1DA650 Content-Type: application/octet-stream; name="CVSPass.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="CVSPass.java" /*=0A= * The Apache Software License, Version 1.1=0A= *=0A= * Copyright (c) 2001 The Apache Software Foundation. All rights =0A= * reserved.=0A= *=0A= * Redistribution and use in source and binary forms, with or without=0A= * modification, are permitted provided that the following conditions=0A= * are met:=0A= *=0A= * 1. Redistributions of source code must retain the above copyright=0A= * notice, this list of conditions and the following disclaimer. =0A= *=0A= * 2. Redistributions in binary form must reproduce the above copyright=0A= * notice, this list of conditions and the following disclaimer in=0A= * the documentation and/or other materials provided with the=0A= * distribution.=0A= *=0A= * 3. The end-user documentation included with the redistribution, if=0A= * any, must include the following acknowlegement: =0A= * "This product includes software developed by the =0A= * Apache Software Foundation (http://www.apache.org/)."=0A= * Alternately, this acknowlegement may appear in the software itself,=0A= * if and wherever such third-party acknowlegements normally appear.=0A= *=0A= * 4. The names "The Jakarta Project", "Ant", and "Apache Software=0A= * Foundation" must not be used to endorse or promote products derived=0A= * from this software without prior written permission. For written =0A= * permission, please contact apache@apache.org.=0A= *=0A= * 5. Products derived from this software may not be called "Apache"=0A= * nor may "Apache" appear in their names without prior written=0A= * permission of the Apache Group.=0A= *=0A= * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED=0A= * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES=0A= * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE=0A= * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR=0A= * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=0A= * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=0A= * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF=0A= * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND=0A= * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,=0A= * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT=0A= * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF=0A= * SUCH DAMAGE.=0A= * = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= *=0A= * This software consists of voluntary contributions made by many=0A= * individuals on behalf of the Apache Software Foundation. For more=0A= * information on the Apache Software Foundation, please see=0A= * .=0A= */=0A= =0A= package org.apache.tools.ant.taskdefs;=0A= =0A= import org.apache.tools.ant.*;=0A= import java.io.*;=0A= =0A= /**=0A= * CVSLogin=0A= *=0A= * Adds an new entry to a CVS password file=0A= *=0A= * @author Jeff Martin=0A= * @version $Revision: 1.1 $=0A= */=0A= public class CVSPass extends Task {=0A= /** CVS Root */=0A= private String cvsRoot =3D null; =0A= /** Password file to add password to */=0A= private File passFile =3D null;=0A= /** Password to add to file */=0A= private String password =3D null;=0A= /** End of line character */=0A= private final String EOL =3D System.getProperty("line.separator");=0A= =0A= /** Array contain char conversion data */=0A= private final char shifts[] =3D {=0A= 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,=0A= 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,=0A= 114,120, 53, 79, 96,109, 72,108, 70, 64, 76, 67,116, 74, 68, 87,=0A= 111, 52, 75,119, 49, 34, 82, 81, 95, 65,112, 86,118,110,122,105,=0A= 41, 57, 83, 43, 46,102, 40, 89, 38,103, 45, 50, 42,123, 91, 35,=0A= 125, 55, 54, 66,124,126, 59, 47, 92, 71,115, 78, 88,107,106, 56,=0A= 36,121,117,104,101,100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48,=0A= 58,113, 32, 90, 44, 98, 60, 51, 33, 97, 62, 77, 84, 80, 85,223,=0A= 225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190,=0A= 199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193,=0A= 174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212,=0A= 207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246,=0A= 192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176,=0A= 227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127,=0A= 182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195,=0A= 243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152 };=0A= =0A= public CVSPass(){=0A= passFile =3D new = File(System.getProperty("user.home")+"/.cvspass");=0A= }=0A= =0A= /**=0A= * Does the work.=0A= *=0A= * @exception BuildException if someting goes wrong with the build=0A= */=0A= public final void execute() throws BuildException {=0A= if(cvsRoot=3D=3Dnull)throw new BuildException("cvsroot is = required");=0A= if(password=3D=3Dnull)throw new BuildException("password is = required");=0A= =0A= log("cvsRoot: " + cvsRoot, project.MSG_DEBUG);=0A= log("password: " + password, project.MSG_DEBUG);=0A= log("passFile: " + passFile, project.MSG_DEBUG);=0A= =0A= try{=0A= StringBuffer buf =3D new StringBuffer();=0A= =0A= if(passFile.exists()){=0A= BufferedReader reader =3D=0A= new BufferedReader(new FileReader(passFile));=0A= =0A= String line =3D null;=0A= =0A= while((line=3Dreader.readLine())!=3Dnull){=0A= if(!line.startsWith(cvsRoot)){=0A= buf.append(line+EOL);=0A= }=0A= }=0A= =0A= reader.close();=0A= }=0A= =0A= String pwdfile =3D buf.toString() + cvsRoot + " A" + = mangle(password);=0A= =0A= log("Writing -> " + pwdfile , project.MSG_DEBUG);=0A= =0A= PrintWriter writer =3D new PrintWriter(new = FileWriter(passFile));=0A= =0A= writer.println( pwdfile );=0A= =0A= writer.close();=0A= }catch(IOException e){=0A= throw new BuildException(e);=0A= }=0A= =0A= }=0A= =0A= private final String mangle(String password){=0A= StringBuffer buf =3D new StringBuffer();=0A= for(int i=3D0;i private final char shifts[] =3D {=0A= > 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,=0A= > 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,=0A= > 114,120, 53, 79, 96,109, 72,108, 70, 64, 76, 67,116, 74, 68, 87,=0A= > 111, 52, 75,119, 49, 34, 82, 81, 95, 65,112, 86,118,110,122,105,=0A= > 41, 57, 83, 43, 46,102, 40, 89, 38,103, 45, 50, 42,123, 91, 35,=0A= > 125, 55, 54, 66,124,126, 59, 47, 92, 71,115, 78, 88,107,106, 56,=0A= > 36,121,117,104,101,100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48,=0A= > 58,113, 32, 90, 44, 98, 60, 51, 33, 97, 62, 77, 84, 80, 85,223,=0A= > 225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190,=0A= > 199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193,=0A= > 174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212,=0A= > 207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246,=0A= > 192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176,=0A= > 227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127,=0A= > 182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195,=0A= > 243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152 };=0A= 83,100d98=0A= < // Create lookup for password mangling=0A= < c[32]=3D'r'; c[33]=3D'x'; c[34]=3D'5'; c[35]=3D'O'; = c[37]=3D'm';=0A= < c[38]=3D'H'; c[39]=3D'l'; c[40]=3D'F'; c[42]=3D'L'; = c[43]=3D'C';=0A= < c[44]=3D't'; c[45]=3D'J'; c[46]=3D'D'; c[47]=3D'W'; = c[48]=3D'o';=0A= < c[49]=3D'4'; c[50]=3D'K'; c[51]=3D'w'; c[52]=3D'1'; = c[53]=3D'"';=0A= < c[54]=3D'R'; c[55]=3D'Q'; c[56]=3D'_'; c[57]=3D'A'; = c[58]=3D'p';=0A= < c[59]=3D'V'; c[60]=3D'v'; c[61]=3D'n'; c[62]=3D'z'; = c[63]=3D'i';=0A= < c[64]=3D')'; c[65]=3D'9'; c[66]=3D'S'; c[67]=3D'+'; = c[68]=3D'.';=0A= < c[69]=3D'f'; c[70]=3D'('; c[71]=3D'Y'; c[72]=3D'&'; = c[73]=3D'g';=0A= < c[74]=3D'-'; c[75]=3D'2'; c[76]=3D'*'; c[81]=3D'7'; = c[82]=3D'6';=0A= < c[83]=3D'B'; c[86]=3D';'; c[87]=3D'/'; c[89]=3D'G'; = c[90]=3D's';=0A= < c[91]=3D'N'; c[92]=3D'X'; c[93]=3D'k'; c[94]=3D'j'; = c[95]=3D'%';=0A= < c[97]=3D'y'; c[98]=3D'u'; c[99]=3D'h'; c[100]=3D'e'; = c[101]=3D'd';=0A= < c[102]=3D'E'; c[103]=3D'I'; c[104]=3D'c'; c[105]=3D'?'; = c[108]=3D'\'';=0A= < c[109]=3D'%'; c[110]=3D'=3D'; c[111]=3D'0'; c[112]=3D':'; = c[113]=3D'q';=0A= < c[115]=3D'Z'; c[116]=3D','; c[117]=3D'b'; c[118]=3D'<'; = c[119]=3D'3';=0A= < c[120]=3D'!'; c[121]=3D'a'; c[122]=3D'>'; c[123]=3D'M'; = c[124]=3D'T';=0A= < c[125]=3D'P'; c[126]=3D'U';=0A= 134c132=0A= < PrintWriter writer =3D new PrintWriter(new = FileWriter(passFile));=0A= ---=0A= > String pwdfile =3D buf.toString() + cvsRoot + " A" + = mangle(password);=0A= 135a134=0A= > log("Writing -> " + pwdfile , project.MSG_DEBUG);=0A= 137,140c136=0A= < writer.print(buf.toString());=0A= < writer.print(cvsRoot);=0A= < writer.print(" A");=0A= < writer.println(mangle(password));=0A= ---=0A= > PrintWriter writer =3D new PrintWriter(new = FileWriter(passFile));=0A= 142c138=0A= < log("Writing -> " + buf.toString() + cvsRoot + " A" + = mangle(password), project.MSG_DEBUG);=0A= ---=0A= > writer.println( pwdfile );=0A= 153,154c149,150=0A= < for(int i=3D0;i for(int i=3D0;i buf.append(shifts[password.charAt(i)]);=0A= ------=_NextPart_000_0020_01C1139B.CF1DA650--