Author: jaz
Date: Mon May 7 17:43:09 2007 New Revision: 536035 URL: http://svn.apache.org/viewvc?view=rev&rev=536035 Log: small changes to re-use better code already available in keystoreutil Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/SSLUtil.java Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java?view=diff&rev=536035&r1=536034&r2=536035 ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java Mon May 7 17:43:09 2007 @@ -104,8 +104,15 @@ return (X509Certificate) cf.generateCertificate(bais); } - public static Map getCertX500Map(X509Certificate cert) { - X500Principal x500 = cert.getSubjectX500Principal(); + public static Map getCertX500Map(java.security.cert.X509Certificate cert) { + return getX500Map(cert.getSubjectX500Principal()); + } + + public static Map getCertX500Map(javax.security.cert.X509Certificate cert) { + return getX500Map(cert.getSubjectDN()); + } + + public static Map getX500Map(Principal x500) { Map x500Map = FastMap.newInstance(); String name = x500.getName().replaceAll("\\\\,", "&com;"); Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/SSLUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/SSLUtil.java?view=diff&rev=536035&r1=536034&r2=536035 ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/SSLUtil.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/SSLUtil.java Mon May 7 17:43:09 2007 @@ -25,6 +25,7 @@ import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.SecureRandom; +import java.security.Principal; import java.security.cert.X509Certificate; import java.security.cert.CertificateException; import java.util.*; @@ -193,17 +194,12 @@ return false; } for (int i = 0; i < peerCerts.length; i++) { - Map certMap = new HashMap(); - String name = peerCerts[i].getSubjectDN().getName(); - String[] sections = name.split("\\,"); - for (int si = 0; si < sections.length; si++) { - String[] nv = sections[si].split("\\="); - for (int nvi = 0; nvi < nv.length; nvi++) { - certMap.put(nv[0], nv[1]); - } - } + Principal x500s = peerCerts[i].getSubjectDN(); + Map subjectMap = KeyStoreUtil.getX500Map(x500s); - Debug.log(peerCerts[i].getSerialNumber().toString(16) + " :: " + certMap.get("CN"), module); + if (Debug.infoOn()) + Debug.logInfo(peerCerts[i].getSerialNumber().toString(16) + " :: " + subjectMap.get("CN"), module); + try { peerCerts[i].checkValidity(); } catch (Exception e) { |
Free forum by Nabble | Edit this page |