KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mx4j > tools > remote > http > HTTPSubjectInvoker


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package mx4j.tools.remote.http;
10
11 import java.lang.reflect.Method JavaDoc;
12 import java.lang.reflect.Proxy JavaDoc;
13 import java.security.AccessControlContext JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import javax.security.auth.Subject JavaDoc;
17
18 import mx4j.tools.remote.SubjectInvoker;
19
20 /**
21  * @version $Revision: 1.5 $
22  */

23 public class HTTPSubjectInvoker extends SubjectInvoker
24 {
25    public static HTTPConnection newInstance(HTTPConnection target, Subject JavaDoc subject, AccessControlContext JavaDoc context, Map JavaDoc environment)
26    {
27       HTTPSubjectInvoker handler = new HTTPSubjectInvoker(target, subject, context, environment);
28       return (HTTPConnection)Proxy.newProxyInstance(target.getClass().getClassLoader(), new Class JavaDoc[]{HTTPConnection.class}, handler);
29    }
30
31    private HTTPSubjectInvoker(HTTPConnection target, Subject JavaDoc subject, AccessControlContext JavaDoc context, Map JavaDoc environment)
32    {
33       super(target, subject, context, environment);
34    }
35
36    protected boolean isPlainInvoke(Method JavaDoc method)
37    {
38       boolean plain = super.isPlainInvoke(method);
39       if (plain) return plain;
40
41       String JavaDoc methodName = method.getName();
42       // HTTPConnection methods that do not require the delegate subject
43
if ("fetchNotifications".equals(methodName)) return true;
44       if ("close".equals(methodName)) return true;
45       return false;
46    }
47 }
48
Popular Tags