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