01: package com.xoetrope.service;
02:
03: import java.io.UnsupportedEncodingException;
04: import java.net.URLDecoder;
05: import java.util.Enumeration;
06: import java.util.Hashtable;
07: import net.xoetrope.optional.service.ServiceContext;
08:
09: import net.xoetrope.optional.service.ServiceProxy;
10: import net.xoetrope.optional.service.ServiceProxyException;
11:
12: /**
13: * Decodes the argument values using Base64 encoding and encodes the response.
14: *
15: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
16: * the GNU Public License (GPL), please see license.txt for more details. If
17: * you make commercial use of this software you must purchase a commercial
18: * license from Xoetrope.</p>
19: * <p> $Revision: 1.8 $</p>
20: */
21: public class Base64DecoderService extends ServiceProxy {
22: /**
23: * Craete a new encoder with teh default options
24: */
25: public Base64DecoderService() {
26: status = OK;
27: }
28:
29: /*public Object call() throws ServiceProxyException
30: {
31: try {
32: return new String( org.apache.catalina.util.Base64.encode( nextProxy.call().toString().getBytes() ) );
33: }
34: catch ( ServiceProxyException ex ) {
35: throw ( ex );
36: }
37: }*/
38:
39: /**
40: * Call this proxy with the specified arguments
41: * @return the result of the call
42: * @param context The ServiceContext contain pass and return parameters
43: * @param method the name of the service being called
44: * @throws net.xoetrope.optional.service.ServiceProxyException Throw an exception if there is a problem with the call
45: */
46: public Object call(String method, ServiceContext context)
47: throws ServiceProxyException {
48: try {
49: Hashtable passArgs = context.getPassArgs();
50: Enumeration e = passArgs.keys();
51: while (e.hasMoreElements()) {
52: String name = (String) e.nextElement();
53: String value = (String) passArgs.get(name);
54: try {
55: context.getArgs().setPassParam(
56: name,
57: new String(org.apache.catalina.util.Base64
58: .decode(URLDecoder.decode(value,
59: "UTF-8").getBytes()))
60: .trim());
61: } catch (UnsupportedEncodingException uee) {
62: }
63: }
64: status = STARTED;
65: String res = nextProxy.call(method, context).toString();
66: status = COMPLETE;
67: return null;
68: } catch (ServiceProxyException ex) {
69: status = FAILED;
70: throw (ex);
71: }
72: }
73: }
|