KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > services > xmlrpc > util > AuthenticatedFileHandler


1 package org.apache.turbine.services.xmlrpc.util;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 import java.util.Vector JavaDoc;
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,v 1.8.2.3 2004/08/14 20:11:41 henning Exp $
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 JavaDoc execute(String JavaDoc method, Vector JavaDoc params, String JavaDoc username, String JavaDoc password)
58             throws TurbineException
59     {
60         Object JavaDoc obj = null;
61
62         // Authenticate the user and get the object.
63
User user = null;
64         user = TurbineSecurity.getAuthenticatedUser(username, password);
65
66         if (user != null)
67         {
68             if (method.equals("send"))
69             {
70                 obj = new Boolean JavaDoc(this.send((String JavaDoc) params.elementAt(0),
71                         (String JavaDoc) params.elementAt(1),
72                         (String JavaDoc) params.elementAt(2)));
73             }
74
75             if (method.equals("get"))
76             {
77                 obj = this.get((String JavaDoc) params.elementAt(0),
78                         (String JavaDoc) params.elementAt(1));
79             }
80
81             if (method.equals("remove"))
82             {
83                 AuthenticatedFileHandler.remove((String JavaDoc) params.elementAt(0),
84                         (String JavaDoc) params.elementAt(1));
85                 obj = new Boolean JavaDoc("true");
86             }
87         }
88         else
89         {
90             obj = new Boolean JavaDoc("false");
91         }
92
93         return (Object JavaDoc) obj;
94     }
95 }
96
Popular Tags