1 25 26 package org.objectweb.jonas.security.iiop; 27 28 import org.omg.IOP.Codec ; 29 import org.omg.IOP.ENCODING_CDR_ENCAPS ; 30 import org.omg.IOP.Encoding ; 31 import org.omg.IOP.CodecFactoryPackage.UnknownEncoding ; 32 import org.omg.PortableInterceptor.ORBInitInfo ; 33 import org.omg.PortableInterceptor.ORBInitializer ; 34 35 import org.objectweb.carol.util.csiv2.SasPolicy; 36 import org.objectweb.carol.util.csiv2.SasPolicyFactory; 37 38 import org.objectweb.jonas.common.Log; 39 40 import org.objectweb.util.monolog.api.BasicLevel; 41 import org.objectweb.util.monolog.api.Logger; 42 43 47 public class Csiv2Initializer extends org.omg.CORBA.LocalObject implements ORBInitializer { 48 49 52 private static Logger logger = Log.getLogger(Log.JONAS_CSIV2_SECURITY_PREFIX); 53 54 57 private static Logger loggerDetails = Log.getLogger(Log.JONAS_CSIV2_DETAILS_SECURITY_PREFIX); 58 59 66 public void post_init(ORBInitInfo info) { 67 if (logger.isLoggable(BasicLevel.DEBUG)) { 69 logger.log(BasicLevel.DEBUG, "Initializing SAS Interceptors"); 70 } 71 72 Encoding encoding = new Encoding (ENCODING_CDR_ENCAPS.value, (byte) 1, (byte) 2); 74 Codec codec = null; 75 try { 76 codec = info.codec_factory().create_codec(encoding); 77 } catch (UnknownEncoding ue) { 78 String err = "Cannot use a given encoding : '" + ue.getMessage() + "'."; 79 logger.log(BasicLevel.ERROR, err); 80 throw new RuntimeException (err); 81 } 82 83 try { 84 info.add_server_request_interceptor(new Csiv2ServerInterceptor(codec, logger, loggerDetails)); 85 } catch (Exception e) { 86 logger.log(BasicLevel.ERROR, "Unable to register CSIv2 server interceptor : '" + e.getMessage() + "'."); 87 } 88 try { 89 info.add_client_request_interceptor(new Csiv2ClientInterceptor(codec, logger, loggerDetails)); 90 } catch (Exception e) { 91 logger.log(BasicLevel.ERROR, "Unable to register CSIv2 client interceptor : '" + e.getMessage() + "'."); 92 } 93 94 try { 95 info.add_ior_interceptor(new Csiv2IorInterceptor(codec, logger, loggerDetails)); 96 } catch (Exception e) { 97 logger.log(BasicLevel.ERROR, "Unable to register CSIv2 IOR interceptor : '" + e.getMessage() + "'."); 98 } 99 100 if (logger.isLoggable(BasicLevel.DEBUG)) { 102 logger.log(BasicLevel.DEBUG, "Initializing SAS policy factory"); 103 } 104 info.register_policy_factory(SasPolicy.POLICY_TYPE, new SasPolicyFactory()); 105 106 } 107 108 116 public void pre_init(ORBInitInfo info) { 117 119 } 120 } | Popular Tags |