01: package org.apache.turbine.services.xmlrpc.util;
02:
03: /*
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
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 extends FileHandler implements
47: AuthenticatedXmlRpcHandler {
48: /**
49: * Default Constructor
50: */
51: public AuthenticatedFileHandler() {
52: }
53:
54: /**
55: * Handles all requests for an Authenticated file transfer.
56: */
57: public Object execute(String method, Vector params,
58: String username, String password) throws TurbineException {
59: Object obj = null;
60:
61: // Authenticate the user and get the object.
62: User user = null;
63: user = TurbineSecurity.getAuthenticatedUser(username, password);
64:
65: if (user != null) {
66: if (method.equals("send")) {
67: // JDK 1.3 has no Boolean.valueOf(boolean)
68: obj = new Boolean(this .send((String) params
69: .elementAt(0), (String) params.elementAt(1),
70: (String) params.elementAt(2)));
71: }
72:
73: if (method.equals("get")) {
74: obj = this .get((String) params.elementAt(0),
75: (String) params.elementAt(1));
76: }
77:
78: if (method.equals("remove")) {
79: AuthenticatedFileHandler.remove((String) params
80: .elementAt(0), (String) params.elementAt(1));
81: obj = Boolean.TRUE;
82: }
83: } else {
84: obj = Boolean.FALSE;
85: }
86:
87: return (Object) obj;
88: }
89: }
|