208193: Add enableTLS, enableTLSDefault APIs.

This commit is contained in:
saul.edwards%sun.com 2004-10-01 16:42:24 +00:00
Родитель 080810f105
Коммит 0b966ffff9
4 изменённых файлов: 52 добавлений и 23 удалений

Просмотреть файл

@ -316,6 +316,14 @@ public class SSLServerSocket extends java.net.ServerSocket {
base.enableSSL3(enable);
}
/**
* Enables TLS on this socket. It is enabled by default, unless the
* default has been changed with <code>SSLSocket.enableTLSDefault</code>.
*/
public void enableTLS(boolean enable) throws SocketException {
base.enableTLS(enable);
}
/**
* @return the local address of this server socket.
*/

Просмотреть файл

@ -456,12 +456,27 @@ public class SSLSocket extends java.net.Socket {
}
/**
* Sets the default for SSL v2 for all new sockets.
* Sets the default for SSL v3 for all new sockets.
*/
static public void enableSSL3Default(boolean enable) throws SocketException{
setSSLDefaultOption(SocketBase.SSL_ENABLE_SSL3, enable);
}
/**
* Enables TLS on this socket. It is enabled by default, unless the
* default has been changed with <code>enableTLSDefault</code>.
*/
public void enableTLS(boolean enable) throws SocketException {
base.enableTLS(enable);
}
/**
* Sets the default for TLS for all new sockets.
*/
static public void enableTLSDefault(boolean enable) throws SocketException{
setSSLDefaultOption(SocketBase.SSL_ENABLE_TLS, enable);
}
/**
* Sets whether the socket requires client authentication from the remote
* peer. If requestClientAuth() has not already been called, this

Просмотреть файл

@ -85,22 +85,23 @@ class SocketBase {
native void socketBind(byte[] addrBA, int port) throws SocketException;
/**
* Enums. These must match the enums table in SSLSocket.c. This is
* Enums. These must match the enums table in common.c. This is
* safer than copying the values of the C constants, which are subject
* to change, into Java code.
*/
static final int SSL_ENABLE_SSL2 = 0;
static final int SSL_ENABLE_SSL3 = 1;
static final int TCP_NODELAY = 2;
static final int SO_KEEPALIVE = 3;
static final int PR_SHUTDOWN_RCV = 4;
static final int PR_SHUTDOWN_SEND = 5;
static final int SSL_REQUIRE_CERTIFICATE = 6;
static final int SSL_REQUEST_CERTIFICATE = 7;
static final int SSL_NO_CACHE = 8;
static final int SSL_POLICY_DOMESTIC = 9;
static final int SSL_POLICY_EXPORT = 10;
static final int SSL_POLICY_FRANCE = 11;
static final int SSL_ENABLE_TLS = 2;
static final int TCP_NODELAY = 3;
static final int SO_KEEPALIVE = 4;
static final int PR_SHUTDOWN_RCV = 5;
static final int PR_SHUTDOWN_SEND = 6;
static final int SSL_REQUIRE_CERTIFICATE = 7;
static final int SSL_REQUEST_CERTIFICATE = 8;
static final int SSL_NO_CACHE = 9;
static final int SSL_POLICY_DOMESTIC = 10;
static final int SSL_POLICY_EXPORT = 11;
static final int SSL_POLICY_FRANCE = 12;
void close() throws IOException {
socketClose();
@ -135,6 +136,10 @@ class SocketBase {
setSSLOption(SSL_ENABLE_SSL3, enable);
}
void enableTLS(boolean enable) throws SocketException {
setSSLOption(SSL_ENABLE_TLS, enable);
}
void setSSLOption(int option, boolean on)
throws SocketException
{

Просмотреть файл

@ -358,21 +358,22 @@ JSSL_DestroySocketData(JNIEnv *env, JSSL_SocketData *sd)
}
/*
* These must match up with the constants defined in SSLSocket.java.
* These must match up with the constants defined in SocketBase.java.
*/
PRInt32 JSSL_enums[] = {
SSL_ENABLE_SSL2, /* 0 */
SSL_ENABLE_SSL3, /* 1 */
PR_SockOpt_NoDelay, /* 2 */
PR_SockOpt_Keepalive, /* 3 */
PR_SHUTDOWN_RCV, /* 4 */
PR_SHUTDOWN_SEND, /* 5 */
SSL_REQUIRE_CERTIFICATE, /* 6 */
SSL_REQUEST_CERTIFICATE, /* 7 */
SSL_NO_CACHE, /* 8 */
SSL_POLICY_DOMESTIC, /* 9 */
SSL_POLICY_EXPORT, /* 10 */
SSL_POLICY_FRANCE, /* 11 */
SSL_ENABLE_TLS, /* 2 */
PR_SockOpt_NoDelay, /* 3 */
PR_SockOpt_Keepalive, /* 4 */
PR_SHUTDOWN_RCV, /* 5 */
PR_SHUTDOWN_SEND, /* 6 */
SSL_REQUIRE_CERTIFICATE, /* 7 */
SSL_REQUEST_CERTIFICATE, /* 8 */
SSL_NO_CACHE, /* 9 */
SSL_POLICY_DOMESTIC, /* 10 */
SSL_POLICY_EXPORT, /* 11 */
SSL_POLICY_FRANCE, /* 12 */
0
};