[WSS4J] wss4j/src/org/apache/ws/security/components/crypto Merlin.java,1.8,1.9

[email protected] Thu, 05 Feb 2004 10:28:37 -0800
Newsgroups gmane.text.xml.wss4j
Message-ID <[email protected]>
Update of /cvsroot/wss4j/wss4j/src/org/apache/ws/security/components/crypto
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20391/src/org/apache/ws/security/components/crypto

Modified Files:
	Merlin.java 
Log Message:
Checking in code that was "lost" during the sf.net CVS corruption. (Thanks Jason for finding the problem and sending me the cvs commit emails)


Index: Merlin.java
===================================================================
RCS file: /cvsroot/wss4j/wss4j/src/org/apache/ws/security/components/crypto/Merlin.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Merlin.java	27 Nov 2003 07:43:42 -0000	1.8
--- Merlin.java	5 Feb 2004 18:28:34 -0000	1.9
***************
*** 88,93 ****
      private static Log log = LogFactory.getLog(Merlin.class);
      private static CertificateFactory certFact;
-     protected PrivateKey key = null;
-     protected Certificate[] certs = null;
      private Properties properties = null;
      private KeyStore keystore = null;
--- 88,91 ----
***************
*** 234,252 ****
  
      private boolean equalsStringArray(String[] in1, String[] in2) {
! 	if (in1.length != in2.length) {
! 	    return false;
! 	}
! 	for (int i = 0; i < in1.length; i++) {
! 	    if (in1[i] != null) {
! 		if (!(in1[i].equals(in2[i]))) {
! 		    return false;
! 		}
! 	    }
! 	    // come here if in1[i] is null, check in2[i]
! 	    else if (in2[i] != null) {
! 		return false;
! 	    }
! 	}
! 	return true;
      }
  
--- 232,250 ----
  
      private boolean equalsStringArray(String[] in1, String[] in2) {
!         if (in1.length != in2.length) {
!             return false;
!         }
!         for (int i = 0; i < in1.length; i++) {
!             if (in1[i] != null) {
!                 if (!(in1[i].equals(in2[i]))) {
!                     return false;
!                 }
!             }
!             // come here if in1[i] is null, check in2[i]
!             else if (in2[i] != null) {
!                 return false;
!             }
!         }
!         return true;
      }
  
***************
*** 274,281 ****
       * --- remains to be tested in several ways --
       */
!     public String getAliasForX509Cert(String issuer, BigInteger serialNumber) throws Exception {
! 	String issuerSplit[] = splitAndTrim(issuer);
! 	X509Certificate x509cert = null;
! 	String certIssuer[] = null;
          for (Enumeration e = keystore.aliases(); e.hasMoreElements();) {
              String alias = (String) e.nextElement();
--- 272,280 ----
       * --- remains to be tested in several ways --
       */
!     public String getAliasForX509Cert(String issuer, BigInteger serialNumber)
!             throws Exception {
!         String issuerSplit[] = splitAndTrim(issuer);
!         X509Certificate x509cert = null;
!         String certIssuer[] = null;
          for (Enumeration e = keystore.aliases(); e.hasMoreElements();) {
              String alias = (String) e.nextElement();
***************
*** 285,294 ****
                      continue;
                  }
! 				x509cert = (X509Certificate)certs[i];
                  if (x509cert.getSerialNumber().compareTo(serialNumber) == 0) {
! 		    		certIssuer = splitAndTrim(x509cert.getIssuerDN().getName());
! 		    		if (equalsStringArray(issuerSplit, certIssuer)) {
! 						return alias;
! 		    		}
                  }
              }
--- 284,293 ----
                      continue;
                  }
!                 x509cert = (X509Certificate) certs[i];
                  if (x509cert.getSerialNumber().compareTo(serialNumber) == 0) {
!                     certIssuer = splitAndTrim(x509cert.getIssuerDN().getName());
!                     if (equalsStringArray(issuerSplit, certIssuer)) {
!                         return alias;
!                     }
                  }
              }
***************
*** 322,328 ****
       */
      public X509Certificate[] getCertificates(String alias) throws Exception {
!         certs = keystore.getCertificateChain(alias);
          if (certs == null || certs.length == 0) {
!             return null;
          }
          X509Certificate[] x509certs = new X509Certificate[certs.length];
--- 321,332 ----
       */
      public X509Certificate[] getCertificates(String alias) throws Exception {
!         Certificate[] certs = keystore.getCertificateChain(alias);
          if (certs == null || certs.length == 0) {
!             // no cert chain, so lets check if getCertificate gives us a  result.
!             Certificate cert = keystore.getCertificate(alias);
!             if (cert == null) {
!                 return null;
!             }
!             certs = new Certificate[]{cert};
          }
          X509Certificate[] x509certs = new X509Certificate[certs.length];



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn