提交 16f02abb 编写于 作者: W wetmore

Merge

...@@ -25,12 +25,9 @@ ...@@ -25,12 +25,9 @@
package java.net; package java.net;
import java.security.AccessController;
import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.InvalidObjectException; import java.io.InvalidObjectException;
import sun.security.action.*;
import java.util.Enumeration; import java.util.Enumeration;
/** /**
...@@ -358,13 +355,13 @@ class Inet6Address extends InetAddress { ...@@ -358,13 +355,13 @@ class Inet6Address extends InetAddress {
} }
private int deriveNumericScope (NetworkInterface ifc) throws UnknownHostException { private int deriveNumericScope (NetworkInterface ifc) throws UnknownHostException {
Enumeration addresses = ifc.getInetAddresses(); Enumeration<InetAddress> addresses = ifc.getInetAddresses();
while (addresses.hasMoreElements()) { while (addresses.hasMoreElements()) {
InetAddress address = (InetAddress)addresses.nextElement(); InetAddress addr = addresses.nextElement();
if (!(address instanceof Inet6Address)) { if (!(addr instanceof Inet6Address)) {
continue; continue;
} }
Inet6Address ia6_addr = (Inet6Address)address; Inet6Address ia6_addr = (Inet6Address)addr;
/* check if site or link local prefixes match */ /* check if site or link local prefixes match */
if (!differentLocalAddressTypes(ia6_addr)){ if (!differentLocalAddressTypes(ia6_addr)){
/* type not the same, so carry on searching */ /* type not the same, so carry on searching */
...@@ -377,22 +374,22 @@ class Inet6Address extends InetAddress { ...@@ -377,22 +374,22 @@ class Inet6Address extends InetAddress {
} }
private int deriveNumericScope (String ifname) throws UnknownHostException { private int deriveNumericScope (String ifname) throws UnknownHostException {
Enumeration en; Enumeration<NetworkInterface> en;
try { try {
en = NetworkInterface.getNetworkInterfaces(); en = NetworkInterface.getNetworkInterfaces();
} catch (SocketException e) { } catch (SocketException e) {
throw new UnknownHostException ("could not enumerate local network interfaces"); throw new UnknownHostException ("could not enumerate local network interfaces");
} }
while (en.hasMoreElements()) { while (en.hasMoreElements()) {
NetworkInterface ifc = (NetworkInterface)en.nextElement(); NetworkInterface ifc = en.nextElement();
if (ifc.getName().equals (ifname)) { if (ifc.getName().equals (ifname)) {
Enumeration addresses = ifc.getInetAddresses(); Enumeration addresses = ifc.getInetAddresses();
while (addresses.hasMoreElements()) { while (addresses.hasMoreElements()) {
InetAddress address = (InetAddress)addresses.nextElement(); InetAddress addr = (InetAddress)addresses.nextElement();
if (!(address instanceof Inet6Address)) { if (!(addr instanceof Inet6Address)) {
continue; continue;
} }
Inet6Address ia6_addr = (Inet6Address)address; Inet6Address ia6_addr = (Inet6Address)addr;
/* check if site or link local prefixes match */ /* check if site or link local prefixes match */
if (!differentLocalAddressTypes(ia6_addr)){ if (!differentLocalAddressTypes(ia6_addr)){
/* type not the same, so carry on searching */ /* type not the same, so carry on searching */
...@@ -420,21 +417,22 @@ class Inet6Address extends InetAddress { ...@@ -420,21 +417,22 @@ class Inet6Address extends InetAddress {
if (ifname != null && !"".equals (ifname)) { if (ifname != null && !"".equals (ifname)) {
try { try {
scope_ifname = NetworkInterface.getByName(ifname); scope_ifname = NetworkInterface.getByName(ifname);
try { if (scope_ifname == null) {
scope_id = deriveNumericScope (scope_ifname); /* the interface does not exist on this system, so we clear
} catch (UnknownHostException e) { * the scope information completely */
// should not happen scope_id_set = false;
assert false; scope_ifname_set = false;
scope_id = 0;
} else {
try {
scope_id = deriveNumericScope (scope_ifname);
} catch (UnknownHostException e) {
// should not happen
assert false;
}
} }
} catch (SocketException e) {} } catch (SocketException e) {}
if (scope_ifname == null) {
/* the interface does not exist on this system, so we clear
* the scope information completely */
scope_id_set = false;
scope_ifname_set = false;
scope_id = 0;
}
} }
/* if ifname was not supplied, then the numeric info is used */ /* if ifname was not supplied, then the numeric info is used */
...@@ -460,6 +458,7 @@ class Inet6Address extends InetAddress { ...@@ -460,6 +458,7 @@ class Inet6Address extends InetAddress {
* an IP multicast address * an IP multicast address
* @since JDK1.1 * @since JDK1.1
*/ */
@Override
public boolean isMulticastAddress() { public boolean isMulticastAddress() {
return ((ipaddress[0] & 0xff) == 0xff); return ((ipaddress[0] & 0xff) == 0xff);
} }
...@@ -470,6 +469,7 @@ class Inet6Address extends InetAddress { ...@@ -470,6 +469,7 @@ class Inet6Address extends InetAddress {
* a wildcard address. * a wildcard address.
* @since 1.4 * @since 1.4
*/ */
@Override
public boolean isAnyLocalAddress() { public boolean isAnyLocalAddress() {
byte test = 0x00; byte test = 0x00;
for (int i = 0; i < INADDRSZ; i++) { for (int i = 0; i < INADDRSZ; i++) {
...@@ -485,6 +485,7 @@ class Inet6Address extends InetAddress { ...@@ -485,6 +485,7 @@ class Inet6Address extends InetAddress {
* a loopback address; or false otherwise. * a loopback address; or false otherwise.
* @since 1.4 * @since 1.4
*/ */
@Override
public boolean isLoopbackAddress() { public boolean isLoopbackAddress() {
byte test = 0x00; byte test = 0x00;
for (int i = 0; i < 15; i++) { for (int i = 0; i < 15; i++) {
...@@ -500,6 +501,7 @@ class Inet6Address extends InetAddress { ...@@ -500,6 +501,7 @@ class Inet6Address extends InetAddress {
* a link local address; or false if address is not a link local unicast address. * a link local address; or false if address is not a link local unicast address.
* @since 1.4 * @since 1.4
*/ */
@Override
public boolean isLinkLocalAddress() { public boolean isLinkLocalAddress() {
return ((ipaddress[0] & 0xff) == 0xfe return ((ipaddress[0] & 0xff) == 0xfe
&& (ipaddress[1] & 0xc0) == 0x80); && (ipaddress[1] & 0xc0) == 0x80);
...@@ -512,6 +514,7 @@ class Inet6Address extends InetAddress { ...@@ -512,6 +514,7 @@ class Inet6Address extends InetAddress {
* a site local address; or false if address is not a site local unicast address. * a site local address; or false if address is not a site local unicast address.
* @since 1.4 * @since 1.4
*/ */
@Override
public boolean isSiteLocalAddress() { public boolean isSiteLocalAddress() {
return ((ipaddress[0] & 0xff) == 0xfe return ((ipaddress[0] & 0xff) == 0xfe
&& (ipaddress[1] & 0xc0) == 0xc0); && (ipaddress[1] & 0xc0) == 0xc0);
...@@ -525,6 +528,7 @@ class Inet6Address extends InetAddress { ...@@ -525,6 +528,7 @@ class Inet6Address extends InetAddress {
* of global scope or it is not a multicast address * of global scope or it is not a multicast address
* @since 1.4 * @since 1.4
*/ */
@Override
public boolean isMCGlobal() { public boolean isMCGlobal() {
return ((ipaddress[0] & 0xff) == 0xff return ((ipaddress[0] & 0xff) == 0xff
&& (ipaddress[1] & 0x0f) == 0x0e); && (ipaddress[1] & 0x0f) == 0x0e);
...@@ -538,6 +542,7 @@ class Inet6Address extends InetAddress { ...@@ -538,6 +542,7 @@ class Inet6Address extends InetAddress {
* of node-local scope or it is not a multicast address * of node-local scope or it is not a multicast address
* @since 1.4 * @since 1.4
*/ */
@Override
public boolean isMCNodeLocal() { public boolean isMCNodeLocal() {
return ((ipaddress[0] & 0xff) == 0xff return ((ipaddress[0] & 0xff) == 0xff
&& (ipaddress[1] & 0x0f) == 0x01); && (ipaddress[1] & 0x0f) == 0x01);
...@@ -551,6 +556,7 @@ class Inet6Address extends InetAddress { ...@@ -551,6 +556,7 @@ class Inet6Address extends InetAddress {
* of link-local scope or it is not a multicast address * of link-local scope or it is not a multicast address
* @since 1.4 * @since 1.4
*/ */
@Override
public boolean isMCLinkLocal() { public boolean isMCLinkLocal() {
return ((ipaddress[0] & 0xff) == 0xff return ((ipaddress[0] & 0xff) == 0xff
&& (ipaddress[1] & 0x0f) == 0x02); && (ipaddress[1] & 0x0f) == 0x02);
...@@ -564,6 +570,7 @@ class Inet6Address extends InetAddress { ...@@ -564,6 +570,7 @@ class Inet6Address extends InetAddress {
* of site-local scope or it is not a multicast address * of site-local scope or it is not a multicast address
* @since 1.4 * @since 1.4
*/ */
@Override
public boolean isMCSiteLocal() { public boolean isMCSiteLocal() {
return ((ipaddress[0] & 0xff) == 0xff return ((ipaddress[0] & 0xff) == 0xff
&& (ipaddress[1] & 0x0f) == 0x05); && (ipaddress[1] & 0x0f) == 0x05);
...@@ -578,6 +585,7 @@ class Inet6Address extends InetAddress { ...@@ -578,6 +585,7 @@ class Inet6Address extends InetAddress {
* or it is not a multicast address * or it is not a multicast address
* @since 1.4 * @since 1.4
*/ */
@Override
public boolean isMCOrgLocal() { public boolean isMCOrgLocal() {
return ((ipaddress[0] & 0xff) == 0xff return ((ipaddress[0] & 0xff) == 0xff
&& (ipaddress[1] & 0x0f) == 0x08); && (ipaddress[1] & 0x0f) == 0x08);
...@@ -590,6 +598,7 @@ class Inet6Address extends InetAddress { ...@@ -590,6 +598,7 @@ class Inet6Address extends InetAddress {
* *
* @return the raw IP address of this object. * @return the raw IP address of this object.
*/ */
@Override
public byte[] getAddress() { public byte[] getAddress() {
return ipaddress.clone(); return ipaddress.clone();
} }
...@@ -624,6 +633,7 @@ class Inet6Address extends InetAddress { ...@@ -624,6 +633,7 @@ class Inet6Address extends InetAddress {
* *
* @return the raw IP address in a string format. * @return the raw IP address in a string format.
*/ */
@Override
public String getHostAddress() { public String getHostAddress() {
String s = numericToTextFormat(ipaddress); String s = numericToTextFormat(ipaddress);
if (scope_ifname_set) { /* must check this first */ if (scope_ifname_set) { /* must check this first */
...@@ -639,6 +649,7 @@ class Inet6Address extends InetAddress { ...@@ -639,6 +649,7 @@ class Inet6Address extends InetAddress {
* *
* @return a hash code value for this IP address. * @return a hash code value for this IP address.
*/ */
@Override
public int hashCode() { public int hashCode() {
if (ipaddress != null) { if (ipaddress != null) {
...@@ -677,6 +688,7 @@ class Inet6Address extends InetAddress { ...@@ -677,6 +688,7 @@ class Inet6Address extends InetAddress {
* <code>false</code> otherwise. * <code>false</code> otherwise.
* @see java.net.InetAddress#getAddress() * @see java.net.InetAddress#getAddress()
*/ */
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null || if (obj == null ||
!(obj instanceof Inet6Address)) !(obj instanceof Inet6Address))
......
...@@ -352,6 +352,9 @@ public class FtpClient extends TransferProtocolClient { ...@@ -352,6 +352,9 @@ public class FtpClient extends TransferProtocolClient {
s = new Socket(Proxy.NO_PROXY); s = new Socket(Proxy.NO_PROXY);
} else } else
s = new Socket(); s = new Socket();
// Bind the socket to the same address as the control channel. This
// is needed in case of multi-homed systems.
s.bind(new InetSocketAddress(serverSocket.getLocalAddress(),0));
if (connectTimeout >= 0) { if (connectTimeout >= 0) {
s.connect(dest, connectTimeout); s.connect(dest, connectTimeout);
} else { } else {
...@@ -417,8 +420,10 @@ public class FtpClient extends TransferProtocolClient { ...@@ -417,8 +420,10 @@ public class FtpClient extends TransferProtocolClient {
// since we can't accept a connection through SOCKS (yet) // since we can't accept a connection through SOCKS (yet)
// throw an exception // throw an exception
throw new FtpProtocolException("Passive mode failed"); throw new FtpProtocolException("Passive mode failed");
} else }
portSocket = new ServerSocket(0, 1); // Bind the ServerSocket to the same address as the control channel
// This is needed for multi-homed systems
portSocket = new ServerSocket(0, 1, serverSocket.getLocalAddress());
try { try {
myAddress = portSocket.getInetAddress(); myAddress = portSocket.getInetAddress();
if (myAddress.isAnyLocalAddress()) if (myAddress.isAnyLocalAddress())
......
...@@ -120,14 +120,8 @@ class ServerImpl implements TimeSource { ...@@ -120,14 +120,8 @@ class ServerImpl implements TimeSource {
if (executor == null) { if (executor == null) {
executor = new DefaultExecutor(); executor = new DefaultExecutor();
} }
Thread t = new Thread (dispatcher);
started = true; started = true;
final Dispatcher d = dispatcher;
Thread t = AccessController.doPrivileged(new PrivilegedAction<Thread>() {
public Thread run() {
Thread t = new Thread (d);
return t;
}
});
t.start(); t.start();
} }
...@@ -355,10 +349,8 @@ class ServerImpl implements TimeSource { ...@@ -355,10 +349,8 @@ class ServerImpl implements TimeSource {
} }
} }
} }
} catch (CancelledKeyException e) { } catch (Exception e) {
logger.log (Level.FINER, "Dispatcher (3)", e); logger.log (Level.FINER, "Dispatcher (3)", e);
} catch (IOException e) {
logger.log (Level.FINER, "Dispatcher (4)", e);
} }
} }
} }
...@@ -370,10 +362,10 @@ class ServerImpl implements TimeSource { ...@@ -370,10 +362,10 @@ class ServerImpl implements TimeSource {
Exchange t = new Exchange (chan, protocol, conn); Exchange t = new Exchange (chan, protocol, conn);
executor.execute (t); executor.execute (t);
} catch (HttpError e1) { } catch (HttpError e1) {
logger.log (Level.FINER, "Dispatcher (5)", e1); logger.log (Level.FINER, "Dispatcher (4)", e1);
conn.close(); conn.close();
} catch (IOException e) { } catch (IOException e) {
logger.log (Level.FINER, "Dispatcher (6)", e); logger.log (Level.FINER, "Dispatcher (5)", e);
conn.close(); conn.close();
} }
} }
......
/* /*
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,35 +26,23 @@ ...@@ -26,35 +26,23 @@
package sun.security.tools; package sun.security.tools;
import java.io.*; import java.io.*;
import java.math.BigInteger;
import java.security.GeneralSecurityException;
import java.security.InvalidParameterException;
import java.security.KeyStore; import java.security.KeyStore;
import java.security.KeyStoreException; import java.security.KeyStoreException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Key; import java.security.Key;
import java.security.PublicKey; import java.security.PublicKey;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.Security; import java.security.Security;
import java.security.Signature; import java.security.Signature;
import java.security.SignatureException;
import java.security.UnrecoverableEntryException; import java.security.UnrecoverableEntryException;
import java.security.UnrecoverableKeyException; import java.security.UnrecoverableKeyException;
import java.security.Principal; import java.security.Principal;
import java.security.Provider; import java.security.Provider;
import java.security.Identity; import java.security.Identity;
import java.security.Signer;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.security.cert.CertificateFactory; import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPrivateKey;
import java.security.interfaces.DSAPublicKey;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.text.Collator; import java.text.Collator;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.*; import java.util.*;
...@@ -62,7 +50,6 @@ import java.lang.reflect.Constructor; ...@@ -62,7 +50,6 @@ import java.lang.reflect.Constructor;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder; import sun.misc.BASE64Encoder;
import sun.security.util.ObjectIdentifier; import sun.security.util.ObjectIdentifier;
import sun.security.pkcs.PKCS10; import sun.security.pkcs.PKCS10;
...@@ -72,11 +59,16 @@ import sun.security.provider.SystemIdentity; ...@@ -72,11 +59,16 @@ import sun.security.provider.SystemIdentity;
import sun.security.provider.X509Factory; import sun.security.provider.X509Factory;
import sun.security.util.DerOutputStream; import sun.security.util.DerOutputStream;
import sun.security.util.Password; import sun.security.util.Password;
import sun.security.util.Resources;
import sun.security.util.PathList; import sun.security.util.PathList;
import javax.crypto.KeyGenerator; import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import sun.security.x509.*; import sun.security.x509.*;
import static java.security.KeyStore.*; import static java.security.KeyStore.*;
...@@ -132,6 +124,7 @@ public final class KeyTool { ...@@ -132,6 +124,7 @@ public final class KeyTool {
private String ksfname = null; private String ksfname = null;
private File ksfile = null; private File ksfile = null;
private InputStream ksStream = null; // keystore stream private InputStream ksStream = null; // keystore stream
private String sslserver = null;
private KeyStore keyStore = null; private KeyStore keyStore = null;
private boolean token = false; private boolean token = false;
private boolean nullStream = false; private boolean nullStream = false;
...@@ -347,6 +340,9 @@ public final class KeyTool { ...@@ -347,6 +340,9 @@ public final class KeyTool {
} else if (collator.compare(flags, "-file") == 0) { } else if (collator.compare(flags, "-file") == 0) {
if (++i == args.length) errorNeedArgument(flags); if (++i == args.length) errorNeedArgument(flags);
filename = args[i]; filename = args[i];
} else if (collator.compare(flags, "-sslserver") == 0) {
if (++i == args.length) errorNeedArgument(flags);
sslserver = args[i];
} else if (collator.compare(flags, "-srckeystore") == 0) { } else if (collator.compare(flags, "-srckeystore") == 0) {
if (++i == args.length) errorNeedArgument(flags); if (++i == args.length) errorNeedArgument(flags);
srcksfname = args[i]; srcksfname = args[i];
...@@ -924,17 +920,7 @@ public final class KeyTool { ...@@ -924,17 +920,7 @@ public final class KeyTool {
doPrintEntries(out); doPrintEntries(out);
} }
} else if (command == PRINTCERT) { } else if (command == PRINTCERT) {
InputStream inStream = System.in; doPrintCert(out);
if (filename != null) {
inStream = new FileInputStream(filename);
}
try {
doPrintCert(inStream, out);
} finally {
if (inStream != System.in) {
inStream.close();
}
}
} else if (command == SELFCERT) { } else if (command == SELFCERT) {
doSelfCert(alias, dname, sigAlgName); doSelfCert(alias, dname, sigAlgName);
kssave = true; kssave = true;
...@@ -1468,8 +1454,8 @@ public final class KeyTool { ...@@ -1468,8 +1454,8 @@ public final class KeyTool {
} else { } else {
// Print the digest of the user cert only // Print the digest of the user cert only
out.println out.println
(rb.getString("Certificate fingerprint (MD5): ") + (rb.getString("Certificate fingerprint (SHA1): ") +
getCertFingerPrint("MD5", chain[0])); getCertFingerPrint("SHA1", chain[0]));
} }
} }
} else if (keyStore.entryInstanceOf(alias, } else if (keyStore.entryInstanceOf(alias,
...@@ -1486,8 +1472,8 @@ public final class KeyTool { ...@@ -1486,8 +1472,8 @@ public final class KeyTool {
out.println(cert.toString()); out.println(cert.toString());
} else { } else {
out.println(rb.getString("trustedCertEntry,")); out.println(rb.getString("trustedCertEntry,"));
out.println(rb.getString("Certificate fingerprint (MD5): ") out.println(rb.getString("Certificate fingerprint (SHA1): ")
+ getCertFingerPrint("MD5", cert)); + getCertFingerPrint("SHA1", cert));
} }
} else { } else {
out.println(rb.getString("Unknown Entry Type")); out.println(rb.getString("Unknown Entry Type"));
...@@ -1744,7 +1730,7 @@ public final class KeyTool { ...@@ -1744,7 +1730,7 @@ public final class KeyTool {
* Reads a certificate (or certificate chain) and prints its contents in * Reads a certificate (or certificate chain) and prints its contents in
* a human readbable format. * a human readbable format.
*/ */
private void doPrintCert(InputStream in, PrintStream out) private void printCertFromStream(InputStream in, PrintStream out)
throws Exception throws Exception
{ {
Collection<? extends Certificate> c = null; Collection<? extends Certificate> c = null;
...@@ -1770,13 +1756,98 @@ public final class KeyTool { ...@@ -1770,13 +1756,98 @@ public final class KeyTool {
Object[] source = {new Integer(i + 1)}; Object[] source = {new Integer(i + 1)};
out.println(form.format(source)); out.println(form.format(source));
} }
printX509Cert(x509Cert, out); if (rfc) dumpCert(x509Cert, out);
else printX509Cert(x509Cert, out);
if (i < (certs.length-1)) { if (i < (certs.length-1)) {
out.println(); out.println();
} }
} }
} }
private void doPrintCert(final PrintStream out) throws Exception {
if (sslserver != null) {
SSLContext sc = SSLContext.getInstance("SSL");
final boolean[] certPrinted = new boolean[1];
sc.init(null, new TrustManager[] {
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
for (int i=0; i<certs.length; i++) {
X509Certificate cert = certs[i];
try {
if (rfc) {
dumpCert(cert, out);
} else {
out.println("Certificate #" + i);
out.println("====================================");
printX509Cert(cert, out);
out.println();
}
} catch (Exception e) {
if (debug) {
e.printStackTrace();
}
}
}
// Set to true where there's something to print
if (certs.length > 0) {
certPrinted[0] = true;
}
}
}
}, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(
new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
// HTTPS instead of raw SSL, so that -Dhttps.proxyHost and
// -Dhttps.proxyPort can be used. Since we only go through
// the handshake process, an HTTPS server is not needed.
// This program should be able to deal with any SSL-based
// network service.
Exception ex = null;
try {
new URL("https://" + sslserver).openConnection().connect();
} catch (Exception e) {
ex = e;
}
// If the certs are not printed out, we consider it an error even
// if the URL connection is successful.
if (!certPrinted[0]) {
Exception e = new Exception(
rb.getString("No certificate from the SSL server"));
if (ex != null) {
e.initCause(ex);
}
throw e;
}
} else {
InputStream inStream = System.in;
if (filename != null) {
inStream = new FileInputStream(filename);
}
try {
printCertFromStream(inStream, out);
} finally {
if (inStream != System.in) {
inStream.close();
}
}
}
}
/** /**
* Creates a self-signed certificate, and stores it as a single-element * Creates a self-signed certificate, and stores it as a single-element
* certificate chain. * certificate chain.
...@@ -3127,7 +3198,7 @@ public final class KeyTool { ...@@ -3127,7 +3198,7 @@ public final class KeyTool {
System.err.println(); System.err.println();
System.err.println(rb.getString System.err.println(rb.getString
("-printcert [-v] [-file <cert_file>]")); ("-printcert [-v] [-rfc] [-file <cert_file> | -sslserver <host[:port]>]"));
System.err.println(); System.err.println();
System.err.println(rb.getString System.err.println(rb.getString
......
/* /*
* Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -171,7 +171,7 @@ public class Resources extends java.util.ListResourceBundle { ...@@ -171,7 +171,7 @@ public class Resources extends java.util.ListResourceBundle {
{"Entry type: <type>", "Entry type: {0}"}, {"Entry type: <type>", "Entry type: {0}"},
{"Certificate chain length: ", "Certificate chain length: "}, {"Certificate chain length: ", "Certificate chain length: "},
{"Certificate[(i + 1)]:", "Certificate[{0,number,integer}]:"}, {"Certificate[(i + 1)]:", "Certificate[{0,number,integer}]:"},
{"Certificate fingerprint (MD5): ", "Certificate fingerprint (MD5): "}, {"Certificate fingerprint (SHA1): ", "Certificate fingerprint (SHA1): "},
{"Entry type: trustedCertEntry\n", "Entry type: trustedCertEntry\n"}, {"Entry type: trustedCertEntry\n", "Entry type: trustedCertEntry\n"},
{"trustedCertEntry,", "trustedCertEntry,"}, {"trustedCertEntry,", "trustedCertEntry,"},
{"Keystore type: ", "Keystore type: "}, {"Keystore type: ", "Keystore type: "},
...@@ -386,8 +386,10 @@ public class Resources extends java.util.ListResourceBundle { ...@@ -386,8 +386,10 @@ public class Resources extends java.util.ListResourceBundle {
{"\t [-alias <alias>]", "\t [-alias <alias>]"}, {"\t [-alias <alias>]", "\t [-alias <alias>]"},
/** rest is same as -certreq starting from -keystore **/ /** rest is same as -certreq starting from -keystore **/
{"-printcert [-v] [-file <cert_file>]", {"-printcert [-v] [-rfc] [-file <cert_file> | -sslserver <host[:port]>]",
"-printcert [-v] [-file <cert_file>]"}, "-printcert [-v] [-rfc] [-file <cert_file> | -sslserver <host[:port]>]"},
{"No certificate from the SSL server",
"No certificate from the SSL server"},
//{"-selfcert [-v] [-protected]", //{"-selfcert [-v] [-protected]",
// "-selfcert [-v] [-protected]"}, // "-selfcert [-v] [-protected]"},
......
...@@ -201,7 +201,6 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -201,7 +201,6 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
} }
if (hp != NULL) { if (hp != NULL) {
struct in_addr **addrp = (struct in_addr **) hp->h_addr_list; struct in_addr **addrp = (struct in_addr **) hp->h_addr_list;
int len = sizeof(struct in_addr);
int i = 0; int i = 0;
while (*addrp != (struct in_addr *) 0) { while (*addrp != (struct in_addr *) 0) {
......
...@@ -143,7 +143,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -143,7 +143,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
const char *hostname; const char *hostname;
jobjectArray ret = 0; jobjectArray ret = 0;
int retLen = 0; int retLen = 0;
jclass byteArrayCls;
jboolean preferIPv6Address; jboolean preferIPv6Address;
int error=0; int error=0;
...@@ -219,7 +218,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -219,7 +218,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
} else { } else {
int i = 0; int i = 0;
int inetCount = 0, inet6Count = 0, inetIndex, inet6Index; int inetCount = 0, inet6Count = 0, inetIndex, inet6Index;
struct addrinfo *itr, *last, *iterator = res; struct addrinfo *itr, *last = NULL, *iterator = res;
while (iterator != NULL) { while (iterator != NULL) {
int skip = 0; int skip = 0;
itr = resNew; itr = resNew;
...@@ -393,10 +392,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this, ...@@ -393,10 +392,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
#ifdef AF_INET6 #ifdef AF_INET6
char host[NI_MAXHOST+1]; char host[NI_MAXHOST+1];
jfieldID fid;
int error = 0; int error = 0;
jint family;
struct sockaddr *him ;
int len = 0; int len = 0;
jbyte caddr[16]; jbyte caddr[16];
...@@ -459,11 +455,10 @@ static jboolean ...@@ -459,11 +455,10 @@ static jboolean
ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout, ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
struct sockaddr_in6* netif, jint ttl) { struct sockaddr_in6* netif, jint ttl) {
jint size; jint size;
jint n, len, hlen1, icmplen; jint n, len;
char sendbuf[1500]; char sendbuf[1500];
unsigned char recvbuf[1500]; unsigned char recvbuf[1500];
struct icmp6_hdr *icmp6; struct icmp6_hdr *icmp6;
struct ip6_hdr *ip6;
struct sockaddr_in6 sa_recv; struct sockaddr_in6 sa_recv;
jbyte *caddr, *recv_caddr; jbyte *caddr, *recv_caddr;
jchar pid; jchar pid;
...@@ -561,7 +556,6 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this, ...@@ -561,7 +556,6 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
jbyteArray ifArray, jbyteArray ifArray,
jint ttl, jint if_scope) { jint ttl, jint if_scope) {
#ifdef AF_INET6 #ifdef AF_INET6
jint addr;
jbyte caddr[16]; jbyte caddr[16];
jint fd, sz; jint fd, sz;
struct sockaddr_in6 him6; struct sockaddr_in6 him6;
......
...@@ -398,7 +398,6 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs) ...@@ -398,7 +398,6 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs)
jobjectArray addrArr; jobjectArray addrArr;
jobjectArray bindArr; jobjectArray bindArr;
jobjectArray childArr; jobjectArray childArr;
netaddr *addrs;
jint addr_index, addr_count, bind_index; jint addr_index, addr_count, bind_index;
jint child_count, child_index; jint child_count, child_index;
netaddr *addrP; netaddr *addrP;
...@@ -815,8 +814,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, netif *ifs) { ...@@ -815,8 +814,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, netif *ifs) {
addr6p[0], addr6p[1], addr6p[2], addr6p[3], addr6p[0], addr6p[1], addr6p[2], addr6p[3],
addr6p[4], addr6p[5], addr6p[6], addr6p[7], addr6p[4], addr6p[5], addr6p[6], addr6p[7],
&if_idx, &plen, &scope, &dad_status, devname) != EOF) { &if_idx, &plen, &scope, &dad_status, devname) != EOF) {
struct netif *ifs_ptr = NULL;
struct netif *last_ptr = NULL;
struct sockaddr_in6 addr; struct sockaddr_in6 addr;
sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s", sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s",
...@@ -852,7 +849,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, netif *ifs) { ...@@ -852,7 +849,6 @@ static netif *enumIPv6Interfaces(JNIEnv *env, netif *ifs) {
*/ */
void freeif(netif *ifs) { void freeif(netif *ifs) {
netif *currif = ifs; netif *currif = ifs;
netif *child = NULL;
while (currif != NULL) { while (currif != NULL) {
netaddr *addrP = currif->addr; netaddr *addrP = currif->addr;
...@@ -1158,10 +1154,9 @@ static short getFlags(JNIEnv *env, jstring name) { ...@@ -1158,10 +1154,9 @@ static short getFlags(JNIEnv *env, jstring name) {
*/ */
static struct sockaddr *getBroadcast(JNIEnv *env, const char *ifname) { static struct sockaddr *getBroadcast(JNIEnv *env, const char *ifname) {
int sock; int sock;
unsigned int mask;
struct sockaddr *ret = NULL; struct sockaddr *ret = NULL;
struct ifreq if2; struct ifreq if2;
short flag; short flag = 0;
sock = JVM_Socket(AF_INET, SOCK_DGRAM, 0); sock = JVM_Socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) { if (sock < 0) {
......
...@@ -89,7 +89,6 @@ static jfieldID pdsi_ttlID; ...@@ -89,7 +89,6 @@ static jfieldID pdsi_ttlID;
static jobject createInteger(JNIEnv *env, int i) { static jobject createInteger(JNIEnv *env, int i) {
static jclass i_class; static jclass i_class;
static jmethodID i_ctrID; static jmethodID i_ctrID;
static jfieldID i_valueID;
if (i_class == NULL) { if (i_class == NULL) {
jclass c = (*env)->FindClass(env, "java/lang/Integer"); jclass c = (*env)->FindClass(env, "java/lang/Integer");
...@@ -109,7 +108,6 @@ static jobject createInteger(JNIEnv *env, int i) { ...@@ -109,7 +108,6 @@ static jobject createInteger(JNIEnv *env, int i) {
static jobject createBoolean(JNIEnv *env, int b) { static jobject createBoolean(JNIEnv *env, int b) {
static jclass b_class; static jclass b_class;
static jmethodID b_ctrID; static jmethodID b_ctrID;
static jfieldID b_valueID;
if (b_class == NULL) { if (b_class == NULL) {
jclass c = (*env)->FindClass(env, "java/lang/Boolean"); jclass c = (*env)->FindClass(env, "java/lang/Boolean");
...@@ -148,8 +146,6 @@ Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) { ...@@ -148,8 +146,6 @@ Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) {
#ifdef __linux__ #ifdef __linux__
struct utsname sysinfo; struct utsname sysinfo;
#endif #endif
char *s;
pdsi_fdID = (*env)->GetFieldID(env, cls, "fd", pdsi_fdID = (*env)->GetFieldID(env, cls, "fd",
"Ljava/io/FileDescriptor;"); "Ljava/io/FileDescriptor;");
CHECK_NULL(pdsi_fdID); CHECK_NULL(pdsi_fdID);
...@@ -373,7 +369,7 @@ Java_java_net_PlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject this, jin ...@@ -373,7 +369,7 @@ Java_java_net_PlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject this, jin
if (JVM_GetSockName(fd, (struct sockaddr *)&addr, &len) == -1) { if (JVM_GetSockName(fd, (struct sockaddr *)&addr, &len) == -1) {
return; return;
} }
localPort = NET_GetPortFromSockaddr(&addr); localPort = NET_GetPortFromSockaddr((struct sockaddr *)&addr);
if (localPort == 0) { if (localPort == 0) {
localPort = (*env)->GetIntField(env, this, pdsi_localPortID); localPort = (*env)->GetIntField(env, this, pdsi_localPortID);
#ifdef AF_INET6 #ifdef AF_INET6
...@@ -416,7 +412,6 @@ Java_java_net_PlainDatagramSocketImpl_send(JNIEnv *env, jobject this, ...@@ -416,7 +412,6 @@ Java_java_net_PlainDatagramSocketImpl_send(JNIEnv *env, jobject this,
/* The fdObj'fd */ /* The fdObj'fd */
jint fd; jint fd;
ssize_t n = -1;
SOCKADDR rmtaddr, *rmtaddrP=&rmtaddr; SOCKADDR rmtaddr, *rmtaddrP=&rmtaddr;
int len; int len;
...@@ -633,9 +628,7 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this, ...@@ -633,9 +628,7 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this,
jint packetBufferOffset, packetBufferLen; jint packetBufferOffset, packetBufferLen;
int fd; int fd;
jbyteArray data;
int datalen;
int n; int n;
SOCKADDR remote_addr; SOCKADDR remote_addr;
int len; int len;
...@@ -812,9 +805,7 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this, ...@@ -812,9 +805,7 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this,
jint packetBufferOffset, packetBufferLen; jint packetBufferOffset, packetBufferLen;
int fd; int fd;
jbyteArray data;
int datalen;
int n; int n;
SOCKADDR remote_addr; SOCKADDR remote_addr;
int len; int len;
...@@ -1059,7 +1050,6 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env, ...@@ -1059,7 +1050,6 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID); jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
int fd; int fd;
int arg = -1;
int t = 1; int t = 1;
if (IS_NULL(fdObj)) { if (IS_NULL(fdObj)) {
......
...@@ -136,8 +136,6 @@ static int getFD(JNIEnv *env, jobject this) { ...@@ -136,8 +136,6 @@ static int getFD(JNIEnv *env, jobject this) {
*/ */
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_java_net_PlainSocketImpl_initProto(JNIEnv *env, jclass cls) { Java_java_net_PlainSocketImpl_initProto(JNIEnv *env, jclass cls) {
char *s;
psi_fdID = (*env)->GetFieldID(env, cls , "fd", psi_fdID = (*env)->GetFieldID(env, cls , "fd",
"Ljava/io/FileDescriptor;"); "Ljava/io/FileDescriptor;");
CHECK_NULL(psi_fdID); CHECK_NULL(psi_fdID);
...@@ -183,7 +181,6 @@ Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this, ...@@ -183,7 +181,6 @@ Java_java_net_PlainSocketImpl_socketCreate(JNIEnv *env, jobject this,
jboolean stream) { jboolean stream) {
jobject fdObj, ssObj; jobject fdObj, ssObj;
int fd; int fd;
int arg = -1;
if (socketExceptionCls == NULL) { if (socketExceptionCls == NULL) {
jclass c = (*env)->FindClass(env, "java/net/SocketException"); jclass c = (*env)->FindClass(env, "java/net/SocketException");
...@@ -290,7 +287,6 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this, ...@@ -290,7 +287,6 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
while (1) { while (1) {
#ifndef USE_SELECT #ifndef USE_SELECT
{ {
fprintf(stdout,"\nNATIVE: fd = %d] ", fd);
struct pollfd pfd; struct pollfd pfd;
pfd.fd = fd; pfd.fd = fd;
pfd.events = POLLOUT; pfd.events = POLLOUT;
...@@ -673,8 +669,6 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this, ...@@ -673,8 +669,6 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
/* accepted fd */ /* accepted fd */
jint newfd; jint newfd;
jthrowable error;
SOCKADDR him; SOCKADDR him;
int len; int len;
...@@ -1087,7 +1081,6 @@ Java_java_net_PlainSocketImpl_socketGetOption(JNIEnv *env, jobject this, ...@@ -1087,7 +1081,6 @@ Java_java_net_PlainSocketImpl_socketGetOption(JNIEnv *env, jobject this,
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_java_net_PlainSocketImpl_socketSendUrgentData(JNIEnv *env, jobject this, Java_java_net_PlainSocketImpl_socketSendUrgentData(JNIEnv *env, jobject this,
jint data) { jint data) {
char *buf;
/* The fd field */ /* The fd field */
jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID); jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
int n, fd; int n, fd;
......
...@@ -65,7 +65,6 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this, ...@@ -65,7 +65,6 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
char BUF[MAX_BUFFER_LEN]; char BUF[MAX_BUFFER_LEN];
char *bufP; char *bufP;
jint fd, nread; jint fd, nread;
jint n;
if (IS_NULL(fdObj)) { if (IS_NULL(fdObj)) {
/* should't this be a NullPointerException? -br */ /* should't this be a NullPointerException? -br */
......
...@@ -67,7 +67,6 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this, ...@@ -67,7 +67,6 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this,
char BUF[MAX_BUFFER_LEN]; char BUF[MAX_BUFFER_LEN];
int buflen; int buflen;
int fd; int fd;
jint n = 0;
if (IS_NULL(fdObj)) { if (IS_NULL(fdObj)) {
JNU_ThrowByName(env, "java/net/SocketException", "Socket closed"); JNU_ThrowByName(env, "java/net/SocketException", "Socket closed");
......
...@@ -281,7 +281,9 @@ int NET_ReadV(int s, const struct iovec * vector, int count) { ...@@ -281,7 +281,9 @@ int NET_ReadV(int s, const struct iovec * vector, int count) {
int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
struct sockaddr *from, int *fromlen) { struct sockaddr *from, int *fromlen) {
BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) ); socklen_t socklen = *fromlen;
BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, &socklen) );
*fromlen = socklen;
} }
int NET_Send(int s, void *msg, int len, unsigned int flags) { int NET_Send(int s, void *msg, int len, unsigned int flags) {
...@@ -298,7 +300,9 @@ int NET_SendTo(int s, const void *msg, int len, unsigned int ...@@ -298,7 +300,9 @@ int NET_SendTo(int s, const void *msg, int len, unsigned int
} }
int NET_Accept(int s, struct sockaddr *addr, int *addrlen) { int NET_Accept(int s, struct sockaddr *addr, int *addrlen) {
BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) ); socklen_t socklen = *addrlen;
BLOCKING_IO_RETURN_INT( s, accept(s, addr, &socklen) );
*addrlen = socklen;
} }
int NET_Connect(int s, struct sockaddr *addr, int addrlen) { int NET_Connect(int s, struct sockaddr *addr, int addrlen) {
...@@ -323,7 +327,7 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds, ...@@ -323,7 +327,7 @@ int NET_Select(int s, fd_set *readfds, fd_set *writefds,
* signal other than our wakeup signal. * signal other than our wakeup signal.
*/ */
int NET_Timeout(int s, long timeout) { int NET_Timeout(int s, long timeout) {
long prevtime,newtime; long prevtime = 0, newtime;
struct timeval t; struct timeval t;
fdEntry_t *fdEntry = getFdEntry(s); fdEntry_t *fdEntry = getFdEntry(s);
......
...@@ -229,7 +229,7 @@ jint IPv6_supported() ...@@ -229,7 +229,7 @@ jint IPv6_supported()
int fd; int fd;
void *ipv6_fn; void *ipv6_fn;
SOCKADDR sa; SOCKADDR sa;
int sa_len = sizeof(sa); socklen_t sa_len = sizeof(sa);
fd = JVM_Socket(AF_INET6, SOCK_STREAM, 0) ; fd = JVM_Socket(AF_INET6, SOCK_STREAM, 0) ;
if (fd < 0) { if (fd < 0) {
...@@ -447,7 +447,6 @@ static void initLoopbackRoutes() { ...@@ -447,7 +447,6 @@ static void initLoopbackRoutes() {
char dest_str[40]; char dest_str[40];
struct in6_addr dest_addr; struct in6_addr dest_addr;
char device[16]; char device[16];
jboolean match = JNI_FALSE;
if (loRoutes != 0) { if (loRoutes != 0) {
free (loRoutes); free (loRoutes);
...@@ -525,7 +524,7 @@ static void initLoopbackRoutes() { ...@@ -525,7 +524,7 @@ static void initLoopbackRoutes() {
{ {
/* now find the scope_id for "lo" */ /* now find the scope_id for "lo" */
char addr6[40], devname[20]; char devname[20];
char addr6p[8][5]; char addr6p[8][5];
int plen, scope, dad_status, if_idx; int plen, scope, dad_status, if_idx;
...@@ -1019,7 +1018,7 @@ int getDefaultIPv6Interface(struct in6_addr *target_addr) { ...@@ -1019,7 +1018,7 @@ int getDefaultIPv6Interface(struct in6_addr *target_addr) {
* index. * index.
*/ */
if (match) { if (match) {
char addr6[40], devname[20]; char devname[20];
char addr6p[8][5]; char addr6p[8][5];
int plen, scope, dad_status, if_idx; int plen, scope, dad_status, if_idx;
...@@ -1086,7 +1085,16 @@ NET_GetSockOpt(int fd, int level, int opt, void *result, ...@@ -1086,7 +1085,16 @@ NET_GetSockOpt(int fd, int level, int opt, void *result,
} }
#endif #endif
#ifdef __solaris__
rv = getsockopt(fd, level, opt, result, len); rv = getsockopt(fd, level, opt, result, len);
#else
{
socklen_t socklen = *len;
rv = getsockopt(fd, level, opt, result, &socklen);
*len = socklen;
}
#endif
if (rv < 0) { if (rv < 0) {
return rv; return rv;
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>
#include <sys/types.h> #include <sys/types.h>
#include <process.h>
#include "java_net_InetAddress.h" #include "java_net_InetAddress.h"
#include "java_net_Inet4AddressImpl.h" #include "java_net_Inet4AddressImpl.h"
...@@ -141,7 +142,6 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -141,7 +142,6 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
unsigned int addr[4]; unsigned int addr[4];
jobjectArray ret = NULL; jobjectArray ret = NULL;
jclass byteArrayCls;
if (!initialized) { if (!initialized) {
ni_iacls = (*env)->FindClass(env, "java/net/InetAddress"); ni_iacls = (*env)->FindClass(env, "java/net/InetAddress");
...@@ -315,7 +315,7 @@ ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout, ...@@ -315,7 +315,7 @@ ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout,
seq = ((unsigned short)rand()) >> 1; seq = ((unsigned short)rand()) >> 1;
/* icmp_id is a 16 bit data type, therefore down cast the pid */ /* icmp_id is a 16 bit data type, therefore down cast the pid */
pid = (u_short) getpid(); pid = (u_short) _getpid();
size = 60*1024; size = 60*1024;
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char *) &size, sizeof(size)); setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char *) &size, sizeof(size));
/** /**
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>
#include <sys/types.h> #include <sys/types.h>
#include <process.h>
#include "java_net_InetAddress.h" #include "java_net_InetAddress.h"
#include "java_net_Inet4AddressImpl.h" #include "java_net_Inet4AddressImpl.h"
...@@ -307,10 +308,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this, ...@@ -307,10 +308,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
jstring ret = NULL; jstring ret = NULL;
char host[NI_MAXHOST+1]; char host[NI_MAXHOST+1];
jfieldID fid;
int error = 0; int error = 0;
jint family;
struct sockaddr *him ;
int len = 0; int len = 0;
jbyte caddr[16]; jbyte caddr[16];
...@@ -374,7 +372,7 @@ static jboolean ...@@ -374,7 +372,7 @@ static jboolean
ping6(JNIEnv *env, jint fd, struct SOCKADDR_IN6* him, jint timeout, ping6(JNIEnv *env, jint fd, struct SOCKADDR_IN6* him, jint timeout,
struct SOCKADDR_IN6* netif, jint ttl) { struct SOCKADDR_IN6* netif, jint ttl) {
jint size; jint size;
jint n, len, hlen1, icmplen, i; jint n, len, i;
char sendbuf[1500]; char sendbuf[1500];
char auxbuf[1500]; char auxbuf[1500];
unsigned char recvbuf[1500]; unsigned char recvbuf[1500];
...@@ -392,7 +390,7 @@ ping6(JNIEnv *env, jint fd, struct SOCKADDR_IN6* him, jint timeout, ...@@ -392,7 +390,7 @@ ping6(JNIEnv *env, jint fd, struct SOCKADDR_IN6* him, jint timeout,
seq = ((unsigned short)rand()) >> 1; seq = ((unsigned short)rand()) >> 1;
/* icmp_id is a 16 bit data type, therefore down cast the pid */ /* icmp_id is a 16 bit data type, therefore down cast the pid */
pid = (unsigned short) getpid(); pid = (unsigned short) _getpid();
size = 60*1024; size = 60*1024;
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char *)&size, sizeof(size)); setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (const char *)&size, sizeof(size));
...@@ -520,7 +518,6 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this, ...@@ -520,7 +518,6 @@ Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
jbyteArray ifArray, jbyteArray ifArray,
jint ttl, jint if_scope) { jint ttl, jint if_scope) {
#ifdef AF_INET6 #ifdef AF_INET6
jint addr;
jbyte caddr[16]; jbyte caddr[16];
jint fd, sz; jint fd, sz;
struct sockaddr_in6 him6; struct sockaddr_in6 him6;
......
...@@ -75,7 +75,6 @@ extern int enumInterfaces_win9x(JNIEnv *, netif **); ...@@ -75,7 +75,6 @@ extern int enumInterfaces_win9x(JNIEnv *, netif **);
extern int enumAddresses_win9x(JNIEnv *, netif *, netaddr **); extern int enumAddresses_win9x(JNIEnv *, netif *, netaddr **);
extern int init_win9x(void); extern int init_win9x(void);
#endif #endif
extern int enumInterfaces_win(JNIEnv *env, netif **netifPP);
/* Windows 95/98/ME running */ /* Windows 95/98/ME running */
...@@ -209,7 +208,6 @@ int enumInterfaces_win(JNIEnv *env, netif **netifPP) ...@@ -209,7 +208,6 @@ int enumInterfaces_win(JNIEnv *env, netif **netifPP)
int count; int count;
netif *netifP; netif *netifP;
DWORD i; DWORD i;
wchar_t wName[128];
int lo=0, eth=0, tr=0, fddi=0, ppp=0, sl=0, net=0; int lo=0, eth=0, tr=0, fddi=0, ppp=0, sl=0, net=0;
/* /*
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#ifndef NETWORK_INTERFACE_H #ifndef NETWORK_INTERFACE_H
#define NETWORK_INTERFACE_H #define NETWORK_INTERFACE_H
#include <iphlpapi.h>
#include "net_util.h" #include "net_util.h"
/* /*
...@@ -86,6 +87,14 @@ extern jfieldID ni_ibaddressID; /* InterfaceAddress.address */ ...@@ -86,6 +87,14 @@ extern jfieldID ni_ibaddressID; /* InterfaceAddress.address */
extern jfieldID ni_ibbroadcastID; /* InterfaceAddress.broadcast */ extern jfieldID ni_ibbroadcastID; /* InterfaceAddress.broadcast */
extern jfieldID ni_ibmaskID; /* InterfaceAddress.maskLength */ extern jfieldID ni_ibmaskID; /* InterfaceAddress.maskLength */
int enumInterfaces_win(JNIEnv *env, netif **netifPP);
/* We have included iphlpapi.h which includes iptypes.h which has the definition
* for MAX_ADAPTER_DESCRIPTION_LENGTH (along with the other definitions in this
* ifndef block). Therefore if MAX_ADAPTER_DESCRIPTION_LENGTH is defined we can
* be sure that the other definitions are also defined */
#ifndef MAX_ADAPTER_DESCRIPTION_LENGTH
/* /*
* Following includes come from iptypes.h * Following includes come from iptypes.h
*/ */
...@@ -373,6 +382,10 @@ typedef struct { ...@@ -373,6 +382,10 @@ typedef struct {
UINT EnableDns; UINT EnableDns;
} FIXED_INFO, *PFIXED_INFO; } FIXED_INFO, *PFIXED_INFO;
#pragma warning(pop)
#endif /*!MAX_ADAPTER_DESCRIPTION_LENGTH*/
#ifndef IP_INTERFACE_NAME_INFO_DEFINED #ifndef IP_INTERFACE_NAME_INFO_DEFINED
#define IP_INTERFACE_NAME_INFO_DEFINED #define IP_INTERFACE_NAME_INFO_DEFINED
...@@ -389,7 +402,6 @@ typedef struct ip_interface_name_info { ...@@ -389,7 +402,6 @@ typedef struct ip_interface_name_info {
#endif #endif
#pragma warning(pop)
/* from ipifcons.h */ /* from ipifcons.h */
......
...@@ -417,8 +417,8 @@ static int getAdapters(JNIEnv *env, adapter **adapterPP) ...@@ -417,8 +417,8 @@ static int getAdapters(JNIEnv *env, adapter **adapterPP)
return -1; return -1;
} }
curr->index = ++adapterCount; curr->index = ++adapterCount;
curr->name = strdup("lo"); curr->name = _strdup("lo");
curr->displayName = strdup("TCP Loopback interface"); curr->displayName = _strdup("TCP Loopback interface");
curr->next = adapterP; curr->next = adapterP;
*adapterPP = curr; *adapterPP = curr;
...@@ -513,12 +513,11 @@ static int getStaticAddresses(JNIEnv *env, char *reg_key, netaddr **netaddrPP) ...@@ -513,12 +513,11 @@ static int getStaticAddresses(JNIEnv *env, char *reg_key, netaddr **netaddrPP)
HKEY enumKey, bindingKey; HKEY enumKey, bindingKey;
DWORD dwLen; DWORD dwLen;
ULONG ulType; ULONG ulType;
TCHAR driver[MAX_STR_LEN];
char addresses[MAX_STR_LEN]; char addresses[MAX_STR_LEN];
unsigned long addr; /* IPv4 address */ unsigned long addr; /* IPv4 address */
unsigned char byte; unsigned char byte;
netaddr *netaddrP, *curr; netaddr *netaddrP, *curr;
int i, addrCount, if_count; int i, addrCount;
/* /*
* Open the HKEY_LOCAL_MACHINE\Enum\%s\%s\%s key * Open the HKEY_LOCAL_MACHINE\Enum\%s\%s\%s key
...@@ -1055,8 +1054,8 @@ int enumInterfaces_win9x(JNIEnv *env, netif **netifPP) { ...@@ -1055,8 +1054,8 @@ int enumInterfaces_win9x(JNIEnv *env, netif **netifPP) {
return -1; return -1;
} }
ifs->name = strdup(adapterP->name); ifs->name = _strdup(adapterP->name);
ifs->displayName = strdup(adapterP->displayName); ifs->displayName = _strdup(adapterP->displayName);
ifs->dwIndex = adapterP->index; ifs->dwIndex = adapterP->index;
ifs->index = adapterP->index; ifs->index = adapterP->index;
ifs->next = netifP; ifs->next = netifP;
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
*/ */
extern int enumAddresses_win(JNIEnv *env, netif *netifP, netaddr **netaddrPP); extern int enumAddresses_win(JNIEnv *env, netif *netifP, netaddr **netaddrPP);
int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP);
/* IP helper library routines */ /* IP helper library routines */
int (PASCAL FAR *GetIpAddrTable_fn)(); int (PASCAL FAR *GetIpAddrTable_fn)();
...@@ -168,11 +169,10 @@ static int ipinflen = 2048; ...@@ -168,11 +169,10 @@ static int ipinflen = 2048;
*/ */
int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP) int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
{ {
DWORD ret, numInterfaces; DWORD ret;
IP_ADAPTER_ADDRESSES *ptr, *ptr1, *adapters=0; IP_ADAPTER_ADDRESSES *ptr, *adapters=0;
ULONG len=ipinflen, count=0; ULONG len=ipinflen, count=0;
netif *nif=0, *dup_nif, *last=0, *loopif=0; netif *nif=0, *dup_nif, *last=0, *loopif=0;
netaddr *addr, *addr1;
int tun=0, net=0; int tun=0, net=0;
*netifPP = 0; *netifPP = 0;
...@@ -330,7 +330,7 @@ err: ...@@ -330,7 +330,7 @@ err:
static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) { static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) {
LPSOCKADDR sock; LPSOCKADDR sock;
int ret, count = 0; int count = 0;
netaddr *curr, *start=0, *prev=0; netaddr *curr, *start=0, *prev=0;
PIP_ADAPTER_UNICAST_ADDRESS uni_addr; PIP_ADAPTER_UNICAST_ADDRESS uni_addr;
PIP_ADAPTER_ANYCAST_ADDRESS any_addr; PIP_ADAPTER_ANYCAST_ADDRESS any_addr;
...@@ -364,7 +364,7 @@ static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) { ...@@ -364,7 +364,7 @@ static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) {
sock = uni_addr->Address.lpSockaddr; sock = uni_addr->Address.lpSockaddr;
SOCKETADDRESS_COPY (&curr->addr, sock); SOCKETADDRESS_COPY (&curr->addr, sock);
if (prefix != NULL) { if (prefix != NULL) {
curr->mask = prefix->PrefixLength; curr->mask = (short)prefix->PrefixLength;
if (sock->sa_family == AF_INET) { if (sock->sa_family == AF_INET) {
sock = prefix->Address.lpSockaddr; sock = prefix->Address.lpSockaddr;
SOCKETADDRESS_COPY(&curr->brdcast, sock); SOCKETADDRESS_COPY(&curr->brdcast, sock);
......
...@@ -64,7 +64,6 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this, ...@@ -64,7 +64,6 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this,
char BUF[MAX_BUFFER_LEN]; char BUF[MAX_BUFFER_LEN];
int buflen; int buflen;
int fd; int fd;
jint n;
if (IS_NULL(fdObj)) { if (IS_NULL(fdObj)) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed"); JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
......
...@@ -651,7 +651,6 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_send(JNIEnv *env, jobject this, ...@@ -651,7 +651,6 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_send(JNIEnv *env, jobject this,
SOCKETADDRESS rmtaddr; SOCKETADDRESS rmtaddr;
SOCKETADDRESS *addrp = &rmtaddr; SOCKETADDRESS *addrp = &rmtaddr;
int addrlen; int addrlen;
int x; /* DELETE ME */
if (IS_NULL(packet)) { if (IS_NULL(packet)) {
...@@ -883,7 +882,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peek(JNIEnv *env, jobject this, ...@@ -883,7 +882,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
*/ */
if (timeout) { if (timeout) {
jlong newTime = JVM_CurrentTimeMillis(env, 0); jlong newTime = JVM_CurrentTimeMillis(env, 0);
timeout -= (newTime - prevTime); timeout -= (jint)(newTime - prevTime);
if (timeout <= 0) { if (timeout <= 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException", JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
"Receive timed out"); "Receive timed out");
...@@ -929,9 +928,8 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peekData(JNIEnv *env, jobject thi ...@@ -929,9 +928,8 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peekData(JNIEnv *env, jobject thi
int fd, fd1, fduse, nsockets=0, errorCode; int fd, fd1, fduse, nsockets=0, errorCode;
int port; int port;
jbyteArray data;
int checkBoth = 0, datalen; int checkBoth = 0;
int n; int n;
SOCKETADDRESS remote_addr; SOCKETADDRESS remote_addr;
jint remote_addrsize=sizeof(remote_addr); jint remote_addrsize=sizeof(remote_addr);
...@@ -1101,7 +1099,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peekData(JNIEnv *env, jobject thi ...@@ -1101,7 +1099,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peekData(JNIEnv *env, jobject thi
*/ */
if (timeout) { if (timeout) {
jlong newTime = JVM_CurrentTimeMillis(env, 0); jlong newTime = JVM_CurrentTimeMillis(env, 0);
timeout -= (newTime - prevTime); timeout -= (jint)(newTime - prevTime);
if (timeout <= 0) { if (timeout <= 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException", JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
"Receive timed out"); "Receive timed out");
...@@ -1203,9 +1201,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_receive0(JNIEnv *env, jobject thi ...@@ -1203,9 +1201,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_receive0(JNIEnv *env, jobject thi
* must be called prior to receive() so that fduse can be set. * must be called prior to receive() so that fduse can be set.
*/ */
int fd, fd1, fduse, errorCode; int fd, fd1, fduse, errorCode;
jbyteArray data;
int datalen;
int n, nsockets=0; int n, nsockets=0;
SOCKETADDRESS remote_addr; SOCKETADDRESS remote_addr;
jint remote_addrsize=sizeof(remote_addr); jint remote_addrsize=sizeof(remote_addr);
...@@ -1376,7 +1372,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_receive0(JNIEnv *env, jobject thi ...@@ -1376,7 +1372,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_receive0(JNIEnv *env, jobject thi
if (timeout) { if (timeout) {
int ret; int ret;
jlong newTime = JVM_CurrentTimeMillis(env, 0); jlong newTime = JVM_CurrentTimeMillis(env, 0);
timeout -= (newTime - prevTime); timeout -= (jint)(newTime - prevTime);
prevTime = newTime; prevTime = newTime;
if (timeout <= 0) { if (timeout <= 0) {
......
...@@ -966,7 +966,8 @@ Java_java_net_TwoStacksPlainSocketImpl_socketSetOption(JNIEnv *env, jobject this ...@@ -966,7 +966,8 @@ Java_java_net_TwoStacksPlainSocketImpl_socketSetOption(JNIEnv *env, jobject this
if (on) { if (on) {
optval.ling.l_onoff = 1; optval.ling.l_onoff = 1;
optval.ling.l_linger = (*env)->GetIntField(env, value, fid); optval.ling.l_linger =
(unsigned short)(*env)->GetIntField(env, value, fid);
} else { } else {
optval.ling.l_onoff = 0; optval.ling.l_onoff = 0;
optval.ling.l_linger = 0; optval.ling.l_linger = 0;
......
...@@ -985,7 +985,7 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout) ...@@ -985,7 +985,7 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
read_rv = select(fd+1, &rd, &wr, &ex, &t); read_rv = select(fd+1, &rd, &wr, &ex, &t);
newTime = JVM_CurrentTimeMillis(env, 0); newTime = JVM_CurrentTimeMillis(env, 0);
timeout -= (newTime - prevTime); timeout -= (jint)(newTime - prevTime);
if (timeout <= 0) { if (timeout <= 0) {
return read_rv > 0 ? 0 : -1; return read_rv > 0 ? 0 : -1;
} }
......
...@@ -294,6 +294,15 @@ JNIEXPORT int JNICALL NET_SocketClose(int fd); ...@@ -294,6 +294,15 @@ JNIEXPORT int JNICALL NET_SocketClose(int fd);
JNIEXPORT int JNICALL NET_Timeout(int fd, long timeout); JNIEXPORT int JNICALL NET_Timeout(int fd, long timeout);
int NET_Socket(int domain, int type, int protocol);
void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
const char *defaultDetail);
void NET_ThrowSocketException(JNIEnv *env, char* msg);
jboolean NET_addrtransAvailable();
/* /*
* differs from NET_Timeout() as follows: * differs from NET_Timeout() as follows:
* *
......
...@@ -159,7 +159,6 @@ static int loadStaticConfig9x(char *sl, char *ns) { ...@@ -159,7 +159,6 @@ static int loadStaticConfig9x(char *sl, char *ns) {
DWORD dwLen; DWORD dwLen;
ULONG ulType; ULONG ulType;
char result[MAX_STR_LEN]; char result[MAX_STR_LEN];
int index;
int sts = STS_NO_CONFIG; int sts = STS_NO_CONFIG;
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
...@@ -275,7 +274,7 @@ static int loadConfig95(char *sl, char *ns) { ...@@ -275,7 +274,7 @@ static int loadConfig95(char *sl, char *ns) {
* the DHCP packet - see RFC 2132). * the DHCP packet - see RFC 2132).
*/ */
if (ret == ERROR_SUCCESS) { if (ret == ERROR_SUCCESS) {
int pos = 0; unsigned int pos = 0;
while (pos < dwLen) { while (pos < dwLen) {
int code, len; int code, len;
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#define SECURITY_WIN32 #define SECURITY_WIN32
#include "sspi.h" #include "sspi.h"
#include "issperr.h"
/* /*
......
This test uses 2 binary data files that were each created by serializing an Inet6Address instance.
In both cases this has to do with the tricky issue of scopes in serialized addresses.
serial1.4.2.ser: Was created by serializing an Inet6Address (::1) with J2SE 1.4.2 and is used to check for backward compatibility.
serial-bge0.ser: Was created on a Sparc workstation because it has an uncommon interface name ('bge0') which is useful for the test.
...@@ -24,7 +24,9 @@ ...@@ -24,7 +24,9 @@
/** /**
* @test * @test
* @bug 4921029 * @bug 4921029
* @bug 6656849
* @summary java.net.Inet6Address fails to be serialized with IPv6 support * @summary java.net.Inet6Address fails to be serialized with IPv6 support
* @summary NullPointerException thrown while de-serializing IPV6 Address.
*/ */
import java.net.*; import java.net.*;
...@@ -76,11 +78,20 @@ public class Serialize { ...@@ -76,11 +78,20 @@ public class Serialize {
System.out.println(nobj); System.out.println(nobj);
// create an address with an unlikely numeric scope_id // create an address with an unlikely numeric scope_id
if (!test ((Inet6Address)InetAddress.getByName ("fe80::1%99"))) { if (!test ((Inet6Address)InetAddress.getByName ("fe80::1%99"))) {
throw new RuntimeException ("test failed on fe80::1%99"); throw new RuntimeException ("test failed on fe80::1%99");
} }
// Deserialize an Inet6 address with a named interface
file = new File (System.getProperty("test.src"), "serial-bge0.ser");
ois = new ObjectInputStream(new FileInputStream(file));
try {
nobj = (Inet6Address) ois.readObject();
} catch (NullPointerException e) {
throw new RuntimeException("6656849 Not fixed: NullPointer when deserializing");
}
System.out.println(nobj);
System.out.println("All tests passed"); System.out.println("All tests passed");
} }
...@@ -97,8 +108,5 @@ public class Serialize { ...@@ -97,8 +108,5 @@ public class Serialize {
} else { } else {
return false; return false;
} }
} }
} }
/*
* Copyright 2008 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.
*
* 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.
*/
// Read printssl.sh, this Java program starts an SSL server
import java.net.ServerSocket;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLSocket;
public class PrintSSL {
public static void main(String[] args) throws Exception {
System.setProperty("javax.net.ssl.keyStorePassword", "passphrase");
System.setProperty("javax.net.ssl.keyStore",
System.getProperty("test.src", "./") + "/../../ssl/etc/keystore");
SSLServerSocketFactory sslssf =
(SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
final ServerSocket server = sslssf.createServerSocket(0);
System.out.println(server.getLocalPort());
System.out.flush();
Thread t = new Thread() {
public void run() {
try {
Thread.sleep(30000);
server.close();
} catch (Exception e) {
;
}
throw new RuntimeException("Timeout");
}
};
t.setDaemon(true);
t.start();
((SSLSocket)server.accept()).startHandshake();
}
}
#
# Copyright 2008 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.
#
# 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.
#
# @test
# @bug 6480981
# @summary keytool should be able to import certificates from remote SSL servers
if [ "${TESTSRC}" = "" ] ; then
TESTSRC="."
fi
if [ "${TESTJAVA}" = "" ] ; then
echo "TESTJAVA not set. Test cannot execute."
echo "FAILED!!!"
exit 1
fi
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux )
FS="/"
;;
Windows_* )
FS="\\"
;;
* )
echo "Unrecognized operating system!"
exit 1;
;;
esac
${TESTJAVA}${FS}bin${FS}javac -d . ${TESTSRC}${FS}PrintSSL.java || exit 10
${TESTJAVA}${FS}bin${FS}java -Dtest.src=$TESTSRC PrintSSL | ( read PORT; ${TESTJAVA}${FS}bin${FS}keytool -printcert -sslserver localhost:$PORT )
status=$?
rm PrintSSL*.class
exit $status
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册