1 24 25 package com.rift.coad.lib.interceptor.iiop; 27 28 import java.util.MissingResourceException ; 30 import org.omg.CORBA.TIMEOUT ; 31 import org.omg.IOP.ServiceContext ; 32 import org.omg.PortableInterceptor.ServerRequestInterceptor ; 33 import org.omg.PortableInterceptor.ServerRequestInfo ; 34 import org.omg.PortableInterceptor.ForwardRequest ; 35 import org.omg.PortableInterceptor.ORBInitInfo ; 36 37 import org.apache.log4j.Logger; 39 40 import com.rift.coad.lib.common.ObjectSerializer; 42 import com.rift.coad.lib.interceptor.credentials.Credential; 43 import com.rift.coad.lib.interceptor.InterceptorWrapper; 44 import com.rift.coad.lib.interceptor.ServerInterceptor; 45 46 47 48 54 public class SecurityServerInterceptor extends InterceptorWrapper implements 55 ServerRequestInterceptor { 56 protected static Logger log = 58 Logger.getLogger(SecurityServerInterceptor.class.getName()); 59 60 61 64 public SecurityServerInterceptor(ORBInitInfo info) { 65 } 66 67 68 73 public String name() { 74 return "SecurityServerInterceptor"; 75 } 76 77 78 81 public void destroy() { 82 } 84 85 86 91 public void receive_request_service_contexts(ServerRequestInfo ri) { 92 93 } 94 95 96 100 public void receive_request(ServerRequestInfo ri) { 101 try { 102 log.debug("Receive a request on the server side"); 105 ServiceContext serviceContext = ri.get_request_service_context( 106 Constants.STANDARD_SECURITY_CONTEXT_ID); 107 if (serviceContext != null) { 108 Credential credential = (Credential)ObjectSerializer. 109 deserialize(serviceContext.context_data); 110 this.getServerInterceptor().createSession(credential); 111 } 112 } catch (org.omg.CORBA.BAD_PARAM ex) { 113 } catch (Exception ex) { 115 log.debug("Failed to setup the security because : " 116 + ex.getMessage(),ex); 117 } 118 } 119 120 121 125 public void send_exception(ServerRequestInfo ri) { 126 try { 127 log.debug("Reply to a request on the server side."); 130 ServiceContext serviceContext = ri.get_request_service_context( 131 Constants.STANDARD_SECURITY_CONTEXT_ID); 132 if (serviceContext != null) { 133 this.getServerInterceptor().release(); 134 } 135 } catch (org.omg.CORBA.BAD_PARAM ex) { 136 } catch (Exception ex) { 138 log.debug("Failed to release security because : " + 139 ex.getMessage(),ex); 140 } 141 } 142 143 144 148 public void send_other(ServerRequestInfo ri) { 149 150 } 151 152 153 158 public void send_reply(ServerRequestInfo ri) { 159 try { 160 log.debug("Reply to a request on the server side."); 163 ServiceContext serviceContext = ri.get_request_service_context( 164 Constants.STANDARD_SECURITY_CONTEXT_ID); 165 if (serviceContext != null) { 166 this.getServerInterceptor().release(); 167 } 168 } catch (org.omg.CORBA.BAD_PARAM ex) { 169 } catch (Exception ex) { 171 log.debug("Failed to release security because : " + 172 ex.getMessage(),ex); 173 } 174 } 175 176 } 177 | Popular Tags |