abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r414893 [11/11] - in /incubator/abdera/java/trunk: ./ build/ core/ core/src/ core/src/main/ core/src/main/java/ core/src/main/java/org/ core/src/main/java/org/apache/ core/src/main/java/org/apache/abdera/ core/src/main/java/org/apache/abder...
Date Fri, 16 Jun 2006 20:10:56 GMT
Added: incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserTest.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserTest.java (added)
+++ incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/ParserTest.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,58 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.test.parser.stax;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.parser.stax.FOMFactory;
+import org.apache.abdera.parser.stax.FOMParser;
+import org.apache.abdera.parser.stax.FOMXPath;
+import org.apache.abdera.xpath.XPath;
+
+import junit.framework.TestCase;
+
+public class ParserTest extends TestCase {
+
+  public static void testConfiguration() {
+    assertTrue(Factory.INSTANCE instanceof FOMFactory);
+    assertTrue(Parser.INSTANCE instanceof FOMParser);
+    assertTrue(XPath.INSTANCE instanceof FOMXPath);
+  }
+  
+  public static void testParse() {
+    
+    Document<Feed> feedDoc = Parser.INSTANCE.parse(ParserTest.class.getResourceAsStream("/simpleFeed.xml"));
+    assertTrue(feedDoc.getRoot() instanceof Feed);
+    assertEquals(feedDoc.getCharset(), "utf-8");
+    
+    Document<Entry> entryDoc = Parser.INSTANCE.parse(ParserTest.class.getResourceAsStream("/simpleEntry.xml"));
+    assertTrue(entryDoc.getRoot() instanceof Entry);
+    assertEquals(entryDoc.getCharset(), "utf-8");
+    
+    Document<Service> serviceDoc = Parser.INSTANCE.parse(ParserTest.class.getResourceAsStream("/simpleService.xml"));
+    assertTrue(serviceDoc.getRoot() instanceof Service);
+    assertEquals(serviceDoc.getCharset(), "utf-8");
+    
+  }
+  
+  //TODO: need lots more unit tests
+}

Added: incubator/abdera/java/trunk/parser/src/test/java/simple.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/simple.xml?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/simple.xml (added)
+++ incubator/abdera/java/trunk/parser/src/test/java/simple.xml Fri Jun 16 13:10:47 2006
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+  
+  <title>Example Feed</title>
+  <link href="http://example.org/"/>
+  <updated>2003-12-13T18:30:02Z</updated>
+  <author>
+    <name>John Doe</name>
+  </author>
+  <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
+
+  <entry>
+    <title>Atom-Powered Robots Run Amok</title>
+    <link href="http://example.org/2003/12/13/atom03"/>
+    <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+    <updated>2003-12-13T18:30:02Z</updated>
+    <summary>Some text.</summary>
+  </entry>
+
+</feed>
\ No newline at end of file

Added: incubator/abdera/java/trunk/parser/src/test/java/simpleEntry.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/simpleEntry.xml?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/simpleEntry.xml (added)
+++ incubator/abdera/java/trunk/parser/src/test/java/simpleEntry.xml Fri Jun 16 13:10:47 2006
@@ -0,0 +1,4 @@
+<?xml version="1.0" ?>
+<entry xmlns="http://www.w3.org/2005/Atom">
+  <!-- no content -->
+</entry>
\ No newline at end of file

Added: incubator/abdera/java/trunk/parser/src/test/java/simpleFeed.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/simpleFeed.xml?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/simpleFeed.xml (added)
+++ incubator/abdera/java/trunk/parser/src/test/java/simpleFeed.xml Fri Jun 16 13:10:47 2006
@@ -0,0 +1,4 @@
+<?xml version="1.0" ?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+  <!-- no content -->
+</feed>
\ No newline at end of file

Added: incubator/abdera/java/trunk/parser/src/test/java/simpleService.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/simpleService.xml?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/simpleService.xml (added)
+++ incubator/abdera/java/trunk/parser/src/test/java/simpleService.xml Fri Jun 16 13:10:47 2006
@@ -0,0 +1,4 @@
+<?xml version="1.0" ?>
+<service xmlns="http://purl.org/atom/app#">
+  <!-- no content -->
+</service>
\ No newline at end of file

