Exemplo n.º 1
0
        public override IorProfile GetProfileForAddr(byte[] objectKey, Codec codec)
        {
            InternetIiopProfile result  = new InternetIiopProfile(Version, Host, 0, objectKey);
            SSLComponentData    sslComp =
                new SSLComponentData(SecurityAssociationOptions.EstablishTrustInClient,
                                     SecurityAssociationOptions.EstablishTrustInTarget,
                                     (short)Port);
            TaggedComponent sslTaggedComp =
                new TaggedComponent(TAG_SSL_SEC_TRANS.ConstVal,
                                    codec.encode_value(sslComp));

            result.AddTaggedComponent(sslTaggedComp);
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// parses an IOR-profile embedded in a CDRStream
        /// </summary>
        /// <param name="cdrStream"></param>
        /// <returns></returns>
        private static IorProfile ParseProfile(CdrInputStream cdrStream)
        {
            int profileType = (int)cdrStream.ReadULong();

            switch (profileType)
            {
            case 0:
                IorProfile result = new InternetIiopProfile(cdrStream);
                return(result);

            case 1:
                return(new MultipleComponentsProfile(cdrStream));

            default:
                // unsupported profile type
                return(new UnsupportedIorProfile(cdrStream, profileType));
            }
        }
Exemplo n.º 3
0
        public void Setup()
        {
            m_version = new GiopVersion(1, 2);
            m_hostName = "localhost";
            m_port = 8089;
            m_objectKey = new byte[] { 65 };
            m_profile = new InternetIiopProfile(m_version, m_hostName, m_port, m_objectKey);

            m_serFactory =
                new SerializerFactory();
            CodecFactory codecFactory =
                new Ch.Elca.Iiop.Interception.CodecFactoryImpl(m_serFactory);
            m_codec =
                codecFactory.create_codec(
                    new omg.org.IOP.Encoding(ENCODING_CDR_ENCAPS.ConstVal, 1, 2));
            IiopUrlUtil iiopUrlUtil =
                IiopUrlUtil.Create(m_codec, new object[] {
                    Services.CodeSetService.CreateDefaultCodesetComponent(m_codec)});
            m_serFactory.Initalize(new SerializerFactoryConfig(), iiopUrlUtil);
        }
Exemplo n.º 4
0
 /// <summary>
 /// parses an IOR-profile embedded in a CDRStream
 /// </summary>
 /// <param name="cdrStream"></param>
 /// <returns></returns>
 private static IorProfile ParseProfile(CdrInputStream cdrStream)
 {
     int profileType = (int)cdrStream.ReadULong();
     switch (profileType)
     {
         case 0:
             IorProfile result = new InternetIiopProfile(cdrStream);
             return result;
         case 1:
             return new MultipleComponentsProfile(cdrStream);
         default:
             // unsupported profile type
             return new UnsupportedIorProfile(cdrStream, profileType);
     }
 }
Exemplo n.º 5
0
        public override IorProfile GetProfileForAddr(byte[] objectKey, Codec codec)
        {
            InternetIiopProfile result = new InternetIiopProfile(Version, Host, (ushort)Port, objectKey);

            return(result);
        }
Exemplo n.º 6
0
 /// <summary>gets a reference to the init service running at the specified host at the specified port</summary>
 private CORBAInitService GetInitService(string host, int port) {
     lock(m_initalServices.SyncRoot) {
         CORBAInitService initService = null;
         string key = host + ":" + port;
         if (!m_initalServices.ContainsKey(key)) {
             IorProfile initServiceProfile = 
                 new InternetIiopProfile(new GiopVersion(1, 0),
                                                         host, (ushort)port,
                                                         IorUtil.GetKeyBytesForId(CORBAInitServiceImpl.INITSERVICE_NAME));
             // don't add a codeset component, because giop 1.0
             Ior initServiceIor = new Ior(Repository.GetRepositoryID(typeof(CORBAInitService)),
                                          new IorProfile[] { initServiceProfile });
             
             string iorString = initServiceIor.ToString();                    
             initService = (CORBAInitService)RemotingServices.Connect(typeof(CORBAInitService), 
                                                                      iorString); // CORBAInitService type not verifiable remote -> make sure that it's possible to verify locally
             m_initalServices.Add(key, initService);
         } else {
             initService = (CORBAInitService) m_initalServices[key];
         }
         return initService;
     }
 }
        private Stream PrepareLocationFwdStream(string host, ushort port,
                                                MarshalByRefObject target) {
            // loc fwd ior
            byte[] objectKey = IorUtil.GetObjectKeyForObj(target);
            string repositoryID = Repository.GetRepositoryID(target.GetType());
            // this server support GIOP 1.2 --> create an GIOP 1.2 profile
            InternetIiopProfile profile = new InternetIiopProfile(new GiopVersion(1, 2), host,
                                                                  port, objectKey);
            profile.AddTaggedComponent(Services.CodeSetService.CreateDefaultCodesetComponent(m_codec));
            Ior locFwdTarget = new Ior(repositoryID, new IorProfile[] { profile });
            CdrOutputStreamImpl iorStream = new CdrOutputStreamImpl(new MemoryStream(),
                                                                    0, new GiopVersion(1, 2));
            locFwdTarget.WriteToStream(iorStream);
            uint encodedIorLength = (uint)iorStream.GetPosition();
 
            // create the location fwd reply
            MemoryStream sourceStream = new MemoryStream();
            CdrOutputStreamImpl cdrOut = new CdrOutputStreamImpl(sourceStream, 0, new GiopVersion(1, 2));
            cdrOut.WriteOpaque(m_giopMagic);
            // version
            cdrOut.WriteOctet(1);
            cdrOut.WriteOctet(2);
            // flags
            cdrOut.WriteOctet(0);
            // msg-type: reply
            cdrOut.WriteOctet(1);
 
            // msg-length
            cdrOut.WriteULong(28 + encodedIorLength);
            // request-id
            cdrOut.WriteULong(5);
            // reply-status: location fwd
            cdrOut.WriteULong(3);
            // one service context to enforce alignement requirement for giop 1.2
            cdrOut.WriteULong(1);
            cdrOut.WriteULong(162739); // service context id
            cdrOut.WriteULong(2); // length of svc context
            cdrOut.WriteBool(true);
            cdrOut.WriteBool(false);
            // svc context end
            // body: 8 aligned
            cdrOut.ForceWriteAlign(Aligns.Align8);

            locFwdTarget.WriteToStream(cdrOut);
 
            sourceStream.Seek(0, SeekOrigin.Begin);
            return sourceStream;
        }
Exemplo n.º 8
0
 private static void AddProfileComponentsFromIorInterceptors(InternetIiopProfile profile) {
     IORInterceptor[] interceptors = OrbServices.GetSingleton().InterceptorManager.GetIorInterceptors();
     if (interceptors.Length > 0) {
         IORInfo info = new IORInfoImpl(profile);
         for (int i = 0; i < interceptors.Length; i++) {
             try {
                 interceptors[i].establish_components(info);
             } catch (ThreadAbortException) {
                 throw;
             } catch (Exception e) {
                 // ignore exceptions
                 Trace.WriteLine("warning: ior interceptor thrown exception: " + e);
             }
         }
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// creates an IOR for an object hosted in the local appdomain.
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 internal static Ior CreateIorForObjectFromThisDomain(MarshalByRefObject obj, Type forType, bool marshalUsingForType) {
     Console.WriteLine("Marshalling using for type: {0}", marshalUsingForType);
     ObjRef objRef = 
         marshalUsingForType ? RemotingServices.Marshal(obj, null, forType)
                             : RemotingServices.Marshal(obj); // make sure, the object is marshalled and get obj-ref
     byte[] objectKey = GetObjectKeyForUri(objRef.URI);
     IiopChannelData serverData = GetIiopChannelData(objRef);
     if (serverData != null) {
         string host = serverData.HostName;
         int port = serverData.Port;
         if ((objectKey == null) || (host == null)) {
             // the objRef: " + refToTarget + ", uri: " +
             // refToTarget.URI + is not serialisable, because connection data is missing
             // hostName=host, objectKey=objectKey
             throw new INV_OBJREF(1961, CompletionStatus.Completed_MayBe);
         }
         string repositoryID = forType == ReflectionHelper.MarshalByRefObjectType
             ? "" // CORBA::Object has "" repository id
             : Repository.GetRepositoryID(forType);
         // this server support GIOP 1.2 --> create an GIOP 1.2 profile
         InternetIiopProfile profile = new InternetIiopProfile(new GiopVersion(1, 2), host,
                                                               (ushort)port, objectKey);
         // add additional tagged components according to the channel options, e.g. for SSL
         profile.AddTaggedComponents(serverData.AdditionalTaggedComponents);
         // add additional tagged components according to registered interceptors:
         AddProfileComponentsFromIorInterceptors(profile);
         
         Ior ior = new Ior(repositoryID, new IorProfile[] { profile });
         return ior;
     } else {
         Debug.WriteLine("ERROR: no server-channel information found!");
         Debug.WriteLine("Please make sure, that an IIOPChannel has been created with specifying a listen port number (0 for automatic)!");
         Debug.WriteLine("e.g. IIOPChannel chan = new IIOPChannel(0);");
         throw new INTERNAL(1960, CompletionStatus.Completed_MayBe);
     }
 }
Exemplo n.º 10
0
 public IORInfoImpl(InternetIiopProfile profile) : this(new InternetIiopProfile[] { profile }) {            
 }
Exemplo n.º 11
0
 public IORInfoImpl(InternetIiopProfile[] profiles) {
     m_profiles = profiles;
 }
Exemplo n.º 12
0
 public override IorProfile GetProfileForAddr(byte[] objectKey, Codec codec) {
     InternetIiopProfile result = new InternetIiopProfile(Version, Host, 0, objectKey);
     SSLComponentData sslComp =
         new SSLComponentData(SecurityAssociationOptions.EstablishTrustInClient,
                              SecurityAssociationOptions.EstablishTrustInTarget,
                              (short)Port);
     TaggedComponent sslTaggedComp =
         new TaggedComponent(TAG_SSL_SEC_TRANS.ConstVal,
                             codec.encode_value(sslComp));
     result.AddTaggedComponent(sslTaggedComp);
     return result;
 }
Exemplo n.º 13
0
 public override IorProfile GetProfileForAddr(byte[] objectKey, Codec codec) {
     InternetIiopProfile result = new InternetIiopProfile(Version, Host, (ushort)Port, objectKey);
     return result;
 }