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 2011/12/13 13:36:23 UTC
svn commit: r1213661 - in /santuario/xml-security-java/trunk: ./
samples/org/apache/xml/security/samples/
samples/org/apache/xml/security/samples/encryption/
samples/org/apache/xml/security/samples/signature/
src/main/java/org/apache/xml/security/utils...
Author: coheigea
Date: Tue Dec 13 12:36:22 2011
New Revision: 1213661
URL: http://svn.apache.org/viewvc?rev=1213661&view=rev
Log:
Some cleanup of the samples
Modified:
santuario/xml-security-java/trunk/build.xml
santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/AxisSigner.java
santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/AxisVerifier.java
santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/DSNamespaceContext.java
santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/encryption/Decrypter.java
santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/encryption/Encrypter.java
santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/CreateEnvelopingSignature.java
santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/CreateSignature.java
santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/VerifySignature.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/DSNamespaceContext.java
Modified: santuario/xml-security-java/trunk/build.xml
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/build.xml?rev=1213661&r1=1213660&r2=1213661&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/build.xml (original)
+++ santuario/xml-security-java/trunk/build.xml Tue Dec 13 12:36:22 2011
@@ -130,16 +130,18 @@
<!-- P A T T E R N S E T S -->
<patternset id="id.patternset.distFiles">
<include name="build.xml"/>
- <include name="KEYS"/>
+ <include name="pom.xml"/>
<include name="LICENSE"/>
<include name="NOTICE"/>
- <include name="Readme.html"/>
- <include name="TODO"/>
</patternset>
<patternset id="id.patternset.srcFiles">
<include name="src/**/*"/>
</patternset>
+
+ <patternset id="id.patternset.sampleFiles">
+ <include name="samples/**/*"/>
+ </patternset>
<!-- T A R G E T S -->
@@ -365,8 +367,8 @@
<target name="encrypt"
depends="build.samples"
description="encrypts xml data">
- <delete file="encryptedInfo.xml"/>
- <delete file="kek"/>
+ <delete file="build/encryptedInfo.xml"/>
+ <delete file="build/kek"/>
<java classname="org.apache.xml.security.samples.encryption.Encrypter"
failonerror="true"
fork="yes"
@@ -378,7 +380,7 @@
<target name="decrypt"
depends="build.samples"
description="decrypts xml data">
- <delete file="decryptedInfo.xml"/>
+ <delete file="build/decryptedInfo.xml"/>
<java classname="org.apache.xml.security.samples.encryption.Decrypter"
failonerror="true"
fork="yes"
@@ -396,7 +398,7 @@
<target name="sign"
depends="build.samples"
description="creates a signature" >
- <delete file="signature.xml"/>
+ <delete file="build/signature.xml"/>
<java classname="org.apache.xml.security.samples.signature.CreateSignature"
failonerror="true"
fork="yes"
@@ -555,6 +557,7 @@
<fileset dir=".">
<patternset refid="id.patternset.distFiles"/>
<patternset refid="id.patternset.srcFiles"/>
+ <patternset refid="id.patternset.sampleFiles"/>
<include name="ant/**/*"/>
</fileset>
@@ -576,6 +579,8 @@
<copy todir="${dir.build.bindist}">
<fileset dir=".">
<patternset refid="id.patternset.distFiles"/>
+ <patternset refid="id.patternset.srcFiles"/>
+ <patternset refid="id.patternset.sampleFiles"/>
<include name="ant/**/*"/>
</fileset>
@@ -760,8 +765,6 @@
<echo message=""/>
<echo message="------------- Signature Samples ----------------"/>
<echo message=""/>
- <echo message="generate-keys - generates new keys to be used by other"/>
- <echo message=" examples"/>
<echo message="sign - runs CreateSignature sample"/>
<echo message="verify - runs signature verification sample"/>
<echo message="signAndVerify - runs sign and then verify"/>
Modified: santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/AxisSigner.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/AxisSigner.java?rev=1213661&r1=1213660&r2=1213661&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/AxisSigner.java (original)
+++ santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/AxisSigner.java Tue Dec 13 12:36:22 2011
@@ -37,7 +37,7 @@ import org.w3c.dom.Element;
public class AxisSigner {
/** Field AXIS_SIGNATURE_FILENAME */
- public static final String AXIS_SIGNATURE_FILENAME = "axisSignature.xml";
+ public static final String AXIS_SIGNATURE_FILENAME = "build/axisSignature.xml";
/**
* Method main
@@ -97,7 +97,7 @@ public class AxisSigner {
);
bodyElem.setAttributeNS(SOAPSECNS, "SOAP-SEC:id", "Body");
- IdResolver.registerElementById(bodyElem, "id");
+ IdResolver.registerElementById(bodyElem, "Body");
Element soapSignatureElem = doc.createElementNS(SOAPSECNS, "SOAP-SEC:Signature");
Modified: santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/AxisVerifier.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/AxisVerifier.java?rev=1213661&r1=1213660&r2=1213661&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/AxisVerifier.java (original)
+++ santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/AxisVerifier.java Tue Dec 13 12:36:22 2011
@@ -27,6 +27,7 @@ import javax.xml.xpath.XPathFactory;
import org.apache.xml.security.signature.XMLSignature;
import org.apache.xml.security.utils.Constants;
+import org.apache.xml.security.utils.IdResolver;
import org.w3c.dom.Element;
/**
@@ -56,12 +57,19 @@ public class AxisVerifier {
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
- xpath.setNamespaceContext(new DSNamespaceContext());
+ DSNamespaceContext context = new DSNamespaceContext();
+ xpath.setNamespaceContext(context);
String expression = "//ds:Signature[1]";
Element sigElement =
(Element) xpath.evaluate(expression, doc, XPathConstants.NODE);
+ expression = "//env:Body[1]";
+ context.putPrefix("env", "http://www.w3.org/2001/12/soap-envelope");
+ Element bodyElement =
+ (Element) xpath.evaluate(expression, doc, XPathConstants.NODE);
+ IdResolver.registerElementById(bodyElement, "Body");
+
XMLSignature sig = new XMLSignature(sigElement, BaseURI);
boolean verify = sig.checkSignatureValue(sig.getKeyInfo().getPublicKey());
Modified: santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/DSNamespaceContext.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/DSNamespaceContext.java?rev=1213661&r1=1213660&r2=1213661&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/DSNamespaceContext.java (original)
+++ santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/DSNamespaceContext.java Tue Dec 13 12:36:22 2011
@@ -45,6 +45,10 @@ public class DSNamespaceContext implemen
public String getNamespaceURI(String arg0) {
return namespaceMap.get(arg0);
}
+
+ public void putPrefix(String prefix, String namespace) {
+ namespaceMap.put(prefix, namespace);
+ }
public String getPrefix(String arg0) {
for (String key : namespaceMap.keySet()) {
Modified: santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/encryption/Decrypter.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/encryption/Decrypter.java?rev=1213661&r1=1213660&r2=1213661&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/encryption/Decrypter.java (original)
+++ santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/encryption/Decrypter.java Tue Dec 13 12:36:22 2011
@@ -57,7 +57,7 @@ public class Decrypter {
}
private static Document loadEncryptionDocument() throws Exception {
- String fileName = "encryptedInfo.xml";
+ String fileName = "build/encryptedInfo.xml";
File encryptionFile = new File(fileName);
javax.xml.parsers.DocumentBuilderFactory dbf =
javax.xml.parsers.DocumentBuilderFactory.newInstance();
@@ -71,7 +71,7 @@ public class Decrypter {
}
private static SecretKey loadKeyEncryptionKey() throws Exception {
- String fileName = "kek";
+ String fileName = "build/kek";
String jceAlgorithmName = "DESede";
File kekFile = new File(fileName);
@@ -135,6 +135,6 @@ public class Decrypter {
*/
xmlCipher.doFinal(document, encryptedDataElement);
- outputDocToFile(document, "decryptedInfo.xml");
+ outputDocToFile(document, "build/decryptedInfo.xml");
}
}
Modified: santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/encryption/Encrypter.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/encryption/Encrypter.java?rev=1213661&r1=1213660&r2=1213661&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/encryption/Encrypter.java (original)
+++ santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/encryption/Encrypter.java Tue Dec 13 12:36:22 2011
@@ -99,11 +99,11 @@ public class Encrypter {
SecretKey kek = keyGenerator.generateKey();
byte[] keyBytes = kek.getEncoded();
- File kekFile = new File("kek");
+ File kekFile = new File("build/kek");
FileOutputStream f = new FileOutputStream(kekFile);
f.write(keyBytes);
f.close();
- System.out.println("Key encryption key stored in " + kekFile.toURL().toString());
+ System.out.println("Key encryption key stored in " + kekFile.toURI().toURL().toString());
return kek;
}
@@ -189,6 +189,6 @@ public class Encrypter {
* Output the document containing the encrypted information into
* a file.
*/
- outputDocToFile(document, "encryptedInfo.xml");
+ outputDocToFile(document, "build/encryptedInfo.xml");
}
}
Modified: santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/CreateEnvelopingSignature.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/CreateEnvelopingSignature.java?rev=1213661&r1=1213660&r2=1213661&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/CreateEnvelopingSignature.java (original)
+++ santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/CreateEnvelopingSignature.java Tue Dec 13 12:36:22 2011
@@ -58,7 +58,7 @@ public class CreateEnvelopingSignature {
String privateKeyAlias = "test";
String privateKeyPass = "xmlsecurity";
String certificateAlias = "test";
- File signatureFile = new File("signature.xml");
+ File signatureFile = new File("build/signature.xml");
KeyStore ks = KeyStore.getInstance(keystoreType);
FileInputStream fis = new FileInputStream(keystoreFile);
Modified: santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/CreateSignature.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/CreateSignature.java?rev=1213661&r1=1213660&r2=1213661&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/CreateSignature.java (original)
+++ santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/CreateSignature.java Tue Dec 13 12:36:22 2011
@@ -62,7 +62,7 @@ public class CreateSignature {
String privateKeyAlias = "test";
String privateKeyPass = "xmlsecurity";
String certificateAlias = "test";
- File signatureFile = new File("signature.xml");
+ File signatureFile = new File("build/signature.xml");
KeyStore ks = KeyStore.getInstance(keystoreType);
FileInputStream fis = new FileInputStream(keystoreFile);
Modified: santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/VerifySignature.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/VerifySignature.java?rev=1213661&r1=1213660&r2=1213661&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/VerifySignature.java (original)
+++ santuario/xml-security-java/trunk/samples/org/apache/xml/security/samples/signature/VerifySignature.java Tue Dec 13 12:36:22 2011
@@ -55,7 +55,7 @@ public class VerifySignature {
boolean schemaValidate = false;
final String signatureSchemaFile = "samples/data/xmldsig-core-schema.xsd";
- String signatureFileName = "signature.xml";
+ String signatureFileName = "build/signature.xml";
if (schemaValidate) {
System.out.println("We do schema-validation");
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java?rev=1213661&r1=1213660&r2=1213661&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java Tue Dec 13 12:36:22 2011
@@ -74,7 +74,7 @@ public class ResolverFragment extends Re
* Identifies a node-set containing the element with ID attribute
* value 'chapter1' of the XML resource containing the signature.
* XML Signature (and its applications) modify this node-set to
- * include the element plus all descendents including namespaces and
+ * include the element plus all descendants including namespaces and
* attributes -- but not comments.
*/
String id = uriNodeValue.substring(1);
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/DSNamespaceContext.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/DSNamespaceContext.java?rev=1213661&r1=1213660&r2=1213661&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/DSNamespaceContext.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/DSNamespaceContext.java Tue Dec 13 12:36:22 2011
@@ -44,6 +44,10 @@ public class DSNamespaceContext implemen
public String getNamespaceURI(String arg0) {
return namespaceMap.get(arg0);
}
+
+ public void putPrefix(String prefix, String namespace) {
+ namespaceMap.put(prefix, namespace);
+ }
public String getPrefix(String arg0) {
for (String key : namespaceMap.keySet()) {