Added: incubator/abdera/java/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/pom.xml?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/pom.xml (added)
+++ incubator/abdera/java/trunk/pom.xml Fri Jun 16 13:10:47 2006
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project 
+  xmlns="http://maven.apache.org/POM/4.0.0" 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.abdera</groupId>
+  <artifactId>abdera</artifactId>
+  <packaging>pom</packaging>
+  <name>Apache Abdera</name>  
+  <version>0.1-SNAPSHOT</version>  
+  <description>Atom Specification Implementation</description>
+  <inceptionYear>2006</inceptionYear>
+  <url>http://incubator.apache.org/projects/abdera.html</url>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>3.8.2</version>
+        <scope>test</scope>
+      </dependency>
+      
+      <dependency>
+        <groupId>commons-logging</groupId>
+        <artifactId>commons-logging</artifactId>
+        <version>1.0.4</version>
+        <scope>compile</scope>
+      </dependency>
+      
+      <dependency>
+        <groupId>commons-httpclient</groupId>
+        <artifactId>commons-httpclient</artifactId>
+        <version>3.0</version>
+        <scope>compile</scope>
+      </dependency>
+      
+      <dependency>
+        <groupId>ws-commons</groupId>
+        <artifactId>axiom-api</artifactId>
+        <version>1.0</version>
+        <scope>compile</scope>
+      </dependency>
+      
+      <dependency>
+        <groupId>ws-commons</groupId>
+        <artifactId>axiom-impl</artifactId>
+        <version>1.0</version>
+        <scope>compile</scope>
+      </dependency>
+      
+      <dependency>
+        <groupId>stax</groupId>
+        <artifactId>stax-api</artifactId>
+        <version>1.0</version>
+        <scope>compile</scope>
+      </dependency>
+      
+      <dependency>
+        <groupId>stax</groupId>
+        <artifactId>stax</artifactId>
+        <version>1.1.2-dev</version>
+        <scope>runtime</scope>
+        <exclusions>
+          <exclusion>
+            <groupId>xmlbeans</groupId>
+            <artifactId>xmlbeans-jsr173-api</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
+      
+      <dependency>
+        <groupId>geronimo</groupId>
+        <artifactId>geronimo-activation</artifactId>
+        <version>1.0</version>
+        <scope>compile</scope>
+      </dependency>
+      
+      <dependency>
+        <groupId>jaxen</groupId>
+        <artifactId>jaxen</artifactId>
+        <version>1.1-beta-7</version>
+        <scope>compile</scope>
+      </dependency>
+      
+      <dependency>
+        <groupId>xml-security</groupId>
+        <artifactId>xmlsec</artifactId>
+        <version>1.3.0</version>
+        <scope>compile</scope>
+      </dependency>
+      
+      <dependency>
+        <groupId>xerces</groupId>
+        <artifactId>xercesImpl</artifactId>
+        <version>2.8.0</version>
+        <scope>compile</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+  
+  <modules>
+    <module>core</module>
+    <module>parser</module>
+    <module>security</module>
+    <module>examples</module>
+  </modules>
+</project>

Propchange: incubator/abdera/java/trunk/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/abdera/java/trunk/security/README
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/README?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/README (added)
+++ incubator/abdera/java/trunk/security/README Fri Jun 16 13:10:47 2006
@@ -0,0 +1,5 @@
+Currently excluded from the build.  
+
+Requires the Apache XML Security version 1.3 to compile and the Bouncing Castle 
+Crypto implementation to run.
+

