You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by mu...@apache.org on 2010/12/30 19:44:17 UTC
svn commit: r1053972 [2/2] - in /santuario/xml-security-java/trunk: ./
data/org/w3c/www/interop/xmldsig11/
data/org/w3c/www/interop/xmldsig11/microsoft/
data/org/w3c/www/interop/xmldsig11/oracle/
data/org/w3c/www/interop/xmldsig11/sun/ libs/ src/org/ap...
Modified: santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java (original)
+++ santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java Thu Dec 30 18:44:13 2010
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2010 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
package org.jcp.xml.dsig.internal.dom;
import javax.xml.crypto.*;
-import javax.xml.crypto.dom.DOMCryptoContext;
import javax.xml.crypto.dsig.*;
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
@@ -32,10 +31,9 @@ import java.security.*;
import java.security.spec.AlgorithmParameterSpec;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
+import org.apache.xml.security.algorithms.implementations.SignatureECDSA;
import org.jcp.xml.dsig.internal.SignerOutputStream;
/**
@@ -43,8 +41,7 @@ import org.jcp.xml.dsig.internal.SignerO
*
* @author Sean Mullan
*/
-public abstract class DOMSignatureMethod extends DOMStructure
- implements SignatureMethod {
+public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
private static Logger log =
Logger.getLogger("org.jcp.xml.dsig.internal.dom");
@@ -56,12 +53,14 @@ public abstract class DOMSignatureMethod
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha384";
final static String RSA_SHA512 =
"http://www.w3.org/2001/04/xmldsig-more#rsa-sha512";
- final static String HMAC_SHA256 =
- "http://www.w3.org/2001/04/xmldsig-more#hmac-sha256";
- final static String HMAC_SHA384 =
- "http://www.w3.org/2001/04/xmldsig-more#hmac-sha384";
- final static String HMAC_SHA512 =
- "http://www.w3.org/2001/04/xmldsig-more#hmac-sha512";
+ final static String ECDSA_SHA1 =
+ "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1";
+ final static String ECDSA_SHA256 =
+ "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256";
+ final static String ECDSA_SHA384 =
+ "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384";
+ final static String ECDSA_SHA512 =
+ "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512";
private SignatureMethodParameterSpec params;
private Signature signature;
@@ -86,7 +85,7 @@ public abstract class DOMSignatureMethod
/**
* Creates a <code>DOMSignatureMethod</code> from an element. This ctor
- * invokes the abstract {@link #unmarshalParams unmarshalParams} method to
+ * invokes the {@link #unmarshalParams unmarshalParams} method to
* unmarshal any algorithm-specific input parameters.
*
* @param smElem a SignatureMethod element
@@ -115,13 +114,21 @@ public abstract class DOMSignatureMethod
return new SHA512withRSA(smElem);
} else if (alg.equals(SignatureMethod.DSA_SHA1)) {
return new SHA1withDSA(smElem);
+ } else if (alg.equals(ECDSA_SHA1)) {
+ return new SHA1withECDSA(smElem);
+ } else if (alg.equals(ECDSA_SHA256)) {
+ return new SHA256withECDSA(smElem);
+ } else if (alg.equals(ECDSA_SHA384)) {
+ return new SHA384withECDSA(smElem);
+ } else if (alg.equals(ECDSA_SHA512)) {
+ return new SHA512withECDSA(smElem);
} else if (alg.equals(SignatureMethod.HMAC_SHA1)) {
return new DOMHMACSignatureMethod.SHA1(smElem);
- } else if (alg.equals(HMAC_SHA256)) {
+ } else if (alg.equals(DOMHMACSignatureMethod.HMAC_SHA256)) {
return new DOMHMACSignatureMethod.SHA256(smElem);
- } else if (alg.equals(HMAC_SHA384)) {
+ } else if (alg.equals(DOMHMACSignatureMethod.HMAC_SHA384)) {
return new DOMHMACSignatureMethod.SHA384(smElem);
- } else if (alg.equals(HMAC_SHA512)) {
+ } else if (alg.equals(DOMHMACSignatureMethod.HMAC_SHA512)) {
return new DOMHMACSignatureMethod.SHA512(smElem);
} else {
throw new MarshalException
@@ -129,84 +136,11 @@ public abstract class DOMSignatureMethod
}
}
- /**
- * Checks if the specified parameters are valid for this algorithm. By
- * default, this method throws an exception if parameters are specified
- * since most SignatureMethod algorithms do not have parameters. Subclasses
- * should override it if they have parameters.
- *
- * @param params the algorithm-specific params (may be <code>null</code>)
- * @throws InvalidAlgorithmParameterException if the parameters are not
- * appropriate for this signature method
- */
- void checkParams(SignatureMethodParameterSpec params)
- throws InvalidAlgorithmParameterException {
- if (params != null) {
- throw new InvalidAlgorithmParameterException("no parameters " +
- "should be specified for the " + getSignatureAlgorithm()
- + " SignatureMethod algorithm");
- }
- }
-
public final AlgorithmParameterSpec getParameterSpec() {
return params;
}
- /**
- * Unmarshals <code>SignatureMethodParameterSpec</code> from the specified
- * <code>Element</code>. By default, this method throws an exception since
- * most SignatureMethod algorithms do not have parameters. Subclasses should
- * override it if they have parameters.
- *
- * @param paramsElem the <code>Element</code> holding the input params
- * @return the algorithm-specific <code>SignatureMethodParameterSpec</code>
- * @throws MarshalException if the parameters cannot be unmarshalled
- */
- SignatureMethodParameterSpec
- unmarshalParams(Element paramsElem) throws MarshalException {
- throw new MarshalException("no parameters should " +
- "be specified for the " + getSignatureAlgorithm() +
- " SignatureMethod algorithm");
- }
-
- /**
- * This method invokes the abstract {@link #marshalParams marshalParams}
- * method to marshal any algorithm-specific parameters.
- */
- public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
- throws MarshalException {
- Document ownerDoc = DOMUtils.getOwnerDocument(parent);
-
- Element smElem = DOMUtils.createElement
- (ownerDoc, "SignatureMethod", XMLSignature.XMLNS, dsPrefix);
- DOMUtils.setAttribute(smElem, "Algorithm", getAlgorithm());
-
- if (params != null) {
- marshalParams(smElem, dsPrefix);
- }
-
- parent.appendChild(smElem);
- }
-
- /**
- * Verifies the passed-in signature with the specified key, using the
- * underlying signature or MAC algorithm.
- *
- * @param key the verification key
- * @param si the DOMSignedInfo
- * @param signature the signature bytes to be verified
- * @param context the XMLValidateContext
- * @return <code>true</code> if the signature verified successfully,
- * <code>false</code> if not
- * @throws NullPointerException if <code>key</code>, <code>si</code> or
- * <code>signature</code> are <code>null</code>
- * @throws InvalidKeyException if the key is improperly encoded, of
- * the wrong type, or parameters are missing, etc
- * @throws SignatureException if an unexpected error occurs, such
- * as the passed in signature is improperly encoded
- * @throws XMLSignatureException if an unexpected error occurs
- */
- boolean verify(Key key, DOMSignedInfo si, byte[] sig,
+ boolean verify(Key key, SignedInfo si, byte[] sig,
XMLValidateContext context) throws InvalidKeyException,
SignatureException, XMLSignatureException {
if (key == null || si == null || sig == null) {
@@ -221,8 +155,8 @@ public abstract class DOMSignatureMethod
Provider p = (Provider) context.getProperty
("org.jcp.xml.dsig.internal.dom.SignatureProvider");
signature = (p == null)
- ? Signature.getInstance(getSignatureAlgorithm())
- : Signature.getInstance(getSignatureAlgorithm(), p);
+ ? Signature.getInstance(getJCAAlgorithm())
+ : Signature.getInstance(getJCAAlgorithm(), p);
} catch (NoSuchAlgorithmException nsae) {
throw new XMLSignatureException(nsae);
}
@@ -232,34 +166,23 @@ public abstract class DOMSignatureMethod
log.log(Level.FINE, "Signature provider:"+ signature.getProvider());
log.log(Level.FINE, "verifying with key: " + key);
}
- si.canonicalize(context, new SignerOutputStream(signature));
+ ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature));
- if (getAlgorithm().equals(SignatureMethod.DSA_SHA1)) {
- try {
+ try {
+ int type = getAlgorithmType();
+ if (type == DSA) {
return signature.verify(convertXMLDSIGtoASN1(sig));
- } catch (IOException ioe) {
- throw new XMLSignatureException(ioe);
+ } else if (type == ECDSA) {
+ return signature.verify(SignatureECDSA.convertXMLDSIGtoASN1(sig));
+ } else {
+ return signature.verify(sig);
}
- } else {
- return signature.verify(sig);
+ } catch (IOException ioe) {
+ throw new XMLSignatureException(ioe);
}
}
- /**
- * Signs the bytes with the specified key, using the underlying
- * signature or MAC algorithm.
- *
- * @param key the signing key
- * @param si the DOMSignedInfo
- * @param context the XMLSignContext
- * @return the signature
- * @throws NullPointerException if <code>key</code> or
- * <code>si</code> are <code>null</code>
- * @throws InvalidKeyException if the key is improperly encoded, of
- * the wrong type, or parameters are missing, etc
- * @throws XMLSignatureException if an unexpected error occurs
- */
- byte[] sign(Key key, DOMSignedInfo si, XMLSignContext context)
+ byte[] sign(Key key, SignedInfo si, XMLSignContext context)
throws InvalidKeyException, XMLSignatureException {
if (key == null || si == null) {
throw new NullPointerException();
@@ -273,8 +196,8 @@ public abstract class DOMSignatureMethod
Provider p = (Provider) context.getProperty
("org.jcp.xml.dsig.internal.dom.SignatureProvider");
signature = (p == null)
- ? Signature.getInstance(getSignatureAlgorithm())
- : Signature.getInstance(getSignatureAlgorithm(), p);
+ ? Signature.getInstance(getJCAAlgorithm())
+ : Signature.getInstance(getJCAAlgorithm(), p);
} catch (NoSuchAlgorithmException nsae) {
throw new XMLSignatureException(nsae);
}
@@ -285,11 +208,14 @@ public abstract class DOMSignatureMethod
log.log(Level.FINE, "Signing with key: " + key);
}
- si.canonicalize(context, new SignerOutputStream(signature));
+ ((DOMSignedInfo)si).canonicalize(context, new SignerOutputStream(signature));
try {
- if (getAlgorithm().equals(SignatureMethod.DSA_SHA1)) {
+ int type = getAlgorithmType();
+ if (type == DSA) {
return convertASN1toXMLDSIG(signature.sign());
+ } else if (type == ECDSA) {
+ return SignatureECDSA.convertASN1toXMLDSIG(signature.sign());
} else {
return signature.sign();
}
@@ -301,52 +227,6 @@ public abstract class DOMSignatureMethod
}
/**
- * Marshals the algorithm-specific parameters to an Element and
- * appends it to the specified parent element. By default, this method
- * throws an exception since most SignatureMethod algorithms do not have
- * parameters. Subclasses should override it if they have parameters.
- *
- * @param parent the parent element to append the parameters to
- * @param paramsPrefix the algorithm parameters prefix to use
- * @throws MarshalException if the parameters cannot be marshalled
- */
- void marshalParams(Element parent, String paramsPrefix)
- throws MarshalException {
- throw new MarshalException("no parameters should " +
- "be specified for the " + getSignatureAlgorithm() +
- " SignatureMethod algorithm");
- }
-
- /**
- * Returns the java.security.Signature standard algorithm name.
- */
- abstract String getSignatureAlgorithm();
-
- /**
- * Returns true if parameters are equal; false otherwise.
- *
- * Subclasses should override this method to compare algorithm-specific
- * parameters.
- */
- boolean paramsEqual(AlgorithmParameterSpec spec) {
- return (getParameterSpec() == spec);
- }
-
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- if (!(o instanceof SignatureMethod)) {
- return false;
- }
- SignatureMethod osm = (SignatureMethod) o;
-
- return (getAlgorithm().equals(osm.getAlgorithm()) &&
- paramsEqual(osm.getParameterSpec()));
- }
-
- /**
* Converts an ASN.1 DSA value to a XML Signature DSA Value.
*
* The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
@@ -441,11 +321,6 @@ public abstract class DOMSignatureMethod
return asn1Bytes;
}
- public int hashCode() {
- assert false : "hashCode not designed";
- return 57;
- }
-
static final class SHA1withRSA extends DOMSignatureMethod {
SHA1withRSA(AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException {
@@ -457,9 +332,12 @@ public abstract class DOMSignatureMethod
public String getAlgorithm() {
return SignatureMethod.RSA_SHA1;
}
- String getSignatureAlgorithm() {
+ String getJCAAlgorithm() {
return "SHA1withRSA";
}
+ int getAlgorithmType() {
+ return RSA;
+ }
}
static final class SHA256withRSA extends DOMSignatureMethod {
@@ -473,9 +351,12 @@ public abstract class DOMSignatureMethod
public String getAlgorithm() {
return RSA_SHA256;
}
- String getSignatureAlgorithm() {
+ String getJCAAlgorithm() {
return "SHA256withRSA";
}
+ int getAlgorithmType() {
+ return RSA;
+ }
}
static final class SHA384withRSA extends DOMSignatureMethod {
@@ -489,9 +370,12 @@ public abstract class DOMSignatureMethod
public String getAlgorithm() {
return RSA_SHA384;
}
- String getSignatureAlgorithm() {
+ String getJCAAlgorithm() {
return "SHA384withRSA";
}
+ int getAlgorithmType() {
+ return RSA;
+ }
}
static final class SHA512withRSA extends DOMSignatureMethod {
@@ -505,9 +389,12 @@ public abstract class DOMSignatureMethod
public String getAlgorithm() {
return RSA_SHA512;
}
- String getSignatureAlgorithm() {
+ String getJCAAlgorithm() {
return "SHA512withRSA";
}
+ int getAlgorithmType() {
+ return RSA;
+ }
}
static final class SHA1withDSA extends DOMSignatureMethod {
@@ -521,8 +408,87 @@ public abstract class DOMSignatureMethod
public String getAlgorithm() {
return SignatureMethod.DSA_SHA1;
}
- String getSignatureAlgorithm() {
+ String getJCAAlgorithm() {
return "SHA1withDSA";
}
+ int getAlgorithmType() {
+ return DSA;
+ }
+ }
+
+ static final class SHA1withECDSA extends DOMSignatureMethod {
+ SHA1withECDSA(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException {
+ super(params);
+ }
+ SHA1withECDSA(Element dmElem) throws MarshalException {
+ super(dmElem);
+ }
+ public String getAlgorithm() {
+ return ECDSA_SHA1;
+ }
+ String getJCAAlgorithm() {
+ return "SHA1withECDSA";
+ }
+ int getAlgorithmType() {
+ return ECDSA;
+ }
+ }
+
+ static final class SHA256withECDSA extends DOMSignatureMethod {
+ SHA256withECDSA(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException {
+ super(params);
+ }
+ SHA256withECDSA(Element dmElem) throws MarshalException {
+ super(dmElem);
+ }
+ public String getAlgorithm() {
+ return ECDSA_SHA256;
+ }
+ String getJCAAlgorithm() {
+ return "SHA256withECDSA";
+ }
+ int getAlgorithmType() {
+ return ECDSA;
+ }
+ }
+
+ static final class SHA384withECDSA extends DOMSignatureMethod {
+ SHA384withECDSA(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException {
+ super(params);
+ }
+ SHA384withECDSA(Element dmElem) throws MarshalException {
+ super(dmElem);
+ }
+ public String getAlgorithm() {
+ return ECDSA_SHA384;
+ }
+ String getJCAAlgorithm() {
+ return "SHA384withECDSA";
+ }
+ int getAlgorithmType() {
+ return ECDSA;
+ }
+ }
+
+ static final class SHA512withECDSA extends DOMSignatureMethod {
+ SHA512withECDSA(AlgorithmParameterSpec params)
+ throws InvalidAlgorithmParameterException {
+ super(params);
+ }
+ SHA512withECDSA(Element dmElem) throws MarshalException {
+ super(dmElem);
+ }
+ public String getAlgorithm() {
+ return ECDSA_SHA512;
+ }
+ String getJCAAlgorithm() {
+ return "SHA512withECDSA";
+ }
+ int getAlgorithmType() {
+ return ECDSA;
+ }
}
}
Modified: santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java (original)
+++ santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java Thu Dec 30 18:44:13 2010
@@ -143,9 +143,4 @@ public final class DOMSignaturePropertie
return (properties.equals(osp.getProperties()) && idsEqual);
}
-
- public int hashCode() {
- assert false : "hashCode not designed";
- return 49;
- }
}
Modified: santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java (original)
+++ santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java Thu Dec 30 18:44:13 2010
@@ -155,11 +155,6 @@ public final class DOMSignatureProperty
target.equals(osp.getTarget()) && idsEqual);
}
- public int hashCode() {
- assert false : "hashCode not designed";
- return 50;
- }
-
private boolean equalsContent(List otherContent) {
int osize = otherContent.size();
if (content.size() != osize) {
Modified: santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java (original)
+++ santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java Thu Dec 30 18:44:13 2010
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2009 The Apache Software Foundation.
+ * Copyright 2005-2010 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -220,8 +220,7 @@ public final class DOMSignedInfo extends
dcm.marshal(siElem, dsPrefix, context);
// create and append SignatureMethod element
- ((DOMSignatureMethod) signatureMethod).marshal
- (siElem, dsPrefix, context);
+ ((DOMStructure) signatureMethod).marshal(siElem, dsPrefix, context);
// create and append Reference elements
for (int i = 0, size = references.size(); i < size; i++) {
@@ -253,9 +252,4 @@ public final class DOMSignedInfo extends
&& signatureMethod.equals(osi.getSignatureMethod()) &&
references.equals(osi.getReferences()) && idEqual);
}
-
- public int hashCode() {
- assert false : "hashCode not designed";
- return 59;
- }
}
Modified: santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMTransform.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMTransform.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMTransform.java (original)
+++ santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMTransform.java Thu Dec 30 18:44:13 2010
@@ -162,11 +162,6 @@ public class DOMTransform extends DOMStr
(getParameterSpec(), otransform.getParameterSpec()));
}
- public int hashCode() {
- assert false : "hashCode not designed";
- return 58;
- }
-
/**
* Transforms the specified data using the underlying transform algorithm.
* This method invokes the {@link #marshal marshal} method and passes it
Modified: santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMX509Data.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMX509Data.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMX509Data.java (original)
+++ santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMX509Data.java Thu Dec 30 18:44:13 2010
@@ -278,9 +278,4 @@ public final class DOMX509Data extends D
return true;
}
-
- public int hashCode() {
- assert false : "hashCode not designed";
- return 56;
- }
}
Modified: santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java (original)
+++ santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java Thu Dec 30 18:44:13 2010
@@ -117,9 +117,4 @@ public final class DOMX509IssuerSerial e
return (issuerName.equals(ois.getIssuerName()) &&
serialNumber.equals(ois.getSerialNumber()));
}
-
- public int hashCode() {
- assert false : "hashCode not designed";
- return 52;
- }
}
Modified: santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java (original)
+++ santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java Thu Dec 30 18:44:13 2010
@@ -183,11 +183,6 @@ public final class DOMXMLObject extends
equalsContent(oxo.getContent()));
}
- public int hashCode() {
- assert false : "hashCode not designed";
- return 53;
- }
-
private boolean equalsContent(List otherContent) {
if (content.size() != otherContent.size()) {
return false;
Modified: santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java (original)
+++ santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java Thu Dec 30 18:44:13 2010
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2009 The Apache Software Foundation.
+ * Copyright 2005-2010 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -386,16 +386,14 @@ public final class DOMXMLSignature exten
}
// calculate signature value
- byte[] val = null;
try {
- val = ((DOMSignatureMethod) si.getSignatureMethod()).sign
- (signingKey, (DOMSignedInfo) si, signContext);
+ byte[] val = ((AbstractDOMSignatureMethod)
+ si.getSignatureMethod()).sign(signingKey, si, signContext);
+ ((DOMSignatureValue) sv).setValue(val);
} catch (InvalidKeyException ike) {
throw new XMLSignatureException(ike);
}
- ((DOMSignatureValue) sv).setValue(val);
-
this.localSigElem = sigElem;
this.ksr = ksr;
}
@@ -422,11 +420,6 @@ public final class DOMXMLSignature exten
objects.equals(osig.getObjects()));
}
- public int hashCode() {
- assert false : "hashCode not designed";
- return 54;
- }
-
private void digestReference(DOMReference ref, XMLSignContext signContext)
throws XMLSignatureException {
if (ref.isDigested()) {
@@ -531,8 +524,8 @@ public final class DOMXMLSignature exten
// canonicalize SignedInfo and verify signature
try {
- validationStatus = ((DOMSignatureMethod) sm).verify
- (validationKey, (DOMSignedInfo) si, value, validateContext);
+ validationStatus = ((AbstractDOMSignatureMethod) sm).verify
+ (validationKey, si, value, validateContext);
} catch (Exception e) {
throw new XMLSignatureException(e);
}
@@ -558,12 +551,6 @@ public final class DOMXMLSignature exten
//XXX compare signature values?
return idEqual;
}
-
- public int hashCode() {
- // uncomment when JDK 1.4 is required
- // assert false : "hashCode not designed";
- return 55;
- }
public void marshal(Node parent, String dsPrefix,
DOMCryptoContext context) throws MarshalException {
Modified: santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java (original)
+++ santuario/xml-security-java/trunk/src/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java Thu Dec 30 18:44:13 2010
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2009 The Apache Software Foundation.
+ * Copyright 2005-2010 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -216,12 +216,20 @@ public final class DOMXMLSignatureFactor
return new DOMSignatureMethod.SHA1withDSA(params);
} else if (algorithm.equals(SignatureMethod.HMAC_SHA1)) {
return new DOMHMACSignatureMethod.SHA1(params);
- } else if (algorithm.equals(DOMSignatureMethod.HMAC_SHA256)) {
+ } else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA256)) {
return new DOMHMACSignatureMethod.SHA256(params);
- } else if (algorithm.equals(DOMSignatureMethod.HMAC_SHA384)) {
+ } else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA384)) {
return new DOMHMACSignatureMethod.SHA384(params);
- } else if (algorithm.equals(DOMSignatureMethod.HMAC_SHA512)) {
+ } else if (algorithm.equals(DOMHMACSignatureMethod.HMAC_SHA512)) {
return new DOMHMACSignatureMethod.SHA512(params);
+ } else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA1)) {
+ return new DOMSignatureMethod.SHA1withECDSA(params);
+ } else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA256)) {
+ return new DOMSignatureMethod.SHA256withECDSA(params);
+ } else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA384)) {
+ return new DOMSignatureMethod.SHA384withECDSA(params);
+ } else if (algorithm.equals(DOMSignatureMethod.ECDSA_SHA512)) {
+ return new DOMSignatureMethod.SHA512withECDSA(params);
} else {
throw new NoSuchAlgorithmException("unsupported algorithm");
}
Modified: santuario/xml-security-java/trunk/src_samples/javax/xml/crypto/dsig/samples/Validate.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src_samples/javax/xml/crypto/dsig/samples/Validate.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src_samples/javax/xml/crypto/dsig/samples/Validate.java (original)
+++ santuario/xml-security-java/trunk/src_samples/javax/xml/crypto/dsig/samples/Validate.java Thu Dec 30 18:44:13 2010
@@ -14,7 +14,6 @@
* limitations under the License.
*
*/
-package javax.xml.crypto.dsig.samples;
import javax.xml.crypto.*;
import javax.xml.crypto.dsig.*;
@@ -137,6 +136,9 @@ public class Validate {
} else if (algName.equalsIgnoreCase("RSA") &&
algURI.equalsIgnoreCase(SignatureMethod.RSA_SHA1)) {
return true;
+ } else if (algName.equalsIgnoreCase("EC") &&
+ algURI.equalsIgnoreCase("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256")) {
+ return true;
} else {
return false;
}
Modified: santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/KeySelectors.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/KeySelectors.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/KeySelectors.java (original)
+++ santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/KeySelectors.java Thu Dec 30 18:44:13 2010
@@ -153,27 +153,11 @@ public class KeySelectors {
} catch (KeyException ke) {
throw new KeySelectorException(ke);
}
- // make sure algorithm is compatible with method
- if (algEquals(sm.getAlgorithm(), pk.getAlgorithm())) {
- return new SimpleKSResult(pk);
- }
+ return new SimpleKSResult(pk);
}
}
throw new KeySelectorException("No KeyValue element found!");
}
-
- //@@@FIXME: this should also work for key types other than DSA/RSA
- static boolean algEquals(String algURI, String algName) {
- if (algName.equalsIgnoreCase("DSA") &&
- algURI.equalsIgnoreCase(SignatureMethod.DSA_SHA1)) {
- return true;
- } else if (algName.equalsIgnoreCase("RSA") &&
- algURI.equalsIgnoreCase(SignatureMethod.RSA_SHA1)) {
- return true;
- } else {
- return false;
- }
- }
}
/**
Copied: santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java (from r996118, xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java)
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java?p2=santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java&p1=xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java&r1=996118&r2=1053972&rev=1053972&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java (original)
+++ santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/dsig/CreateInteropXMLDSig11Test.java Thu Dec 30 18:44:13 2010
@@ -50,11 +50,14 @@ public class CreateInteropXMLDSig11Test
private KeySelector kvks, sks;
private CanonicalizationMethod withComments, withoutComments;
private DigestMethod sha1, sha256, sha384, sha512;
- private SignatureMethod ecdsaSha1, ecdsaSha256, ecdsaSha384, ecdsaSha512, rsaSha256, rsaSha384, rsaSha512, hmacSha256, hmacSha384, hmacSha512;
- private KeyInfo p256ki, p384ki, p521ki, rsaki, hmacki;
+ private SignatureMethod ecdsaSha1, ecdsaSha256, ecdsaSha384, ecdsaSha512,
+ rsaSha256, rsaSha384, rsaSha512, hmacSha256,
+ hmacSha384, hmacSha512;
+ private KeyInfo p256ki, p384ki, p521ki, rsaki, rsa2048ki, hmacki;
private XMLSignatureFactory fac;
private DocumentBuilder db;
- private KeyPair p256, p384, p521;
+ private KeyPair p256, p384, p521, rsa2048;
+ private boolean ecSupport = true;
static {
Security.insertProviderAt
@@ -64,19 +67,29 @@ public class CreateInteropXMLDSig11Test
public CreateInteropXMLDSig11Test(String name) throws Exception {
super(name);
String fs = File.separator;
- String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
+ String base = System.getProperty("basedir") == null
+ ? "./"
+ : System.getProperty("basedir");
dir = new File(base + fs + "data" + fs
+ "org" + fs + "w3c" + fs + "www" + fs
+ "interop" + fs + "xmldsig11");
// Create KeyPairs
- KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
- kpg.initialize(new ECGenParameterSpec("1.2.840.10045.3.1.7"));
- p256 = kpg.generateKeyPair();
- kpg.initialize(new ECGenParameterSpec("1.3.132.0.34"));
- p384 = kpg.generateKeyPair();
- kpg.initialize(new ECGenParameterSpec("1.3.132.0.35"));
- p521 = kpg.generateKeyPair();
+ try {
+ KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
+ kpg.initialize(new ECGenParameterSpec("1.2.840.10045.3.1.7"));
+ p256 = kpg.generateKeyPair();
+ kpg.initialize(new ECGenParameterSpec("1.3.132.0.34"));
+ p384 = kpg.generateKeyPair();
+ kpg.initialize(new ECGenParameterSpec("1.3.132.0.35"));
+ p521 = kpg.generateKeyPair();
+ } catch (NoSuchAlgorithmException nsae) {
+ // EC not supported on this platform
+ ecSupport = false;
+ }
+ KeyPairGenerator rsakpg = KeyPairGenerator.getInstance("RSA");
+ rsakpg.initialize(2048);
+ rsa2048 = rsakpg.generateKeyPair();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
@@ -91,20 +104,30 @@ public class CreateInteropXMLDSig11Test
(C14NMethodParameterSpec) null);
sha1 = fac.newDigestMethod(DigestMethod.SHA1, null);
sha256 = fac.newDigestMethod(DigestMethod.SHA256, null);
- sha384 = fac.newDigestMethod("http://www.w3.org/2001/04/xmldsig-more#sha384", null);
+ sha384 = fac.newDigestMethod(
+ "http://www.w3.org/2001/04/xmldsig-more#sha384", null);
sha512 = fac.newDigestMethod(DigestMethod.SHA512, null);
- p256ki = kifac.newKeyInfo(Collections.singletonList(kifac.newKeyValue(p256.getPublic())));
- p384ki = kifac.newKeyInfo(Collections.singletonList(kifac.newKeyValue(p384.getPublic())));
- p521ki = kifac.newKeyInfo(Collections.singletonList(kifac.newKeyValue(p521.getPublic())));
- rsaki = kifac.newKeyInfo(Collections.singletonList(kifac.newKeyValue(TestUtils.getPublicKey("RSA"))));
- ecdsaSha1 = fac.newSignatureMethod
- ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1", null);
- ecdsaSha256 = fac.newSignatureMethod
- ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256", null);
- ecdsaSha384 = fac.newSignatureMethod
- ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384", null);
- ecdsaSha512 = fac.newSignatureMethod
- ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512", null);
+ if (ecSupport) {
+ p256ki = kifac.newKeyInfo(Collections.singletonList(
+ kifac.newKeyValue(p256.getPublic())));
+ p384ki = kifac.newKeyInfo(Collections.singletonList(
+ kifac.newKeyValue(p384.getPublic())));
+ p521ki = kifac.newKeyInfo(Collections.singletonList(
+ kifac.newKeyValue(p521.getPublic())));
+ ecdsaSha1 = fac.newSignatureMethod
+ ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1", null);
+ ecdsaSha256 = fac.newSignatureMethod
+ ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256", null);
+ ecdsaSha384 = fac.newSignatureMethod
+ ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha384", null);
+ ecdsaSha512 = fac.newSignatureMethod
+ ("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha512", null);
+ }
+ rsaki = kifac.newKeyInfo(Collections.singletonList
+ (kifac.newKeyValue(
+ TestUtils.getPublicKey("RSA"))));
+ rsa2048ki = kifac.newKeyInfo(Collections.singletonList
+ (kifac.newKeyValue(rsa2048.getPublic())));
rsaSha256 = fac.newSignatureMethod
("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", null);
rsaSha384 = fac.newSignatureMethod
@@ -122,7 +145,10 @@ public class CreateInteropXMLDSig11Test
}
public void test_create_enveloping_p256_sha1() throws Exception {
- test_create_signature_enveloping(ecdsaSha1, sha1, p256ki, p256.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha1, sha1, p256ki,
+ p256.getPrivate(), kvks);
+ }
}
private void test_create_signature_enveloping
@@ -173,82 +199,127 @@ public class CreateInteropXMLDSig11Test
}
public void test_create_enveloping_p256_sha256() throws Exception {
- test_create_signature_enveloping(ecdsaSha256, sha256, p256ki, p256.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha256, sha256, p256ki,
+ p256.getPrivate(), kvks);
+ }
}
public void test_create_enveloping_p256_sha384() throws Exception {
- test_create_signature_enveloping(ecdsaSha384, sha384, p256ki, p256.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha384, sha384, p256ki,
+ p256.getPrivate(), kvks);
+ }
}
public void test_create_enveloping_p256_sha512() throws Exception {
- test_create_signature_enveloping(ecdsaSha512, sha512, p256ki, p256.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha512, sha512, p256ki,
+ p256.getPrivate(), kvks);
+ }
}
public void test_create_enveloping_p384_sha1() throws Exception {
- test_create_signature_enveloping(ecdsaSha1, sha1, p384ki, p384.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha1, sha1, p384ki,
+ p384.getPrivate(), kvks);
+ }
}
public void test_create_enveloping_p384_sha256() throws Exception {
- test_create_signature_enveloping(ecdsaSha256, sha256, p384ki, p384.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha256, sha256, p384ki,
+ p384.getPrivate(), kvks);
+ }
}
public void test_create_enveloping_p384_sha384() throws Exception {
- test_create_signature_enveloping(ecdsaSha384, sha384, p384ki, p384.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha384, sha384, p384ki,
+ p384.getPrivate(), kvks);
+ }
}
public void test_create_enveloping_p384_sha512() throws Exception {
- test_create_signature_enveloping(ecdsaSha512, sha512, p384ki, p384.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha512, sha512, p384ki,
+ p384.getPrivate(), kvks);
+ }
}
public void test_create_enveloping_p521_sha1() throws Exception {
- test_create_signature_enveloping(ecdsaSha1, sha1, p521ki, p521.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha1, sha1, p521ki,
+ p521.getPrivate(), kvks);
+ }
}
public void test_create_enveloping_p521_sha256() throws Exception {
- test_create_signature_enveloping(ecdsaSha256, sha256, p521ki, p521.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha256, sha256, p521ki,
+ p521.getPrivate(), kvks);
+ }
}
public void test_create_enveloping_p521_sha384() throws Exception {
- test_create_signature_enveloping(ecdsaSha384, sha384, p521ki, p521.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha384, sha384, p521ki,
+ p521.getPrivate(), kvks);
+ }
}
public void test_create_enveloping_p521_sha512() throws Exception {
- test_create_signature_enveloping(ecdsaSha512, sha512, p521ki, p521.getPrivate(), kvks);
+ if (ecSupport) {
+ test_create_signature_enveloping(ecdsaSha512, sha512, p521ki,
+ p521.getPrivate(), kvks);
+ }
}
public void test_create_enveloping_rsa_sha256() throws Exception {
- test_create_signature_enveloping(rsaSha256, sha1, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+ test_create_signature_enveloping(rsaSha256, sha1, rsaki,
+ TestUtils.getPrivateKey("RSA"), kvks);
}
public void test_create_enveloping_rsa_sha384() throws Exception {
- test_create_signature_enveloping(rsaSha384, sha1, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+ test_create_signature_enveloping(rsaSha384, sha1, rsa2048ki,
+ rsa2048.getPrivate(), kvks);
}
public void test_create_enveloping_rsa_sha512() throws Exception {
- test_create_signature_enveloping(rsaSha512, sha1, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+ test_create_signature_enveloping(rsaSha512, sha1, rsa2048ki,
+ rsa2048.getPrivate(), kvks);
}
public void test_create_enveloping_sha256_rsa_sha256() throws Exception {
- test_create_signature_enveloping(rsaSha256, sha256, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+ test_create_signature_enveloping(rsaSha256, sha256, rsaki,
+ TestUtils.getPrivateKey("RSA"), kvks);
}
public void test_create_enveloping_sha384_rsa_sha256() throws Exception {
- test_create_signature_enveloping(rsaSha256, sha384, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+ test_create_signature_enveloping(rsaSha256, sha384, rsaki,
+ TestUtils.getPrivateKey("RSA"), kvks);
}
public void test_create_enveloping_sha512_rsa_sha256() throws Exception {
- test_create_signature_enveloping(rsaSha256, sha512, rsaki, TestUtils.getPrivateKey("RSA"), kvks);
+ test_create_signature_enveloping(rsaSha256, sha512, rsaki,
+ TestUtils.getPrivateKey("RSA"), kvks);
}
public void test_create_enveloping_hmac_sha256() throws Exception {
- test_create_signature_enveloping(hmacSha256, sha1, rsaki, TestUtils.getSecretKey("testkey".getBytes("ASCII")), sks);
+ test_create_signature_enveloping(hmacSha256, sha1, rsaki,
+ TestUtils.getSecretKey
+ ("testkey".getBytes("ASCII")), sks);
}
public void test_create_enveloping_hmac_sha384() throws Exception {
- test_create_signature_enveloping(hmacSha384, sha1, rsaki, TestUtils.getSecretKey("testkey".getBytes("ASCII")), sks);
+ test_create_signature_enveloping(hmacSha384, sha1, rsaki,
+ TestUtils.getSecretKey
+ ("testkey".getBytes("ASCII")), sks);
}
public void test_create_enveloping_hmac_sha512() throws Exception {
- test_create_signature_enveloping(hmacSha512, sha1, rsaki, TestUtils.getSecretKey("testkey".getBytes("ASCII")), sks);
+ test_create_signature_enveloping(hmacSha512, sha1, rsaki,
+ TestUtils.getSecretKey
+ ("testkey".getBytes("ASCII")), sks);
}
}
Copied: santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java (from r996118, xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java)
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java?p2=santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java&p1=xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java&r1=996118&r2=1053972&rev=1053972&view=diff
==============================================================================
--- xml/security/branches/java_xmldsig11_ecdsa/src_unitTests/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java (original)
+++ santuario/xml-security-java/trunk/src_unitTests/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java Thu Dec 30 18:44:13 2010
@@ -17,6 +17,8 @@
package javax.xml.crypto.test.dsig;
import java.io.File;
+import java.security.KeyFactory;
+import java.security.NoSuchAlgorithmException;
import java.security.Security;
import javax.xml.crypto.KeySelector;
@@ -34,6 +36,7 @@ public class InteropXMLDSig11Test extend
private SignatureValidator validator;
private File dir;
private KeySelector kvks, sks;
+ private boolean ecSupport = true;
static {
Security.insertProviderAt
@@ -42,6 +45,12 @@ public class InteropXMLDSig11Test extend
public InteropXMLDSig11Test(String name) throws Exception {
super(name);
+ // check if EC is supported
+ try {
+ KeyFactory.getInstance("EC");
+ } catch (NoSuchAlgorithmException nsae) {
+ ecSupport = false;
+ }
String fs = File.separator;
String base = System.getProperty("basedir") == null
? "./": System.getProperty("basedir");
@@ -54,51 +63,75 @@ public class InteropXMLDSig11Test extend
}
public void test_enveloping_p256_sha1() throws Exception {
- test_xmldsig11("signature-enveloping-p256_sha1", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p256_sha1", "oracle");
+ }
}
public void test_enveloping_p256_sha256() throws Exception {
- test_xmldsig11("signature-enveloping-p256_sha256", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p256_sha256", "oracle");
+ }
}
public void test_enveloping_p256_sha384() throws Exception {
- test_xmldsig11("signature-enveloping-p256_sha384", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p256_sha384", "oracle");
+ }
}
public void test_enveloping_p256_sha512() throws Exception {
- test_xmldsig11("signature-enveloping-p256_sha512", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p256_sha512", "oracle");
+ }
}
public void test_enveloping_p384_sha1() throws Exception {
- test_xmldsig11("signature-enveloping-p384_sha1", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p384_sha1", "oracle");
+ }
}
public void test_enveloping_p384_sha256() throws Exception {
- test_xmldsig11("signature-enveloping-p384_sha256", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p384_sha256", "oracle");
+ }
}
public void test_enveloping_p384_sha384() throws Exception {
- test_xmldsig11("signature-enveloping-p384_sha384", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p384_sha384", "oracle");
+ }
}
public void test_enveloping_p384_sha512() throws Exception {
- test_xmldsig11("signature-enveloping-p384_sha512", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p384_sha512", "oracle");
+ }
}
public void test_enveloping_p521_sha1() throws Exception {
- test_xmldsig11("signature-enveloping-p521_sha1", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p521_sha1", "oracle");
+ }
}
public void test_enveloping_p521_sha256() throws Exception {
- test_xmldsig11("signature-enveloping-p521_sha256", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p521_sha256", "oracle");
+ }
}
public void test_enveloping_p521_sha384() throws Exception {
- test_xmldsig11("signature-enveloping-p521_sha384", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p521_sha384", "oracle");
+ }
}
public void test_enveloping_p521_sha512() throws Exception {
- test_xmldsig11("signature-enveloping-p521_sha512", "oracle");
+ if (ecSupport) {
+ test_xmldsig11("signature-enveloping-p521_sha512", "oracle");
+ }
}
public void test_enveloping_rsa_sha256() throws Exception {
Modified: santuario/xml-security-java/trunk/src_unitTests/org/apache/xml/security/c14n/implementations/UtfHelperTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src_unitTests/org/apache/xml/security/c14n/implementations/UtfHelperTest.java?rev=1053972&r1=1053971&r2=1053972&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src_unitTests/org/apache/xml/security/c14n/implementations/UtfHelperTest.java (original)
+++ santuario/xml-security-java/trunk/src_unitTests/org/apache/xml/security/c14n/implementations/UtfHelperTest.java Thu Dec 30 18:44:13 2010
@@ -26,7 +26,7 @@ import junit.framework.TestSuite;
public class UtfHelperTest extends TestCase {
public void testBug40156() {
- String s="äöü";
+ String s="\u00e4\u00f6\u00fc";
byte a[]=UtfHelpper.getStringInUtf8(s);
try {
byte correct[]=s.getBytes("UTF8");