harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r985408 - in /harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main: java/org/apache/harmony/xnet/provider/jsse/ native/jsse/shared/ native/jsse/unix/
Date Fri, 13 Aug 2010 23:57:43 GMT
Author: odeakin
Date: Fri Aug 13 23:57:42 2010
New Revision: 985408

URL: http://svn.apache.org/viewvc?rev=985408&view=rev
Log:
Add implementation of getSupportedCipherSuitesImpl().

Modified:
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLParameters.java
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.c
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.h
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/unix/exports.txt

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLParameters.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLParameters.java?rev=985408&r1=985407&r2=985408&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLParameters.java
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLParameters.java
Fri Aug 13 23:57:42 2010
@@ -286,7 +286,7 @@ public class SSLParameters {
 
 
     // TODO: implement the natives for get/set cipher suites
-    private native String[] getSupportedCipherSuitesImpl(long SSL);
+    private static native String[] getSupportedCipherSuitesImpl(long SSL);
 
     protected String[] getSupportedCipherSuites(long SSL) {
         if (supportedCipherSuites == null) {
@@ -306,7 +306,7 @@ public class SSLParameters {
     }
 
 
-    private native void setEnabledCipherSuitesImpl(long context, long SSL,  String[] enabledCiphers);
+    private static native void setEnabledCipherSuitesImpl(long context, long SSL,  String[]
enabledCiphers);
 
     /**
      * Sets the set of available cipher suites for use in SSL connection.

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java?rev=985408&r1=985407&r2=985408&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
Fri Aug 13 23:57:42 2010
@@ -90,10 +90,12 @@ public class SSLSocketImpl extends SSLSo
      * @see javax.net.ssl.SSLSocket#SSLSocket() method documentation
      * for more information.
      */
-    protected SSLSocketImpl(SSLParameters sslParameters) {
+    protected SSLSocketImpl(SSLParameters sslParameters) throws IOException{
         super();
         this.sslParameters = sslParameters;
         // init should be called after creation!
+        // Initialise SSL now so it can be used
+        SSL = initImpl(sslParameters.getSSLContextAddress());
     }
 
     /**
@@ -185,7 +187,9 @@ public class SSLSocketImpl extends SSLSo
         appDataIS = new SSLSocketInputStream(this);
         appDataOS = new SSLSocketOutputStream(this);
 
-        SSL = initImpl(sslParameters.getSSLContextAddress());
+        if (SSL == 0) {
+            SSL = initImpl(sslParameters.getSSLContextAddress());
+        }
     }
 
     /**

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.c?rev=985408&r1=985407&r2=985408&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.c
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.c
Fri Aug 13 23:57:42 2010
@@ -180,3 +180,34 @@ JNIEXPORT void JNICALL Java_org_apache_h
         SSL_set_verify(ssl, mode, NULL);
     }
 }
+
+JNIEXPORT jobjectArray JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLParameters_getSupportedCipherSuitesImpl
+  (JNIEnv *env, jclass clazz, jlong jssl)
+{
+    SSL *ssl = (SSL*)jssl;
+    int i, count;
+    jclass stringClass;
+    jobjectArray stringArray; 
+    STACK_OF(SSL_CIPHER) *ciphers;
+
+    ciphers = SSL_get_ciphers(ssl);
+    count = sk_num(&ciphers->stack);
+
+    stringClass = (*env)->FindClass(env, "java/lang/String");
+    stringArray = (*env)->NewObjectArray(env, count, stringClass, NULL);
+
+    for (i=0; i<count; i++)
+    {
+        const char *cipherName = SSL_CIPHER_get_name(sk_value(&ciphers->stack, i));
+        jstring jcipherName = (*env)->NewStringUTF(env, cipherName);
+        (*env)->SetObjectArrayElement(env, stringArray, i, jcipherName);
+        (*env)->DeleteLocalRef(env, jcipherName);
+    }
+    return stringArray;
+}
+
+JNIEXPORT void JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLParameters_setEnabledCipherSuitesImpl
+  (JNIEnv *env, jclass clazz, jlong context, jlong jssl, jobjectArray jenabledCiphers)
+{
+    // TODO: implement using SSL_CTX_set_cipher_list/SSL_set_cipher_list
+}

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.h?rev=985408&r1=985407&r2=985408&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.h
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.h
Fri Aug 13 23:57:42 2010
@@ -40,6 +40,11 @@ JNIEXPORT void JNICALL Java_org_apache_h
   (JNIEnv *, jclass, jlong, jlong, jint);
 JNIEXPORT void JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLParameters_setClientAuthImpl
   (JNIEnv *, jclass, jlong, jlong, jshort);
+JNIEXPORT jobjectArray JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLParameters_getSupportedCipherSuitesImpl
+  (JNIEnv *, jclass, jlong);
+JNIEXPORT void JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLParameters_setEnabledCipherSuitesImpl
+  (JNIEnv *, jclass, jlong, jlong, jobjectArray);
+
 
 #ifdef __cplusplus
 }

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/unix/exports.txt?rev=985408&r1=985407&r2=985408&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/unix/exports.txt
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/unix/exports.txt
Fri Aug 13 23:57:42 2010
@@ -1,9 +1,12 @@
 Java_org_apache_harmony_xnet_provider_jsse_SSLParameters_initialiseContext
 Java_org_apache_harmony_xnet_provider_jsse_SSLParameters_setEnabledProtocolsImpl
 Java_org_apache_harmony_xnet_provider_jsse_SSLParameters_setClientAuthImpl
+Java_org_apache_harmony_xnet_provider_jsse_SSLParameters_getSupportedCipherSuitesImpl
+Java_org_apache_harmony_xnet_provider_jsse_SSLParameters_setEnabledCipherSuitesImpl
 Java_org_apache_harmony_xnet_provider_jsse_SSLSessionImpl_initialiseSession
 Java_org_apache_harmony_xnet_provider_jsse_SSLSocketImpl_initImpl
 Java_org_apache_harmony_xnet_provider_jsse_SSLSocketImpl_sslAcceptImpl
 Java_org_apache_harmony_xnet_provider_jsse_SSLSocketImpl_sslConnectImpl
 Java_org_apache_harmony_xnet_provider_jsse_SSLSocketImpl_writeAppDataImpl
 Java_org_apache_harmony_xnet_provider_jsse_SSLSocketImpl_needAppDataImpl
+



Mime
View raw message