KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > security > level2 > ServerAccessDecisionInterceptor


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1999-2004 Gerald Brose
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */

21 package org.jacorb.security.level2;
22
23 import org.omg.PortableInterceptor.*;
24 import org.omg.SecurityLevel2.*;
25 import org.jacorb.util.*;
26 import org.jacorb.orb.portableInterceptor.ServerRequestInfoImpl;
27 import java.util.*;
28
29 /**
30  * ServerAccessDecisionInterceptor.java
31  *
32  *
33  * Created: Wed Jul 5 14:31:30 2000
34  *
35  * @author Nicolas Noffke
36  * $Id: ServerAccessDecisionInterceptor.java,v 1.16 2004/05/06 12:40:01 nicolas Exp $
37  */

38
39 public class ServerAccessDecisionInterceptor
40     extends org.omg.CORBA.LocalObject JavaDoc
41     implements ServerRequestInterceptor
42 {
43     public static final String JavaDoc DEFAULT_NAME =
44         "ServerAccessDecisionInterceptor";
45
46     private String JavaDoc name = null;
47
48     private AccessDecision access_decision = null;
49     private org.omg.SecurityLevel2.Current current = null;
50     private Hashtable special_operations = null;
51
52     public ServerAccessDecisionInterceptor
53         (org.omg.SecurityLevel2.Current current)
54     {
55         this( current, DEFAULT_NAME );
56     }
57
58     public ServerAccessDecisionInterceptor
59         (org.omg.SecurityLevel2.Current current,
60          String JavaDoc name )
61     {
62         this.current = current;
63         this.name = name;
64
65         access_decision = current.access_decision();
66
67         special_operations = new Hashtable();
68         special_operations.put("_is_a", "");
69         special_operations.put("_get_interface", "");
70         special_operations.put("_non_existent", "");
71
72         special_operations.put("_get_policy", "");
73         special_operations.put("_get_domain_managers", "");
74         special_operations.put("_set_policy_overrides", "");
75     }
76
77     // InterceptorOperations interface
78
public String JavaDoc name()
79     {
80         return name;
81     }
82
83     public void destroy()
84     {
85     }
86
87     /**
88      * Put the propagation context from the service context
89      * into the PICurrent.
90      */

91     public void receive_request_service_contexts(ServerRequestInfo ri)
92         throws ForwardRequest
93     {
94     }
95
96     public void receive_request(ServerRequestInfo ri)
97         throws ForwardRequest
98     {
99         //Debug.output(1,"Call to: " + ri.target_most_derived_interface() );
100

101         if (special_operations.containsKey(ri.operation()))
102         {
103             //System.out.println("Ignoring op " + ri.operation());
104
return;
105         }
106 // else if (ri.target_most_derived_interface().
107
// startsWith("IDL:jacorb/orb/domain"))
108
// {
109
// //System.out.println("Ignoring call to domain object");
110
// return;
111
// }
112
else
113         {
114             //System.out.println("(ServerAccessDecInterc.)Controlling operation: " + ri.operation());
115
}
116
117         //proprietary call!!
118
org.omg.CORBA.Object JavaDoc target =
119             ((ServerRequestInfoImpl) ri).target();
120
121             if (! access_decision.access_allowed(
122                        new Credentials[] { current.received_credentials() },
123                        target,
124                        ri.operation(),
125                        ri.target_most_derived_interface())
126                 )
127             {
128                 throw new org.omg.CORBA.NO_PERMISSION JavaDoc();
129             }
130             else
131             {
132                 //System.out.println("Access allowed!!");
133
}
134     }
135
136     public void send_reply(ServerRequestInfo ri)
137     {
138     }
139
140     public void send_exception(ServerRequestInfo ri)
141         throws ForwardRequest
142     {
143     }
144
145     public void send_other(ServerRequestInfo ri)
146         throws ForwardRequest
147     {
148     }
149
150 } // ServerAccessDecisionInterceptor
151

152
153
154
155
156
157
Popular Tags