diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 47addd89d..ff5258d06 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -245,9 +245,10 @@ Victor Toni Waldek Herka Will Wang William Ferguson +Wolf Siberski +Wolfgang Baer Wolfgang Frech Wolfgang Werner -Wolf Siberski Yohann Roussel Yuji Yamano Yves Martin diff --git a/WHATSNEW b/WHATSNEW index d001045d4..a28e2bb78 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -28,6 +28,8 @@ Other changes: * trim the driver attribute on the 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 ======================================== diff --git a/build.xml b/build.xml index 8530bbe0b..bd6e7866b 100644 --- a/build.xml +++ b/build.xml @@ -190,13 +190,6 @@ - - - - - - - @@ -503,8 +496,6 @@ - - @@ -651,7 +642,6 @@ - diff --git a/contributors.xml b/contributors.xml index 2f2216161..b68cd0546 100644 --- a/contributors.xml +++ b/contributors.xml @@ -970,17 +970,21 @@ William Ferguson + + Wolf + Siberski + Wolfgang - Frech + Baer Wolfgang - Werner + Frech - Wolf - Siberski + Wolfgang + Werner Yohann diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java index 741cf2fba..45971607c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Get.java +++ b/src/main/org/apache/tools/ant/taskdefs/Get.java @@ -336,80 +336,12 @@ public class Get extends Task { 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 { /** diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java index 79ab3183a..58c33fead 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/splash/SplashTask.java @@ -28,6 +28,7 @@ import javax.swing.ImageIcon; 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 @@ public class SplashTask extends Task { 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); } diff --git a/src/main/org/apache/tools/ant/util/Base64Converter.java b/src/main/org/apache/tools/ant/util/Base64Converter.java new file mode 100644 index 000000000..07b2326bc --- /dev/null +++ b/src/main/org/apache/tools/ant/util/Base64Converter.java @@ -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); + } +}