1 22 package org.jboss.iiop.csiv2; 23 24 import org.omg.CORBA.Any ; 25 import org.omg.CORBA.ORB ; 26 import org.omg.CORBA.LocalObject ; 27 import org.omg.CORBA.BAD_PARAM ; 28 import org.omg.CSIIOP.Integrity; 29 import org.omg.CSIIOP.DetectReplay; 30 import org.omg.CSIIOP.DetectMisordering; 31 import org.omg.PortableInterceptor.IORInfo ; 32 import org.omg.PortableInterceptor.IORInterceptor ; 33 34 import org.omg.IOP.Codec ; 35 import org.omg.IOP.CodecPackage.InvalidTypeForEncoding ; 36 import org.omg.IOP.TAG_INTERNET_IOP ; 37 import org.omg.IOP.TaggedComponent ; 38 39 import org.omg.SSLIOP.SSL; 40 import org.omg.SSLIOP.SSLHelper; 41 import org.omg.SSLIOP.TAG_SSL_SEC_TRANS; 42 43 import org.jboss.iiop.CorbaORBService; 44 import org.jboss.logging.Logger; 45 import org.jboss.metadata.IorSecurityConfigMetaData; 46 47 54 public class CSIv2IORInterceptor 55 extends LocalObject 56 implements IORInterceptor 57 { 58 private static final Logger log = Logger.getLogger(CSIv2IORInterceptor.class); 59 63 private static final int MIN_SSL_OPTIONS = Integrity.value | 64 DetectReplay.value | 65 DetectMisordering.value; 66 67 private TaggedComponent defaultSSLComponent; 68 private TaggedComponent defaultCSIComponent; 69 70 public CSIv2IORInterceptor(Codec codec) 71 { 72 int sslPort = CorbaORBService.getTheActualSSLPort(); 73 try 74 { 75 SSL ssl = new SSL((short) MIN_SSL_OPTIONS, 77 (short) 0, 78 (short) sslPort); 79 ORB orb = ORB.init(); 80 Any any = orb.create_any(); 81 SSLHelper.insert(any, ssl); 82 byte[] componentData = codec.encode_value(any); 83 defaultSSLComponent = new TaggedComponent (TAG_SSL_SEC_TRANS.value, 84 componentData); 85 86 IorSecurityConfigMetaData metadata = new IorSecurityConfigMetaData(); 87 defaultCSIComponent = CSIv2Util.createSecurityTaggedComponent(metadata, 88 codec, sslPort, orb); 89 } 90 catch (InvalidTypeForEncoding e) 91 { 92 log.warn("Caught unexcepted exception while encoding SSL component", e); 93 throw new RuntimeException (e); 94 } 95 } 96 97 99 public String name() 100 { 101 return CSIv2IORInterceptor.class.getName(); 102 } 103 104 public void destroy() 105 { 106 } 107 108 public void establish_components(IORInfo info) 110 { 111 CSIv2Policy csiv2Policy = null; 113 114 try 115 { 116 csiv2Policy = (CSIv2Policy) info.get_effective_policy(CSIv2Policy.TYPE); 117 } 118 catch (BAD_PARAM e) 119 { 120 log.debug("No CSIv2Policy"); 121 } 122 catch (Exception e) 123 { 124 log.debug("Error fetching CSIv2Policy", e); 125 } 126 127 if (csiv2Policy != null) 128 { 129 TaggedComponent sslComponent = 132 csiv2Policy.getSSLTaggedComponent(); 133 if (sslComponent != null && 134 CorbaORBService.getSSLComponentsEnabledFlag() == true) 135 { 136 info.add_ior_component_to_profile(sslComponent, 137 TAG_INTERNET_IOP.value); 138 } 139 TaggedComponent csiv2Component = 140 csiv2Policy.getSecurityTaggedComponent(); 141 if (csiv2Component != null) 142 { 143 info.add_ior_component_to_profile(csiv2Component, 144 TAG_INTERNET_IOP.value); 145 } 146 } 147 else 148 { 149 if (defaultSSLComponent != null && 150 CorbaORBService.getSSLComponentsEnabledFlag() == true) 151 { 152 info.add_ior_component_to_profile(defaultSSLComponent, 155 TAG_INTERNET_IOP.value); 156 } 157 if (defaultCSIComponent != null) 158 { 159 info.add_ior_component_to_profile(defaultCSIComponent, 162 TAG_INTERNET_IOP.value); 163 } 164 } 165 166 return; 167 } 168 } 169 | Popular Tags |