Author: klape
Date: 2012-07-16 16:30:51 -0400 (Mon, 16 Jul 2012)
New Revision: 16472
Added:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wssecurity/IssuerMatchTestCase.java
Modified:
stack/native/branches/jbossws-native-3.1.2/
stack/native/branches/jbossws-native-3.1.2/modules/core/
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/
Log:
[JBPAPP-7982] Enhance X509 certificate issuer comparison
Property changes on: stack/native/branches/jbossws-native-3.1.2
___________________________________________________________________
Modified: svn:mergeinfo
- /stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP-8128:15667
/stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP6864:14776-14778,14786,14894,14905,14907-14908
/stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365:14192
/stack/native/branches/jbossws-native-3.4.0.SP1:13928,13933,13936,13946
/stack/native/trunk:12502,13992,14157,14160,14181,14183,14842
+ /stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP-8128:15667
/stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP6864:14776-14778,14786,14894,14905,14907-14908
/stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365:14192
/stack/native/branches/jbossws-native-3.1.2.SP7_JBPAPP-8007:15579
/stack/native/branches/jbossws-native-3.4.0.SP1:13928,13933,13936,13946
/stack/native/trunk:12502,13992,14157,14160,14181,14183,14842
Property changes on: stack/native/branches/jbossws-native-3.1.2/modules/core
___________________________________________________________________
Modified: svn:mergeinfo
- /stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP-8128/modules/core:15667
/stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP6864/modules/core:14776-14778,14786,14894,14905,14907-14908
/stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365/modules/core:14192
/stack/native/branches/jbossws-native-3.4.0.SP1/modules/core:13928,13933,13936,13946
/stack/native/trunk/modules/core:12502,13992,14011,14157,14160,14181,14183,14842
+ /stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP-8128/modules/core:15667
/stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP6864/modules/core:14776-14778,14786,14894,14905,14907-14908
/stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365/modules/core:14192
/stack/native/branches/jbossws-native-3.1.2.SP7_JBPAPP-8007/modules/core:15579
/stack/native/branches/jbossws-native-3.4.0.SP1/modules/core:13928,13933,13936,13946
/stack/native/trunk/modules/core:12502,13992,14011,14157,14160,14181,14183,14842
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java 2012-07-16
18:24:36 UTC (rev 16471)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/extensions/security/SecurityStore.java 2012-07-16
20:30:51 UTC (rev 16472)
@@ -50,6 +50,8 @@
import java.util.Properties;
import java.util.StringTokenizer;
+import javax.security.auth.x500.X500Principal;
+
import org.jboss.logging.Logger;
import org.jboss.ws.extensions.security.exception.FailedAuthenticationException;
import org.jboss.ws.extensions.security.exception.WSSecurityException;
@@ -492,11 +494,12 @@
continue;
X509Certificate x509 = (X509Certificate)cert;
- if (issuer.equals(x509.getIssuerDN().toString()) &&
serial.equals(x509.getSerialNumber().toString()))
+ X500Principal principal = new X500Principal(issuer);
+ if (principal.equals(x509.getIssuerX500Principal()) &&
serial.equals(x509.getSerialNumber().toString()))
return x509;
}
}
- catch (KeyStoreException e)
+ catch (Exception e)
{
throw new WSSecurityException("Problems retrieving cert: " +
e.getMessage(), e);
}
Property changes on:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests
___________________________________________________________________
Modified: svn:mergeinfo
-
/stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP-8128/modules/testsuite/native-tests:15667
/stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP6864/modules/testsuite/native-tests:14776-14778,14786,14894,14905,14907-14908
/stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365/modules/testsuite/native-tests:14192
/stack/native/branches/jbossws-native-3.4.0.SP1/modules/testsuite/native-tests:13928,13933,13936,13946
/stack/native/trunk/modules/testsuite/native-tests:12502,13992,14013,14157,14160,14181,14183,14842
+
/stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP-8128/modules/testsuite/native-tests:15667
/stack/native/branches/jbossws-native-3.1.2.SP10_JBPAPP6864/modules/testsuite/native-tests:14776-14778,14786,14894,14905,14907-14908
/stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365/modules/testsuite/native-tests:14192
/stack/native/branches/jbossws-native-3.1.2.SP7_JBPAPP-8007/modules/testsuite/native-tests:15579
/stack/native/branches/jbossws-native-3.4.0.SP1/modules/testsuite/native-tests:13928,13933,13936,13946
/stack/native/trunk/modules/testsuite/native-tests:12502,13992,14013,14157,14160,14181,14183,14842
Copied:
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wssecurity/IssuerMatchTestCase.java
(from rev 15579,
stack/native/branches/jbossws-native-3.1.2.SP7_JBPAPP-8007/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wssecurity/IssuerMatchTestCase.java)
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wssecurity/IssuerMatchTestCase.java
(rev 0)
+++
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wssecurity/IssuerMatchTestCase.java 2012-07-16
20:30:51 UTC (rev 16472)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.wssecurity;
+
+import java.net.URL;
+import java.security.cert.X509Certificate;
+
+import org.jboss.ws.extensions.security.SecurityStore;
+import org.jboss.ws.metadata.wsse.WSSecurityConfiguration;
+
+import org.jboss.wsf.test.JBossWSTest;
+
+public class IssuerMatchTestCase extends JBossWSTest
+{
+ public void testIssuerMatch() throws Exception
+ {
+ //The space at the beginning of the issuer string causes
+ //the signer to not match exactly
+ //TODO: get these values from the certificate
+ String issuer = " EMAILADDRESS=admin(a)jboss.com,
CN=jboss.com, OU=QA, O=JBoss
Inc., L=Snoqualmie Pass, ST=Washington, C=US";
+ String serial = "3";
+
+ URL keystoreUrl =
getResourceURL("jaxws/samples/wssecurity/wsse.keystore");
+ WSSecurityConfiguration config = new WSSecurityConfiguration();
+ config.setKeyStoreURL(keystoreUrl);
+ config.setKeyStoreType("jks");
+ config.setKeyStorePassword("jbossws");
+ SecurityStore store = new SecurityStore(config);
+ X509Certificate cert = store.getCertificateByIssuerSerial(issuer, serial);
+
+ assertNotNull("Certificate null?", cert);
+ }
+}