You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2015/12/15 18:13:22 UTC
svn commit: r1720201 [12/24] - in /santuario/xml-security-java/trunk:
samples/javax/xml/crypto/dsig/samples/
samples/org/apache/xml/security/samples/
samples/org/apache/xml/security/samples/algorithms/
samples/org/apache/xml/security/samples/canonicali...
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/InteropC14nTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/InteropC14nTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/InteropC14nTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/InteropC14nTest.java Tue Dec 15 17:13:17 2015
@@ -47,7 +47,7 @@ public class InteropC14nTest extends org
base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
base = base + fs + "src/test/resources" + fs + "interop";
}
-
+
@org.junit.Test
public void test_y1_exc_signature() throws Exception {
validator = new SignatureValidator(new File(base, "c14n/Y1"));
@@ -58,7 +58,7 @@ public class InteropC14nTest extends org
assertTrue("Signature failed core validation", coreValidity);
}
-
+
/* COMMENTED OUT since this test requires MD5 support
public void test_y2_signature_joseph_exc() throws Exception {
validator = new SignatureValidator(new File(base, "c14n/Y2"));
@@ -69,7 +69,7 @@ public class InteropC14nTest extends org
assertTrue("Signature failed core validation", coreValidity);
}
*/
-
+
@org.junit.Test
public void test_y3_signature() throws Exception {
validator = new SignatureValidator(new File(base, "c14n/Y3"));
@@ -83,7 +83,7 @@ public class InteropC14nTest extends org
(file, new KeySelectors.RawX509KeySelector());
assertTrue("Signature failed core validation#2", coreValidity);
}
-
+
@org.junit.Test
public void test_y4_signature() throws Exception {
validator = new SignatureValidator(new File(base, "c14n/Y4"));
@@ -97,7 +97,7 @@ public class InteropC14nTest extends org
(file, new KeySelectors.RawX509KeySelector());
assertTrue("Signature failed core validation#2", coreValidity);
}
-
+
@org.junit.Test
@org.junit.Ignore
public void test_y5_signature() throws Exception {
@@ -112,7 +112,7 @@ public class InteropC14nTest extends org
(file, new KeySelectors.RawX509KeySelector());
assertTrue("Signature failed core validation#2", coreValidity);
}
-
+
@org.junit.Test
@org.junit.Ignore
public void test_y5_signatureCommented() throws Exception {
@@ -127,5 +127,5 @@ public class InteropC14nTest extends org
(file, new KeySelectors.RawX509KeySelector());
assertTrue("Signature failed core validation#2", coreValidity);
}
-
+
}
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/InteropXMLDSig11Test.java Tue Dec 15 17:13:17 2015
@@ -202,7 +202,7 @@ public class InteropXMLDSig11Test extend
assertTrue(file + " failed core validation", coreValidity);
}
- private void test_xmldsig11(String test, KeySelector ks, String vendor)
+ private void test_xmldsig11(String test, KeySelector ks, String vendor)
throws Exception {
String file = vendor + File.separator + test + ".xml";
// System.out.println("Validating " + file);
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenRefCountTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenRefCountTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenRefCountTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenRefCountTest.java Tue Dec 15 17:13:17 2015
@@ -40,26 +40,26 @@ public class JSRForbiddenRefCountTest ex
@org.junit.Test
public void testReferenceCount() throws Exception {
- Element signedInfoElement =
+ Element signedInfoElement =
getSignedInfoElement("src/test/resources/interop/c14n/Y4", "signature-manifest.xml");
-
+
InternalDOMCryptoContext context = new InternalDOMCryptoContext();
new DOMSignedInfo(signedInfoElement, context, null);
-
+
context.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.TRUE);
try {
new DOMSignedInfo(signedInfoElement, context, null);
} catch (MarshalException ex) {
- String error =
+ String error =
"A maxiumum of 30 references per Manifest are allowed with secure validation";
assertTrue(ex.getMessage().contains(error));
}
}
-
+
private static class InternalDOMCryptoContext extends DOMCryptoContext {
//
}
-
+
private Element getSignedInfoElement(
String directory, String file
) throws Exception {
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenReferenceTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenReferenceTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenReferenceTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRForbiddenReferenceTest.java Tue Dec 15 17:13:17 2015
@@ -41,8 +41,8 @@ public class JSRForbiddenReferenceTest e
public JSRForbiddenReferenceTest() {
String fs = System.getProperty("file.separator");
String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
-
- dir = new File(base + fs + "src/test/resources" + fs
+
+ dir = new File(base + fs + "src/test/resources" + fs
+ "javax" + fs + "xml" + fs + "crypto", "dsig");
validator = new SignatureValidator(dir);
}
@@ -52,17 +52,17 @@ public class JSRForbiddenReferenceTest e
public void testLocalFilesystem() throws Exception {
String file = "signature-external-c14n-xmlatrs.xml";
- DOMValidateContext vc =
+ DOMValidateContext vc =
validator.getValidateContext(
file, new KeySelectors.SecretKeySelector("secret".getBytes("ASCII"))
);
-
+
vc.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.FALSE);
boolean coreValidity = validator.validate(vc);
assertTrue("Signature failed core validation", coreValidity);
-
+
vc.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.TRUE);
-
+
try {
validator.validate(vc);
fail("Failure expected when secure validation is enabled");
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRWrappingAttackTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRWrappingAttackTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRWrappingAttackTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/JSRWrappingAttackTest.java Tue Dec 15 17:13:17 2015
@@ -45,8 +45,8 @@ public class JSRWrappingAttackTest exten
public JSRWrappingAttackTest() {
String fs = System.getProperty("file.separator");
String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
-
- dir = new File(base + fs + "src/test/resources" + fs
+
+ dir = new File(base + fs + "src/test/resources" + fs
+ "at" + fs + "iaik" + fs + "ixsil" + fs + "coreFeatures", "signatures");
validator = new SignatureValidator(dir);
}
@@ -55,26 +55,26 @@ public class JSRWrappingAttackTest exten
@org.junit.Test
public void testWrappingAttack() throws Exception {
String file = "manifestSignatureWrapping.xml";
-
+
Document doc = XMLUtils.createDocumentBuilder(false, false).parse(new File(dir, file));
Element sigElement = SignatureValidator.getSignatureElement(doc);
if (sigElement == null) {
throw new Exception("Couldn't find signature Element");
}
- DOMValidateContext vc =
+ DOMValidateContext vc =
new DOMValidateContext(new KeySelectors.KeyValueKeySelector(), sigElement);
vc.setBaseURI(dir.toURI().toString());
vc.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.FALSE);
boolean coreValidity = validator.validate(vc);
assertTrue("Signature failed core validation", coreValidity);
-
+
vc.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.TRUE);
-
+
Element manifestElement =
(Element) doc.getElementsByTagName("Manifest").item(0);
vc.setIdAttributeNS(manifestElement, null, "Id");
-
+
try {
boolean valid = validator.validate(vc);
System.out.println("Valid: " + valid);
@@ -83,5 +83,5 @@ public class JSRWrappingAttackTest exten
assertTrue(ex.getMessage().contains("URIReferenceException"));
}
}
-
+
}
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/LocalHttpCacheURIDereferencer.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/LocalHttpCacheURIDereferencer.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/LocalHttpCacheURIDereferencer.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/LocalHttpCacheURIDereferencer.java Tue Dec 15 17:13:17 2015
@@ -32,7 +32,7 @@ import javax.xml.crypto.dsig.XMLSignatur
/**
* This URIDereferencer implementation retrieves http references used in
- * test signatures from local disk in order to avoid network requests.
+ * test signatures from local disk in order to avoid network requests.
*/
public class LocalHttpCacheURIDereferencer implements URIDereferencer {
@@ -42,7 +42,7 @@ public class LocalHttpCacheURIDereferenc
private final Map<String, File> uriMap;
public LocalHttpCacheURIDereferencer() {
- XMLSignatureFactory xmlSignatureFactory =
+ XMLSignatureFactory xmlSignatureFactory =
XMLSignatureFactory.getInstance("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
ud = xmlSignatureFactory.getURIDereferencer();
String base = BASEDIR == null ? "./": BASEDIR;
@@ -56,7 +56,7 @@ public class LocalHttpCacheURIDereferenc
uriMap.put("http://www.ietf.org/rfc/rfc3161.txt",
new File(dir, "rfc3161.txt"));
}
-
+
public Data dereference(URIReference uriReference, XMLCryptoContext context)
throws URIReferenceException {
String uri = uriReference.getURI();
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ManifestTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ManifestTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ManifestTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ManifestTest.java Tue Dec 15 17:13:17 2015
@@ -33,9 +33,9 @@ import javax.xml.crypto.dsig.*;
public class ManifestTest extends org.junit.Assert {
private XMLSignatureFactory fac;
- private static Reference VALID_REF = new
+ private static Reference VALID_REF = new
TestUtils.MyOwnDOMReference("ref#1", true);
- private static Reference INVALID_REF = new
+ private static Reference INVALID_REF = new
TestUtils.MyOwnDOMReference("ref#2", false);
public ManifestTest() {
@@ -50,7 +50,7 @@ public class ManifestTest extends org.ju
String id = "manifest_id";
List<Reference> refs = new ArrayList<Reference>();
// test XMLSignatureFactory.newManifest(List references)
- // and XMLSignatureFactory.newManifest(List references,
+ // and XMLSignatureFactory.newManifest(List references,
// String id)
// for generating Manifest objects
refs.add(VALID_REF);
@@ -73,25 +73,25 @@ public class ManifestTest extends org.ju
assertTrue(Arrays.equals(man.getReferences().toArray(), refs.toArray()));
assertEquals(man.getId(), expectedId);
}
-
+
try {
man = fac.newManifest(null);
fail("Should throw a NPE for null references");
} catch (NullPointerException npe) {
} catch (Exception ex) {
- fail("Should throw a NPE instead of " + ex +
+ fail("Should throw a NPE instead of " + ex +
" for null references");
}
-
+
try {
man = fac.newManifest(null, id);
fail("Should throw a NPE for null references");
} catch (NullPointerException npe) {
} catch (Exception ex) {
- fail("Should throw a NPE instead of " + ex +
+ fail("Should throw a NPE instead of " + ex +
" for null references");
}
-
+
// Clear the references list content
refs.clear();
try {
@@ -99,55 +99,55 @@ public class ManifestTest extends org.ju
fail("Should throw a IAE for empty references");
} catch (IllegalArgumentException iae) {
} catch (Exception ex) {
- fail("Should throw a IAE instead of " + ex +
+ fail("Should throw a IAE instead of " + ex +
" for empty references");
}
-
+
try {
man = fac.newManifest(refs, id);
fail("Should throw a IAE for empty references");
} catch (IllegalArgumentException iae) {
} catch (Exception ex) {
- fail("Should throw a IAE instead of " + ex +
+ fail("Should throw a IAE instead of " + ex +
" for empty references");
}
-
+
// use raw List type to test for invalid Reference entries
List invalidRefs = new ArrayList();
addEntryToRawList(invalidRefs, "references");
try {
fac.newManifest(invalidRefs);
- fail("Should throw a CCE for references containing " +
+ fail("Should throw a CCE for references containing " +
"non-Reference objects");
} catch (ClassCastException cce) {
} catch (Exception ex) {
- fail("Should throw a CCE instead of " + ex +
+ fail("Should throw a CCE instead of " + ex +
" for references containing non-Reference objects");
}
-
+
try {
fac.newManifest(invalidRefs, id);
- fail("Should throw a CCE for references containing " +
+ fail("Should throw a CCE for references containing " +
"non-Reference objects");
} catch (ClassCastException cce) {
} catch (Exception ex) {
- fail("Should throw a CCE instead of " + ex +
+ fail("Should throw a CCE instead of " + ex +
" for references containing non-Reference objects");
}
}
-
+
@org.junit.Test
public void testisFeatureSupported() throws Exception {
List<Reference> refs = new ArrayList<Reference>();
refs.add(VALID_REF);
Manifest man = fac.newManifest(refs);
-
+
try {
- man.isFeatureSupported(null);
- fail("Should raise a NPE for null feature");
+ man.isFeatureSupported(null);
+ fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
-
+
assertTrue(!man.isFeatureSupported("not supported"));
}
@@ -170,7 +170,7 @@ public class ManifestTest extends org.ju
} catch (UnsupportedOperationException ex) {
}
}
-
+
@SuppressWarnings({
"unchecked", "rawtypes"
})
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PKSignatureAlgorithmTest.java Tue Dec 15 17:13:17 2015
@@ -76,7 +76,7 @@ public class PKSignatureAlgorithmTest ex
public PKSignatureAlgorithmTest() throws Exception {
//
- // If the BouncyCastle provider is not installed, then try to load it
+ // If the BouncyCastle provider is not installed, then try to load it
// via reflection.
//
if (Security.getProvider("BC") == null) {
@@ -101,48 +101,48 @@ public class PKSignatureAlgorithmTest ex
} catch (NoSuchAlgorithmException nsae) {
ecAlgParamsSupport = false;
}
-
+
db = XMLUtils.createDocumentBuilder(false);
// create common objects
fac = XMLSignatureFactory.getInstance("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
withoutComments = fac.newCanonicalizationMethod
(CanonicalizationMethod.INCLUSIVE, (C14NMethodParameterSpec) null);
-
+
// Digest Methods
sha1 = fac.newDigestMethod(DigestMethod.SHA1, null);
-
+
rsaSha1 = fac.newSignatureMethod("http://www.w3.org/2000/09/xmldsig#rsa-sha1", null);
rsaSha224 = fac.newSignatureMethod("http://www.w3.org/2001/04/xmldsig-more#rsa-sha224", null);
rsaSha256 = fac.newSignatureMethod("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", null);
rsaSha384 = fac.newSignatureMethod("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384", null);
rsaSha512 = fac.newSignatureMethod("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512", null);
rsaRipemd160 = fac.newSignatureMethod("http://www.w3.org/2001/04/xmldsig-more#rsa-ripemd160", null);
-
+
rsaSha1Mgf1 = fac.newSignatureMethod("http://www.w3.org/2007/05/xmldsig-more#sha1-rsa-MGF1", null);
rsaSha224Mgf1 = fac.newSignatureMethod("http://www.w3.org/2007/05/xmldsig-more#sha224-rsa-MGF1", null);
rsaSha256Mgf1 = fac.newSignatureMethod("http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1", null);
rsaSha384Mgf1 = fac.newSignatureMethod("http://www.w3.org/2007/05/xmldsig-more#sha384-rsa-MGF1", null);
rsaSha512Mgf1 = fac.newSignatureMethod("http://www.w3.org/2007/05/xmldsig-more#sha512-rsa-MGF1", null);
-
+
ecdsaSha1 = fac.newSignatureMethod("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1", null);
ecdsaSha224 = fac.newSignatureMethod("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha224", 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);
ecdsaRipemd160 = fac.newSignatureMethod("http://www.w3.org/2007/05/xmldsig-more#ecdsa-ripemd160", null);
-
+
kvks = new KeySelectors.KeyValueKeySelector();
-
+
KeyPairGenerator rsaKpg = KeyPairGenerator.getInstance("RSA");
rsaKpg.initialize(2048);
rsaKeyPair = rsaKpg.genKeyPair();
-
+
ecKeyPair = KeyPairGenerator.getInstance("EC").genKeyPair();
-
+
KeyInfoFactory kifac = fac.getKeyInfoFactory();
rsaki = kifac.newKeyInfo(Collections.singletonList
(kifac.newKeyValue(rsaKeyPair.getPublic())));
-
+
boolean isIBM = "IBM Corporation".equals(System.getProperty("java.vendor"));
if (!isIBM) {
ecki = kifac.newKeyInfo(Collections.singletonList
@@ -160,31 +160,31 @@ public class PKSignatureAlgorithmTest ex
test_create_signature_enveloping(rsaSha1, sha1, rsaki,
rsaKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testRSA_SHA_224() throws Exception {
test_create_signature_enveloping(rsaSha224, sha1, rsaki,
rsaKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testRSA_SHA_256() throws Exception {
test_create_signature_enveloping(rsaSha256, sha1, rsaki,
rsaKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testRSA_SHA_384() throws Exception {
test_create_signature_enveloping(rsaSha384, sha1, rsaki,
rsaKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testRSA_SHA_512() throws Exception {
test_create_signature_enveloping(rsaSha512, sha1, rsaki,
rsaKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testRSA_RIPEMD160() throws Exception {
if (!bcInstalled) {
@@ -193,7 +193,7 @@ public class PKSignatureAlgorithmTest ex
test_create_signature_enveloping(rsaRipemd160, sha1, rsaki,
rsaKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testRSA_SHA1_MGF1() throws Exception {
if (!bcInstalled) {
@@ -202,7 +202,7 @@ public class PKSignatureAlgorithmTest ex
test_create_signature_enveloping(rsaSha1Mgf1, sha1, rsaki,
rsaKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testRSA_SHA224_MGF1() throws Exception {
if (!bcInstalled) {
@@ -211,7 +211,7 @@ public class PKSignatureAlgorithmTest ex
test_create_signature_enveloping(rsaSha224Mgf1, sha1, rsaki,
rsaKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testRSA_SHA256_MGF1() throws Exception {
if (!bcInstalled) {
@@ -220,7 +220,7 @@ public class PKSignatureAlgorithmTest ex
test_create_signature_enveloping(rsaSha256Mgf1, sha1, rsaki,
rsaKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testRSA_SHA384_MGF1() throws Exception {
if (!bcInstalled) {
@@ -229,7 +229,7 @@ public class PKSignatureAlgorithmTest ex
test_create_signature_enveloping(rsaSha384Mgf1, sha1, rsaki,
rsaKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testRSA_SHA512_MGF1() throws Exception {
if (!bcInstalled) {
@@ -238,42 +238,42 @@ public class PKSignatureAlgorithmTest ex
test_create_signature_enveloping(rsaSha512Mgf1, sha1, rsaki,
rsaKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testECDSA_SHA1() throws Exception {
org.junit.Assume.assumeTrue(ecAlgParamsSupport && ecki != null);
test_create_signature_enveloping(ecdsaSha1, sha1, ecki,
ecKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testECDSA_SHA224() throws Exception {
org.junit.Assume.assumeTrue(ecAlgParamsSupport && ecki != null);
test_create_signature_enveloping(ecdsaSha224, sha1, ecki,
ecKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testECDSA_SHA256() throws Exception {
org.junit.Assume.assumeTrue(ecAlgParamsSupport && ecki != null);
test_create_signature_enveloping(ecdsaSha256, sha1, ecki,
ecKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testECDSA_SHA384() throws Exception {
org.junit.Assume.assumeTrue(ecAlgParamsSupport && ecki != null);
test_create_signature_enveloping(ecdsaSha384, sha1, ecki,
ecKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testECDSA_SHA512() throws Exception {
org.junit.Assume.assumeTrue(ecAlgParamsSupport && ecki != null);
test_create_signature_enveloping(ecdsaSha512, sha1, ecki,
ecKeyPair.getPrivate(), kvks);
}
-
+
@org.junit.Test
public void testECDSA_RIPEMD160() throws Exception {
if (!bcInstalled) {
@@ -283,7 +283,7 @@ public class PKSignatureAlgorithmTest ex
test_create_signature_enveloping(ecdsaRipemd160, sha1, ecki,
ecKeyPair.getPrivate(), kvks);
}
-
+
private void test_create_signature_enveloping(
SignatureMethod sm, DigestMethod dm, KeyInfo ki, Key signingKey, KeySelector ks
) throws Exception {
@@ -313,7 +313,7 @@ public class PKSignatureAlgorithmTest ex
sig.sign(dsc);
TestUtils.validateSecurityOrEncryptionElement(doc.getDocumentElement());
-
+
// XMLUtils.outputDOM(doc.getDocumentElement(), System.out);
DOMValidateContext dvc = new DOMValidateContext
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/PhaosXMLDSig3Test.java Tue Dec 15 17:13:17 2015
@@ -31,7 +31,7 @@ import javax.xml.crypto.dsig.dom.DOMVali
import javax.xml.crypto.test.KeySelectors;
/**
- * This is a testcase to validate all "phaos-xmldsig-three"
+ * This is a testcase to validate all "phaos-xmldsig-three"
* testcases from Phaos
*
* @author Sean Mullan
@@ -73,7 +73,7 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_dsa_enveloped() throws Exception {
String file = "signature-dsa-enveloped.xml";
- boolean coreValidity =
+ boolean coreValidity =
validator.validate(file, new KeySelectors.RawX509KeySelector());
assertTrue("Signature failed core validation", coreValidity);
}
@@ -82,7 +82,7 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_dsa_enveloping() throws Exception {
String file = "signature-dsa-enveloping.xml";
- boolean coreValidity =
+ boolean coreValidity =
validator.validate(file, new KeySelectors.RawX509KeySelector());
assertTrue("Signature failed core validation", coreValidity);
}
@@ -91,13 +91,13 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_dsa_manifest() throws Exception {
String file = "signature-dsa-manifest.xml";
- boolean coreValidity =
+ boolean coreValidity =
validator.validate(file, new KeySelectors.KeyValueKeySelector());
assertTrue("Signature failed core validation", coreValidity);
}
@org.junit.Test
- public void test_signature_hmac_sha1_40_c14n_comments_detached()
+ public void test_signature_hmac_sha1_40_c14n_comments_detached()
throws Exception {
String file = "signature-hmac-sha1-40-c14n-comments-detached.xml";
@@ -113,7 +113,7 @@ public class PhaosXMLDSig3Test extends o
}
@org.junit.Test
- public void test_signature_hmac_sha1_40_exclusive_c14n_comments_detached()
+ public void test_signature_hmac_sha1_40_exclusive_c14n_comments_detached()
throws Exception {
String file = "signature-hmac-sha1-40-exclusive-c14n-comments-detached.xml";
@@ -129,7 +129,7 @@ public class PhaosXMLDSig3Test extends o
}
@org.junit.Test
- public void test_signature_hmac_sha1_exclusive_c14n_comments_detached()
+ public void test_signature_hmac_sha1_exclusive_c14n_comments_detached()
throws Exception {
String file = "signature-hmac-sha1-exclusive-c14n-comments-detached.xml";
@@ -140,7 +140,7 @@ public class PhaosXMLDSig3Test extends o
}
@org.junit.Test
- public void test_signature_hmac_sha1_exclusive_c14n_enveloped()
+ public void test_signature_hmac_sha1_exclusive_c14n_enveloped()
throws Exception {
String file = "signature-hmac-sha1-exclusive-c14n-enveloped.xml";
@@ -154,7 +154,7 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_rsa_detached_b64_transform() throws Exception {
String file = "signature-rsa-detached-b64-transform.xml";
- boolean coreValidity =
+ boolean coreValidity =
validator.validate(file, new KeySelectors.KeyValueKeySelector());
assertTrue("Signature failed core validation", coreValidity);
}
@@ -163,7 +163,7 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_rsa_detached_xpath_transform() throws Exception {
String file = "signature-rsa-detached-xpath-transform.xml";
- boolean coreValidity =
+ boolean coreValidity =
validator.validate(file, new KeySelectors.KeyValueKeySelector());
assertTrue("Signature failed core validation", coreValidity);
}
@@ -173,7 +173,7 @@ public class PhaosXMLDSig3Test extends o
String file = "signature-rsa-detached-xslt-transform-bad-retrieval-method.xml";
try {
- validator.validate(file,
+ validator.validate(file,
new KeySelectors.CollectionKeySelector(base));
fail("Should throw XMLSignatureException for using DSA key with " +
"RSA algorithm");
@@ -184,8 +184,8 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_rsa_detached_xslt_transform_rm() throws Exception {
String file = "signature-rsa-detached-xslt-transform-retrieval-method.xml";
- boolean coreValidity =
- validator.validate(file,
+ boolean coreValidity =
+ validator.validate(file,
new KeySelectors.CollectionKeySelector(base));
assertTrue("Signature failed core validation", coreValidity);
}
@@ -194,7 +194,7 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_rsa_detached_xslt_transform() throws Exception {
String file = "signature-rsa-detached-xslt-transform.xml";
- boolean coreValidity =
+ boolean coreValidity =
validator.validate(file, new KeySelectors.KeyValueKeySelector());
assertTrue("Signature failed core validation", coreValidity);
}
@@ -215,7 +215,7 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_rsa_enveloped_bad_digest_val() throws Exception {
String file = "signature-rsa-enveloped-bad-digest-val.xml";
- boolean coreValidity =
+ boolean coreValidity =
validator.validate(file, new KeySelectors.RawX509KeySelector());
assertFalse("Signature should fail core validation", coreValidity);
}
@@ -233,7 +233,7 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_rsa_enveloping() throws Exception {
String file = "signature-rsa-enveloping.xml";
- boolean coreValidity =
+ boolean coreValidity =
validator.validate(file, new KeySelectors.RawX509KeySelector());
assertTrue("Signature failed core validation", coreValidity);
}
@@ -260,7 +260,7 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_rsa_manifest_x509_data_issuer_serial() throws Exception {
String file = "signature-rsa-manifest-x509-data-issuer-serial.xml";
- boolean coreValidity = validator.validate(file,
+ boolean coreValidity = validator.validate(file,
new KeySelectors.CollectionKeySelector(base));
assertTrue("Signature failed core validation", coreValidity);
}
@@ -269,7 +269,7 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_rsa_manifest_x509_data_ski() throws Exception {
String file = "signature-rsa-manifest-x509-data-ski.xml";
- boolean coreValidity = validator.validate(file,
+ boolean coreValidity = validator.validate(file,
new KeySelectors.CollectionKeySelector(base));
assertTrue("Signature failed core validation", coreValidity);
}
@@ -278,7 +278,7 @@ public class PhaosXMLDSig3Test extends o
public void test_signature_rsa_manifest_x509_data_subject_name() throws Exception {
String file = "signature-rsa-manifest-x509-data-subject-name.xml";
- boolean coreValidity = validator.validate(file,
+ boolean coreValidity = validator.validate(file,
new KeySelectors.CollectionKeySelector(base));
assertTrue("Signature failed core validation", coreValidity);
}
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/ReferenceTest.java Tue Dec 15 17:13:17 2015
@@ -46,9 +46,9 @@ public class ReferenceTest extends org.j
private String uri = "http://www.ietf.org/rfc/rfc3275.txt";
private static final String[] CRYPTO_ALGS = { "RSA", "DSA" };
- private static final String[] SIG_ALGS = {
- SignatureMethod.RSA_SHA1,
- SignatureMethod.DSA_SHA1
+ private static final String[] SIG_ALGS = {
+ SignatureMethod.RSA_SHA1,
+ SignatureMethod.DSA_SHA1
};
static {
@@ -61,29 +61,29 @@ public class ReferenceTest extends org.j
("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
kifac = KeyInfoFactory.getInstance
("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
- dmSHA1 = fac.newDigestMethod(DigestMethod.SHA1, null);
+ dmSHA1 = fac.newDigestMethod(DigestMethod.SHA1, null);
}
@SuppressWarnings("rawtypes")
@org.junit.Test
public void testConstructor() throws Exception {
Reference ref;
- // test XMLSignatureFactory.newReference(String uri,
+ // test XMLSignatureFactory.newReference(String uri,
// DigestMethod dm) for generating Reference objects
ref = fac.newReference(null, dmSHA1);
assertNotNull(ref);
ref = fac.newReference(uri, dmSHA1);
assertNotNull(ref);
-
+
try {
ref = fac.newReference("illegal!@#$%" + uri, dmSHA1);
fail("Should throw a IAE for non-RFC2396-compliant uri");
} catch (IllegalArgumentException iae) {
} catch (Exception ex) {
- fail("Should throw a IAE instead of " + ex +
+ fail("Should throw a IAE instead of " + ex +
" for non-RFC2396-compliant uri");
}
-
+
try {
ref = fac.newReference(uri, null);
fail("Should throw a NPE for null dm");
@@ -92,10 +92,10 @@ public class ReferenceTest extends org.j
fail("Should throw a NPE instead of " + ex + " for null dm");
}
- // test XMLSignatureFactory.newReference(String uri,
+ // test XMLSignatureFactory.newReference(String uri,
// DigestMethod dm, List transforms, String type, String id)
// for generating Reference objects
- try {
+ try {
ref = fac.newReference(null, dmSHA1, null, null, null);
assertEquals(ref.getDigestMethod(), dmSHA1);
} catch(Exception ex) {
@@ -109,7 +109,7 @@ public class ReferenceTest extends org.j
} catch(Exception ex) {
fail("Should throw a NPE instead of " + ex + " for null dm");
}
-
+
String id = "id";
String type = "type";
try {
@@ -117,19 +117,19 @@ public class ReferenceTest extends org.j
assertNotNull(ref.getDigestMethod());
assertEquals(uri, ref.getURI());
assertEquals(id, ref.getId());
- assertEquals(type, ref.getType());
+ assertEquals(type, ref.getType());
assertEquals(ref.getTransforms(), Collections.EMPTY_LIST);
-
+
} catch(Exception ex) {
fail("Unexpected Exception: " + ex);
}
-
+
List<Transform> transforms = new ArrayList<Transform>();
try {
// try empty transforms list
- ref = fac.newReference(uri, dmSHA1, transforms,
+ ref = fac.newReference(uri, dmSHA1, transforms,
type, id);
- assertTrue(Arrays.equals(transforms.toArray(),
+ assertTrue(Arrays.equals(transforms.toArray(),
ref.getTransforms().toArray()));
} catch(Exception ex) {
fail("Unexpected Exception: " + ex);
@@ -138,52 +138,52 @@ public class ReferenceTest extends org.j
addEntryToRawList(invalidTransforms, new Object());
try {
// try a transforms list with an invalid object
- fac.newReference(uri, dmSHA1, invalidTransforms,
+ fac.newReference(uri, dmSHA1, invalidTransforms,
type, id);
} catch (ClassCastException cce) {
} catch (Exception ex) {
fail("Should throw a ClassCastException instead of " + ex);
}
-
- // Test with various composition of Transform list
- // 1. String only
+
+ // Test with various composition of Transform list
+ // 1. String only
invalidTransforms.clear();
addEntryToRawList(invalidTransforms, Transform.BASE64);
try {
// try a transforms list with a String object
- fac.newReference(uri, dmSHA1, invalidTransforms,
+ fac.newReference(uri, dmSHA1, invalidTransforms,
type, id);
fail("Should throw a CCE for illegal transforms");
} catch (ClassCastException cce) {
} catch(Exception ex) {
- fail("Should throw a CCE instead of " + ex +
+ fail("Should throw a CCE instead of " + ex +
" for illegal transforms");
}
-
+
// 2. Transform only
transforms.clear();
Transform c14nWithComments = fac.newTransform
- (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
+ (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
(TransformParameterSpec) null);
transforms.add(c14nWithComments);
try {
// try a transforms list with a Transform object
ref = fac.newReference(uri, dmSHA1, transforms, type, id);
- assertTrue(Arrays.equals(transforms.toArray(),
+ assertTrue(Arrays.equals(transforms.toArray(),
ref.getTransforms().toArray()));
} catch (Exception ex) {
fail("Unexpected Exception: " + ex);
}
}
-
+
@org.junit.Test
public void testisFeatureSupported() throws Exception {
Reference ref = fac.newReference(null, dmSHA1, null, null, null);
try {
- ref.isFeatureSupported(null);
- fail("Should raise a NPE for null feature");
+ ref.isFeatureSupported(null);
+ fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
-
+
assertTrue(!ref.isFeatureSupported("not supported"));
}
@@ -202,7 +202,7 @@ public class ReferenceTest extends org.j
String type = "http://www.w3.org/2000/09/xmldsig#Object";
byte[] in = new byte[200];
Random rand = new Random();
-
+
// Test XMLSignContext
XMLSignContext signContext;
XMLValidateContext validateContext;
@@ -211,7 +211,7 @@ public class ReferenceTest extends org.j
URIDereferencer dereferrer =
new TestUtils.OctetStreamURIDereferencer(in);
Document doc = TestUtils.newDocument();
- signContext = new
+ signContext = new
DOMSignContext(TestUtils.getPrivateKey(CRYPTO_ALGS[i]), doc);
signContext.setURIDereferencer(dereferrer);
if (cache) {
@@ -221,7 +221,7 @@ public class ReferenceTest extends org.j
ref = fac.newReference(null, dmSHA1, null, type, null);
XMLSignature sig = fac.newXMLSignature(fac.newSignedInfo
(fac.newCanonicalizationMethod
- (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
+ (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
(C14NMethodParameterSpec) null),
fac.newSignatureMethod(SIG_ALGS[i], null),
Collections.singletonList(ref)),
@@ -239,7 +239,7 @@ public class ReferenceTest extends org.j
assertTrue(digestInputEqual(ref));
}
validateContext = new DOMValidateContext
- (TestUtils.getPublicKey(CRYPTO_ALGS[i]),
+ (TestUtils.getPublicKey(CRYPTO_ALGS[i]),
doc.getDocumentElement());
validateContext.setURIDereferencer(dereferrer);
@@ -249,7 +249,7 @@ public class ReferenceTest extends org.j
}
boolean result = sig.validate(validateContext);
assertTrue(result);
-
+
@SuppressWarnings("unchecked")
Iterator<Reference> iter = sig.getSignedInfo().getReferences().iterator();
while (iter.hasNext()) {
@@ -269,7 +269,7 @@ public class ReferenceTest extends org.j
assertTrue(valid);
}
} catch (XMLSignatureException xse) {
- fail("Unexpected Exception: " + xse);
+ fail("Unexpected Exception: " + xse);
}
}
}
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SecureXSLTTest.java Tue Dec 15 17:13:17 2015
@@ -41,41 +41,41 @@ public class SecureXSLTTest extends org.
String fs = System.getProperty("file.separator");
String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
-
- File baseDir = new File(base + fs + "src/test/resources"
+
+ File baseDir = new File(base + fs + "src/test/resources"
+ fs + "javax" + fs + "xml" + fs + "crypto", "dsig");
testSignature(new File(baseDir, "signature1.xml"));
}
-
+
public void testSignature2() throws Exception {
String fs = System.getProperty("file.separator");
String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
-
- File baseDir = new File(base + fs + "src/test/resources"
+
+ File baseDir = new File(base + fs + "src/test/resources"
+ fs + "javax" + fs + "xml" + fs + "crypto", "dsig");
testSignature(new File(baseDir, "signature2.xml"));
}
-
+
public void testSignature3() throws Exception {
String fs = System.getProperty("file.separator");
String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
-
- File baseDir = new File(base + fs + "src/test/resources"
+
+ File baseDir = new File(base + fs + "src/test/resources"
+ fs + "javax" + fs + "xml" + fs + "crypto", "dsig");
testSignature(new File(baseDir, "signature3.xml"));
}
-
+
private void testSignature(File signatureFile) throws Exception {
XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
File f = new File("doc.xml");
-
- Document doc =
+
+ Document doc =
XMLUtils.createDocumentBuilder(false).parse(new FileInputStream(signatureFile));
NodeList nl =
@@ -86,7 +86,7 @@ public class SecureXSLTTest extends org.
DOMValidateContext valContext = new DOMValidateContext
(new KeySelectors.KeyValueKeySelector(), nl.item(0));
- // enable reference caching in your validation context
+ // enable reference caching in your validation context
valContext.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
try {
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureDigestMethodTest.java Tue Dec 15 17:13:17 2015
@@ -69,7 +69,7 @@ public class SignatureDigestMethodTest e
public SignatureDigestMethodTest() throws Exception {
//
- // If the BouncyCastle provider is not installed, then try to load it
+ // If the BouncyCastle provider is not installed, then try to load it
// via reflection.
//
if (Security.getProvider("BC") == null) {
@@ -86,14 +86,14 @@ public class SignatureDigestMethodTest e
bcInstalled = true;
}
}
-
+
db = XMLUtils.createDocumentBuilder(false);
// create common objects
fac = XMLSignatureFactory.getInstance("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
KeyInfoFactory kifac = fac.getKeyInfoFactory();
withoutComments = fac.newCanonicalizationMethod
(CanonicalizationMethod.INCLUSIVE, (C14NMethodParameterSpec) null);
-
+
// Digest Methods
sha1 = fac.newDigestMethod(DigestMethod.SHA1, null);
sha224 = fac.newDigestMethod("http://www.w3.org/2001/04/xmldsig-more#sha224", null);
@@ -106,14 +106,14 @@ public class SignatureDigestMethodTest e
sha3_256 = fac.newDigestMethod("http://www.w3.org/2007/05/xmldsig-more#sha3-256", null);
sha3_384 = fac.newDigestMethod("http://www.w3.org/2007/05/xmldsig-more#sha3-384", null);
sha3_512 = fac.newDigestMethod("http://www.w3.org/2007/05/xmldsig-more#sha3-512", null);
-
+
rsaSha1 = fac.newSignatureMethod
("http://www.w3.org/2000/09/xmldsig#rsa-sha1", null);
-
+
rsaki = kifac.newKeyInfo(Collections.singletonList
(kifac.newKeyValue(
TestUtils.getPublicKey("RSA"))));
-
+
kvks = new KeySelectors.KeyValueKeySelector();
}
@@ -127,31 +127,31 @@ public class SignatureDigestMethodTest e
test_create_signature_enveloping(rsaSha1, sha1, rsaki,
TestUtils.getPrivateKey("RSA"), kvks);
}
-
+
@org.junit.Test
public void testSHA224() throws Exception {
test_create_signature_enveloping(rsaSha1, sha224, rsaki,
TestUtils.getPrivateKey("RSA"), kvks);
}
-
+
@org.junit.Test
public void testSHA256() throws Exception {
test_create_signature_enveloping(rsaSha1, sha256, rsaki,
TestUtils.getPrivateKey("RSA"), kvks);
}
-
+
@org.junit.Test
public void testSHA384() throws Exception {
test_create_signature_enveloping(rsaSha1, sha384, rsaki,
TestUtils.getPrivateKey("RSA"), kvks);
}
-
+
@org.junit.Test
public void testSHA512() throws Exception {
test_create_signature_enveloping(rsaSha1, sha512, rsaki,
TestUtils.getPrivateKey("RSA"), kvks);
}
-
+
@org.junit.Test
public void testRIPEMD160() throws Exception {
if (!bcInstalled) {
@@ -160,7 +160,7 @@ public class SignatureDigestMethodTest e
test_create_signature_enveloping(rsaSha1, ripemd160, rsaki,
TestUtils.getPrivateKey("RSA"), kvks);
}
-
+
@org.junit.Test
public void testWHIRLPOOL() throws Exception {
if (!bcInstalled) {
@@ -169,7 +169,7 @@ public class SignatureDigestMethodTest e
test_create_signature_enveloping(rsaSha1, whirlpool, rsaki,
TestUtils.getPrivateKey("RSA"), kvks);
}
-
+
@org.junit.Test
public void testSHA3_224() throws Exception {
if (!bcInstalled) {
@@ -178,7 +178,7 @@ public class SignatureDigestMethodTest e
test_create_signature_enveloping(rsaSha1, sha3_224, rsaki,
TestUtils.getPrivateKey("RSA"), kvks);
}
-
+
@org.junit.Test
public void testSHA3_256() throws Exception {
if (!bcInstalled) {
@@ -187,7 +187,7 @@ public class SignatureDigestMethodTest e
test_create_signature_enveloping(rsaSha1, sha3_256, rsaki,
TestUtils.getPrivateKey("RSA"), kvks);
}
-
+
@org.junit.Test
public void testSHA3_384() throws Exception {
if (!bcInstalled) {
@@ -196,7 +196,7 @@ public class SignatureDigestMethodTest e
test_create_signature_enveloping(rsaSha1, sha3_384, rsaki,
TestUtils.getPrivateKey("RSA"), kvks);
}
-
+
@org.junit.Test
public void testSHA3_512() throws Exception {
if (!bcInstalled) {
@@ -205,7 +205,7 @@ public class SignatureDigestMethodTest e
test_create_signature_enveloping(rsaSha1, sha3_512, rsaki,
TestUtils.getPrivateKey("RSA"), kvks);
}
-
+
private void test_create_signature_enveloping(
SignatureMethod sm, DigestMethod dm, KeyInfo ki, Key signingKey, KeySelector ks
) throws Exception {
@@ -235,7 +235,7 @@ public class SignatureDigestMethodTest e
sig.sign(dsc);
TestUtils.validateSecurityOrEncryptionElement(doc.getDocumentElement());
-
+
// XMLUtils.outputDOM(doc.getDocumentElement(), System.out);
DOMValidateContext dvc = new DOMValidateContext
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureMethodTest.java Tue Dec 15 17:13:17 2015
@@ -51,10 +51,10 @@ public class SignatureMethodTest extends
String algo = SIG_ALGOS[i];
sm = factory.newSignatureMethod(algo, null);
try {
- sm.isFeatureSupported(null);
- fail("Should raise a NPE for null feature");
+ sm.isFeatureSupported(null);
+ fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
-
+
assertTrue(!sm.isFeatureSupported("not supported"));
}
}
@@ -74,7 +74,7 @@ public class SignatureMethodTest extends
try {
sm = factory.newSignatureMethod
(algo, new TestUtils.MyOwnSignatureMethodParameterSpec());
- fail("Should raise an IAPE for invalid parameters");
+ fail("Should raise an IAPE for invalid parameters");
} catch (InvalidAlgorithmParameterException iape) {
} catch (Exception ex) {
fail("Should raise an IAPE instead of " + ex);
@@ -82,19 +82,19 @@ public class SignatureMethodTest extends
}
try {
- sm = factory.newSignatureMethod("non-existent", null);
- fail("Should raise an NSAE for non-existent algos");
+ sm = factory.newSignatureMethod("non-existent", null);
+ fail("Should raise an NSAE for non-existent algos");
} catch (NoSuchAlgorithmException nsae) {
//
}
try {
- sm = factory.newSignatureMethod(null, null);
- fail("Should raise a NPE for null algo");
+ sm = factory.newSignatureMethod(null, null);
+ fail("Should raise a NPE for null algo");
} catch (NullPointerException npe) {
//
}
}
-
+
}
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertiesTest.java Tue Dec 15 17:13:17 2015
@@ -42,45 +42,45 @@ public class SignaturePropertiesTest ext
(Collections.singletonList(new TestUtils.MyOwnXMLStructure()),
"propTarget", "propId");
}
-
+
@SuppressWarnings("rawtypes")
@org.junit.Test
public void testConstructor() {
- // test XMLSignatureFactory.newSignatureProperties(List, String)
+ // test XMLSignatureFactory.newSignatureProperties(List, String)
SignatureProperties props;
try {
- props = factory.newSignatureProperties(null, id);
- fail("Should raise a NPE for null content");
+ props = factory.newSignatureProperties(null, id);
+ fail("Should raise a NPE for null content");
} catch (NullPointerException npe) {
} catch (Exception ex) {
fail("Should raise a NPE for null content instead of " + ex);
}
-
+
List<SignatureProperty> list = new ArrayList<SignatureProperty>();
try {
- props = factory.newSignatureProperties(list, id);
- fail("Should raise an IAE for empty content");
+ props = factory.newSignatureProperties(list, id);
+ fail("Should raise an IAE for empty content");
} catch (IllegalArgumentException iae) {
} catch (Exception ex) {
fail("Should raise an IAE for empty content instead of " + ex);
}
-
+
String strEntry = "wrong type";
// use raw List type to test for invalid SignatureProperty types
List invalidList = new ArrayList();
addEntryToRawList(invalidList, strEntry);
try {
- factory.newSignatureProperties(invalidList, id);
+ factory.newSignatureProperties(invalidList, id);
fail("Should raise a CCE for content containing " +
- "invalid, i.e. non-SignatureProperty, entries");
+ "invalid, i.e. non-SignatureProperty, entries");
} catch (ClassCastException cce) {
// cce.printStackTrace();
} catch (Exception ex) {
fail("Should raise a CCE for content with invalid entries " +
"instead of " + ex);
}
-
+
list.add(prop);
props = factory.newSignatureProperties(list, id);
assertNotNull(props);
@@ -102,13 +102,13 @@ public class SignaturePropertiesTest ext
list.add(prop);
SignatureProperties props = factory.newSignatureProperties(list, id);
try {
- props.isFeatureSupported(null);
- fail("Should raise a NPE for null feature");
+ props.isFeatureSupported(null);
+ fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
assertTrue(!props.isFeatureSupported("not supported"));
}
-
+
@SuppressWarnings({
"unchecked", "rawtypes"
})
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignaturePropertyTest.java Tue Dec 15 17:13:17 2015
@@ -40,24 +40,24 @@ public class SignaturePropertyTest exten
factory = XMLSignatureFactory.getInstance
("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
}
-
+
@SuppressWarnings("rawtypes")
@org.junit.Test
public void testConstructor() {
- // test XMLSignatureFactory.newSignatureProperty(List, String, String)
+ // test XMLSignatureFactory.newSignatureProperty(List, String, String)
SignatureProperty prop;
try {
- prop = factory.newSignatureProperty(null, target, id);
- fail("Should raise a NPE for null content");
+ prop = factory.newSignatureProperty(null, target, id);
+ fail("Should raise a NPE for null content");
} catch (NullPointerException npe) {
} catch (Exception ex) {
fail("Should raise a NPE for null content instead of " + ex);
}
List<XMLStructure> list = new ArrayList<XMLStructure>();
try {
- prop = factory.newSignatureProperty(list, target, id);
- fail("Should raise an IAE for empty content");
+ prop = factory.newSignatureProperty(list, target, id);
+ fail("Should raise an IAE for empty content");
} catch (IllegalArgumentException iae) {
} catch (Exception ex) {
fail("Should raise an IAE for empty content instead of " + ex);
@@ -67,9 +67,9 @@ public class SignaturePropertyTest exten
List invalidList = new ArrayList();
addEntryToRawList(invalidList, strEntry);
try {
- factory.newSignatureProperty(invalidList, target, id);
+ factory.newSignatureProperty(invalidList, target, id);
fail("Should raise a CCE for content containing " +
- "invalid, i.e. non-XMLStructure, entries");
+ "invalid, i.e. non-XMLStructure, entries");
} catch (ClassCastException cce) {
} catch (Exception ex) {
fail("Should raise a CCE for content with invalid entries " +
@@ -78,7 +78,7 @@ public class SignaturePropertyTest exten
list.add(new TestUtils.MyOwnXMLStructure());
try {
prop = factory.newSignatureProperty(list, null, id);
- fail("Should raise a NPE for null target");
+ fail("Should raise a NPE for null target");
} catch (NullPointerException npe) {
} catch (Exception ex) {
fail("Should raise a NPE for null target instead of " + ex);
@@ -106,13 +106,13 @@ public class SignaturePropertyTest exten
SignatureProperty prop = factory.newSignatureProperty
(list, target, id);
try {
- prop.isFeatureSupported(null);
- fail("Should raise a NPE for null feature");
+ prop.isFeatureSupported(null);
+ fail("Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
assertTrue(!prop.isFeatureSupported("not supported"));
}
-
+
@SuppressWarnings({
"unchecked", "rawtypes"
})
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignatureValidator.java Tue Dec 15 17:13:17 2015
@@ -81,7 +81,7 @@ public class SignatureValidator {
("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
XMLSignature signature = factory.unmarshalXMLSignature(vc);
boolean coreValidity = signature.validate(vc);
-
+
// Check core validation status
if (coreValidity == false) {
// check the validation status of each Reference
@@ -98,7 +98,7 @@ public class SignatureValidator {
public static Element getSignatureElement(Document doc) {
NodeIterator ni = ((DocumentTraversal)doc).createNodeIterator(
doc.getDocumentElement(), NodeFilter.SHOW_ELEMENT, null, false);
-
+
for (Node n = ni.nextNode(); n != null; n = ni.nextNode() ) {
if ("Signature".equals(n.getLocalName())) {
return (Element) n;
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/SignedInfoTest.java Tue Dec 15 17:13:17 2015
@@ -46,12 +46,12 @@ public class SignedInfoTest extends org.
fac = XMLSignatureFactory.getInstance
("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
cm = fac.newCanonicalizationMethod
- (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
+ (CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
(C14NMethodParameterSpec) null);
sm = fac.newSignatureMethod(SignatureMethod.DSA_SHA1, null);
references = new ArrayList<Reference>();
references.add(fac.newReference
- ("http://www.sun.com/index.html",
+ ("http://www.sun.com/index.html",
fac.newDigestMethod(DigestMethod.SHA1, null)));
}
@@ -59,10 +59,10 @@ public class SignedInfoTest extends org.
@org.junit.Test
public void testConstructor() {
// test XMLSignatureFactory.newSignedInfo(
- // CanonicalizationMethod cm,
+ // CanonicalizationMethod cm,
// SignatureMethod sm, List references)
SignedInfo si;
-
+
for (int i = 0; i < 3; i++) {
try {
switch (i) {
@@ -90,10 +90,10 @@ public class SignedInfoTest extends org.
fail("Should throw an IAE for empty references");
} catch(IllegalArgumentException iae) {
} catch(Exception ex) {
- fail("Should throw an IAE instead of " + ex +
+ fail("Should throw an IAE instead of " + ex +
" for empty references");
}
-
+
// use raw List type to test for invalid Reference entries
List invalidRefs = new ArrayList();
addEntryToRawList(invalidRefs, "String");
@@ -102,21 +102,21 @@ public class SignedInfoTest extends org.
fail("Should throw an CCE for illegal references");
} catch(ClassCastException cce) {
} catch(Exception ex) {
- fail("Should throw an IAE instead of " + ex +
+ fail("Should throw an IAE instead of " + ex +
" for empty references");
}
si = fac.newSignedInfo(cm, sm, references);
assertNotNull(si);
- assertEquals(si.getCanonicalizationMethod().getAlgorithm(),
+ assertEquals(si.getCanonicalizationMethod().getAlgorithm(),
cm.getAlgorithm());
- assertEquals(si.getCanonicalizationMethod().getParameterSpec(),
+ assertEquals(si.getCanonicalizationMethod().getParameterSpec(),
cm.getParameterSpec());
- assertEquals(si.getSignatureMethod().getAlgorithm(),
+ assertEquals(si.getSignatureMethod().getAlgorithm(),
sm.getAlgorithm());
- assertEquals(si.getSignatureMethod().getParameterSpec(),
+ assertEquals(si.getSignatureMethod().getParameterSpec(),
sm.getParameterSpec());
- assertTrue(Arrays.equals(si.getReferences().toArray(),
+ assertTrue(Arrays.equals(si.getReferences().toArray(),
references.toArray()));
assertNull(si.getId());
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java Tue Dec 15 17:13:17 2015
@@ -85,16 +85,16 @@ import org.xml.sax.SAXException;
* @author Valerie Peng
*/
public class TestUtils {
-
- private static final String DSA_Y =
+
+ private static final String DSA_Y =
"07066284216756577193658833512863439617178933165631848358445549382240081120085333137303066923542492834619027404463194956043802393462371310375123430985057160";
- private static final String DSA_P =
+ private static final String DSA_P =
"013232376895198612407547930718267435757728527029623408872245156039757713029036368719146452186041204237350521785240337048752071462798273003935646236777459223";
- private static final String DSA_Q =
+ private static final String DSA_Q =
"0857393771208094202104259627990318636601332086981";
- private static final String DSA_G =
+ private static final String DSA_G =
"05421644057436475141609648488325705128047428394380474376834667300766108262613900542681289080713724597310673074119355136085795982097390670890367185141189796";
- private static final String DSA_X =
+ private static final String DSA_X =
"0527140396812450214498055937934275626078768840117";
private static final String DSA_2048_Y =
"15119007057343785981993995134621348945077524760182795513668325877793414638620983617627033248732235626178802906346261435991040697338468329634416089753032362617771631199351767336660070462291411472735835843440140283101463231807789628656218830720378705090795271104661936237385140354825159080766174663596286149653433914842868551355716015585570827642835307073681358328172009941968323702291677280809277843998510864653406122348712345584706761165794179850728091522094227603562280855104749858249588234915206290448353957550635709520273178475097150818955098638774564910092913714625772708285992586894795017709678223469405896699928";
@@ -106,14 +106,14 @@ public class TestUtils {
"2859278237642201956931085611015389087970918161297522023542900348087718063098423976428252369340967506010054236052095950169272612831491902295835660747775572934757474194739347115870723217560530672532404847508798651915566434553729839971841903983916294692452760249019857108409189016993380919900231322610083060784269299257074905043636029708121288037909739559605347853174853410208334242027740275688698461842637641566056165699733710043802697192696426360843173620679214131951400148855611740858610821913573088059404459364892373027492936037789337011875710759208498486908611261954026964574111219599568903257472567764789616958430";
private static final String DSA_2048_X =
"14562787764977288900757387442281559936279834964901963465277698843172";
- private static final String RSA_MOD =
+ private static final String RSA_MOD =
"010800185049102889923150759252557522305032794699952150943573164381936603255999071981574575044810461362008102247767482738822150129277490998033971789476107463";
private static final String RSA_PUB = "065537";
- private static final String RSA_PRIV =
+ private static final String RSA_PRIV =
"0161169735844219697954459962296126719476357984292128166117072108359155865913405986839960884870654387514883422519600695753920562880636800379454345804879553";
private TestUtils() {}
-
+
public static PublicKey getPublicKey(String algo)
throws InvalidKeySpecException, NoSuchAlgorithmException {
if (algo.equalsIgnoreCase("DSA")) {
@@ -122,26 +122,26 @@ public class TestUtils {
return getPublicKey("RSA", 512);
} else throw new RuntimeException("Unsupported key algorithm " + algo);
}
-
+
public static PublicKey getPublicKey(String algo, int keysize)
throws InvalidKeySpecException, NoSuchAlgorithmException {
KeyFactory kf = KeyFactory.getInstance(algo);
KeySpec kspec;
if (algo.equalsIgnoreCase("DSA")) {
if (keysize == 1024) {
- kspec = new DSAPublicKeySpec(new BigInteger(DSA_Y),
- new BigInteger(DSA_P),
- new BigInteger(DSA_Q),
+ kspec = new DSAPublicKeySpec(new BigInteger(DSA_Y),
+ new BigInteger(DSA_P),
+ new BigInteger(DSA_Q),
new BigInteger(DSA_G));
} else if (keysize == 2048) {
- kspec = new DSAPublicKeySpec(new BigInteger(DSA_2048_Y),
- new BigInteger(DSA_2048_P),
- new BigInteger(DSA_2048_Q),
+ kspec = new DSAPublicKeySpec(new BigInteger(DSA_2048_Y),
+ new BigInteger(DSA_2048_P),
+ new BigInteger(DSA_2048_Q),
new BigInteger(DSA_2048_G));
} else throw new RuntimeException("Unsupported keysize:" + keysize);
} else if (algo.equalsIgnoreCase("RSA")) {
if (keysize == 512) {
- kspec = new RSAPublicKeySpec(new BigInteger(RSA_MOD),
+ kspec = new RSAPublicKeySpec(new BigInteger(RSA_MOD),
new BigInteger(RSA_PUB));
} else throw new RuntimeException("Unsupported keysize:" + keysize);
} else throw new RuntimeException("Unsupported key algorithm " + algo);
@@ -155,7 +155,7 @@ public class TestUtils {
DOMSource source = new DOMSource(toValidate);
validator.validate(source);
}
-
+
public static PrivateKey getPrivateKey(String algo)
throws InvalidKeySpecException, NoSuchAlgorithmException {
if (algo.equalsIgnoreCase("DSA")) {
@@ -165,18 +165,18 @@ public class TestUtils {
} else throw new RuntimeException("Unsupported key algorithm " + algo);
}
- public static PrivateKey getPrivateKey(String algo, int keysize)
+ public static PrivateKey getPrivateKey(String algo, int keysize)
throws InvalidKeySpecException, NoSuchAlgorithmException {
KeyFactory kf = KeyFactory.getInstance(algo);
KeySpec kspec;
if (algo.equalsIgnoreCase("DSA")) {
if (keysize == 1024) {
kspec = new DSAPrivateKeySpec
- (new BigInteger(DSA_X), new BigInteger(DSA_P),
+ (new BigInteger(DSA_X), new BigInteger(DSA_P),
new BigInteger(DSA_Q), new BigInteger(DSA_G));
} else if (keysize == 2048) {
kspec = new DSAPrivateKeySpec
- (new BigInteger(DSA_2048_X), new BigInteger(DSA_2048_P),
+ (new BigInteger(DSA_2048_X), new BigInteger(DSA_2048_P),
new BigInteger(DSA_2048_Q), new BigInteger(DSA_2048_G));
} else throw new RuntimeException("Unsupported keysize:" + keysize);
} else if (algo.equalsIgnoreCase("RSA")) {
@@ -191,13 +191,13 @@ public class TestUtils {
public static SecretKey getSecretKey(final byte[] secret) {
return new SecretKey() {
private static final long serialVersionUID = 5629454124145851381L;
-
+
public String getFormat() { return "RAW"; }
public byte[] getEncoded() { return secret; }
public String getAlgorithm(){ return "SECRET"; }
};
}
-
+
public static Document newDocument() {
try {
DocumentBuilder docBuilder = XMLUtils.createDocumentBuilder(false);
@@ -208,16 +208,16 @@ public class TestUtils {
}
public static class MyOwnC14nParameterSpec implements C14NMethodParameterSpec {}
-
- public static class MyOwnDigestMethodParameterSpec
+
+ public static class MyOwnDigestMethodParameterSpec
implements DigestMethodParameterSpec {}
-
- public static class MyOwnSignatureMethodParameterSpec
+
+ public static class MyOwnSignatureMethodParameterSpec
implements SignatureMethodParameterSpec {}
- public static XMLValidateContext getXMLValidateContext(String type,
- File input,
- String tag)
+ public static XMLValidateContext getXMLValidateContext(String type,
+ File input,
+ String tag)
throws Exception {
if (type.equalsIgnoreCase("dom")) {
DocumentBuilder docBuilder = XMLUtils.createDocumentBuilder(false, false);
@@ -232,12 +232,12 @@ public class TestUtils {
(TestUtils.getPublicKey("RSA", 512), list.item(0));
}
} else {
- throw new Exception("Unsupported XMLValidateContext type: " +
+ throw new Exception("Unsupported XMLValidateContext type: " +
type);
}
}
- public static class MyOwnDOMReference extends DOMStructure
+ public static class MyOwnDOMReference extends DOMStructure
implements Reference {
private String id;
private boolean status;
@@ -251,13 +251,13 @@ public class TestUtils {
MD = MessageDigest.getInstance("SHA");
XMLSignatureFactory factory = XMLSignatureFactory.getInstance
("DOM", new org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI());
- DIG_METHOD =
+ DIG_METHOD =
factory.newDigestMethod(DigestMethod.SHA1, null);
} catch (Exception ex) {
// should never be thrown
}
}
-
+
public MyOwnDOMReference(String id, boolean status) {
super(newDocument());
this.id = id;
@@ -275,48 +275,48 @@ public class TestUtils {
}
return digest;
}
-
+
public byte[] getCalculatedDigestValue() {
return null;
}
-
+
public DigestMethod getDigestMethod() { return DIG_METHOD; }
-
+
public String getId() {
return id;
}
-
+
public String getType() {
return null;
}
-
+
public String getURI() {
return null;
}
-
+
public List<Transform> getTransforms() {
return Collections.emptyList();
}
-
- public boolean validate(XMLValidateContext vCtx)
+
+ public boolean validate(XMLValidateContext vCtx)
throws XMLSignatureException {
this.dis = new ByteArrayInputStream(id.getBytes());
this.derefData = new OctetStreamData(this.dis);
return status;
}
-
+
public Data getDereferencedData() {
return derefData;
- }
-
+ }
+
public InputStream getDigestInputStream() {
return dis;
}
}
public static class MyOwnXMLStructure implements XMLStructure {
-
- public boolean isFeatureSupported(String feature)
+
+ public boolean isFeatureSupported(String feature)
throws NullPointerException {
if (feature == null) throw new NullPointerException();
return false;
@@ -324,21 +324,21 @@ public class TestUtils {
}
public static class OctetStreamURIDereferencer implements URIDereferencer {
-
+
private byte[] data = null;
-
+
public OctetStreamURIDereferencer(byte[] in) {
data = (byte[]) in.clone();
}
-
+
public Data dereference(URIReference ref, XMLCryptoContext ctxt) {
return new OctetStreamData(new ByteArrayInputStream(data));
}
-
+
public byte[] getData() {
return data;
}
-
+
public boolean equals(Object obj) {
if (obj instanceof OctetStreamURIDereferencer) {
return Arrays.equals
@@ -347,20 +347,20 @@ public class TestUtils {
return false;
}
}
-
+
public int hashCode() {
return 5678;
}
}
public static class NodeSetURIDereferencer implements URIDereferencer {
-
+
private Node data = null;
-
+
public NodeSetURIDereferencer(Node node) {
data = node;
}
-
+
public Data dereference(URIReference ref, XMLCryptoContext ctxt) {
return new NodeSetData() {
public Iterator<Node> iterator() {
@@ -378,5 +378,5 @@ public class TestUtils {
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.transform(source, result);
}
-
+
}
Modified: santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java?rev=1720201&r1=1720200&r2=1720201&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/javax/xml/crypto/test/dsig/TransformTest.java Tue Dec 15 17:13:17 2015
@@ -60,7 +60,7 @@ public class TransformTest extends org.j
@org.junit.Test
public void testisFeatureSupported() throws Exception {
- Transform tm;
+ Transform tm;
for (int i = 0; i < TRANSFORM_ALGOS.length; i++) {
String algo = TRANSFORM_ALGOS[i];
TransformParameterSpec params = null;
@@ -75,21 +75,21 @@ public class TransformTest extends org.j
}
tm = factory.newTransform(algo, params);
try {
- tm.isFeatureSupported(null);
- fail(TRANSFORM_ALGOS[i] +
- ": Should raise a NPE for null feature");
+ tm.isFeatureSupported(null);
+ fail(TRANSFORM_ALGOS[i] +
+ ": Should raise a NPE for null feature");
} catch (NullPointerException npe) {}
-
+
assertTrue(!tm.isFeatureSupported("not supported"));
}
}
@org.junit.Test
public void testConstructor() throws Exception {
- // test newTransform(String algorithm,
+ // test newTransform(String algorithm,
// AlgorithmParameterSpec params)
// for generating Transform objects
- Transform tm;
+ Transform tm;
for (int i = 0; i < TRANSFORM_ALGOS.length; i++) {
String algo = TRANSFORM_ALGOS[i];
TransformParameterSpec params = null;
@@ -108,35 +108,35 @@ public class TransformTest extends org.j
assertEquals(tm.getAlgorithm(), algo);
assertEquals(tm.getParameterSpec(), params);
} catch (Exception ex) {
- fail(TRANSFORM_ALGOS[i] + ": Unexpected exception " + ex);
+ fail(TRANSFORM_ALGOS[i] + ": Unexpected exception " + ex);
}
try {
tm = factory.newTransform
(algo, new TestUtils.MyOwnC14nParameterSpec());
- fail(TRANSFORM_ALGOS[i] +
- ": Should raise an IAPE for invalid parameters");
+ fail(TRANSFORM_ALGOS[i] +
+ ": Should raise an IAPE for invalid parameters");
} catch (InvalidAlgorithmParameterException iape) {
} catch (Exception ex) {
- fail(TRANSFORM_ALGOS[i] +
- ": Should raise a IAPE instead of " + ex);
+ fail(TRANSFORM_ALGOS[i] +
+ ": Should raise a IAPE instead of " + ex);
}
}
try {
- tm = factory.newTransform(null, (TransformParameterSpec) null);
- fail("Should raise a NPE for null algo");
+ tm = factory.newTransform(null, (TransformParameterSpec) null);
+ fail("Should raise a NPE for null algo");
} catch (NullPointerException npe) {
} catch (Exception ex) {
- fail("Should raise a NPE instead of " + ex);
+ fail("Should raise a NPE instead of " + ex);
}
try {
tm = factory.newTransform
- ("non-existent", (TransformParameterSpec) null);
- fail("Should raise an NSAE for non-existent algos");
+ ("non-existent", (TransformParameterSpec) null);
+ fail("Should raise an NSAE for non-existent algos");
} catch (NoSuchAlgorithmException nsae) {
} catch (Exception ex) {
- fail("Should raise an NSAE instead of " + ex);
+ fail("Should raise an NSAE instead of " + ex);
}
}