1 /** 2 * EasyBeans 3 * Copyright (C) 2006 Bull S.A.S. 4 * Contact: easybeans@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 1121 2006-09-27 08:51:06Z benoitf $ 23 * -------------------------------------------------------------------------- 24 */ 25 26 package org.objectweb.easybeans.security.propagation.rmi.jrmp.interceptors; 27 28 import java.io.IOException; 29 30 import org.objectweb.carol.rmi.jrmp.interceptor.JServerRequestInterceptor; 31 import org.objectweb.carol.rmi.jrmp.interceptor.JServerRequestInfo; 32 import org.objectweb.easybeans.security.propagation.context.SecurityContext; 33 import org.objectweb.easybeans.security.propagation.context.SecurityCurrent; 34 35 /** 36 * @author Florent Benoit 37 */ 38 public class ServerSecurityInterceptor implements JServerRequestInterceptor { 39 40 /** 41 * Name of the interceptor. 42 */ 43 private static final String NAME = "JRMPServerSecurityInterceptor"; 44 45 /** 46 * Receive request from client. 47 * @param jServerRequestInfo the jrmp server request information 48 * @exception IOException if an exception occurs with the ObjectOutput 49 */ 50 public void receive_request(final JServerRequestInfo jServerRequestInfo) throws IOException { 51 // Check if a security context was received 52 SecurityServiceContext securityServiceContext = (SecurityServiceContext) jServerRequestInfo 53 .get_request_service_context(SecurityServiceContext.SEC_CTX_ID); 54 if (securityServiceContext != null) { 55 // Sets Security context received by client 56 SecurityCurrent.getCurrent().setSecurityContext(securityServiceContext.getSecurityContext()); 57 } 58 } 59 60 /** 61 * Send reply with context to the client. 62 * @param jServerRequestInfo the jrmp server request information 63 * @exception IOException if an exception occur with the ObjectOutput 64 */ 65 public void send_reply(final JServerRequestInfo jServerRequestInfo) throws IOException { 66 SecurityCurrent.getCurrent().setSecurityContext(new SecurityContext()); 67 } 68 69 /** 70 * Gets the name of this interceptor. 71 * @return name of the interceptor. 72 */ 73 public String name() { 74 return NAME; 75 } 76 77 /** 78 * Send exception with context. Not used. 79 * @param jServerRequestInfo the jrmp server request information 80 * @exception IOException if an exception occur with the ObjectOutput 81 */ 82 public void send_exception(final JServerRequestInfo jServerRequestInfo) throws IOException { 83 84 } 85 86 /** 87 * Not used by this interceptor. 88 * @param jServerRequestInfo the jrmp server request information 89 * @exception IOException if an exception occur with the ObjectOutput 90 */ 91 public void send_other(final JServerRequestInfo jServerRequestInfo) throws IOException { 92 93 } 94 95 } 96