Added: incubator/abdera/java/trunk/security/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/pom.xml?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/pom.xml (added)
+++ incubator/abdera/java/trunk/security/pom.xml Fri Jun 16 13:10:47 2006
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project 
+  xmlns="http://maven.apache.org/POM/4.0.0" 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache.abdera</groupId>
+    <artifactId>abdera</artifactId>
+    <version>0.1-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>abdera-security</artifactId>
+  <packaging>jar</packaging>  
+  <name>Abdera Security</name>  
+  <version>0.1-SNAPSHOT</version>
+  <description>Atom Specification Implementation Security</description>  
+  <inceptionYear>2006</inceptionYear>
+  <dependencies>
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>3.8.2</version>
+        <scope>test</scope>
+      </dependency>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-core</artifactId>
+      <version>0.1-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>xml-security</groupId>
+      <artifactId>xmlsec</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>xerces</groupId>
+      <artifactId>xercesImpl</artifactId>
+    </dependency>
+  </dependencies>
+</project>

Propchange: incubator/abdera/java/trunk/security/pom.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/Encryption.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/Encryption.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/Encryption.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/Encryption.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,39 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security;
+
+import org.apache.abdera.model.Document;
+import org.apache.abdera.util.ServiceUtil;
+
+
+public interface Encryption {
+
+  public static final Encryption INSTANCE = 
+    (Encryption) ServiceUtil.newInstance(
+      "org.apache.abdera.security.Encryption", 
+      "org.apache.abdera.security.xmlsec.XmlEncryption");
+  
+  Document encrypt(Document doc, EncryptionOptions options) throws SecurityException;
+  
+  Document decrypt(Document doc, EncryptionOptions options) throws SecurityException;
+  
+  boolean isEncrypted(Document doc) throws SecurityException;
+  
+  EncryptionOptions getDefaultEncryptionOptions();
+  
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/EncryptionOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/EncryptionOptions.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/EncryptionOptions.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/EncryptionOptions.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security;
+
+import java.security.Key;
+
+public interface EncryptionOptions 
+  extends SecurityOptions {
+
+  Key getDataEncryptionKey();
+  
+  void setDataEncryptionKey(Key key);
+  
+  Key getKeyEncryptionKey();
+  
+  void setKeyEncryptionKey(Key key);
+  
+  String getKeyCipherAlgorithm();
+  
+  void setKeyCipherAlgorithm(String alg);
+  
+  String getDataCipherAlgorithm();
+  
+  void setDataCipherAlgorithm(String alg);
+  
+  boolean includeKeyInfo();
+  
+  void setIncludeKeyInfo(boolean includeKeyInfo);
+  
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SecurityException.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SecurityException.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SecurityException.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SecurityException.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,40 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security;
+
+public class SecurityException extends Exception {
+
+  private static final long serialVersionUID = 7981088993260681788L;
+
+  public SecurityException() {
+    super();
+  }
+
+  public SecurityException(String message) {
+    super(message);
+  }
+
+  public SecurityException(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public SecurityException(Throwable cause) {
+    super(cause);
+  }
+
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SecurityOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SecurityOptions.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SecurityOptions.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SecurityOptions.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,28 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security;
+
+import org.apache.abdera.parser.Parser;
+
+public interface SecurityOptions {
+
+  Parser getParser();
+  
+  void setParser(Parser parser);
+  
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/Signature.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/Signature.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/Signature.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/Signature.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,46 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security;
+
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.util.ServiceUtil;
+
+
+public interface Signature {
+
+  public static final Signature INSTANCE = 
+    (Signature) ServiceUtil.newInstance(
+      "org.apache.abdera.security.Signature", 
+      "org.apache.abdera.security.xmlsec.XmlSignature");
+  
+  boolean isSigned(Entry entry) throws SecurityException;
+  
+  boolean isSigned(Feed feed) throws SecurityException;
+  
+  Entry sign(Entry entry, SignatureOptions options) throws SecurityException;
+  
+  Feed sign(Feed feed, SignatureOptions options) throws SecurityException;
+  
+  boolean verify(Entry entry, SignatureOptions options) throws SecurityException;
+  
+  boolean verify(Feed feed, SignatureOptions options) throws SecurityException;
+  
+  SignatureOptions getDefaultSignatureOptions() throws SecurityException;
+  
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SignatureOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SignatureOptions.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SignatureOptions.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/SignatureOptions.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,35 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security;
+
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+
+public interface SignatureOptions 
+  extends SecurityOptions {
+
+  PrivateKey getSigningKey();
+  
+  void setSigningKey(PrivateKey privateKey);
+  
+  X509Certificate getCertificate();
+  
+  void setCertificate(X509Certificate cert);
+
+  
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/Constants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/Constants.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/Constants.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/Constants.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,36 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security.util;
+
+import javax.xml.namespace.QName;
+
+public final class Constants {
+
+  Constants() {}
+  
+  public static final String DSIG_NS = "http://www.w3.org/2000/09/xmldsig#";
+  public static final String XENC_NS = "http://www.w3.org/2001/04/xmlenc#";
+  public static final String LN_SIGNATURE = "Signature";
+  public static final String LN_ENCRYPTEDDATA = "EncryptedData";
+  public static final String DSIG_PREFIX = "dsig";
+  public static final String XENC_PREFIX = "xenc";
+  
+  public static final QName SIGNATURE = new QName(DSIG_NS, LN_SIGNATURE, DSIG_PREFIX);
+  public static final QName ENCRYPTEDDATA = new QName(XENC_NS, LN_ENCRYPTEDDATA, XENC_PREFIX);
+
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/EncryptionBase.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/EncryptionBase.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/EncryptionBase.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/EncryptionBase.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,36 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security.util;
+
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.ExtensionElement;
+import org.apache.abdera.security.Encryption;
+import org.apache.abdera.security.SecurityException;
+
+
+public abstract class EncryptionBase 
+  extends SecurityBase
+  implements Encryption {
+
+  public boolean isEncrypted(
+    Document doc) throws SecurityException {
+      ExtensionElement el = (ExtensionElement) doc.getRoot();
+      return el.getQName().equals(Constants.ENCRYPTEDDATA);
+  }
+
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/SecurityBase.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/SecurityBase.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/SecurityBase.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/SecurityBase.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,104 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.security.SecurityOptions;
+import org.apache.xml.serialize.Serializer;
+import org.apache.xml.serialize.XMLSerializer;
+
+
+public abstract class SecurityBase {
+  
+  protected org.w3c.dom.Document fomToDom(
+    Document doc, 
+    SecurityOptions options) {
+    org.w3c.dom.Document dom = null;
+    if (doc != null) {
+      try {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        doc.writeTo(out);
+        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setValidating(false);
+        dbf.setNamespaceAware(true);
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        dom = db.parse(in);
+      } catch (Exception e) {}
+    } 
+    return dom;
+  }
+  
+  protected Document domToFom(
+    org.w3c.dom.Document dom, 
+    SecurityOptions options) {
+      Document doc = null;
+      if (dom != null) {
+        try {
+          Serializer ser = new XMLSerializer();
+          ByteArrayOutputStream out = new ByteArrayOutputStream();
+          ser.setOutputByteStream(out);
+          ser.asDOMSerializer().serialize(dom);
+          ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+          doc = options.getParser().parse(in);
+        } catch (Exception e) {}
+      }
+      return doc;
+  }
+  
+  protected org.w3c.dom.Element fomToDom(
+    Element element, 
+    SecurityOptions options) {
+    org.w3c.dom.Element dom = null;
+    if (element != null) {
+      try {
+        ByteArrayInputStream in = new ByteArrayInputStream(element.toString().getBytes());
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setValidating(false);
+        dbf.setNamespaceAware(true);
+        DocumentBuilder db = dbf.newDocumentBuilder();
+        dom = db.parse(in).getDocumentElement();
+      } catch (Exception e) {}
+    } 
+    return dom;
+  }
+  
+  protected Element domToFom(
+    org.w3c.dom.Element element, 
+    SecurityOptions options) {
+    Element el = null;
+    if (element != null) {
+      try {
+        Serializer ser = new XMLSerializer();
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ser.setOutputByteStream(out);
+        ser.asDOMSerializer().serialize(element);
+        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+        el = options.getParser().parse(in).getRoot();
+      } catch (Exception e) {}
+    }
+    return el;
+  }
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/SignatureBase.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/SignatureBase.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/SignatureBase.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/SignatureBase.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security.util;
+
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.ExtensibleElement;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.security.SecurityException;
+import org.apache.abdera.security.Signature;
+
+
+public abstract class SignatureBase 
+  extends SecurityBase
+  implements Signature {
+
+  public boolean isSigned(
+    Entry entry)  throws SecurityException {
+      return _isSigned(entry);
+  }
+
+  public boolean isSigned(
+    Feed feed)  throws SecurityException {
+      return _isSigned(feed);
+  }
+  
+  private boolean _isSigned(ExtensibleElement element) {
+    return element.getExtension(Constants.SIGNATURE) != null;
+  }
+
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlEncryption.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlEncryption.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlEncryption.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlEncryption.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,95 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security.xmlsec;
+
+import java.security.Key;
+
+import org.apache.abdera.model.Document;
+import org.apache.abdera.security.Encryption;
+import org.apache.abdera.security.EncryptionOptions;
+import org.apache.abdera.security.SecurityException;
+import org.apache.abdera.security.util.EncryptionBase;
+import org.apache.xml.security.encryption.EncryptedData;
+import org.apache.xml.security.encryption.EncryptedKey;
+import org.apache.xml.security.encryption.XMLCipher;
+import org.apache.xml.security.keys.KeyInfo;
+
+
+public class XmlEncryption 
+  extends EncryptionBase 
+  implements Encryption {
+
+  static {
+    if (!org.apache.xml.security.Init.isInitialized())
+      org.apache.xml.security.Init.init();
+  }
+  
+  public Document encrypt(
+    Document doc, 
+    EncryptionOptions options) throws SecurityException {
+      try {
+        org.w3c.dom.Document dom = fomToDom(doc, options);
+        Key dek = options.getDataEncryptionKey();
+        Key kek = options.getKeyEncryptionKey();
+        String dalg = options.getDataCipherAlgorithm();
+        String kalg = options.getKeyCipherAlgorithm();
+        boolean includeki = options.includeKeyInfo();
+        EncryptedKey enckey = null;
+        XMLCipher xmlCipher = XMLCipher.getInstance(dalg);
+        xmlCipher.init(XMLCipher.ENCRYPT_MODE, dek);
+        if (includeki && kek != null && dek != null) {
+          XMLCipher keyCipher = XMLCipher.getInstance(kalg);
+          keyCipher.init(XMLCipher.WRAP_MODE, kek);
+          enckey = keyCipher.encryptKey(dom, dek);
+          EncryptedData encdata = xmlCipher.getEncryptedData();
+          KeyInfo keyInfo = new KeyInfo(dom);
+          keyInfo.add(enckey);
+          encdata.setKeyInfo(keyInfo);
+        }
+        dom = xmlCipher.doFinal(dom, dom.getDocumentElement(), false);
+        return domToFom(dom, options);
+      } catch (Exception e) {
+        throw new SecurityException(e);
+      }
+  }
+
+  public Document decrypt(
+    Document doc, 
+    EncryptionOptions options) throws SecurityException {
+      if (!isEncrypted(doc)) return null;
+      try {
+        org.w3c.dom.Document dom = fomToDom(doc, options);
+        Key kek = options.getKeyEncryptionKey();
+        Key dek = options.getDataEncryptionKey();
+        org.w3c.dom.Element element = dom.getDocumentElement();
+        XMLCipher xmlCipher = XMLCipher.getInstance();
+        xmlCipher.init(XMLCipher.DECRYPT_MODE, dek);
+        xmlCipher.setKEK(kek);
+        dom = xmlCipher.doFinal(dom, element);
+        return domToFom(dom, options);
+      } catch (Exception e) {
+        throw new SecurityException(e);
+      }
+  }
+
+
+  public EncryptionOptions getDefaultEncryptionOptions() {
+    return new XmlEncryptionOptions();
+  }
+
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlEncryptionOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlEncryptionOptions.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlEncryptionOptions.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlEncryptionOptions.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,74 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security.xmlsec;
+
+import java.security.Key;
+
+import org.apache.abdera.security.EncryptionOptions;
+
+
+public class XmlEncryptionOptions 
+  extends XmlSecurityOptions
+  implements EncryptionOptions {
+
+  private Key dek = null;
+  private Key kek = null;
+  private String kca = "http://www.w3.org/2001/04/xmlenc#kw-aes128";
+  private String dca = "http://www.w3.org/2001/04/xmlenc#aes128-cbc";
+  private boolean setki = false;
+  
+  public Key getDataEncryptionKey() {
+    return dek;
+  }
+
+  public void setDataEncryptionKey(Key key) {
+    this.dek = key;
+  }
+
+  public Key getKeyEncryptionKey() {
+    return kek;
+  }
+
+  public void setKeyEncryptionKey(Key key) {
+    this.kek = key;
+  }
+
+  public String getKeyCipherAlgorithm() {
+    return kca;
+  }
+
+  public void setKeyCipherAlgorithm(String alg) {
+    this.kca = alg;
+  }
+
+  public String getDataCipherAlgorithm() {
+    return dca;
+  }
+
+  public void setDataCipherAlgorithm(String alg) {
+    this.dca = alg;
+  }
+
+  public boolean includeKeyInfo() {
+    return setki;
+  }
+
+  public void setIncludeKeyInfo(boolean includeKeyInfo) {
+    this.setki = includeKeyInfo;
+  }
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSecurityOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSecurityOptions.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSecurityOptions.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSecurityOptions.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,37 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security.xmlsec;
+
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.security.SecurityOptions;
+
+
+public abstract class XmlSecurityOptions 
+  implements SecurityOptions {
+
+  protected Parser parser = null;
+
+  public Parser getParser() {
+    return (parser != null) ? parser : Parser.INSTANCE;
+  }
+
+  public void setParser(Parser parser) {
+    this.parser = parser;
+  }
+
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSignature.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSignature.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSignature.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSignature.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,162 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security.xmlsec;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.cert.X509Certificate;
+
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.security.SecurityException;
+import org.apache.abdera.security.SignatureOptions;
+import org.apache.abdera.security.util.Constants;
+import org.apache.abdera.security.util.SignatureBase;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.keys.KeyInfo;
+import org.apache.xml.security.signature.XMLSignature;
+import org.apache.xml.security.signature.XMLSignatureException;
+import org.apache.xml.security.transforms.Transforms;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+public class XmlSignature 
+  extends SignatureBase {
+
+  static {
+    if (!org.apache.xml.security.Init.isInitialized())
+      org.apache.xml.security.Init.init();
+  }
+  
+  private Element _sign(
+    Element element, 
+    SignatureOptions options) 
+      throws XMLSecurityException, 
+             URISyntaxException {    
+    element.setBaseUri(element.getResolvedBaseUri());
+    org.w3c.dom.Element dom = fomToDom((Element)element.clone(), options);
+    org.w3c.dom.Document domdoc = dom.getOwnerDocument();
+    PrivateKey signingKey = options.getSigningKey();
+    X509Certificate cert = options.getCertificate();
+    URI baseUri = element.getResolvedBaseUri();
+    XMLSignature sig = new XMLSignature(
+      domdoc, 
+      (baseUri != null) ? baseUri.toString() : "", 
+      XMLSignature.ALGO_ID_SIGNATURE_DSA);
+    dom.appendChild(sig.getElement());
+    Transforms transforms = new Transforms(domdoc);
+    transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
+    transforms.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
+    sig.addDocument("", transforms, org.apache.xml.security.utils.Constants.ALGO_ID_DIGEST_SHA1);
+    sig.addKeyInfo(cert);
+    sig.addKeyInfo(cert.getPublicKey());
+    sig.sign(signingKey);    
+    return (Element)domToFom(dom, options);
+  }
+  
+  public Entry sign(
+    Entry entry, 
+    SignatureOptions options) 
+      throws SecurityException {
+    try {
+      return (Entry) _sign(entry, options);
+    } catch (Exception e) {
+      throw new SecurityException(e);
+    }
+  }
+
+  public Feed sign(
+    Feed feed, 
+    SignatureOptions options)
+      throws SecurityException {
+    try {
+      return (Feed) _sign(feed, options);
+    } catch (Exception e) {
+      throw new SecurityException(e);
+    }
+  }
+  
+  private boolean _verify(
+    Element element, 
+    SignatureOptions options) 
+      throws XMLSignatureException, 
+             XMLSecurityException, 
+             URISyntaxException {
+    boolean answer = false;
+    org.w3c.dom.Element dom = fomToDom((Element)element, options);
+    NodeList children = dom.getChildNodes();
+    for (int n = 0; n < children.getLength(); n++) {
+      Node node = children.item(n);
+      if (node.getNodeType() == Node.ELEMENT_NODE) {
+        org.w3c.dom.Element el = (org.w3c.dom.Element) node;
+        if (Constants.DSIG_NS.equals(el.getNamespaceURI()) &&
+            Constants.LN_SIGNATURE.equals(el.getLocalName())) {
+          URI baseUri = element.getResolvedBaseUri();
+          XMLSignature sig = 
+            new XMLSignature(
+              el, (baseUri != null) ? baseUri.toString() : "");
+          KeyInfo ki = sig.getKeyInfo();
+          if (ki != null) {
+            X509Certificate cert = ki.getX509Certificate();
+            if (cert != null) {
+              answer = sig.checkSignatureValue(cert);
+            } else {
+              PublicKey key = ki.getPublicKey();
+              if (key != null) {
+                answer = sig.checkSignatureValue(key);
+              }
+            }
+          }
+        }
+      }
+    }
+    
+    return answer;
+  }
+  
+  public boolean verify(
+    Entry entry, 
+    SignatureOptions options) throws SecurityException {
+      if (!isSigned(entry)) return false;
+      try {
+        return _verify(entry,options);
+      } catch (Exception e) {
+        throw new SecurityException(e);
+      }
+  }
+
+  public boolean verify(
+    Feed feed, 
+    SignatureOptions options) throws SecurityException {
+      if (!isSigned(feed)) return false;
+      try {
+        return _verify(feed,options);
+      } catch (Exception e) {
+        throw new SecurityException(e);
+      }
+  }
+
+  public SignatureOptions getDefaultSignatureOptions() throws SecurityException {
+    return new XmlSignatureOptions();
+  }
+
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSignatureOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSignatureOptions.java?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSignatureOptions.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/xmlsec/XmlSignatureOptions.java Fri Jun 16 13:10:47 2006
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.security.xmlsec;
+
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+
+import org.apache.abdera.security.SignatureOptions;
+
+
+public class XmlSignatureOptions 
+  extends XmlSecurityOptions 
+  implements SignatureOptions {
+
+  private PrivateKey signingKey = null;
+  private X509Certificate cert = null;
+
+  public PrivateKey getSigningKey() {
+    return signingKey;
+  }
+
+  public void setSigningKey(PrivateKey privateKey) {
+    this.signingKey = privateKey;
+  }
+
+  public X509Certificate getCertificate() {
+    return cert;
+  }
+
+  public void setCertificate(X509Certificate cert) {
+    this.cert = cert;
+  }
+
+}

Added: incubator/abdera/java/trunk/security/src/test/java/Placeholder
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/test/java/Placeholder?rev=414893&view=auto
==============================================================================
--- incubator/abdera/java/trunk/security/src/test/java/Placeholder (added)
+++ incubator/abdera/java/trunk/security/src/test/java/Placeholder Fri Jun 16 13:10:47 2006
@@ -0,0 +1 @@
+TODO: We need Security test cases
\ No newline at end of file



Mime
View raw message