提交 a462b5ee 编写于 作者: C chegar

Merge

......@@ -45,8 +45,14 @@ FILES_java = \
sun/net/dns/ResolverConfiguration.java \
sun/net/dns/ResolverConfigurationImpl.java \
sun/net/ftp/FtpClient.java \
sun/net/ftp/FtpClientProvider.java \
sun/net/ftp/FtpDirEntry.java \
sun/net/ftp/FtpReplyCode.java \
sun/net/ftp/FtpDirParser.java \
sun/net/ftp/FtpLoginException.java \
sun/net/ftp/FtpProtocolException.java \
sun/net/ftp/impl/FtpClient.java \
sun/net/ftp/impl/DefaultFtpClientProvider.java \
sun/net/spi/DefaultProxySelector.java \
sun/net/spi/nameservice/NameServiceDescriptor.java \
sun/net/spi/nameservice/NameService.java \
......
......@@ -2051,6 +2051,8 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
*
* @param n shift distance, in bits.
* @return {@code this << n}
* @throws ArithmeticException if the shift distance is {@code
* Integer.MIN_VALUE}.
* @see #shiftRight
*/
public BigInteger shiftLeft(int n) {
......@@ -2058,8 +2060,13 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
return ZERO;
if (n==0)
return this;
if (n<0)
return shiftRight(-n);
if (n<0) {
if (n == Integer.MIN_VALUE) {
throw new ArithmeticException("Shift distance of Integer.MIN_VALUE not supported.");
} else {
return shiftRight(-n);
}
}
int nInts = n >>> 5;
int nBits = n & 0x1f;
......@@ -2097,13 +2104,20 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
*
* @param n shift distance, in bits.
* @return {@code this >> n}
* @throws ArithmeticException if the shift distance is {@code
* Integer.MIN_VALUE}.
* @see #shiftLeft
*/
public BigInteger shiftRight(int n) {
if (n==0)
return this;
if (n<0)
return shiftLeft(-n);
if (n<0) {
if (n == Integer.MIN_VALUE) {
throw new ArithmeticException("Shift distance of Integer.MIN_VALUE not supported.");
} else {
return shiftLeft(-n);
}
}
int nInts = n >>> 5;
int nBits = n & 0x1f;
......
......@@ -101,11 +101,21 @@ public abstract class CookieHandler {
* Gets all the applicable cookies from a cookie cache for the
* specified uri in the request header.
*
* HTTP protocol implementers should make sure that this method is
* <P>The {@code URI} passed as an argument specifies the intended use for
* the cookies. In particular the scheme should reflect whether the cookies
* will be sent over http, https or used in another context like javascript.
* The host part should reflect either the destination of the cookies or
* their origin in the case of javascript.</P>
* <P>It is up to the implementation to take into account the {@code URI} and
* the cookies attributes and security settings to determine which ones
* should be returned.</P>
*
* <P>HTTP protocol implementers should make sure that this method is
* called after all request headers related to choosing cookies
* are added, and before the request is sent.
* are added, and before the request is sent.</P>
*
* @param uri a <code>URI</code> to send cookies to in a request
* @param uri a <code>URI</code> representing the intended use for the
* cookies
* @param requestHeaders - a Map from request header
* field names to lists of field values representing
* the current request headers
......
......@@ -218,6 +218,13 @@ public class CookieManager extends CookieHandler
// 'secure' cookies over unsecure links)
if (pathMatches(path, cookie.getPath()) &&
(secureLink || !cookie.getSecure())) {
// Enforce httponly attribute
if (cookie.isHttpOnly()) {
String s = uri.getScheme();
if (!"http".equalsIgnoreCase(s) && !"https".equalsIgnoreCase(s)) {
continue;
}
}
// Let's check the authorize port list if it exists
String ports = cookie.getPortlist();
if (ports != null && !ports.isEmpty()) {
......
/*
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -297,6 +297,7 @@ class JarFile extends ZipFile {
String name = names[i].toUpperCase(Locale.ENGLISH);
if (name.endsWith(".DSA") ||
name.endsWith(".RSA") ||
name.endsWith(".EC") ||
name.endsWith(".SF")) {
// Assume since we found a signature-related file
// that the jar is signed and that we therefore
......
/*
* Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -50,7 +50,7 @@ class JarVerifier {
private Hashtable verifiedSigners;
/* a table mapping names to code signers, for jar entries that have
passed the .SF/.DSA -> MANIFEST check */
passed the .SF/.DSA/.EC -> MANIFEST check */
private Hashtable sigFileSigners;
/* a hash table to hold .SF bytes */
......@@ -111,7 +111,7 @@ class JarVerifier {
/*
* Assumptions:
* 1. The manifest should be the first entry in the META-INF directory.
* 2. The .SF/.DSA files follow the manifest, before any normal entries
* 2. The .SF/.DSA/.EC files follow the manifest, before any normal entries
* 3. Any of the following will throw a SecurityException:
* a. digest mismatch between a manifest section and
* the SF section.
......@@ -129,7 +129,7 @@ class JarVerifier {
}
if (SignatureFileVerifier.isBlockOrSF(uname)) {
/* We parse only DSA or RSA PKCS7 blocks. */
/* We parse only DSA, RSA or EC PKCS7 blocks. */
parsingBlockOrSF = true;
baos.reset();
mev.setEntry(null, je);
......
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.net.ftp;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ServiceConfigurationError;
//import sun.misc.Service;
/**
* Service provider class for FtpClient.
* Sub-classes of FtpClientProvider provide an implementation of {@link FtpClient}
* and associated classes. Applications do not normally use this class directly.
* See {@link #provider() } for how providers are found and loaded.
*
* @since 1.7
*/
public abstract class FtpClientProvider {
/**
* Creates a FtpClient from this provider.
*
* @return The created {@link FtpClient}.
*/
public abstract FtpClient createFtpClient();
private static final Object lock = new Object();
private static FtpClientProvider provider = null;
/**
* Initializes a new instance of this class.
*
* @throws SecurityException if a security manager is installed and it denies
* {@link RuntimePermission}<tt>("ftpClientProvider")</tt>
*/
protected FtpClientProvider() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new RuntimePermission("ftpClientProvider"));
}
}
private static boolean loadProviderFromProperty() {
String cm = System.getProperty("sun.net.ftpClientProvider");
if (cm == null) {
return false;
}
try {
Class c = Class.forName(cm, true, null);
provider = (FtpClientProvider) c.newInstance();
return true;
} catch (ClassNotFoundException x) {
throw new ServiceConfigurationError(x.toString());
} catch (IllegalAccessException x) {
throw new ServiceConfigurationError(x.toString());
} catch (InstantiationException x) {
throw new ServiceConfigurationError(x.toString());
} catch (SecurityException x) {
throw new ServiceConfigurationError(x.toString());
}
}
private static boolean loadProviderAsService() {
// Iterator i = Service.providers(FtpClientProvider.class,
// ClassLoader.getSystemClassLoader());
// while (i.hasNext()) {
// try {
// provider = (FtpClientProvider) i.next();
// return true;
// } catch (ServiceConfigurationError sce) {
// if (sce.getCause() instanceof SecurityException) {
// // Ignore, try next provider, if any
// continue;
// }
// throw sce;
// }
// }
return false;
}
/**
* Returns the system wide default FtpClientProvider for this invocation of
* the Java virtual machine.
*
* <p> The first invocation of this method locates the default provider
* object as follows: </p>
*
* <ol>
*
* <li><p> If the system property
* <tt>java.net.FtpClientProvider</tt> is defined then it is
* taken to be the fully-qualified name of a concrete provider class.
* The class is loaded and instantiated; if this process fails then an
* unspecified unchecked error or exception is thrown. </p></li>
*
* <li><p> If a provider class has been installed in a jar file that is
* visible to the system class loader, and that jar file contains a
* provider-configuration file named
* <tt>java.net.FtpClientProvider</tt> in the resource
* directory <tt>META-INF/services</tt>, then the first class name
* specified in that file is taken. The class is loaded and
* instantiated; if this process fails then an unspecified unchecked error or exception is
* thrown. </p></li>
*
* <li><p> Finally, if no provider has been specified by any of the above
* means then the system-default provider class is instantiated and the
* result is returned. </p></li>
*
* </ol>
*
* <p> Subsequent invocations of this method return the provider that was
* returned by the first invocation. </p>
*
* @return The system-wide default FtpClientProvider
*/
public static FtpClientProvider provider() {
synchronized (lock) {
if (provider != null) {
return provider;
}
return (FtpClientProvider) AccessController.doPrivileged(
new PrivilegedAction<Object>() {
public Object run() {
if (loadProviderFromProperty()) {
return provider;
}
if (loadProviderAsService()) {
return provider;
}
provider = new sun.net.ftp.impl.DefaultFtpClientProvider();
return provider;
}
});
}
}
}
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.net.ftp;
import java.util.Date;
import java.util.HashMap;
/**
* A {@code FtpDirEntry} is a class agregating all the information that the FTP client
* can gather from the server by doing a {@code LST} (or {@code NLST}) command and
* parsing the output. It will typically contain the name, type, size, last modification
* time, owner and group of the file, although some of these could be unavailable
* due to specific FTP server limitations.
*
* @see sun.net.ftp.FtpDirParser
* @since 1.7
*/
public class FtpDirEntry {
public enum Type {
FILE, DIR, PDIR, CDIR, LINK
};
public enum Permission {
USER(0), GROUP(1), OTHERS(2);
int value;
Permission(int v) {
value = v;
}
};
private final String name;
private String user = null;
private String group = null;
private long size = -1;
private java.util.Date created = null;
private java.util.Date lastModified = null;
private Type type = Type.FILE;
private boolean[][] permissions = null;
private HashMap<String, String> facts = new HashMap<String, String>();
private FtpDirEntry() {
name = null;
}
/**
* Creates an FtpDirEntry instance with only the name being set.
*
* @param name The name of the file
*/
public FtpDirEntry(String name) {
this.name = name;
}
/**
* Returns the name of the remote file.
*
* @return a {@code String} containing the name of the remote file.
*/
public String getName() {
return name;
}
/**
* Returns the user name of the owner of the file as returned by the FTP
* server, if provided. This could be a name or a user id (number).
*
* @return a {@code String} containing the user name or
* {@code null} if that information is not available.
*/
public String getUser() {
return user;
}
/**
* Sets the user name of the owner of the file. Intended mostly to be
* used from inside a {@link java.net.FtpDirParser} implementation.
*
* @param user The user name of the owner of the file, or {@code null}
* if that information is not available.
* @return this FtpDirEntry
*/
public FtpDirEntry setUser(String user) {
this.user = user;
return this;
}
/**
* Returns the group name of the file as returned by the FTP
* server, if provided. This could be a name or a group id (number).
*
* @return a {@code String} containing the group name or
* {@code null} if that information is not available.
*/
public String getGroup() {
return group;
}
/**
* Sets the name of the group to which the file belong. Intended mostly to be
* used from inside a {@link java.net.FtpDirParser} implementation.
*
* @param group The name of the group to which the file belong, or {@code null}
* if that information is not available.
* @return this FtpDirEntry
*/
public FtpDirEntry setGroup(String group) {
this.group = group;
return this;
}
/**
* Returns the size of the remote file as it was returned by the FTP
* server, if provided.
*
* @return the size of the file or -1 if that information is not available.
*/
public long getSize() {
return size;
}
/**
* Sets the size of that file. Intended mostly to be used from inside an
* {@link java.net.FtpDirParser} implementation.
*
* @param size The size, in bytes, of that file. or -1 if unknown.
* @return this FtpDirEntry
*/
public FtpDirEntry setSize(long size) {
this.size = size;
return this;
}
/**
* Returns the type of the remote file as it was returned by the FTP
* server, if provided.
* It returns a FtpDirEntry.Type enum and the values can be:
* - FtpDirEntry.Type.FILE for a normal file
* - FtpDirEntry.Type.DIR for a directory
* - FtpDirEntry.Type.LINK for a symbolic link
*
* @return a {@code FtpDirEntry.Type} describing the type of the file
* or {@code null} if that information is not available.
*/
public Type getType() {
return type;
}
/**
* Sets the type of the file. Intended mostly to be used from inside an
* {@link java.net.FtpDirParser} implementation.
*
* @param type the type of this file or {@code null} if that information
* is not available.
* @return this FtpDirEntry
*/
public FtpDirEntry setType(Type type) {
this.type = type;
return this;
}
/**
* Returns the last modification time of the remote file as it was returned
* by the FTP server, if provided, {@code null} otherwise.
*
* @return a <code>Date</code> representing the last time the file was
* modified on the server, or {@code null} if that
* information is not available.
*/
public java.util.Date getLastModified() {
return this.lastModified;
}
/**
* Sets the last modification time of the file. Intended mostly to be used
* from inside an {@link java.net.FtpDirParser} implementation.
*
* @param lastModified The Date representing the last modification time, or
* {@code null} if that information is not available.
* @return this FtpDirEntry
*/
public FtpDirEntry setLastModified(Date lastModified) {
this.lastModified = lastModified;
return this;
}
/**
* Returns whether read access is granted for a specific permission.
*
* @param p the Permission (user, group, others) to check.
* @return {@code true} if read access is granted.
*/
public boolean canRead(Permission p) {
if (permissions != null) {
return permissions[p.value][0];
}
return false;
}
/**
* Returns whether write access is granted for a specific permission.
*
* @param p the Permission (user, group, others) to check.
* @return {@code true} if write access is granted.
*/
public boolean canWrite(Permission p) {
if (permissions != null) {
return permissions[p.value][1];
}
return false;
}
/**
* Returns whether execute access is granted for a specific permission.
*
* @param p the Permission (user, group, others) to check.
* @return {@code true} if execute access is granted.
*/
public boolean canExexcute(Permission p) {
if (permissions != null) {
return permissions[p.value][2];
}
return false;
}
/**
* Sets the permissions for that file. Intended mostly to be used
* from inside an {@link java.net.FtpDirParser} implementation.
* The permissions array is a 3x3 {@code boolean} array, the first index being
* the User, group or owner (0, 1 and 2 respectively) while the second
* index is read, write or execute (0, 1 and 2 respectively again).
* <p>E.G.: {@code permissions[1][2]} is the group/execute permission.</p>
*
* @param permissions a 3x3 {@code boolean} array
* @return this {@code FtpDirEntry}
*/
public FtpDirEntry setPermissions(boolean[][] permissions) {
this.permissions = permissions;
return this;
}
/**
* Adds a 'fact', as defined in RFC 3659, to the list of facts of this file.
* Intended mostly to be used from inside a {@link java.net.FtpDirParser}
* implementation.
*
* @param fact the name of the fact (e.g. "Media-Type"). It is not case-sensitive.
* @param value the value associated with this fact.
* @return this {@code FtpDirEntry}
*/
public FtpDirEntry addFact(String fact, String value) {
facts.put(fact.toLowerCase(), value);
return this;
}
/**
* Returns the requested 'fact', as defined in RFC 3659, if available.
*
* @param fact The name of the fact *e.g. "Media-Type"). It is not case sensitive.
* @return The value of the fact or, {@code null} if that fact wasn't
* provided by the server.
*/
public String getFact(String fact) {
return facts.get(fact.toLowerCase());
}
/**
* Returns the creation time of the file, when provided by the server.
*
* @return The Date representing the creation time, or {@code null}
* if the server didn't provide that information.
*/
public Date getCreated() {
return created;
}
/**
* Sets the creation time for that file. Intended mostly to be used from
* inside a {@link java.net.FtpDirParser} implementation.
*
* @param created the Date representing the creation time for that file, or
* {@code null} if that information is not available.
* @return this FtpDirEntry
*/
public FtpDirEntry setCreated(Date created) {
this.created = created;
return this;
}
/**
* Returns a string representation of the object.
* The {@code toString} method for class {@code FtpDirEntry}
* returns a string consisting of the name of the file, followed by its
* type between brackets, followed by the user and group between
* parenthesis, then size between '{', and, finally, the lastModified of last
* modification if it's available.
*
* @return a string representation of the object.
*/
@Override
public String toString() {
if (lastModified == null) {
return name + " [" + type + "] (" + user + " / " + group + ") " + size;
}
return name + " [" + type + "] (" + user + " / " + group + ") {" + size + "} " + java.text.DateFormat.getDateInstance().format(lastModified);
}
}
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.net.ftp;
/**
* This interface describes a parser for the FtpClient class. Such a parser is
* used when listing a remote directory to transform text lines like:
* drwxr-xr-x 1 user01 ftp 512 Jan 29 23:32 prog
* into FtpDirEntry instances.
*
* @see java.net.FtpClient#setFileParser(FtpDirParser)
* @since 1.7
*/
public interface FtpDirParser {
/**
* Takes one line from a directory listing and returns an FtpDirEntry instance
* based on the information contained.
*
* @param line a <code>String</code>, a line sent by the FTP server as a
* result of the LST command.
* @return an <code>FtpDirEntry</code> instance.
* @see java.net.FtpDirEntry
*/
public FtpDirEntry parseLine(String line);
}
/*
* Copyright 1994-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1994-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,7 +25,7 @@
package sun.net.ftp;
import java.io.*;
import java.io.IOException;
/**
* This exception is thrown when an error is encountered during an
......@@ -33,10 +33,10 @@ import java.io.*;
*
* @author Jonathan Payne
*/
public class FtpLoginException extends FtpProtocolException {
public class FtpLoginException extends IOException {
private static final long serialVersionUID = 2218162403237941536L;
FtpLoginException(String s) {
public FtpLoginException(String s) {
super(s);
}
}
/*
* Copyright 1994-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1994-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -22,21 +22,49 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.net.ftp;
import java.io.*;
/**
* This exeception is thrown when unexpected results are returned during
* an FTP session.
*
* Thrown to indicate that the FTP server reported an error.
* For instance that the requested file doesn't exist or
* that a command isn't supported.
* <p>The specific error code can be retreived with {@link #getReplyCode() }.</p>
* @author Jonathan Payne
*/
public class FtpProtocolException extends IOException {
public class FtpProtocolException extends Exception {
private static final long serialVersionUID = 5978077070276545054L;
private final FtpReplyCode code;
/**
* Constructs a new {@code FtpProtocolException} from the
* specified detail message. The reply code is set to unknow error.
*
* @param detail the detail message.
*/
public FtpProtocolException(String detail) {
super(detail);
code = FtpReplyCode.UNKNOWN_ERROR;
}
/**
* Constructs a new {@code FtpProtocolException} from the
* specified response code and exception detail message
*
* @param detail the detail message.
* @param code The {@code FtpRelyCode} received from server.
*/
public FtpProtocolException(String detail, FtpReplyCode code) {
super(detail);
this.code = code;
}
FtpProtocolException(String s) {
super(s);
/**
* Gets the reply code sent by the server that led to this exception
* being thrown.
*
* @return The {@link FtpReplyCode} associated with that exception.
*/
public FtpReplyCode getReplyCode() {
return code;
}
}
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.net.ftp;
/**
* This class describes a FTP protocol reply code and associates a meaning
* to the numerical value according to the various RFCs (RFC 959 in
* particular).
*
*/
public enum FtpReplyCode {
RESTART_MARKER(110),
SERVICE_READY_IN(120),
DATA_CONNECTION_ALREADY_OPEN(125),
FILE_STATUS_OK(150),
COMMAND_OK(200),
NOT_IMPLEMENTED(202),
SYSTEM_STATUS(211),
DIRECTORY_STATUS(212),
FILE_STATUS(213),
HELP_MESSAGE(214),
NAME_SYSTEM_TYPE(215),
SERVICE_READY(220),
SERVICE_CLOSING(221),
DATA_CONNECTION_OPEN(225),
CLOSING_DATA_CONNECTION(226),
ENTERING_PASSIVE_MODE(227),
ENTERING_EXT_PASSIVE_MODE(229),
LOGGED_IN(230),
SECURELY_LOGGED_IN(232),
SECURITY_EXCHANGE_OK(234),
SECURITY_EXCHANGE_COMPLETE(235),
FILE_ACTION_OK(250),
PATHNAME_CREATED(257),
NEED_PASSWORD(331),
NEED_ACCOUNT(332),
NEED_ADAT(334),
NEED_MORE_ADAT(335),
FILE_ACTION_PENDING(350),
SERVICE_NOT_AVAILABLE(421),
CANT_OPEN_DATA_CONNECTION(425),
CONNECTION_CLOSED(426),
NEED_SECURITY_RESOURCE(431),
FILE_ACTION_NOT_TAKEN(450),
ACTION_ABORTED(451),
INSUFFICIENT_STORAGE(452),
COMMAND_UNRECOGNIZED(500),
INVALID_PARAMETER(501),
BAD_SEQUENCE(503),
NOT_IMPLEMENTED_FOR_PARAMETER(504),
NOT_LOGGED_IN(530),
NEED_ACCOUNT_FOR_STORING(532),
PROT_LEVEL_DENIED(533),
REQUEST_DENIED(534),
FAILED_SECURITY_CHECK(535),
UNSUPPORTED_PROT_LEVEL(536),
PROT_LEVEL_NOT_SUPPORTED_BY_SECURITY(537),
FILE_UNAVAILABLE(550),
PAGE_TYPE_UNKNOWN(551),
EXCEEDED_STORAGE(552),
FILE_NAME_NOT_ALLOWED(553),
PROTECTED_REPLY(631),
UNKNOWN_ERROR(999);
private final int value;
FtpReplyCode(int val) {
this.value = val;
}
/**
* Returns the numerical value of the code.
*
* @return the numerical value.
*/
public int getValue() {
return value;
}
/**
* Determines if the code is a Positive Preliminary response.
* This means beginning with a 1 (which means a value between 100 and 199)
*
* @return <code>true</code> if the reply code is a positive preliminary
* response.
*/
public boolean isPositivePreliminary() {
return value >= 100 && value < 200;
}
/**
* Determines if the code is a Positive Completion response.
* This means beginning with a 2 (which means a value between 200 and 299)
*
* @return <code>true</code> if the reply code is a positive completion
* response.
*/
public boolean isPositiveCompletion() {
return value >= 200 && value < 300;
}
/**
* Determines if the code is a positive internediate response.
* This means beginning with a 3 (which means a value between 300 and 399)
*
* @return <code>true</code> if the reply code is a positive intermediate
* response.
*/
public boolean isPositiveIntermediate() {
return value >= 300 && value < 400;
}
/**
* Determines if the code is a transient negative response.
* This means beginning with a 4 (which means a value between 400 and 499)
*
* @return <code>true</code> if the reply code is a transient negative
* response.
*/
public boolean isTransientNegative() {
return value >= 400 && value < 500;
}
/**
* Determines if the code is a permanent negative response.
* This means beginning with a 5 (which means a value between 500 and 599)
*
* @return <code>true</code> if the reply code is a permanent negative
* response.
*/
public boolean isPermanentNegative() {
return value >= 500 && value < 600;
}
/**
* Determines if the code is a protected reply response.
* This means beginning with a 6 (which means a value between 600 and 699)
*
* @return <code>true</code> if the reply code is a protected reply
* response.
*/
public boolean isProtectedReply() {
return value >= 600 && value < 700;
}
/**
* Determines if the code is a syntax related response.
* This means the second digit is a 0.
*
* @return <code>true</code> if the reply code is a syntax related
* response.
*/
public boolean isSyntax() {
return ((value / 10) - ((value / 100) * 10)) == 0;
}
/**
* Determines if the code is an information related response.
* This means the second digit is a 1.
*
* @return <code>true</code> if the reply code is an information related
* response.
*/
public boolean isInformation() {
return ((value / 10) - ((value / 100) * 10)) == 1;
}
/**
* Determines if the code is a connection related response.
* This means the second digit is a 2.
*
* @return <code>true</code> if the reply code is a connection related
* response.
*/
public boolean isConnection() {
return ((value / 10) - ((value / 100) * 10)) == 2;
}
/**
* Determines if the code is an authentication related response.
* This means the second digit is a 3.
*
* @return <code>true</code> if the reply code is an authentication related
* response.
*/
public boolean isAuthentication() {
return ((value / 10) - ((value / 100) * 10)) == 3;
}
/**
* Determines if the code is an unspecified type of response.
* This means the second digit is a 4.
*
* @return <code>true</code> if the reply code is an unspecified type of
* response.
*/
public boolean isUnspecified() {
return ((value / 10) - ((value / 100) * 10)) == 4;
}
/**
* Determines if the code is a file system related response.
* This means the second digit is a 5.
*
* @return <code>true</code> if the reply code is a file system related
* response.
*/
public boolean isFileSystem() {
return ((value / 10) - ((value / 100) * 10)) == 5;
}
/**
* Static utility method to convert a value into a FtpReplyCode.
*
* @param v the value to convert
* @return the <code>FtpReplyCode</code> associated with the value.
*/
public static FtpReplyCode find(int v) {
for (FtpReplyCode code : FtpReplyCode.values()) {
if (code.getValue() == v) {
return code;
}
}
return UNKNOWN_ERROR;
}
}
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.net.ftp.impl;
/**
* Default FtpClientProvider.
* Uses sun.net.ftp.FtpCLient.
*/
public class DefaultFtpClientProvider extends sun.net.ftp.FtpClientProvider {
@Override
public sun.net.ftp.FtpClient createFtpClient() {
return sun.net.ftp.impl.FtpClient.create();
}
}
此差异已折叠。
......@@ -277,14 +277,16 @@ class DigestAuthentication extends AuthenticationInfo {
params.setOpaque (p.findValue("opaque"));
params.setQop (p.findValue("qop"));
String uri;
String uri="";
String method;
if (type == PROXY_AUTHENTICATION &&
conn.tunnelState() == HttpURLConnection.TunnelState.SETUP) {
uri = HttpURLConnection.connectRequestURI(conn.getURL());
method = HTTP_CONNECT;
} else {
uri = conn.getRequestURI();
try {
uri = conn.getRequestURI();
} catch (IOException e) {}
method = conn.getMethod();
}
......
......@@ -1552,7 +1552,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
* because ntlm does not support this feature.
*/
private AuthenticationInfo
resetProxyAuthentication(AuthenticationInfo proxyAuthentication, AuthenticationHeader auth) {
resetProxyAuthentication(AuthenticationInfo proxyAuthentication, AuthenticationHeader auth) throws IOException {
if ((proxyAuthentication != null )&&
proxyAuthentication.getAuthScheme() != NTLM) {
String raw = auth.raw();
......@@ -1776,7 +1776,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
/**
* Sets pre-emptive proxy authentication in header
*/
private void setPreemptiveProxyAuthentication(MessageHeader requests) {
private void setPreemptiveProxyAuthentication(MessageHeader requests) throws IOException {
AuthenticationInfo pauth
= AuthenticationInfo.getProxyAuth(http.getProxyHostUsed(),
http.getProxyPortUsed());
......@@ -2132,13 +2132,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
String requestURI = null;
String getRequestURI() {
String getRequestURI() throws IOException {
if (requestURI == null) {
try {
requestURI = http.getURLFile();
} catch (IOException e) {
requestURI = "";
}
requestURI = http.getURLFile();
}
return requestURI;
}
......
/*
* Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -86,6 +86,9 @@ public class Providers {
private static final String[] jarVerificationProviders = {
"sun.security.provider.Sun",
"sun.security.rsa.SunRsaSign",
// Note: SunEC *is* in a signed JAR file, but it's not signed
// by EC itself. So it's still safe to be listed here.
"sun.security.ec.SunEC",
BACKUP_PROVIDER_CLASSNAME,
};
......
/*
* Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -286,8 +286,6 @@ public class SignerInfo implements DerEncoder {
}
String digestAlgname = getDigestAlgorithmId().getName();
if (digestAlgname.equalsIgnoreCase("SHA"))
digestAlgname = "SHA1";
byte[] dataSigned;
......@@ -337,9 +335,12 @@ public class SignerInfo implements DerEncoder {
String encryptionAlgname =
getDigestEncryptionAlgorithmId().getName();
if (encryptionAlgname.equalsIgnoreCase("SHA1withDSA"))
encryptionAlgname = "DSA";
String algname = digestAlgname + "with" + encryptionAlgname;
// Workaround: sometimes the encryptionAlgname is actually
// a signature name
String tmp = AlgorithmId.getEncAlgFromSigAlg(encryptionAlgname);
if (tmp != null) encryptionAlgname = tmp;
String algname = AlgorithmId.makeSigAlg(
digestAlgname, encryptionAlgname);
Signature sig = Signature.getInstance(algname);
X509Certificate cert = getCertificate(block);
......
......@@ -1031,9 +1031,9 @@ public class JarSigner {
}
if (sigfile.length() > 8) {
sigfile = sigfile.substring(0, 8).toUpperCase();
sigfile = sigfile.substring(0, 8).toUpperCase(Locale.ENGLISH);
} else {
sigfile = sigfile.toUpperCase();
sigfile = sigfile.toUpperCase(Locale.ENGLISH);
}
StringBuilder tmpSigFile = new StringBuilder(sigfile.length());
......@@ -1083,8 +1083,8 @@ public class JarSigner {
ZipOutputStream zos = new ZipOutputStream(ps);
/* First guess at what they might be - we don't xclude RSA ones. */
String sfFilename = (META_INF + sigfile + ".SF").toUpperCase();
String bkFilename = (META_INF + sigfile + ".DSA").toUpperCase();
String sfFilename = (META_INF + sigfile + ".SF").toUpperCase(Locale.ENGLISH);
String bkFilename = (META_INF + sigfile + ".DSA").toUpperCase(Locale.ENGLISH);
Manifest manifest = new Manifest();
Map<String,Attributes> mfEntries = manifest.getEntries();
......@@ -1447,9 +1447,10 @@ public class JarSigner {
* . META-INF/*.SF
* . META-INF/*.DSA
* . META-INF/*.RSA
* . META-INF/*.EC
*/
private boolean signatureRelated(String name) {
String ucName = name.toUpperCase();
String ucName = name.toUpperCase(Locale.ENGLISH);
if (ucName.equals(JarFile.MANIFEST_NAME) ||
ucName.equals(META_INF) ||
(ucName.startsWith(SIG_PREFIX) &&
......@@ -1459,7 +1460,7 @@ public class JarSigner {
if (ucName.startsWith(META_INF) &&
SignatureFileVerifier.isBlockOrSF(ucName)) {
// .SF/.DSA/.RSA files in META-INF subdirs
// .SF/.DSA/.RSA/.EC files in META-INF subdirs
// are not considered signature-related
return (ucName.indexOf("/") == ucName.lastIndexOf("/"));
}
......@@ -2227,7 +2228,6 @@ class SignatureFile {
}
BigInteger serial = certChain[0].getSerialNumber();
String digestAlgorithm;
String signatureAlgorithm;
String keyAlgorithm = privateKey.getAlgorithm();
/*
......@@ -2237,22 +2237,24 @@ class SignatureFile {
if (sigalg == null) {
if (keyAlgorithm.equalsIgnoreCase("DSA"))
digestAlgorithm = "SHA1";
signatureAlgorithm = "SHA1withDSA";
else if (keyAlgorithm.equalsIgnoreCase("RSA"))
digestAlgorithm = "SHA256";
else {
signatureAlgorithm = "SHA256withRSA";
else if (keyAlgorithm.equalsIgnoreCase("EC"))
signatureAlgorithm = "SHA256withECDSA";
else
throw new RuntimeException("private key is not a DSA or "
+ "RSA key");
}
signatureAlgorithm = digestAlgorithm + "with" + keyAlgorithm;
} else {
signatureAlgorithm = sigalg;
}
// check common invalid key/signature algorithm combinations
String sigAlgUpperCase = signatureAlgorithm.toUpperCase();
String sigAlgUpperCase = signatureAlgorithm.toUpperCase(Locale.ENGLISH);
if ((sigAlgUpperCase.endsWith("WITHRSA") &&
!keyAlgorithm.equalsIgnoreCase("RSA")) ||
(sigAlgUpperCase.endsWith("WITHECDSA") &&
!keyAlgorithm.equalsIgnoreCase("EC")) ||
(sigAlgUpperCase.endsWith("WITHDSA") &&
!keyAlgorithm.equalsIgnoreCase("DSA"))) {
throw new SignatureException
......
......@@ -1407,7 +1407,7 @@ public final class KeyTool {
} else if ("RSA".equalsIgnoreCase(keyAlgName)) {
return "SHA256WithRSA";
} else if ("EC".equalsIgnoreCase(keyAlgName)) {
return "SHA1withECDSA";
return "SHA256withECDSA";
} else {
throw new Exception(rb.getString
("Cannot derive signature algorithm"));
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册