001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999-2004 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: ServerSecurityInterceptor.java 4804 2004-05-25 15:13:29Z benoitf $
023: * --------------------------------------------------------------------------
024: *
025: */package org.objectweb.jonas.security.interceptors.jrmp;
026:
027: import java.io.IOException;
028:
029: import org.objectweb.security.context.SecurityCurrent;
030: import org.objectweb.security.context.SecurityContext;
031:
032: //carol JRMP Interceptor API Import
033: import org.objectweb.carol.rmi.jrmp.interceptor.JServerRequestInterceptor;
034: import org.objectweb.carol.rmi.jrmp.interceptor.JServerRequestInfo;
035:
036: /**
037: * Class <code>ServerSecurityInterceptor</code> is a JRMP security server interceptor for
038: * Security Context propagation
039: *
040: * @autors Jeff Mesnil
041: * @contributor Guillaume Riviere
042: * @version 1.0, 10/03/2003
043: */
044: public class ServerSecurityInterceptor implements
045: JServerRequestInterceptor {
046:
047: /**
048: * security context id
049: */
050: public static int SEC_CTX_ID = 1;
051:
052: /**
053: * interceptor name
054: */
055: private String interceptorName = "ServerSecurityInterceptor";
056:
057: /**
058: * Empty constructor
059: */
060: public ServerSecurityInterceptor() {
061: }
062:
063: /**
064: * Receive request
065: * @param JServerRequestInfo the jrmp server request information
066: * @exception IOException if an exception occurs with the ObjectOutput
067: */
068: public void receive_request(JServerRequestInfo jri)
069: throws IOException {
070: // Gets SecurityCurrent object (always existing in JOnAS Server)
071: SecurityCurrent current = SecurityCurrent.getCurrent();
072: if (current != null) {
073: SecurityServiceContext sctx = (SecurityServiceContext) jri
074: .get_request_service_context(SEC_CTX_ID);
075: if (sctx != null) {
076: // put into the the Current object (true for client side context
077: current.setSecurityContext(sctx.getSecurityContext());
078: }
079: }
080: }
081:
082: /**
083: * send reply with context
084: * @param JServerRequestInfo the jrmp server request information
085: * @exception IOException if an exception occur with the ObjectOutput
086: */
087: public void send_reply(JServerRequestInfo jri) throws IOException {
088: SecurityCurrent current = SecurityCurrent.getCurrent();
089: if (current != null) {
090: current.setSecurityContext(new SecurityContext());
091: }
092: }
093:
094: /**
095: * get the name of this interceptor
096: * @return name
097: */
098: public String name() {
099: return interceptorName;
100: }
101:
102: public void send_exception(JServerRequestInfo jri)
103: throws IOException {
104: }
105:
106: public void send_other(JServerRequestInfo jri) throws IOException {
107: }
108: }
|