abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r555349 [1/2] - in /incubator/abdera/java/trunk: build/ examples/src/main/java/org/apache/abdera/examples/appserver/ protocol/src/main/java/org/apache/abdera/protocol/ protocol/src/main/java/org/apache/abdera/protocol/util/ security/ securi...
Date Wed, 11 Jul 2007 18:07:45 GMT
Author: jmsnell
Date: Wed Jul 11 11:07:36 2007
New Revision: 555349

URL: http://svn.apache.org/viewvc?view=rev&rev=555349
Log:
Refactoring of the server code and improvements to the security code

  * Refactor the service module packages to improve code organization and reduce the overall number of packages and interfaces
  * Give Provider implementations more control over how to route requests and the option to support new http methods (such as PATCH)
  * Additional utility methods to make server implementation easier
  
  * General improvements to the utility servlet filters in the Security module.
  * Initial (but still untested) support for encrypted requests

  * Initial (but still untested) support for gzip/deflate compressed responses... only useful, of course, when using a server that does 
    not support compression automatically

Added:
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/ItemManager.java
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Resolver.java
    incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/DHContext.java
      - copied, changed from r541096, incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHContext.java
    incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AESEncryptedResponseFilter.java
      - copied, changed from r541096, incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/EncryptedResponseFilter.java
    incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AbstractEncryptedRequestFilter.java
    incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AbstractEncryptedResponseFilter.java
    incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/BCEncryptedResponseFilter.java
    incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHEncryptedRequestFilter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Provider.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Provider.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java
      - copied, changed from r550706, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/RequestContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandler.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/RequestHandler.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ResponseContext.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/ResponseContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Target.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Target.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/TargetType.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/TargetType.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractItemManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractProvider.java
      - copied, changed from r553708, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/AbstractProvider.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractRequestContext.java
      - copied, changed from r541117, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/AbstractRequestContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractRequestHandler.java
      - copied, changed from r547103, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbstractRequestHandler.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractResponseContext.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/AbstractResponseContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractServiceContext.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/AbstractServiceContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractSingletonProviderManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractSingletonRequestHandlerManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractTarget.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/AbstractTarget.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/BaseResponseContext.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/BaseResponseContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultRequestHandler.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/DefaultRequestHandler.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultRequestHandlerManager.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/DefaultRequestHandlerManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/DefaultServiceContext.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/DefaultServiceContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/EmptyResponseContext.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/EmptyResponseContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/HttpServletRequestContext.java
      - copied, changed from r550706, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/HttpServletRequestContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/MediaResponseContext.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/MediaResponseContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/RegexTargetResolver.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/SimpleSubjectResolver.java
      - copied, changed from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/SimpleSubjectResolver.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaFilter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbstractFilter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/CompressionFilter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/MethodOverrideFilter.java
Removed:
    incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHContext.java
    incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/EncryptedResponseFilter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/AbstractServiceContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/DefaultServiceContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/auth/
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbstractRequestHandler.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbstractRequestHandlerManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/DefaultRequestHandler.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/DefaultRequestHandlerManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/HttpServletRequestContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/RequestHandler.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/RequestHandlerManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/TypeRequestHandler.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSingletonProviderManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/RegexTargetResolver.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/SimpleSubjectResolver.java
Modified:
    incubator/abdera/java/trunk/build/build.xml
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProviderManager.java
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleServiceContext.java
    incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleTargetResolver.java
    incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/ProtocolConstants.java
    incubator/abdera/java/trunk/security/pom.xml
    incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/KeyHelper.java
    incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHEncryptedResponseFilter.java
    incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/SecurityFilter.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/AbderaServlet.java
    incubator/abdera/java/trunk/server/src/test/java/org/apache/abdera/test/server/UtilityTest.java

Modified: incubator/abdera/java/trunk/build/build.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/build/build.xml?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/build/build.xml (original)
+++ incubator/abdera/java/trunk/build/build.xml Wed Jul 11 11:07:36 2007
@@ -276,9 +276,9 @@
     </copy>
   </target>
 
-  <target name="compile.security" depends="init, compile.core" if="do.security">
+  <target name="compile.security" depends="init, compile.core, compile.server" if="do.security">
     <mkdir dir="${security.work}" />
-    <javac srcdir="${security.src}" destdir="${security.work}" classpathref="jar.dependencies" classpath="${core.work}" debug="${debug}" />
+    <javac srcdir="${security.src}" destdir="${security.work}" classpathref="jar.dependencies" classpath="${core.work};${protocol.work};${server.work}" debug="${debug}" />
     <javac srcdir="${security.test.java}" destdir="${test}" classpathref="jar.dependencies" classpath="${core.work};${parser.work};${security.work};${protocol.work}:${client.work}" debug="${debug}" />
     <mkdir dir="${security.work}/META-INF" />
     <copy todir="${test}">

Modified: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java (original)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProvider.java Wed Jul 11 11:07:36 2007
@@ -17,7 +17,6 @@
 */
 package org.apache.abdera.examples.appserver;
 
-import java.security.MessageDigest;
 import java.util.Date;
 
 import javax.activation.MimeType;
@@ -33,25 +32,30 @@
 import org.apache.abdera.model.Workspace;
 import org.apache.abdera.parser.ParseException;
 import org.apache.abdera.parser.Parser;
-import org.apache.abdera.protocol.server.provider.AbstractResponseContext;
-import org.apache.abdera.protocol.server.provider.BaseResponseContext;
-import org.apache.abdera.protocol.server.provider.EmptyResponseContext;
-import org.apache.abdera.protocol.server.provider.Provider;
-import org.apache.abdera.protocol.server.provider.RequestContext;
-import org.apache.abdera.protocol.server.provider.ResponseContext;
-import org.apache.abdera.protocol.server.provider.TargetType;
+import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.RequestContext;
+import org.apache.abdera.protocol.server.ResponseContext;
+import org.apache.abdera.protocol.server.TargetType;
+import org.apache.abdera.protocol.server.impl.AbstractProvider;
+import org.apache.abdera.protocol.server.impl.AbstractResponseContext;
+import org.apache.abdera.protocol.server.impl.BaseResponseContext;
+import org.apache.abdera.protocol.server.impl.EmptyResponseContext;
 import org.apache.abdera.util.EntityTag;
 import org.apache.abdera.util.MimeTypeHelper;
 import org.apache.abdera.i18n.iri.IRI;
