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: */package org.objectweb.jonas.security.interceptors.iiop;
021:
022: import org.omg.IOP.ServiceContext;
023: import org.omg.PortableInterceptor.ForwardRequest;
024: import org.omg.PortableInterceptor.ORBInitInfo;
025: import org.omg.PortableInterceptor.ServerRequestInfo;
026: import org.omg.PortableInterceptor.ServerRequestInterceptor;
027:
028: import org.objectweb.security.context.SecurityContext;
029: import org.objectweb.security.context.SecurityCurrent;
030:
031: /**
032: * Class <code>CorbaServerSecurityInterceptor</code> is a Server Interceptor
033: * for Security
034: * @author Guillaume Riviere (Guillaume.Riviere@inrialpes.fr)
035: * @version 1.0, 13/09/2002
036: */
037: public class CorbaServerSecurityInterceptor extends SecurityInterceptor
038: implements ServerRequestInterceptor {
039:
040: /**
041: * interceptor name
042: */
043: private String interceptorName = "CorbaServerSecurityInteceptor";
044:
045: /**
046: * Security context
047: */
048: private SecurityContext sCtx = null;
049:
050: /**
051: * constructor
052: */
053: public CorbaServerSecurityInterceptor(ORBInitInfo info) {
054: }
055:
056: /**
057: * get the name of this interceptor
058: * @return name
059: */
060: public String name() {
061: return interceptorName;
062: }
063:
064: /**
065: * Receive request context
066: * @param JServerRequestInfo the server request information
067: * @exception IOException if an exception occur with the ObjectOutput
068: */
069: public void receive_request_service_contexts(ServerRequestInfo jri)
070: throws ForwardRequest {
071: // Gets SecurityCurrent object (always existing in JOnAS Server)
072: SecurityCurrent current = SecurityCurrent.getCurrent();
073: if (current != null) {
074: try {
075: ServiceContext serviceCtx = (ServiceContext) jri
076: .get_request_service_context(SEC_CTX_ID);
077: if (serviceCtx != null) {
078: sCtx = unmarshallSecurityContext(serviceCtx.context_data);
079: }
080: } catch (org.omg.CORBA.BAD_PARAM e) {
081: // No Security context, do nothing
082: }
083: }
084: }
085:
086: /**
087: * Receive request
088: * @param JServerRequestInfo the server request information
089: * @exception IOException if an exception occur with the ObjectOutput
090: */
091: public void receive_request(ServerRequestInfo jri)
092: throws ForwardRequest {
093: SecurityCurrent current = SecurityCurrent.getCurrent();
094: if ((current != null) && (sCtx != null)) {
095: // put into the the Current object
096: current.setSecurityContext(sCtx);
097: sCtx = null;
098: }
099: }
100:
101: /**
102: * send reply with context
103: * @param JServerRequestInfo the server request information
104: * @exception IOException if an exception occur with the ObjectOutput
105: */
106: public void send_reply(ServerRequestInfo jri) {
107: }
108:
109: public void send_exception(ServerRequestInfo jri)
110: throws ForwardRequest {
111: }
112:
113: public void send_other(ServerRequestInfo jri) throws ForwardRequest {
114: }
115:
116: public void destroy() {
117: }
118: }
|