1 package org.apache.turbine.services.xmlrpc.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Vector;
23
24 import org.apache.turbine.om.security.User;
25 import org.apache.turbine.services.security.TurbineSecurity;
26 import org.apache.turbine.util.TurbineException;
27
28 import org.apache.xmlrpc.AuthenticatedXmlRpcHandler;
29
30 /***
31 * An authenticated Handler for use with the XML-RPC service that will deal
32 * with clients sending file to the server (Turbine application)
33 * and clients getting files from the server (Turbine application).
34 *
35 * usage in TurbineResources.properties is:
36 * services.XmlRpcService.handler.file = org.apache.turbine.services.xmlrpc.util.AuthenticatedFileHandler
37 *
38 * See the FileHandler class for further documentation.
39 *
40 * @author <a href="mailto:john@zenplex.com">John Thorhauer</a>
41 * @version $Id: AuthenticatedFileHandler.java 534527 2007-05-02 16:10:59Z tv $
42 * @deprecated This is not scope of the Service itself but of an
43 * application which uses the service. This class shouldn't
44 * be part of Turbine but of an addon application.
45 */
46 public class AuthenticatedFileHandler
47 extends FileHandler
48 implements AuthenticatedXmlRpcHandler
49 {
50 /***
51 * Default Constructor
52 */
53 public AuthenticatedFileHandler()
54 {
55 }
56
57 /***
58 * Handles all requests for an Authenticated file transfer.
59 */
60 public Object execute(String method, Vector params, String username, String password)
61 throws TurbineException
62 {
63 Object obj = null;
64
65
66 User user = null;
67 user = TurbineSecurity.getAuthenticatedUser(username, password);
68
69 if (user != null)
70 {
71 if (method.equals("send"))
72 {
73
74 obj = new Boolean(this.send((String) params.elementAt(0),
75 (String) params.elementAt(1),
76 (String) params.elementAt(2)));
77 }
78
79 if (method.equals("get"))
80 {
81 obj = this.get((String) params.elementAt(0),
82 (String) params.elementAt(1));
83 }
84
85 if (method.equals("remove"))
86 {
87 AuthenticatedFileHandler.remove((String) params.elementAt(0),
88 (String) params.elementAt(1));
89 obj = Boolean.TRUE;
90 }
91 }
92 else
93 {
94 obj = Boolean.FALSE;
95 }
96
97 return (Object) obj;
98 }
99 }