/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* true".
*
* @param v if "true" then be verbose
*/
public void setVerbose(boolean v) {
verbose = v;
}
/**
* Don't stop if get fails if set to "true".
*
* @param v if "true" then don't report download errors up to ant
*/
public void setIgnoreErrors(boolean v) {
ignoreErrors = v;
}
/**
* Use timestamps, if set to "true".
*
*
In this situation, the if-modified-since header is set so * that the file is only fetched if it is newer than the local * file (or there is no local file) This flag is only valid on * HTTP connections, it is ignored in other cases. When the flag * is set, the local copy of the downloaded file will also have * its timestamp set to the remote file time.
* *Note that remote files of date 1/1/1970 (GMT) are treated as * 'no timestamp', and web servers often serve files with a * timestamp in the future by replacing their timestamp with that * of the current time. Also, inter-computer clock differences can * cause no end of grief.
* @param v "true" to enable file time fetching */ public void setUseTimestamp(boolean v) { if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { useTimestamp = v; } } /** * Username for basic auth. * * @param u username for authentication */ public void setUsername(String u) { this.uname = u; } /** * password for the basic auth. * * @param p password for authentication */ public void setPassword(String p) { this.pword = p; } /********************************************************************* * BASE 64 encoding of a String or an array of bytes. * * Based on RFC 1421. * * @author * Unknown * @author * Gautam Guliani *********************************************************************/ 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; 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); } } }