You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by dk...@apache.org on 2009/06/11 23:06:46 UTC
svn commit: r783904 - in /webservices/wss4j/branches/1_5_x-fixes: pom.xml
src/org/apache/ws/security/components/crypto/CryptoBase.java
test/wssec/TestWSSecurityWSS86.java
Author: dkulp
Date: Thu Jun 11 21:06:46 2009
New Revision: 783904
URL: http://svn.apache.org/viewvc?rev=783904&view=rev
Log:
Move bc back to test scope
Modified:
webservices/wss4j/branches/1_5_x-fixes/pom.xml
webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/components/crypto/CryptoBase.java
webservices/wss4j/branches/1_5_x-fixes/test/wssec/TestWSSecurityWSS86.java
Modified: webservices/wss4j/branches/1_5_x-fixes/pom.xml
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/1_5_x-fixes/pom.xml?rev=783904&r1=783903&r2=783904&view=diff
==============================================================================
--- webservices/wss4j/branches/1_5_x-fixes/pom.xml (original)
+++ webservices/wss4j/branches/1_5_x-fixes/pom.xml Thu Jun 11 21:06:46 2009
@@ -174,7 +174,7 @@
!org.apache.ws.axis.security.*,
javax.xml.crypto.*,
org.apache.xml.security.*,
- org.bouncycastle.*,
+ org.bouncycastle.*;resolution:=optional,
org.jcp.xml.dsig.internal.*,
org.opensaml.*;resolution:=optional,
*;resolution:=optional
@@ -344,7 +344,7 @@
<groupId>bouncycastle</groupId>
<artifactId>bcprov-jdk14</artifactId>
<version>${bcprov.jdk14.version}</version>
- <scope>compile</scope>
+ <scope>test</scope>
</dependency>
</dependencies>
</profile>
@@ -358,7 +358,7 @@
<groupId>bouncycastle</groupId>
<artifactId>bcprov-jdk15</artifactId>
<version>${bcprov.jdk15.version}</version>
- <scope>compile</scope>
+ <scope>test</scope>
</dependency>
</dependencies>
</profile>
Modified: webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/components/crypto/CryptoBase.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/components/crypto/CryptoBase.java?rev=783904&r1=783903&r2=783904&view=diff
==============================================================================
--- webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/components/crypto/CryptoBase.java (original)
+++ webservices/wss4j/branches/1_5_x-fixes/src/org/apache/ws/security/components/crypto/CryptoBase.java Thu Jun 11 21:06:46 2009
@@ -20,10 +20,9 @@
import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.WSSecurityException;
-import org.bouncycastle.asn1.x509.X509Name;
-
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.lang.reflect.Constructor;
import java.math.BigInteger;
import java.security.Key;
import java.security.KeyStore;
@@ -58,10 +57,25 @@
*/
public abstract class CryptoBase implements Crypto {
private static Log log = LogFactory.getLog(CryptoBase.class);
+ private static final Constructor BC_509CLASS_CONS;
+
+
protected static Map certFactMap = new HashMap();
protected KeyStore keystore = null;
static String SKI_OID = "2.5.29.14";
protected KeyStore cacerts = null;
+
+ static {
+ Constructor cons = null;
+ try {
+ Class c = Class.forName("org.bouncycastle.asn1.x509.X509Name");
+ cons = c.getConstructor(new Class[] {String.class});
+ } catch (Exception e) {
+ //ignore
+ }
+ BC_509CLASS_CONS = cons;
+ }
+
/**
* Constructor
@@ -253,7 +267,18 @@
public String getAliasForX509Cert(String issuer) throws WSSecurityException {
return getAliasForX509Cert(issuer, null, false);
}
-
+
+
+ private Object createBCX509Name(String s) {
+ if (BC_509CLASS_CONS != null) {
+ try {
+ return BC_509CLASS_CONS.newInstance(new Object[] {s});
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+ return new X500Principal(s);
+ }
/**
* Lookup a X509 Certificate in the keystore according to a given serial number and
* the issuer of a Certificate.
@@ -285,8 +310,7 @@
BigInteger serialNumber,
boolean useSerialNumber
) throws WSSecurityException {
- X500Principal issuerRDN = null;
- X509Name issuerName = null;
+ Object issuerName = null;
Certificate cert = null;
//
@@ -298,10 +322,10 @@
// back on a direct conversion to a BC X509Name
//
try {
- issuerRDN = new X500Principal(issuer);
- issuerName = new X509Name(issuerRDN.getName());
+ X500Principal issuerRDN = new X500Principal(issuer);
+ issuerName = createBCX509Name(issuerRDN.getName());
} catch (java.lang.IllegalArgumentException ex) {
- issuerName = new X509Name(issuer);
+ issuerName = createBCX509Name(issuer);
}
try {
@@ -322,7 +346,7 @@
}
X509Certificate x509cert = (X509Certificate) cert;
if (!useSerialNumber || x509cert.getSerialNumber().compareTo(serialNumber) == 0) {
- X509Name certName = new X509Name(x509cert.getIssuerDN().getName());
+ Object certName = createBCX509Name(x509cert.getIssuerDN().getName());
if (certName.equals(issuerName)) {
return alias;
}
Modified: webservices/wss4j/branches/1_5_x-fixes/test/wssec/TestWSSecurityWSS86.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/1_5_x-fixes/test/wssec/TestWSSecurityWSS86.java?rev=783904&r1=783903&r2=783904&view=diff
==============================================================================
--- webservices/wss4j/branches/1_5_x-fixes/test/wssec/TestWSSecurityWSS86.java (original)
+++ webservices/wss4j/branches/1_5_x-fixes/test/wssec/TestWSSecurityWSS86.java Thu Jun 11 21:06:46 2009
@@ -108,6 +108,7 @@
AxisClient tmpEngine = new AxisClient(new NullProvider());
msgContext = new MessageContext(tmpEngine);
message = getSOAPMessage();
+ secEngine.getWssConfig(); //make sure BC gets registered
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org