You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/09/16 18:35:43 UTC
svn commit: r1171651 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/ssl/ native/include/acr/
native/modules/openssl/
Author: mturk
Date: Fri Sep 16 16:35:43 2011
New Revision: 1171651
URL: http://svn.apache.org/viewvc?rev=1171651&view=rev
Log:
Fix typo in class names
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertificate.java
- copied, changed from r1171512, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertifficate.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertificateFormat.java
- copied, changed from r1171512, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertifficateFormat.java
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertifficate.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertifficateFormat.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLKey.java
commons/sandbox/runtime/trunk/src/main/native/include/acr/ssl.h
commons/sandbox/runtime/trunk/src/main/native/modules/openssl/cert.c
commons/sandbox/runtime/trunk/src/main/native/modules/openssl/key.c
Copied: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertificate.java (from r1171512, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertifficate.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertificate.java?p2=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertificate.java&p1=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertifficate.java&r1=1171512&r2=1171651&rev=1171651&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertifficate.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertificate.java Fri Sep 16 16:35:43 2011
@@ -17,26 +17,25 @@
package org.apache.commons.runtime.ssl;
import org.apache.commons.runtime.InvalidArgumentException;
-import org.apache.commons.runtime.OperationNotImplementedException;
-import org.apache.commons.runtime.Status;
-import org.apache.commons.runtime.SystemException;
-
+import org.apache.commons.runtime.InvalidDataException;
import java.io.File;
-import java.nio.ByteBuffer;
/**
* SSL Certificate.
*/
-public final class SSLCertifficate extends NativePointer
+public final class SSLCertificate extends NativePointer
{
// Hide NativePointer
private final long pointer = 0L;
private final String desc;
- private static native long load0(String file, String desc, int format, long pcb);
+ private static native long load0(String file, String desc, int format, long pcb)
+ throws InvalidDataException;
+ private static native long load1(String file, String desc, int format, String password)
+ throws InvalidDataException;
- private SSLCertifficate()
+ private SSLCertificate()
{
this.desc = null;
// No instance
@@ -45,29 +44,39 @@ public final class SSLCertifficate exten
/**
* Creates a new object instance.
*/
- public SSLCertifficate(String desc)
+ public SSLCertificate(String desc)
{
this.desc = desc;
}
- public void load(String file, SSLCertifficateFormat format, PasswordCallback cb)
+ public void load(String file, SSLCertificateFormat format, PasswordCallback cb)
+ throws InvalidDataException
{
if (super.pointer != 0L) {
// Already loaded
// TODO: Throw exception
}
super.pointer = load0(file, desc, format.valueOf(), ((NativePointer)cb).pointer);
- // TODO: Check for retval
}
- public void load(String file, SSLCertifficateFormat format)
+ public void load(String file, SSLCertificateFormat format)
+ throws InvalidDataException
{
if (super.pointer != 0L) {
// Already loaded
// TODO: Throw exception
}
super.pointer = load0(file, desc, format.valueOf(), 0L);
- // TODO: Check for retval
+ }
+
+ public void load(String file, SSLCertificateFormat format, String password)
+ throws InvalidDataException
+ {
+ if (super.pointer != 0L) {
+ // Already loaded
+ // TODO: Throw exception
+ }
+ super.pointer = load1(file, desc, format.valueOf(), password);
}
}
Copied: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertificateFormat.java (from r1171512, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertifficateFormat.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertificateFormat.java?p2=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertificateFormat.java&p1=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertifficateFormat.java&r1=1171512&r2=1171651&rev=1171651&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertifficateFormat.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLCertificateFormat.java Fri Sep 16 16:35:43 2011
@@ -19,7 +19,7 @@ package org.apache.commons.runtime.ssl;
/**
* Represents the SSL certificate format.
*/
-public enum SSLCertifficateFormat
+public enum SSLCertificateFormat
{
/**
@@ -40,7 +40,7 @@ public enum SSLCertifficateFormat
PKCS12( 5);
private int value;
- private SSLCertifficateFormat(int v)
+ private SSLCertificateFormat(int v)
{
value = v;
}
@@ -50,9 +50,9 @@ public enum SSLCertifficateFormat
return value;
}
- public static SSLCertifficateFormat valueOf(int value)
+ public static SSLCertificateFormat valueOf(int value)
{
- for (SSLCertifficateFormat e : values()) {
+ for (SSLCertificateFormat e : values()) {
if (e.value == value)
return e;
}
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLKey.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLKey.java?rev=1171651&r1=1171650&r2=1171651&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLKey.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/ssl/SSLKey.java Fri Sep 16 16:35:43 2011
@@ -17,12 +17,8 @@
package org.apache.commons.runtime.ssl;
import org.apache.commons.runtime.InvalidArgumentException;
-import org.apache.commons.runtime.OperationNotImplementedException;
-import org.apache.commons.runtime.Status;
-import org.apache.commons.runtime.SystemException;
-
+import org.apache.commons.runtime.InvalidDataException;
import java.io.File;
-import java.nio.ByteBuffer;
/**
* SSL Key.
@@ -34,7 +30,10 @@ public final class SSLKey extends Native
private final long pointer = 0L;
private final String desc;
- private static native long load0(String file, String desc, int format, long pcb);
+ private static native long load0(String file, String desc, int format, long pcb)
+ throws InvalidDataException;
+ private static native long load1(String file, String desc, int format, String password)
+ throws InvalidDataException;
private SSLKey()
{
@@ -51,23 +50,33 @@ public final class SSLKey extends Native
}
public void load(String file, SSLKeyFormat format, PasswordCallback cb)
+ throws InvalidDataException
{
if (super.pointer != 0L) {
// Already loaded
// TODO: Throw exception
}
super.pointer = load0(file, desc, format.valueOf(), ((NativePointer)cb).pointer);
- // TODO: Check for retval
+ }
+
+ public void load(String file, SSLKeyFormat format, String password)
+ throws InvalidDataException
+ {
+ if (super.pointer != 0L) {
+ // Already loaded
+ // TODO: Throw exception
+ }
+ super.pointer = load1(file, desc, format.valueOf(), password);
}
public void load(String file, SSLKeyFormat format)
+ throws InvalidDataException
{
if (super.pointer != 0L) {
// Already loaded
// TODO: Throw exception
}
super.pointer = load0(file, desc, format.valueOf(), 0L);
- // TODO: Check for retval
}
}
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/ssl.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/ssl.h?rev=1171651&r1=1171650&r2=1171651&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/ssl.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/ssl.h Fri Sep 16 16:35:43 2011
@@ -283,8 +283,8 @@ typedef struct ssl_pass_cb_t {
char *password;
int password_len;
const char *desc;
- char buf[256];
acr_callback_t *cb;
+ char buf[256];
} ssl_pass_cb_t;
/* Default password callback that
@@ -305,7 +305,7 @@ typedef struct acr_ssl_ctxt_t {
int ssl_proxy;
/* certificate revocation list */
- X509_STORE *crl;
+ X509_STORE *crls;
/* pointer to the context verify store */
X509_STORE *store;
X509 *certs[SSL_AIDX_MAX];
Modified: commons/sandbox/runtime/trunk/src/main/native/modules/openssl/cert.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/modules/openssl/cert.c?rev=1171651&r1=1171650&r2=1171651&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/modules/openssl/cert.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/modules/openssl/cert.c Fri Sep 16 16:35:43 2011
@@ -72,8 +72,36 @@ ACR_SSL_EXPORT(jlong, SSLCertificate, lo
WITH_CSTR(desc) {
/* Load key */
cert = load_cert(cb, format, J2S(file), J2S(desc));
+ if (cert == 0)
+ ssl_throw_errno(env, ACR_EX_EILSEQ);
} DONE_WITH_STR(desc);
} DONE_WITH_STR(file);
return P2J(cert);
}
+
+ACR_SSL_EXPORT(jlong, SSLCertificate, load1)(JNI_STDARGS, jstring file,
+ jstring desc,
+ jint format,
+ jstring password)
+{
+ ssl_pass_cb_t cb = { 0, -1, 0, 0 };
+ X509 *cert = 0;
+
+ WITH_CSTR(file) {
+ WITH_CSTR(desc) {
+ WITH_CSTR(password) {
+ if (J2S(password) != 0) {
+ cb.password = J2S(password);
+ cb.password_len = strlen(J2S(password));
+ }
+ /* Load key */
+ cert = load_cert(&cb, format, J2S(file), J2S(desc));
+ if (cert == 0)
+ ssl_throw_errno(env, ACR_EX_EILSEQ);
+ } DONE_WITH_STR(password);
+ } DONE_WITH_STR(desc);
+ } DONE_WITH_STR(file);
+
+ return P2J(cert);
+}
Modified: commons/sandbox/runtime/trunk/src/main/native/modules/openssl/key.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/modules/openssl/key.c?rev=1171651&r1=1171650&r2=1171651&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/modules/openssl/key.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/modules/openssl/key.c Fri Sep 16 16:35:43 2011
@@ -73,8 +73,36 @@ ACR_SSL_EXPORT(jlong, SSLKey, load0)(JNI
WITH_CSTR(desc) {
/* Load key */
key = load_key(cb, format, J2S(file), J2S(desc));
+ if (key == 0)
+ ssl_throw_errno(env, ACR_EX_EILSEQ);
} DONE_WITH_STR(desc);
} DONE_WITH_STR(file);
return P2J(key);
}
+
+ACR_SSL_EXPORT(jlong, SSLKey, load1)(JNI_STDARGS, jstring file,
+ jstring desc,
+ jint format,
+ jstring password)
+{
+ ssl_pass_cb_t cb = { 0, -1, 0, 0 };
+ EVP_PKEY *key = 0;
+
+ WITH_CSTR(file) {
+ WITH_CSTR(desc) {
+ WITH_CSTR(password) {
+ if (J2S(password) != 0) {
+ cb.password = J2S(password);
+ cb.password_len = strlen(J2S(password));
+ }
+ /* Load key */
+ key = load_key(&cb, format, J2S(file), J2S(desc));
+ if (key == 0)
+ ssl_throw_errno(env, ACR_EX_EILSEQ);
+ } DONE_WITH_STR(password);
+ } DONE_WITH_STR(desc);
+ } DONE_WITH_STR(file);
+
+ return P2J(key);
+}