org.apache.abdera.security.util.filters
Class DHEncryptedResponseFilter

java.lang.Object
  extended by org.apache.abdera.security.util.filters.AbstractEncryptedResponseFilter
      extended by org.apache.abdera.security.util.filters.DHEncryptedResponseFilter
All Implemented Interfaces:
Filter

public class DHEncryptedResponseFilter
extends AbstractEncryptedResponseFilter

A Servlet Filter that uses Diffie-Hellman Key Exchange to encrypt Atom documents. The HTTP request must include an Accept-Encryption header in the form: Accept-Encryption: DH p={dh_p}, g={dh_g}, l={dh_l}, k={base64_pubkey} Example AbderaClient Code:

 DHContext context = new DHContext();
 Abdera abdera = new Abdera();
 CommonsClient client = new CommonsClient(abdera);
 RequestOptions options = client.getDefaultRequestOptions();
 options.setHeader("Accept-Encryption", context.getRequestString());
 
 ClientResponse response = client.get("http://localhost:8080/TestWeb/test", options);
 Document<Element> doc = response.getDocument();
 
 String dh_ret = response.getHeader("Content-Encrypted");
 if (dh_ret != null) {
     context.setPublicKey(dh_ret);
     AbderaSecurity absec = new AbderaSecurity(abdera);
     Encryption enc = absec.getEncryption();
     EncryptionOptions encoptions = context.getEncryptionOptions(enc);
     doc = enc.decrypt(doc, encoptions);
 }
 
 doc.writeTo(System.out);
 
Webapp Deployment:
 <filter>
   <filter-name>enc filter</filter-name>
   <filter-class>com.test.EncryptedResponseFilter</filter-class>
 </filter>
 <filter-mapping>
   <filter-name>enc filter</filter-name>
   <servlet-name>TestServlet</servlet-name>
 </filter-mapping>
 


Constructor Summary
DHEncryptedResponseFilter()
           
 
Method Summary
protected  boolean doEncryption(RequestContext request, Object arg)
           
 ResponseContext filter(RequestContext request, FilterChain chain)
          Process the filter request.
protected  Object initArg(RequestContext request)
           
protected  EncryptionOptions initEncryptionOptions(RequestContext request, ResponseContext response, Encryption enc, Object arg)
           
 
Methods inherited from class org.apache.abdera.security.util.filters.AbstractEncryptedResponseFilter
addProvider, initProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DHEncryptedResponseFilter

public DHEncryptedResponseFilter()
Method Detail

doEncryption

protected boolean doEncryption(RequestContext request,
                               Object arg)
Specified by:
doEncryption in class AbstractEncryptedResponseFilter

initArg

protected Object initArg(RequestContext request)
Specified by:
initArg in class AbstractEncryptedResponseFilter

initEncryptionOptions

protected EncryptionOptions initEncryptionOptions(RequestContext request,
                                                  ResponseContext response,
                                                  Encryption enc,
                                                  Object arg)
Specified by:
initEncryptionOptions in class AbstractEncryptedResponseFilter

filter

public ResponseContext filter(RequestContext request,
                              FilterChain chain)
Description copied from interface: Filter
Process the filter request. The filter must call chain.next(request) to pass the request on to the next filter or the provider.

Specified by:
filter in interface Filter
Overrides:
filter in class AbstractEncryptedResponseFilter


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.