KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > security > interceptors > iiop > CorbaServerSecurityInterceptor


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999-2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or 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  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  */

21 package org.objectweb.jonas.security.interceptors.iiop;
22
23 import org.omg.IOP.ServiceContext JavaDoc;
24 import org.omg.PortableInterceptor.ForwardRequest JavaDoc;
25 import org.omg.PortableInterceptor.ORBInitInfo JavaDoc;
26 import org.omg.PortableInterceptor.ServerRequestInfo JavaDoc;
27 import org.omg.PortableInterceptor.ServerRequestInterceptor JavaDoc;
28
29 import org.objectweb.security.context.SecurityContext;
30 import org.objectweb.security.context.SecurityCurrent;
31
32 /**
33  * Class <code>CorbaServerSecurityInterceptor</code> is a Server Interceptor
34  * for Security
35  * @author Guillaume Riviere (Guillaume.Riviere@inrialpes.fr)
36  * @version 1.0, 13/09/2002
37  */

38 public class CorbaServerSecurityInterceptor extends SecurityInterceptor implements ServerRequestInterceptor JavaDoc {
39
40     /**
41      * interceptor name
42      */

43     private String JavaDoc interceptorName = "CorbaServerSecurityInteceptor";
44
45     /**
46      * Security context
47      */

48     private SecurityContext sCtx = null;
49
50     /**
51      * constructor
52      */

53     public CorbaServerSecurityInterceptor(ORBInitInfo JavaDoc info) {
54     }
55
56     /**
57      * get the name of this interceptor
58      * @return name
59      */

60     public String JavaDoc name() {
61         return interceptorName;
62     }
63
64     /**
65      * Receive request context
66      * @param JServerRequestInfo the server request information
67      * @exception IOException if an exception occur with the ObjectOutput
68      */

69     public void receive_request_service_contexts(ServerRequestInfo JavaDoc jri) throws ForwardRequest JavaDoc {
70         // Gets SecurityCurrent object (always existing in JOnAS Server)
71
SecurityCurrent current = SecurityCurrent.getCurrent();
72         if (current != null) {
73             try {
74                 ServiceContext JavaDoc serviceCtx = (ServiceContext JavaDoc) jri.get_request_service_context(SEC_CTX_ID);
75                 if (serviceCtx != null) {
76                     sCtx = unmarshallSecurityContext(serviceCtx.context_data);
77                 }
78             } catch (org.omg.CORBA.BAD_PARAM JavaDoc e) {
79                 // No Security context, do nothing
80
}
81         }
82     }
83
84     /**
85      * Receive request
86      * @param JServerRequestInfo the server request information
87      * @exception IOException if an exception occur with the ObjectOutput
88      */

89     public void receive_request(ServerRequestInfo JavaDoc jri) throws ForwardRequest JavaDoc {
90         SecurityCurrent current = SecurityCurrent.getCurrent();
91         if ((current != null) && (sCtx != null)) {
92             // put into the the Current object
93
current.setSecurityContext(sCtx);
94             sCtx = null;
95         }
96     }
97
98     /**
99      * send reply with context
100      * @param JServerRequestInfo the server request information
101      * @exception IOException if an exception occur with the ObjectOutput
102      */

103     public void send_reply(ServerRequestInfo JavaDoc jri) {
104     }
105
106     public void send_exception(ServerRequestInfo JavaDoc jri) throws ForwardRequest JavaDoc {
107     }
108
109     public void send_other(ServerRequestInfo JavaDoc jri) throws ForwardRequest JavaDoc {
110     }
111
112     public void destroy() {
113     }
114 }
Popular Tags