View Javadoc

1   package org.astrogrid.security;
2   
3   import java.util.Hashtable;
4   import org.apache.axis.SimpleTargetedChain;
5   import org.apache.axis.ConfigurationException;
6   import org.apache.axis.configuration.SimpleProvider;
7   import org.apache.axis.transport.http.HTTPSender;
8   import org.apache.axis.transport.java.JavaSender;
9   import org.apache.axis.transport.local.LocalSender;
10  
11  /***
12   * A SimpleProvider set up with hardcoded configuration for a client.
13   * The transports "java", "local" and "http" are configured as handler chains
14   * with their appropriate pivot handlers. In each chain, AstroGrid's security
15   * handler is set as the request handler and no response handlers are set.
16   *
17   * @author Guy Rixon
18   */
19  public class SecuredClientConfig extends SimpleProvider {
20  
21    /***
22     * Constructor a configuration for a client engine with security handlers.
23     */
24    public SecuredClientConfig() throws ConfigurationException {
25  
26      // This is the handler for signing messages.
27      AxisClientCredentialHandler h = new AxisClientCredentialHandler();
28      
29      // These are the message transports. "Local" is for unit tests.
30      // For each transport we make a chain including the handler which delivers
31      // the messages and the handler that signs them.
32      deployTransport("java",  new SimpleTargetedChain(h, new JavaSender(),  null));
33      deployTransport("local", new SimpleTargetedChain(h, new LocalSender(), null));
34      deployTransport("http",  new SimpleTargetedChain(h, new HTTPSender(),  null));
35      
36      // These options stop the message-sending handlers from fiddling with the
37      // XML after the messages are signed. If the XML is tampered with the
38      // signatures become invalid.
39      Hashtable options = super.getGlobalOptions();
40      if (options == null) {
41        options = new Hashtable();
42        super.setGlobalOptions(options);
43      }
44      options.put("enableNamespacePrefixOptimization", Boolean.FALSE);
45      options.put("disablePrettyXML", Boolean.TRUE);
46    }
47  
48  }