-import org.apache.axiom.om.util.Base64;
 
 public class SimpleProvider 
+  extends AbstractProvider
   implements Provider {
 
   private EntityTag service_etag = new EntityTag("simple");
   private Document<Service> service_doc;
   private Document<Feed> feed_doc;
   
+  public SimpleProvider() {
+    super(10);
+  }
+  
   private Document<Service> init_service_doc(Abdera abdera) {
     Factory factory = abdera.getFactory();
     Service service = factory.newService();
@@ -94,7 +98,7 @@
   
   public ResponseContext getService(
     RequestContext request) {
-      Abdera abdera = request.getServiceContext().getAbdera();
+      Abdera abdera = request.getAbdera();
       Document<Service> service = get_service_doc(abdera);
       AbstractResponseContext rc; 
       rc = new BaseResponseContext<Document<Service>>(service); 
@@ -104,7 +108,7 @@
   
   public ResponseContext getFeed(
     RequestContext request) {
-      Abdera abdera = request.getServiceContext().getAbdera();
+      Abdera abdera = request.getAbdera();
       Document<Feed> feed = get_feed_doc(abdera);
       AbstractResponseContext rc; 
       rc = new BaseResponseContext<Document<Feed>>(feed);
@@ -115,7 +119,7 @@
   @SuppressWarnings("unchecked")
   public ResponseContext createEntry(
     RequestContext request) {
-      Abdera abdera = request.getServiceContext().getAbdera();
+      Abdera abdera = request.getAbdera();
       Factory factory = abdera.getFactory();
       Parser parser = abdera.getParser();
       try {
@@ -155,10 +159,6 @@
       }
   }
   
-  private IRI resolveBase(RequestContext request) {
-    return request.getBaseUri().resolve(request.getUri());
-  }
-  
   public ResponseContext deleteEntry(
     RequestContext request) {
       Entry entry = getAbderaEntry(request);
@@ -186,7 +186,7 @@
   @SuppressWarnings("unchecked")
   public ResponseContext updateEntry(
     RequestContext request) {
-      Abdera abdera = request.getServiceContext().getAbdera();
+      Abdera abdera = request.getAbdera();
       Parser parser = abdera.getParser();
       Factory factory = abdera.getFactory();
       Entry orig_entry = getAbderaEntry(request);
@@ -228,28 +228,20 @@
   }
 
   private EntityTag calculateEntityTag(Base base) {
-    try {
-      String id = null;
-      String modified = null;
-      if (base instanceof Entry) {
-        id = ((Entry)base).getId().toString();
-        modified = ((Entry)base).getUpdatedElement().getText();
-      } else if (base instanceof Feed) {
-        id = ((Feed)base).getId().toString();
-        modified = ((Feed)base).getUpdatedElement().getText();
-      }
-      String tag = id + ":" + modified;
-      byte[] digest = MessageDigest.getInstance("sha1").digest(tag.getBytes());
-      String etag = Base64.encode(digest);
-      return new EntityTag(etag);
-    } catch (Exception e) {
-      // Not going to happen
+    String id = null;
+    String modified = null;
+    if (base instanceof Entry) {
+      id = ((Entry)base).getId().toString();
+      modified = ((Entry)base).getUpdatedElement().getText();
+    } else if (base instanceof Feed) {
+      id = ((Feed)base).getId().toString();
+      modified = ((Feed)base).getUpdatedElement().getText();
     }
-    return null;
+    return EntityTag.generate(id, modified);      
   }
   
   private Entry getAbderaEntry(RequestContext request) {
-    Abdera abdera = request.getServiceContext().getAbdera();
+    Abdera abdera = request.getAbdera();
     String entry_id = getEntryID(request);
     Document<Feed> feed = get_feed_doc(abdera);
     try { 
@@ -266,50 +258,4 @@
     return segments[segments.length-1];
   }
   
-  public ResponseContext entryPost(
-    RequestContext request) {
-      return new EmptyResponseContext(403);
-  }
-  
-  public ResponseContext deleteMedia(
-    RequestContext request) {
-      throw new UnsupportedOperationException();
-  }
-  
-  public ResponseContext mediaPost(
-    RequestContext request) {
-      throw new UnsupportedOperationException();
-  }
-  
-  public ResponseContext getMedia(
-    RequestContext request) {
-      throw new UnsupportedOperationException();
-  }
-  
-  public ResponseContext updateMedia(
-    RequestContext request) {
-      throw new UnsupportedOperationException();
-  }
-
-  private boolean isValidEntry(Entry entry) {
-    try {
-      if (entry.getId() == null || 
-          entry.getId().toString().length() == 0) return false;
-      if (entry.getTitle() == null) return false;
-      if (entry.getAuthor() == null) return false;
-      if (entry.getUpdated() == null) return false;
-      if (entry.getContent() == null) {
-        if (entry.getAlternateLink() == null) return false;
-        if (entry.getSummary() == null) return false;
-      }
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-    return true;
-  }
-
-  public ResponseContext getCategories(RequestContext request) {
-    return null;
-  }
-
 }

Modified: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProviderManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProviderManager.java?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProviderManager.java (original)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleProviderManager.java Wed Jul 11 11:07:36 2007
@@ -17,21 +17,15 @@
 */
 package org.apache.abdera.examples.appserver;
 
-import org.apache.abdera.protocol.server.provider.Provider;
-import org.apache.abdera.protocol.server.provider.ProviderManager;
-import org.apache.abdera.protocol.server.provider.RequestContext;
+import org.apache.abdera.protocol.server.Provider;
+import org.apache.abdera.protocol.server.impl.AbstractSingletonProviderManager;
 
 public class SimpleProviderManager 
-  implements ProviderManager {
+  extends AbstractSingletonProviderManager {
 
-  private static Provider provider = null; 
-
-  public synchronized Provider getProvider(RequestContext request) {
-    if (provider == null)
-      provider = new SimpleProvider();
-    return provider;
+  @Override
+  protected Provider initProvider() {
+    return new SimpleProvider();
   }
-
-  public void release(Provider provider) {}
 
 }

Modified: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleServiceContext.java?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleServiceContext.java (original)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleServiceContext.java Wed Jul 11 11:07:36 2007
@@ -17,19 +17,14 @@
 */
 package org.apache.abdera.examples.appserver;
 
-import org.apache.abdera.protocol.server.DefaultServiceContext;
+import org.apache.abdera.protocol.server.impl.DefaultServiceContext;
 
 public class SimpleServiceContext 
   extends DefaultServiceContext {
 
-  @Override
-  protected String getDefaultProviderManager() {
-    return SimpleProviderManager.class.getName();
-  }
-
-  @Override
-  protected String getDefaultTargetResolver() {
-    return SimpleTargetResolver.class.getName();
+  public SimpleServiceContext() {
+    this.defaultprovidermanager = SimpleProviderManager.class.getName();
+    this.defaulttargetresolver = SimpleTargetResolver.class.getName();
   }
   
 }

Modified: incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleTargetResolver.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleTargetResolver.java?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleTargetResolver.java (original)
+++ incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appserver/SimpleTargetResolver.java Wed Jul 11 11:07:36 2007
@@ -17,8 +17,8 @@
 */
 package org.apache.abdera.examples.appserver;
 
-import org.apache.abdera.protocol.server.provider.TargetType;
-import org.apache.abdera.protocol.server.util.RegexTargetResolver;
+import org.apache.abdera.protocol.server.TargetType;
+import org.apache.abdera.protocol.server.impl.RegexTargetResolver;
 
 public class SimpleTargetResolver 
   extends RegexTargetResolver {

Added: incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/ItemManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/ItemManager.java?view=auto&rev=555349
==============================================================================
--- incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/ItemManager.java (added)
+++ incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/ItemManager.java Wed Jul 11 11:07:36 2007
@@ -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.protocol;
+
+
+
+public interface ItemManager<T> {
+
+  T get(Request request);
+  
+  void release(T item);
+  
+}

Added: incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Resolver.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Resolver.java?view=auto&rev=555349
==============================================================================
--- incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Resolver.java (added)
+++ incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/Resolver.java Wed Jul 11 11:07:36 2007
@@ -0,0 +1,24 @@
+/*
+* 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.protocol;
+
+public interface Resolver<T> {
+
+  T resolve(Request request);
+  
+}

Modified: incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/ProtocolConstants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/ProtocolConstants.java?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/ProtocolConstants.java (original)
+++ incubator/abdera/java/trunk/protocol/src/main/java/org/apache/abdera/protocol/util/ProtocolConstants.java Wed Jul 11 11:07:36 2007
@@ -19,14 +19,14 @@
 
 public interface ProtocolConstants {
 
-  public final static int NOCACHE = 1;
-  public final static int NOSTORE = 2;
-  public final static int NOTRANSFORM = 4;
-  public final static int PUBLIC = 8;
-  public final static int PRIVATE = 16;
-  public final static int REVALIDATE = 32;
+  public final static int NOCACHE         = 1;
+  public final static int NOSTORE         = 2;
+  public final static int NOTRANSFORM     = 4;
+  public final static int PUBLIC          = 8;
+  public final static int PRIVATE         = 16;
+  public final static int REVALIDATE      = 32;
   public final static int PROXYREVALIDATE = 64;
-  public final static int ONLYIFCACHED = 128;
+  public final static int ONLYIFCACHED    = 128;
 
   
 }

Modified: incubator/abdera/java/trunk/security/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/pom.xml?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/security/pom.xml (original)
+++ incubator/abdera/java/trunk/security/pom.xml Wed Jul 11 11:07:36 2007
@@ -67,6 +67,12 @@
       <scope>compile</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-server</artifactId>
+      <version>0.3.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
       <groupId>xml-security</groupId>
       <artifactId>xmlsec</artifactId>
     </dependency>

Copied: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/DHContext.java (from r541096, incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/DHContext.java?view=diff&rev=555349&p1=incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHContext.java&r1=541096&p2=incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/DHContext.java&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHContext.java (original)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/DHContext.java Wed Jul 11 11:07:36 2007
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.security.util.servlet;
+package org.apache.abdera.security.util;
 
 import java.math.BigInteger;
 import java.security.AlgorithmParameterGenerator;
@@ -61,7 +61,8 @@
  * // decrypt
  * 
  */
-public class DHContext {
+public class DHContext 
+  implements Cloneable {
 
   BigInteger p = null, g = null;
   int l = 0;
@@ -80,6 +81,13 @@
     } catch (Exception e) {}
   }
   
+  private DHContext(KeyPair keyPair, BigInteger p, BigInteger g, int l) {
+    this.keyPair = keyPair;
+    this.p = p;
+    this.g = g;
+    this.l = l;
+  }
+  
   public String getRequestString() {
     StringBuffer buf = new StringBuffer();
     buf.append("p=");
@@ -207,4 +215,13 @@
     options.setDataCipherAlgorithm(XMLCipher.TRIPLEDES);
     return options;
   }
+
+  @Override
+  public Object clone() 
+    throws CloneNotSupportedException {
+      if (publicKey == null) throw new CloneNotSupportedException();
+      // create a copy, not an actual clone
+      return new DHContext(keyPair,p,g,l);
+  }
+  
 }

Modified: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/KeyHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/KeyHelper.java?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/KeyHelper.java (original)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/KeyHelper.java Wed Jul 11 11:07:36 2007
@@ -24,19 +24,24 @@
 import java.io.InputStream;
 import java.security.cert.Certificate;
 import java.security.Key;
+import java.security.KeyFactory;
 import java.security.KeyPair;
 import java.security.KeyPairGenerator;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchProviderException;
+import java.security.PublicKey;
 import java.security.SecureRandom;
 import java.security.UnrecoverableKeyException;
 import java.security.cert.CertificateException;
+import java.security.spec.X509EncodedKeySpec;
 
 import javax.crypto.KeyGenerator;
 import javax.crypto.SecretKey;
 
+import org.apache.commons.codec.binary.Hex;
+
 public class KeyHelper {
   
   public static void saveKeystore(
@@ -136,6 +141,13 @@
       return keyGenerator.generateKey();
     }
   
+  public static Key generateKey(String type) 
+    throws NoSuchAlgorithmException {
+      KeyGenerator keygen = KeyGenerator.getInstance(type);
+      keygen.init(new SecureRandom());
+      return keygen.generateKey();
+  }
+  
   public static SecretKey generateSecretKey(
     String type, 
     int size,
@@ -146,4 +158,17 @@
     keyGenerator.init(size);
     return keyGenerator.generateKey();
   }
+  
+  public static PublicKey generatePublicKey(String hex) {
+    try {
+      if (hex == null || hex.trim().length() == 0) return null;
+      byte[] data = Hex.decodeHex(hex.toCharArray());
+      X509EncodedKeySpec keyspec = new X509EncodedKeySpec(data);
+      KeyFactory keyfactory = KeyFactory.getInstance("RSA");
+      return keyfactory.generatePublic(keyspec);
+    } catch (Exception e) {
+      return null;
+    }
+  }
+  
 }

Copied: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AESEncryptedResponseFilter.java (from r541096, incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/EncryptedResponseFilter.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AESEncryptedResponseFilter.java?view=diff&rev=555349&p1=incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/EncryptedResponseFilter.java&r1=541096&p2=incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AESEncryptedResponseFilter.java&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/EncryptedResponseFilter.java (original)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AESEncryptedResponseFilter.java Wed Jul 11 11:07:36 2007
@@ -17,26 +17,17 @@
 */
 package org.apache.abdera.security.util.servlet;
 
-import java.io.IOException;
-import java.security.Key;
 import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.Security;
 import java.security.cert.X509Certificate;
 import java.security.interfaces.RSAPublicKey;
 
-import javax.crypto.KeyGenerator;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletRequest;
 
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Element;
 import org.apache.abdera.security.Encryption;
 import org.apache.abdera.security.EncryptionOptions;
+import org.apache.abdera.security.util.KeyHelper;
 import org.apache.xml.security.encryption.XMLCipher;
 
 /**
@@ -51,51 +42,51 @@
  * &lt;/filter-mapping>
  * </pre>
  */
-public class EncryptedResponseFilter 
-  extends SecurityFilter {
+public class AESEncryptedResponseFilter 
+  extends BCEncryptedResponseFilter {
 
-  public void init(
-    FilterConfig config) 
-      throws ServletException {
-    try {
-      Class.forName("org.bouncycastle.LICENSE");
-      Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
-    } catch (Exception e) {}
+  public static final String PUBLICKEY = "X-PublicKey";
+  
+  protected X509Certificate[] getCerts(ServletRequest request) {
+    return (X509Certificate[]) request.getAttribute(
+      "javax.servlet.request.X509Certificate");
+  }
+  
+  protected PublicKey getPublicKey(ServletRequest request) {
+    HttpServletRequest servletrequest = (HttpServletRequest) request;
+    String header = servletrequest.getHeader(PUBLICKEY);
+    PublicKey pkey = KeyHelper.generatePublicKey(header);
+    if (pkey == null) pkey = retrievePublicKey(request);
+    return pkey;
+  }
+  
+  protected boolean doEncryption(ServletRequest request, Object arg) {
+    return arg != null && arg instanceof RSAPublicKey;
   }
   
-  @SuppressWarnings("unchecked")
-  public void doFilter(
+  protected Object initArg(ServletRequest request) {
+    return getPublicKey(request);
+  }
+  
+  protected PublicKey retrievePublicKey(ServletRequest request) {
+    X509Certificate[] cert = getCerts(request);
+    return cert != null ? cert[0].getPublicKey() : null;
+  }
+  
+  protected EncryptionOptions initEncryptionOptions(
     ServletRequest request, 
     ServletResponse response,
-    FilterChain chain) 
-      throws IOException, 
-             ServletException {
+    Encryption enc,
+    Object arg) {
     try {
-      X509Certificate[] cert = (X509Certificate[]) request.getAttribute(
-        "javax.servlet.request.X509Certificate");
-      PublicKey pkey = (cert != null) ? cert[0].getPublicKey() : null;
-      if (pkey != null && pkey instanceof RSAPublicKey) {
-        BufferingResponseWrapper wrapper = 
-          new BufferingResponseWrapper(
-            (HttpServletResponse)response);
-        chain.doFilter(request, wrapper);
-        Document<Element> doc = getDocument(wrapper);
-        if (doc != null) {  
-          KeyGenerator keygen = KeyGenerator.getInstance("AES");
-          keygen.init(new SecureRandom());
-          Key key = keygen.generateKey();
-          Encryption enc = security.getEncryption(); 
-          EncryptionOptions options = enc.getDefaultEncryptionOptions();
-          options.setDataEncryptionKey(key);
-          options.setKeyEncryptionKey(pkey);
-          options.setKeyCipherAlgorithm(XMLCipher.RSA_v1dot5);
-          options.setIncludeKeyInfo(true);
-          Document<Element> enc_doc = enc.encrypt(doc, options);
-          enc_doc.writeTo(response.getOutputStream());
-        }
-      } else {
-        chain.doFilter(request, response);
-      }
-    } catch (Exception e) {}
-  } 
+      EncryptionOptions options = enc.getDefaultEncryptionOptions();
+      options.setDataEncryptionKey(KeyHelper.generateKey("AES"));
+      options.setKeyEncryptionKey((PublicKey)arg);
+      options.setKeyCipherAlgorithm(XMLCipher.RSA_v1dot5);
+      options.setIncludeKeyInfo(true);
+      return options;
+    } catch (Exception e) {
+      return null;
+    }
+  }
 }

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AbstractEncryptedRequestFilter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AbstractEncryptedRequestFilter.java?view=auto&rev=555349
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AbstractEncryptedRequestFilter.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AbstractEncryptedRequestFilter.java Wed Jul 11 11:07:36 2007
@@ -0,0 +1,117 @@
+/*
+* 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.servlet;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.security.Encryption;
+import org.apache.abdera.security.EncryptionOptions;
+import org.apache.abdera.security.SecurityException;
+
+public abstract class AbstractEncryptedRequestFilter 
+  extends SecurityFilter {
+
+  // The methods that allow encrypted bodies
+  protected final List<String> methods = new ArrayList<String>(); 
+  
+  protected AbstractEncryptedRequestFilter() {
+    this("POST","PUT");
+  }
+  
+  protected AbstractEncryptedRequestFilter(String... methods) {
+    for (String method: methods) this.methods.add(method);
+  }
+
+  @Override
+  public void init(FilterConfig config) throws ServletException {
+    super.init(config);
+    String s = config.getInitParameter("methods");
+    if (s != null && s.length() > 0) {
+      this.methods.clear();
+      String[] methods = s.split("\\s*,\\s*");
+      for (String method : methods) this.methods.add(method);
+    }
+  }
+  
+  @SuppressWarnings("unchecked")
+  public void doFilter(
+    ServletRequest request, 
+    ServletResponse response,
+    FilterChain chain) 
+      throws IOException, 
+             ServletException {
+    
+    bootstrap(request,response);
+    HttpServletRequest req = (HttpServletRequest) request;
+    String method = req.getMethod();
+    if (methods.contains(method.toUpperCase())) {
+      BufferedRequestWrapper wrapper = 
+        new BufferedRequestWrapper((HttpServletRequest) request);
+      try {
+        Document<Element> doc = getDocument(wrapper);
+        if (doc != null) {
+          Encryption enc = security.getEncryption();
+          if (enc.isEncrypted(doc)) {
+            Object arg = initArg(request);
+            EncryptionOptions options = initEncryptionOptions(request,response,enc,arg);
+            doDecryption(doc, options, enc, wrapper);
+          }
+        }
+      } catch (Exception e) { 
+      } finally {wrapper.reset();}
+      request = wrapper;
+    }
+    chain.doFilter(request, response);
+  }
+
+  protected void doDecryption(
+    Document doc, 
+    EncryptionOptions options, 
+    Encryption enc, 
+    BufferedRequestWrapper wrapper) 
+      throws SecurityException, IOException {
+    doc = enc.decrypt(doc, options);
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    doc.writeTo(out);
+    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+    wrapper.setInputStream(in);
+  }
+  
+  protected abstract void bootstrap(ServletRequest request, ServletResponse response);
+  
+  protected abstract Object initArg(ServletRequest request);
+  
+  protected abstract EncryptionOptions initEncryptionOptions(
+    ServletRequest request, 
+    ServletResponse response, 
+    Encryption encryption,
+    Object arg);
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AbstractEncryptedResponseFilter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AbstractEncryptedResponseFilter.java?view=auto&rev=555349
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AbstractEncryptedResponseFilter.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/AbstractEncryptedResponseFilter.java Wed Jul 11 11:07:36 2007
@@ -0,0 +1,88 @@
+/*
+* 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.servlet;
+
+import java.io.IOException;
+import java.security.Provider;
+import java.security.Security;
+
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.security.Encryption;
+import org.apache.abdera.security.EncryptionOptions;
+
+public abstract class AbstractEncryptedResponseFilter 
+  extends SecurityFilter {
+    
+  public void init(
+    FilterConfig config) 
+      throws ServletException {
+    initProvider();
+  }
+  
+  protected void initProvider() {}
+  
+  protected void addProvider(Provider provider) {
+    if (Security.getProvider(provider.getName()) == null) 
+      Security.addProvider(provider);
+  }
+  
+  @SuppressWarnings("unchecked")
+  public void doFilter(
+    ServletRequest request, 
+    ServletResponse response,
+    FilterChain chain) 
+      throws IOException, 
+             ServletException {
+    try {
+      Object arg = initArg(request);
+      if (doEncryption(request, arg)) {
+        BufferingResponseWrapper wrapper = 
+          new BufferingResponseWrapper(
+            (HttpServletResponse)response);
+        chain.doFilter(request, wrapper);
+        Document<Element> doc = getDocument(wrapper);
+        if (doc != null) {  
+          Encryption enc = security.getEncryption(); 
+          EncryptionOptions options = initEncryptionOptions(request,response,enc,arg);
+          Document<Element> enc_doc = enc.encrypt(doc, options);
+          enc_doc.writeTo(response.getOutputStream());
+        }
+      } else {
+        chain.doFilter(request, response);
+      }
+    } catch (Exception e) {}
+  } 
+
+  protected abstract boolean doEncryption(ServletRequest request, Object arg);
+  
+  protected abstract EncryptionOptions initEncryptionOptions(
+      ServletRequest request, 
+      ServletResponse response,
+      Encryption enc,
+      Object arg);
+  
+  protected abstract Object initArg(ServletRequest request);
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/BCEncryptedResponseFilter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/BCEncryptedResponseFilter.java?view=auto&rev=555349
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/BCEncryptedResponseFilter.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/BCEncryptedResponseFilter.java Wed Jul 11 11:07:36 2007
@@ -0,0 +1,32 @@
+/*
+* 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.servlet;
+
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+
+public abstract class BCEncryptedResponseFilter 
+  extends AbstractEncryptedResponseFilter {
+
+  public void initProvider() {
+    try {
+      Class.forName("org.bouncycastle.LICENSE");
+    } catch (Exception e) {}
+    addProvider(new BouncyCastleProvider());
+  }
+  
+}

Added: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHEncryptedRequestFilter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHEncryptedRequestFilter.java?view=auto&rev=555349
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHEncryptedRequestFilter.java (added)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHEncryptedRequestFilter.java Wed Jul 11 11:07:36 2007
@@ -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.util.servlet;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.abdera.security.Encryption;
+import org.apache.abdera.security.EncryptionOptions;
+import org.apache.abdera.security.util.DHContext;
+
+/**
+ * A filter implementation that allows requests to be encrypted using Diffie-Hellman
+ * key negotiation.  A client first uses GET/HEAD/OPTIONS to get the servers DH
+ * information, then sends an encrypted request containing it's DH information.
+ * The server can then decrypt and process the request.
+ * 
+ * Note: this is currently untested.
+ */
+public class DHEncryptedRequestFilter 
+  extends AbstractEncryptedRequestFilter {
+
+  private DHContext context;
+  
+  @Override
+  public void init(FilterConfig config) throws ServletException {
+    super.init(config);
+    context = new DHContext();
+  }
+  
+  @Override
+  public void bootstrap(
+    ServletRequest request, 
+    ServletResponse response ) {
+    String method = ((HttpServletRequest)request).getMethod();
+    // include a X-DH header in the response to GET, HEAD and OPTIONS requests
+    // the header will specify all the information the client needs to construct
+    // it's own DH context and encrypt the request
+    if ("GET".equalsIgnoreCase(method) || 
+        "HEAD".equalsIgnoreCase(method) || 
+        "OPTIONS".equalsIgnoreCase(method)) {
+      ((HttpServletResponse)response).setHeader(
+        DHEncryptedResponseFilter.DH, 
+        this.context.getRequestString());
+    } 
+  }
+
+  @Override
+  protected Object initArg(ServletRequest request) {
+    DHContext context = null;
+    String dh = ((HttpServletRequest)request).getHeader(DHEncryptedResponseFilter.DH);
+    if (dh != null && dh.length() > 0) {
+      try {
+        context = (DHContext) this.context.clone();
+        context.setPublicKey(dh);
+      } catch (Exception e) {}
+    }
+    return context;
+  }
+
+  @Override
+  protected EncryptionOptions initEncryptionOptions(
+    ServletRequest request,
+    ServletResponse response, 
+    Encryption encryption, 
+    Object arg) {
+      EncryptionOptions options = null;
+      if (arg != null && arg instanceof DHContext) {
+        try {
+          options = ((DHContext)arg).getEncryptionOptions(encryption);
+        } catch (Exception e) {}
+      }
+      return options;
+  }
+
+}

Modified: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHEncryptedResponseFilter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHEncryptedResponseFilter.java?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHEncryptedResponseFilter.java (original)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/DHEncryptedResponseFilter.java Wed Jul 11 11:07:36 2007
@@ -17,24 +17,14 @@
 */
 package org.apache.abdera.security.util.servlet;
 
-import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.Security;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Element;
 import org.apache.abdera.security.Encryption;
 import org.apache.abdera.security.EncryptionOptions;
+import org.apache.abdera.security.util.DHContext;
 
 /**
  * A Servlet Filter that uses Diffie-Hellman Key Exchange to encrypt 
@@ -78,57 +68,45 @@
  * </pre>
  */
 public class DHEncryptedResponseFilter 
-  extends SecurityFilter {
+  extends BCEncryptedResponseFilter {
 
-  public void init(
-    FilterConfig config) 
-      throws ServletException {
-    try {
-      Class.forName("org.bouncycastle.LICENSE");
-      Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
-    } catch (Exception e) {}
+  public static final String DH = "X-DH";
+    
+  protected boolean doEncryption(ServletRequest request, Object arg) {
+    return arg != null;
   }
   
-  @SuppressWarnings("unchecked")
-  public void doFilter(
-    ServletRequest request, 
-    ServletResponse response,
-    FilterChain chain) 
-      throws IOException, 
-             ServletException {
+  protected Object initArg(ServletRequest request) {
+    return getDHContext((HttpServletRequest)request);
+  }
+  
+  protected EncryptionOptions initEncryptionOptions(
+      ServletRequest request, 
+      ServletResponse response,
+      Encryption enc,
+      Object arg) {
+    EncryptionOptions options = null;
     try {
-      DHContext context = getDHContext((HttpServletRequest)request);
-      if (context != null) {
-        BufferingResponseWrapper wrapper = 
-          new BufferingResponseWrapper(
-            (HttpServletResponse)response);
-        chain.doFilter(request, wrapper);
-        Document<Element> doc = getDocument(wrapper);
-        if (doc != null) {  
-          Encryption enc = security.getEncryption(); 
-          EncryptionOptions options = context.getEncryptionOptions(enc);
-          Document<Element> enc_doc = enc.encrypt(doc, options);
-          returnPublicKey((HttpServletResponse)response,context);
-          enc_doc.writeTo(response.getOutputStream());
-        }
-      } else {
-        chain.doFilter(request, response);
-      }
+      DHContext context = (DHContext) arg;
+      options = context.getEncryptionOptions(enc);
+      returnPublicKey((HttpServletResponse)response,context);
     } catch (Exception e) {}
-  } 
+    return options;
+    
+  }
   
   private void returnPublicKey(HttpServletResponse response, DHContext context) {
-    response.setHeader("X-DH",context.getResponseString());
+    response.setHeader(DH,context.getResponseString());
   }
   
-  private DHContext getDHContext(HttpServletRequest request) 
-    throws InvalidAlgorithmParameterException, 
-           NoSuchAlgorithmException, 
-           InvalidKeySpecException {
-    String dh_req = request.getHeader("X-DH");
-    if (dh_req == null || dh_req.length() == 0) return null;
-    DHContext context = new DHContext(dh_req);
-    return context;
+  private DHContext getDHContext(HttpServletRequest request) {
+    try {
+      String dh_req = request.getHeader(DH);
+      if (dh_req == null || dh_req.length() == 0) return null;
+      return new DHContext(dh_req);
+    } catch (Exception e) {
+      return null;
+    }
   }
   
 }

Modified: incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/SecurityFilter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/SecurityFilter.java?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/SecurityFilter.java (original)
+++ incubator/abdera/java/trunk/security/src/main/java/org/apache/abdera/security/util/servlet/SecurityFilter.java Wed Jul 11 11:07:36 2007
@@ -17,190 +17,19 @@
 */
 package org.apache.abdera.security.util.servlet;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.CharArrayReader;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.Reader;
-
 import javax.servlet.Filter;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
 
-import org.apache.abdera.Abdera;
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Element;
-import org.apache.abdera.parser.Parser;
+import org.apache.abdera.protocol.server.servlet.AbderaFilter;
 import org.apache.abdera.security.AbderaSecurity;
-import org.apache.abdera.i18n.io.RewindableInputStream;
 
 public abstract class SecurityFilter 
+  extends AbderaFilter
   implements Filter {
 
-  protected final Abdera abdera;
   protected final AbderaSecurity security;
   
   protected SecurityFilter() {
-    this.abdera = new Abdera();
-    this.security = new AbderaSecurity(abdera);
-  }
-  
-  public void init(FilterConfig config) throws ServletException {
-  }
-  
-  public void destroy() {
-  }
-
-  protected Document<Element> getDocument(BufferingResponseWrapper wrapper) {
-    Reader rdr = wrapper.getReader();
-    InputStream in = wrapper.getInputStream();
-    Parser parser = abdera.getParser();
-    try {
-      if (rdr != null) {
-        return parser.parse(rdr);
-      }
-      if (in != null) {
-        return parser.parse(in);
-      }
-    } catch (Exception e) {}
-    return null;
-  }
-  
-  public static class BufferingResponseWrapper 
-    extends HttpServletResponseWrapper {
-    
-    CharArrayWriter output = null;
-    ByteArrayOutputStream outStream = null;
-    
-    BufferingResponseWrapper(HttpServletResponse response) {
-      super(response);
-    }
-    
-    @Override
-    public PrintWriter getWriter() throws IOException {
-      if (outStream != null) throw new IllegalStateException();
-      if (output == null) output = new CharArrayWriter();
-      return new PrintWriter(output);
-    }
-    
-    @Override
-    public ServletOutputStream getOutputStream() throws IOException {
-      if (output != null) throw new IllegalStateException();
-      if (outStream == null) outStream = new ByteArrayOutputStream();
-      return new BufferingServletOutputStream(outStream);
-    }
-    
-    public Reader getReader() {
-      if (output == null) return null;
-      return new CharArrayReader(output.toCharArray());
-    }
-    
-    public InputStream getInputStream() {
-      if (outStream == null) return null;
-      return new ByteArrayInputStream(outStream.toByteArray());
-    }
+    this.security = new AbderaSecurity(getAbdera());
   }
-  
-  public static class BufferingServletOutputStream 
-    extends ServletOutputStream {
-  
-    ByteArrayOutputStream out = null;
-    
-    BufferingServletOutputStream(ByteArrayOutputStream out) {
-      this.out = out;
-    }
-    
-    public void write(int b) throws IOException {
-      out.write(b);
-    }
-    
-    public void write(byte[] b) throws IOException {
-      out.write(b);
-    }
     
-    public void write(byte[] b, int off, int len) throws IOException {
-      out.write(b, off, len);
-    }
-  
-    @Override
-    public void close() throws IOException {
-      out.close();
-      super.close();
-    }
-  
-    @Override
-    public void flush() throws IOException {
-      out.flush();
-      super.flush();
-    }
-    
-  }
-
-  public static class BufferedRequestWrapper 
-  extends HttpServletRequestWrapper {
-  
-  private BufferedServletInputStream bin;
-  private RewindableInputStream rin;
-  private BufferedReader rdr;
-  
-  public BufferedRequestWrapper(HttpServletRequest request) {
-    super(request);
-  }
-
-  @Override
-  public ServletInputStream getInputStream() throws IOException {
-    if (rdr != null) throw new IllegalStateException();
-    if (bin == null) {
-      rin = new RewindableInputStream(super.getInputStream());
-      bin = new BufferedServletInputStream(rin);
-    }
-    return bin;
-  }
-
-  @Override
-  public BufferedReader getReader() throws IOException {
-    if (rdr == null) {
-      String charset = this.getCharacterEncoding();
-      rdr = (charset == null) ?
-        new BufferedReader(new InputStreamReader(getInputStream())) :
-        new BufferedReader(new InputStreamReader(getInputStream(),charset));
-    }
-    return rdr;
-  }
- 
-  public void reset() throws IOException {
-    if (bin != null) rin.rewind();
-    rdr = null;
-  }
-}
-
-public static class BufferedServletInputStream 
-  extends ServletInputStream {
-
-  private InputStream in;
-  
-  public BufferedServletInputStream(InputStream in) {
-    this.in = in;
-    try {
-      in.mark(in.available());
-    } catch (Exception e) {}
-  }
-  
-  @Override
-  public int read() throws IOException {
-    return in.read();
-  }
-  
-}
 }

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Provider.java (from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Provider.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Provider.java?view=diff&rev=555349&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Provider.java&r1=541096&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Provider.java&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Provider.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Provider.java Wed Jul 11 11:07:36 2007
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.provider;
+package org.apache.abdera.protocol.server;
 
 public interface Provider {
 
@@ -43,4 +43,7 @@
   
   ResponseContext mediaPost(RequestContext request);
   
+  ResponseContext request(RequestContext request);
+  
+  String[] getAllowedMethods(TargetType type);
 }

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java (from r550706, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/RequestContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java?view=diff&rev=555349&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/RequestContext.java&r1=550706&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/RequestContext.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestContext.java Wed Jul 11 11:07:36 2007
@@ -15,22 +15,23 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.provider;
+package org.apache.abdera.protocol.server;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
+import java.security.Principal;
 import java.util.List;
 
 import javax.security.auth.Subject;
 
+import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Element;
 import org.apache.abdera.parser.ParseException;
 import org.apache.abdera.parser.Parser;
 import org.apache.abdera.parser.ParserOptions;
 import org.apache.abdera.protocol.Request;
-import org.apache.abdera.protocol.server.ServiceContext;
 import org.apache.abdera.i18n.iri.IRI;
 
 public interface RequestContext 
@@ -40,13 +41,19 @@
   public enum Property { 
     SESSIONID, SESSIONCREATED, SESSIONACCESSED, SESSIONTIMEOUT,
     CHARACTERENCODING, LOCALES, PROTOCOL, REMOTEADDRESS, REMOTEHOST,
-    REMOTEUSER, SCHEME, PRINCIPAL};
+    REMOTEUSER, SCHEME, PRINCIPAL, AUTHTYPE, CONTENTLENGTH, 
+    CONTENTTYPE, CONTEXTPATH, LOCALADDR, LOCALNAME,
+    SERVERNAME, SERVERPORT};
   
+  Abdera getAbdera();
+    
   ServiceContext getServiceContext();
     
   Target getTarget();
     
   Subject getSubject();
+  
+  Principal getPrincipal();
   
   String getMethod();
   

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandler.java (from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/RequestHandler.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandler.java?view=diff&rev=555349&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/RequestHandler.java&r1=541096&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandler.java&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/servlet/RequestHandler.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/RequestHandler.java Wed Jul 11 11:07:36 2007
@@ -15,20 +15,18 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.servlet;
+package org.apache.abdera.protocol.server;
 
 import java.io.IOException;
 
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.abdera.protocol.server.ServiceContext;
 
 public interface RequestHandler {
 
   void process(
     ServiceContext context, 
-    HttpServletRequest request, 
+    RequestContext request,
     HttpServletResponse response) throws IOException;
   
 }

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ResponseContext.java (from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/ResponseContext.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ResponseContext.java?view=diff&rev=555349&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/ResponseContext.java&r1=541096&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ResponseContext.java&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/ResponseContext.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ResponseContext.java Wed Jul 11 11:07:36 2007
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.provider;
+package org.apache.abdera.protocol.server;
 
 import java.io.IOException;
 import java.io.OutputStream;

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ServiceContext.java Wed Jul 11 11:07:36 2007
@@ -19,11 +19,11 @@
 
 import java.util.Map;
 
+import javax.security.auth.Subject;
+
 import org.apache.abdera.Abdera;
-import org.apache.abdera.protocol.server.auth.SubjectResolver;
-import org.apache.abdera.protocol.server.provider.ProviderManager;
-import org.apache.abdera.protocol.server.provider.TargetResolver;
-import org.apache.abdera.protocol.server.servlet.RequestHandlerManager;
+import org.apache.abdera.protocol.ItemManager;
+import org.apache.abdera.protocol.Resolver;
 
 public interface ServiceContext {
 
@@ -31,13 +31,13 @@
   
   void init(Abdera abdera, Map<String,String> config);
   
-  RequestHandlerManager getRequestHandlerManager();
+  ItemManager<RequestHandler> getRequestHandlerManager();
   
-  ProviderManager getProviderManager();
+  ItemManager<Provider> getProviderManager();
   
-  SubjectResolver getSubjectResolver();
+  Resolver<Subject> getSubjectResolver();
   
-  TargetResolver getTargetResolver(String contextPath);
+  Resolver<Target> getTargetResolver(String contextPath);
   
   String getProperty(String name);
   

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java?view=diff&rev=555349&r1=555348&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/ServiceManager.java Wed Jul 11 11:07:36 2007
@@ -20,24 +20,35 @@
 import java.util.Map;
 
 import org.apache.abdera.Abdera;
+import org.apache.abdera.protocol.server.impl.DefaultServiceContext;
 import org.apache.abdera.protocol.server.util.ServerConstants;
 import org.apache.abdera.util.ServiceUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public class ServiceManager 
   implements ServerConstants {
   
+  private final static Log log = LogFactory.getLog(ServiceManager.class);
+  
   private static ServiceManager INSTANCE = null;
   private static Abdera abdera = null;
   
   ServiceManager() {}
   
   public static synchronized ServiceManager getInstance() {
-    if (INSTANCE == null) INSTANCE = new ServiceManager();
+    if (INSTANCE == null) {
+      log.debug("Creating new ServiceManager instance");
+      INSTANCE = new ServiceManager();
+    }
     return INSTANCE;
   }
   
   public static synchronized Abdera getAbdera() {
-    if (abdera == null) abdera = new Abdera();
+    if (abdera == null) {
+      log.debug("Creating new Abdera instance for the ServiceManager");
+      abdera = new Abdera();
+    }
     return abdera;
   }
   
@@ -45,6 +56,7 @@
     Map<String,String> properties) {
     Abdera abdera = getAbdera();
     String instance = properties.get(SERVICE_CONTEXT);
+    log.debug("Creating new Service Context instance - " + instance);
     ServiceContext context = 
       (ServiceContext) ServiceUtil.newInstance(
         SERVICE_CONTEXT, 
@@ -52,6 +64,7 @@
           instance : 
           DefaultServiceContext.class.getName(),
         abdera);
+    log.debug("Initializing Service Context - " + context);
     context.init(abdera, properties);
     return context;
   }

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Target.java (from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Target.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Target.java?view=diff&rev=555349&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Target.java&r1=541096&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Target.java&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/Target.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/Target.java Wed Jul 11 11:07:36 2007
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.provider;
+package org.apache.abdera.protocol.server;
 
 public interface Target {
 

Copied: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/TargetType.java (from r541096, incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/TargetType.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/TargetType.java?view=diff&rev=555349&p1=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/TargetType.java&r1=541096&p2=incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/TargetType.java&r2=555349
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/provider/TargetType.java (original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/TargetType.java Wed Jul 11 11:07:36 2007
@@ -15,7 +15,7 @@
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */
-package org.apache.abdera.protocol.server.provider;
+package org.apache.abdera.protocol.server;
 
 public final class TargetType {
 

Added: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractItemManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractItemManager.java?view=auto&rev=555349
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractItemManager.java (added)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/impl/AbstractItemManager.java Wed Jul 11 11:07:36 2007
@@ -0,0 +1,32 @@
+/*
+* 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.protocol.server.impl;
+
+import org.apache.abdera.protocol.ItemManager;
+import org.apache.abdera.protocol.Request;
+import org.apache.abdera.protocol.util.PoolManager;
+
+public abstract class AbstractItemManager<T>
+  extends PoolManager<T>
+  implements ItemManager<T> {
+
+  public T get(Request request) {
+    return getInstance();
+  }
+
+}



Mime
View raw message