PR libgcj/14012, PR libgcj/14013, PR libgcj/15157, PR libgcj/15509
2005-01-11 Michael Koch <konqueror@gmx.de> PR libgcj/14012, PR libgcj/14013, PR libgcj/15157, PR libgcj/15509 * gnu/java/net/BASE64.java, gnu/java/net/EmptyX509TrustManager.java, gnu/java/net/LineInputStream.java, gnu/java/net/protocol/http/Authenticator.java, gnu/java/net/protocol/http/ByteArrayRequestBodyWriter.java, gnu/java/net/protocol/http/ByteArrayResponseBodyReader.java, gnu/java/net/protocol/http/ChunkedInputStream.java, gnu/java/net/protocol/http/Cookie.java, gnu/java/net/protocol/http/CookieManager.java, gnu/java/net/protocol/http/Credentials.java, gnu/java/net/protocol/http/HTTPConnection.java, gnu/java/net/protocol/http/HTTPDateFormat.java, gnu/java/net/protocol/http/HTTPURLConnection.java, gnu/java/net/protocol/http/Headers.java, gnu/java/net/protocol/http/Request.java, gnu/java/net/protocol/http/RequestBodyWriter.java, gnu/java/net/protocol/http/Response.java, gnu/java/net/protocol/http/ResponseBodyReader.java, gnu/java/net/protocol/http/ResponseHeaderHandler.java, gnu/java/net/protocol/http/SimpleCookieManager.java, gnu/java/net/protocol/http/event/ConnectionEvent.java, gnu/java/net/protocol/http/event/ConnectionListener.java, gnu/java/net/protocol/http/event/RequestEvent.java, gnu/java/net/protocol/http/event/RequestListener.java: New files. * gnu/java/net/protocol/http/Connection.java: Removed. * gnu/java/net/protocol/http/Handler.java, javax/net/ssl/HttpsURLConnection.java: Updated. * Makefile.am: Added new files and remove old ones. * Makefile.in: Regenerated. From-SVN: r93195
This commit is contained in:
parent
7eb3b9ec89
commit
30e8a59c74
30 changed files with 5473 additions and 622 deletions
|
@ -59,10 +59,18 @@ public abstract class HttpsURLConnection extends HttpURLConnection
|
|||
// Fields.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/** The default verifier. */
|
||||
/**
|
||||
* The default verifier.
|
||||
* This is lazily initialized as required.
|
||||
* @see #getDefaultHostnameVerifier
|
||||
*/
|
||||
private static HostnameVerifier defaultVerifier;
|
||||
|
||||
/** The default factory. */
|
||||
/**
|
||||
* The default factory.
|
||||
* This is lazily initialized as required.
|
||||
* @see #getDefaultSSLSocketFactory
|
||||
*/
|
||||
private static SSLSocketFactory defaultFactory;
|
||||
|
||||
/**
|
||||
|
@ -75,21 +83,6 @@ public abstract class HttpsURLConnection extends HttpURLConnection
|
|||
*/
|
||||
private SSLSocketFactory factory;
|
||||
|
||||
// Static initializer.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
static {
|
||||
defaultVerifier = new TrivialHostnameVerifier();
|
||||
try
|
||||
{
|
||||
defaultFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Constructor.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
@ -102,8 +95,6 @@ public abstract class HttpsURLConnection extends HttpURLConnection
|
|||
protected HttpsURLConnection(URL url) throws IOException
|
||||
{
|
||||
super(url);
|
||||
hostnameVerifier = defaultVerifier;
|
||||
factory = defaultFactory;
|
||||
}
|
||||
|
||||
// Class methods.
|
||||
|
@ -112,11 +103,17 @@ public abstract class HttpsURLConnection extends HttpURLConnection
|
|||
/**
|
||||
* Returns the default hostname verifier used in all new
|
||||
* connections.
|
||||
* If the default verifier has not been set, a new default one will be
|
||||
* provided by this method.
|
||||
*
|
||||
* @return The default hostname verifier.
|
||||
*/
|
||||
public static HostnameVerifier getDefaultHostnameVerifier()
|
||||
public static synchronized HostnameVerifier getDefaultHostnameVerifier()
|
||||
{
|
||||
if (defaultVerifier == null)
|
||||
{
|
||||
defaultVerifier = new TrivialHostnameVerifier();
|
||||
}
|
||||
return defaultVerifier;
|
||||
}
|
||||
|
||||
|
@ -137,17 +134,33 @@ public abstract class HttpsURLConnection extends HttpURLConnection
|
|||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkPermission(new SSLPermission("setHostnameVerifier"));
|
||||
defaultVerifier = newDefault;
|
||||
synchronized (HttpsURLConnection.class)
|
||||
{
|
||||
defaultVerifier = newDefault;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default SSL socket factory used in all new
|
||||
* connections.
|
||||
* If the default SSL socket factory has not been set, a new default one
|
||||
* will be provided by this method.
|
||||
*
|
||||
* @return The default SSL socket factory.
|
||||
*/
|
||||
public static SSLSocketFactory getDefaultSSLSocketFactory()
|
||||
public static synchronized SSLSocketFactory getDefaultSSLSocketFactory()
|
||||
{
|
||||
if (defaultFactory == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
defaultFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
return defaultFactory;
|
||||
}
|
||||
|
||||
|
@ -168,7 +181,10 @@ public abstract class HttpsURLConnection extends HttpURLConnection
|
|||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkSetFactory();
|
||||
defaultFactory = newDefault;
|
||||
synchronized (HttpsURLConnection.class)
|
||||
{
|
||||
defaultFactory = newDefault;
|
||||
}
|
||||
}
|
||||
|
||||
// Instance methods.
|
||||
|
@ -181,6 +197,10 @@ public abstract class HttpsURLConnection extends HttpURLConnection
|
|||
*/
|
||||
public HostnameVerifier getHostnameVerifier()
|
||||
{
|
||||
if (hostnameVerifier == null)
|
||||
{
|
||||
hostnameVerifier = getDefaultHostnameVerifier();
|
||||
}
|
||||
return hostnameVerifier;
|
||||
}
|
||||
|
||||
|
@ -205,6 +225,10 @@ public abstract class HttpsURLConnection extends HttpURLConnection
|
|||
*/
|
||||
public SSLSocketFactory getSSLSocketFactory()
|
||||
{
|
||||
if (factory == null)
|
||||
{
|
||||
factory = getDefaultSSLSocketFactory();
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue