public static Microsoft.ServiceBus.Channels.IConnection UpgradeConnection(Microsoft.ServiceBus.Channels.IConnection connection, StreamUpgradeAcceptor upgradeAcceptor, IDefaultCommunicationTimeouts defaultTimeouts)
        {
            Microsoft.ServiceBus.Channels.ConnectionStream connectionStream = new Microsoft.ServiceBus.Channels.ConnectionStream(connection, defaultTimeouts);
            Stream stream = upgradeAcceptor.AcceptUpgrade(connectionStream);

            if (upgradeAcceptor is StreamSecurityUpgradeAcceptor && Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation)
            {
                TraceUtility.TraceEvent(TraceEventType.Information, TraceCode.StreamSecurityUpgradeAccepted, new StringTraceRecord("Type", upgradeAcceptor.GetType().ToString()), connection, null);
            }
            return(new Microsoft.ServiceBus.Channels.StreamConnection(stream, connectionStream));
        }
예제 #2
0
		public void ClientAcceptUpgradeWithoutServiceCertificate ()
		{
			StreamSecurityUpgradeProvider p = CreateClientProvider ();
			Assert.IsNotNull (p, "#1");
			Assert.IsNull (p.Identity, "#2"); // not yet, before Open().
			p.Open ();
			StreamUpgradeAcceptor a = p.CreateUpgradeAcceptor ();
			try {
				Stream s = a.AcceptUpgrade (new MemoryStream (new byte [] {1, 2, 3, 4, 5}));
				Assert.Fail ("It should somehow raise an error."); // on Winfx it is unwise ArgumentNullException
			} catch (Exception) {
			} finally {
				p.Close ();
			}
		}