KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > security > interceptors > jeremie > JonasSecurityReceiver


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

25
26 package org.objectweb.jonas.security.interceptors.jeremie;
27
28 import org.objectweb.security.propagation.SecurityReceiver;
29 import org.objectweb.security.context.SecurityCurrent;
30 import org.objectweb.security.context.SecurityContext;
31
32 /**
33  * This class represents the implementation of a SecurityReceiver in JOnAS.
34  * @author Jeff Mesnil
35  */

36 public class JonasSecurityReceiver implements SecurityReceiver {
37
38     /**
39      * Empty constructor
40      */

41     public JonasSecurityReceiver() {
42     }
43
44     public void received_request(int request_id, SecurityContext ctx) {
45         // Gets SecurityCurrent object (always existing in JOnAS Server)
46
SecurityCurrent current = SecurityCurrent.getCurrent();
47         if (current == null) {
48             return;
49         }
50         // Associates the current thread with this security context
51
current.setSecurityContext(ctx);
52     }
53
54     public SecurityContext sending_reply(int request_id) {
55         // Gets Current object (always existing in JOnAS Server)
56
SecurityCurrent current = SecurityCurrent.getCurrent();
57         if (current == null) {
58             return null;
59         }
60         // Get the Security Context
61
SecurityContext ctx = current.getSecurityContext();
62         // associates the current thread with a new default SecurityContext
63
current.setSecurityContext(new SecurityContext());
64         //System.out.println ("JOnAS send a reply : "+
65
// ctx.getCallerPrincipal().getName()) ;
66
return ctx;
67     }
68 }
Popular Tags