Author: peterreilly Date: Tue Sep 5 13:38:35 2006 New Revision: 440476 URL: http://svn.apache.org/viewvc?view=rev&rev=440476 Log: Bugzilla 35619: remove dependency on sun internal base64 encoder
Added: ant/core/trunk/src/main/org/apache/tools/ant/util/Base64Converter.java (with props) Modified: ant/core/trunk/CONTRIBUTORS ant/core/trunk/WHATSNEW ant/core/trunk/build.xml ant/core/trunk/contributors.xml ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java Modified: ant/core/trunk/CONTRIBUTORS URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?view=diff&rev=440476&r1=440475&r2=440476 ============================================================================== Binary files - no diff available. Modified: ant/core/trunk/WHATSNEW URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=440476&r1=440475&r2=440476 ============================================================================== --- ant/core/trunk/WHATSNEW (original) +++ ant/core/trunk/WHATSNEW Tue Sep 5 13:38:35 2006 @@ -28,6 +28,8 @@ * trim the driver attribute on the <sql> task. Bugzilla report 21228. * Allow (jar) files as well as directories to be given to jdepend. Bugzilla report 28865. +* Convert SplashTask to use NOT sun internal classes. + Bugzilla report 35619. Changes from Ant 1.6.5 to Ant 1.7.0Beta1 ======================================== Modified: ant/core/trunk/build.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/build.xml?view=diff&rev=440476&r1=440475&r2=440476 ============================================================================== --- ant/core/trunk/build.xml (original) +++ ant/core/trunk/build.xml Tue Sep 5 13:38:35 2006 @@ -190,13 +190,6 @@ <filename name="${ant.package}/taskdefs/email/UUMailer*"/> </selector> - <selector id="needs.sun.b64"> - <or> - <filename name="${optional.package}/splash/SplashTask*"/> - <filename name="${optional.package}/splash/SplashScreenTest.java"/> - </or> - </selector> - <!-- depends on external libraries --> <selector id="needs.trax"> <or> @@ -503,8 +496,6 @@ </and> </condition> - <available property="base64.present" classname="sun.misc.BASE64Encoder"/> - <property name="build.tests.resolved" location="${build.tests}"/> <condition property="tests.are.on.system.classpath"> <or> @@ -651,7 +642,6 @@ <selector refid="needs.jdk1.5+" unless="jdk1.5+"/> <selector refid="not.in.kaffe" if="kaffe"/> <selector refid="needs.sun.uue" unless="sunuue.present"/> - <selector refid="needs.sun.b64" unless="base64.present"/> <selector refid="needs.trax" unless="trax.present"/> <selector refid="needs.apache-resolver" unless="apache.resolver.present"/> Modified: ant/core/trunk/contributors.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?view=diff&rev=440476&r1=440475&r2=440476 ============================================================================== --- ant/core/trunk/contributors.xml (original) +++ ant/core/trunk/contributors.xml Tue Sep 5 13:38:35 2006 @@ -971,16 +971,20 @@ <last>Ferguson</last> </name> <name> + <first>Wolf</first> + <last>Siberski</last> + </name> + <name> <first>Wolfgang</first> - <last>Frech</last> + <last>Baer</last> </name> <name> <first>Wolfgang</first> - <last>Werner</last> + <last>Frech</last> </name> <name> - <first>Wolf</first> - <last>Siberski</last> + <first>Wolfgang</first> + <last>Werner</last> </name> <name> <first>Yohann</first> Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java?view=diff&rev=440476&r1=440475&r2=440476 ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Get.java Tue Sep 5 13:38:35 2006 @@ -336,80 +336,12 @@ this.pword = p; } - /********************************************************************* - * BASE 64 encoding of a String or an array of bytes. - * - * Based on RFC 1421. - * - *********************************************************************/ - - protected static class Base64Converter { - - public final char[] alphabet = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7 - 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8 to 15 - 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16 to 23 - 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24 to 31 - 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32 to 39 - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40 to 47 - 'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48 to 55 - '4', '5', '6', '7', '8', '9', '+', '/'}; // 56 to 63 - - public String encode(String s) { - return encode(s.getBytes()); - } - - public String encode(byte[] octetString) { - int bits24; - int bits6; - - char[] out = new char[((octetString.length - 1) / 3 + 1) * 4]; - int outIndex = 0; - int i = 0; - - while ((i + 3) <= octetString.length) { - // store the octets - bits24 = (octetString[i++] & 0xFF) << 16; - bits24 |= (octetString[i++] & 0xFF) << 8; - bits24 |= octetString[i++]; - - bits6 = (bits24 & 0x00FC0000) >> 18; - out[outIndex++] = alphabet[bits6]; - bits6 = (bits24 & 0x0003F000) >> 12; - out[outIndex++] = alphabet[bits6]; - bits6 = (bits24 & 0x00000FC0) >> 6; - out[outIndex++] = alphabet[bits6]; - bits6 = (bits24 & 0x0000003F); - out[outIndex++] = alphabet[bits6]; - } - if (octetString.length - i == 2) { - // store the octets - bits24 = (octetString[i] & 0xFF) << 16; - bits24 |= (octetString[i + 1] & 0xFF) << 8; - bits6 = (bits24 & 0x00FC0000) >> 18; - out[outIndex++] = alphabet[bits6]; - bits6 = (bits24 & 0x0003F000) >> 12; - out[outIndex++] = alphabet[bits6]; - bits6 = (bits24 & 0x00000FC0) >> 6; - out[outIndex++] = alphabet[bits6]; - - // padding - out[outIndex++] = '='; - } else if (octetString.length - i == 1) { - // store the octets - bits24 = (octetString[i] & 0xFF) << 16; - bits6 = (bits24 & 0x00FC0000) >> 18; - out[outIndex++] = alphabet[bits6]; - bits6 = (bits24 & 0x0003F000) >> 12; - out[outIndex++] = alphabet[bits6]; - - // padding - out[outIndex++] = '='; - out[outIndex++] = '='; - } - return new String(out); - } - } + /** + * Provide this for Backward Compatibility. + */ + + protected static class Base64Converter + extends org.apache.tools.ant.util.Base64Converter {} public interface DownloadProgress { /** Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java?view=diff&rev=440476&r1=440475&r2=440476 ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java Tue Sep 5 13:38:35 2006 @@ -28,6 +28,7 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; +import org.apache.tools.ant.util.Base64Converter; /** * Creates a splash screen. The splash screen is displayed @@ -141,9 +142,11 @@ conn = url.openConnection(); if (user != null && user.length() > 0) { + // converted from sun internal classes to + // new Base64Converter + // utility class extracted from Get task String encodedcreds = - new sun.misc.BASE64Encoder().encode( - (new String(user + ":" + password)).getBytes()); + new Base64Converter().encode(user + ":" + password); conn.setRequestProperty("Proxy-Authorization", encodedcreds); } Added: ant/core/trunk/src/main/org/apache/tools/ant/util/Base64Converter.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/Base64Converter.java?view=auto&rev=440476 ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/util/Base64Converter.java (added) +++ ant/core/trunk/src/main/org/apache/tools/ant/util/Base64Converter.java Tue Sep 5 13:38:35 2006 @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.tools.ant.util; + +/** + * BASE 64 encoding of a String or an array of bytes. + * + * Based on RFC 1421. + * + **/ +public class Base64Converter { + + private final static char[] ALPHABET = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7 + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8 to 15 + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16 to 23 + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24 to 31 + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32 to 39 + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40 to 47 + 'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48 to 55 + '4', '5', '6', '7', '8', '9', '+', '/'}; // 56 to 63 + + /** Provided for BC purposes */ + public static final char[] alphabet = ALPHABET; + + + /** + * Encode a string into base64 encoding. + * @param s the string to encode. + * @return the encoded string. + */ + public String encode(String s) { + return encode(s.getBytes()); + } + + /** + * Encode a byte array into base64 encoding. + * @param octetString the byte array to encode. + * @return the encoded string. + */ + public String encode(byte[] octetString) { + int bits24; + int bits6; + + char[] out = new char[((octetString.length - 1) / 3 + 1) * 4]; + int outIndex = 0; + int i = 0; + + while ((i + 3) <= octetString.length) { + // store the octets + bits24 = (octetString[i++] & 0xFF) << 16; + bits24 |= (octetString[i++] & 0xFF) << 8; + bits24 |= octetString[i++]; + + bits6 = (bits24 & 0x00FC0000) >> 18; + out[outIndex++] = ALPHABET[bits6]; + bits6 = (bits24 & 0x0003F000) >> 12; + out[outIndex++] = ALPHABET[bits6]; + bits6 = (bits24 & 0x00000FC0) >> 6; + out[outIndex++] = ALPHABET[bits6]; + bits6 = (bits24 & 0x0000003F); + out[outIndex++] = ALPHABET[bits6]; + } + if (octetString.length - i == 2) { + // store the octets + bits24 = (octetString[i] & 0xFF) << 16; + bits24 |= (octetString[i + 1] & 0xFF) << 8; + bits6 = (bits24 & 0x00FC0000) >> 18; + out[outIndex++] = ALPHABET[bits6]; + bits6 = (bits24 & 0x0003F000) >> 12; + out[outIndex++] = ALPHABET[bits6]; + bits6 = (bits24 & 0x00000FC0) >> 6; + out[outIndex++] = ALPHABET[bits6]; + + // padding + out[outIndex++] = '='; + } else if (octetString.length - i == 1) { + // store the octets + bits24 = (octetString[i] & 0xFF) << 16; + bits6 = (bits24 & 0x00FC0000) >> 18; + out[outIndex++] = ALPHABET[bits6]; + bits6 = (bits24 & 0x0003F000) >> 12; + out[outIndex++] = ALPHABET[bits6]; + + // padding + out[outIndex++] = '='; + out[outIndex++] = '='; + } + return new String(out); + } +} Propchange: ant/core/trunk/src/main/org/apache/tools/ant/util/Base64Converter.java ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]