knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject knox git commit: KNOX-523 - Java 8 compatibility
Date Thu, 26 Mar 2015 02:52:00 GMT
Repository: knox
Updated Branches:
  refs/heads/master 3ba341a31 -> 887a49a87


KNOX-523 - Java 8 compatibility

Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/887a49a8
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/887a49a8
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/887a49a8

Branch: refs/heads/master
Commit: 887a49a879738abba4eba2984095309bc3ea740b
Parents: 3ba341a
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Wed Mar 25 22:51:51 2015 -0400
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Wed Mar 25 22:51:51 2015 -0400

----------------------------------------------------------------------
 .../security/impl/X509CertificateUtil.java      | 42 +++++++++++++-------
 1 file changed, 28 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/887a49a8/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/X509CertificateUtil.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/X509CertificateUtil.java
b/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/X509CertificateUtil.java
index 17c75cf..eb777f0 100644
--- a/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/X509CertificateUtil.java
+++ b/gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/X509CertificateUtil.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.gateway.services.security.impl;
 import java.io.IOException;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.math.BigInteger;
 import java.security.GeneralSecurityException;
@@ -27,6 +28,7 @@ import java.security.KeyPair;
 import java.security.PrivateKey;
 import java.security.PublicKey;
 import java.security.SecureRandom;
+import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
 import java.util.Date;
 
@@ -86,22 +88,34 @@ public class X509CertificateUtil {
 				certificateSerialNumberObject);
 
     // info.set(X509CertInfo.SUBJECT, new CertificateSubjectName(owner));
-    Class<?> certificateSubjectNameClass = Class.forName(getCertificateSubjectNameModuleName());
-    Constructor<?> certificateSubjectNameConstr = certificateSubjectNameClass
-				.getConstructor(new Class[] { x500NameClass });
-    Object certificateSubjectNameObject = certificateSubjectNameConstr
-				.newInstance(x500NameObject);
-    methodSET.invoke(certInfoObject, getSetField(certInfoObject, "SUBJECT"),
-				certificateSubjectNameObject);
+    try {
+      Class<?> certificateSubjectNameClass = Class.forName(getCertificateSubjectNameModuleName());
+      Constructor<?> certificateSubjectNameConstr = certificateSubjectNameClass
+  				.getConstructor(new Class[] { x500NameClass });
+      Object certificateSubjectNameObject = certificateSubjectNameConstr
+  				.newInstance(x500NameObject);
+      methodSET.invoke(certInfoObject, getSetField(certInfoObject, "SUBJECT"),
+  				certificateSubjectNameObject);
+    }
+    catch (InvocationTargetException ite) {
+      methodSET.invoke(certInfoObject, getSetField(certInfoObject, "SUBJECT"),
+          x500NameObject);
+    }
 
     // info.set(X509CertInfo.ISSUER, new CertificateIssuerName(owner));
-    Class<?> certificateIssuerNameClass = Class.forName(getCertificateIssuerNameModuleName());
-    Constructor<?> certificateIssuerNameConstr = certificateIssuerNameClass
-				.getConstructor(new Class[] { x500NameClass });
-    Object certificateIssuerNameObject = certificateIssuerNameConstr
-				.newInstance(x500NameObject);
-    methodSET.invoke(certInfoObject, getSetField(certInfoObject, "ISSUER"),
-				certificateIssuerNameObject);
+    try {
+      Class<?> certificateIssuerNameClass = Class.forName(getCertificateIssuerNameModuleName());
+      Constructor<?> certificateIssuerNameConstr = certificateIssuerNameClass
+  				.getConstructor(new Class[] { x500NameClass });
+      Object certificateIssuerNameObject = certificateIssuerNameConstr
+  				.newInstance(x500NameObject);
+      methodSET.invoke(certInfoObject, getSetField(certInfoObject, "ISSUER"),
+  				certificateIssuerNameObject);
+    }
+    catch (InvocationTargetException ite) {
+      methodSET.invoke(certInfoObject, getSetField(certInfoObject, "ISSUER"),
+          x500NameObject);
+    }
 
     // info.set(X509CertInfo.KEY, new CertificateX509Key(pair.getPublic()));
     Class<?> certificateX509KeyClass = Class.forName(getCertificateX509KeyModuleName());


Mime
View raw message