KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > security > interceptors > jrmp > ServerSecurityInterceptor


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  * --------------------------------------------------------------------------
22  * $Id: ServerSecurityInterceptor.java,v 1.3 2004/05/25 15:13:29 benoitf Exp $
23  * --------------------------------------------------------------------------
24  *
25  */

26 package org.objectweb.jonas.security.interceptors.jrmp;
27
28 import java.io.IOException JavaDoc;
29
30 import org.objectweb.security.context.SecurityCurrent;
31 import org.objectweb.security.context.SecurityContext;
32
33 //carol JRMP Interceptor API Import
34
import org.objectweb.carol.rmi.jrmp.interceptor.JServerRequestInterceptor;
35 import org.objectweb.carol.rmi.jrmp.interceptor.JServerRequestInfo;
36
37 /**
38  * Class <code>ServerSecurityInterceptor</code> is a JRMP security server interceptor for
39  * Security Context propagation
40  *
41  * @autors Jeff Mesnil
42  * @contributor Guillaume Riviere
43  * @version 1.0, 10/03/2003
44  */

45 public class ServerSecurityInterceptor implements JServerRequestInterceptor {
46
47     /**
48      * security context id
49      */

50     public static int SEC_CTX_ID = 1;
51
52     /**
53      * interceptor name
54      */

55     private String JavaDoc interceptorName = "ServerSecurityInterceptor";
56
57     /**
58      * Empty constructor
59      */

60     public ServerSecurityInterceptor() {
61     }
62
63     /**
64      * Receive request
65      * @param JServerRequestInfo the jrmp server request information
66      * @exception IOException if an exception occurs with the ObjectOutput
67      */

68     public void receive_request(JServerRequestInfo jri) throws IOException JavaDoc {
69         // Gets SecurityCurrent object (always existing in JOnAS Server)
70
SecurityCurrent current = SecurityCurrent.getCurrent();
71         if (current != null) {
72             SecurityServiceContext sctx = (SecurityServiceContext) jri.get_request_service_context(SEC_CTX_ID);
73             if (sctx != null) {
74                 // put into the the Current object (true for client side context
75
current.setSecurityContext(sctx.getSecurityContext());
76             }
77         }
78     }
79
80     /**
81      * send reply with context
82      * @param JServerRequestInfo the jrmp server request information
83      * @exception IOException if an exception occur with the ObjectOutput
84      */

85     public void send_reply(JServerRequestInfo jri) throws IOException JavaDoc {
86         SecurityCurrent current = SecurityCurrent.getCurrent();
87         if (current != null) {
88             current.setSecurityContext(new SecurityContext());
89         }
90     }
91
92     /**
93      * get the name of this interceptor
94      * @return name
95      */

96     public String JavaDoc name() {
97         return interceptorName;
98     }
99
100     public void send_exception(JServerRequestInfo jri) throws IOException JavaDoc {
101     }
102
103     public void send_other(JServerRequestInfo jri) throws IOException JavaDoc {
104     }
105 }
Popular Tags