Re: Accessing secure and unsecure services from same app domain
- From: jay@xxxxxxxxxxxxxxx
- Date: 21 Dec 2006 19:36:49 -0800
Disregard. It's working. Your message prompted me to take another look.
I had a boolean wrong in the server's RegisterChannel.
Thanks for your help.
jay@xxxxxxxxxxxxxxx wrote:
Hello
That's what it's doing (perhaps incorrectly). The server has 2 channels
open on 8080 and 8081. The client opens 2 channels on 8080 and 8081.
However, it still doesn't work. If one is secure, I can't access the
other unsecure.
Thanks for your help.
Shailen Sukul wrote:
You could publish the same object to 2 diff urls that use 2 diff channels.
Then you could specify the url to use, hence the channel when retrieving
your object.
--
With Regards
Shailen Sukul
.Net Architect
(MCPD: Ent Apps, MCSD.Net MCSD MCAD)
Ashlen Consulting Services
http://www.ashlen.net.au
<jay@xxxxxxxxxxxxxxx> wrote in message
news:1166557552.385049.173430@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
.NET 2.0
Hello
I'm trying to get up to speed with remoting.
I created a test app that has two servers and two clients.
There's one secure server and client, and one unsecure server and
client.
When I create the clients, the first channel I register is always used.
So, if I register the UNSECURE client first, then I can't call the
SECURE service, and vice-versa. An AUTHORIZATION exception is thrown.
Is there a way to specify which channel to use when making a remoting
call? Both channels are registered, but it always goes to the first one
regardless of the priority.
Thanks in advance for your help.
SERVER TEST CODE
using ConsoleApplication5;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Text;
namespace Server2
{
/// <summary>
/// 8080 - Unsecure
/// 8081
/// </summary>
class Program
{
private static void StartUnsecure()
{
IDictionary properties = new Hashtable();
properties.Add("port", 8080);
properties.Add("secure", false);
properties.Add("name", "unsecure");
//properties.Add("impersonate", false);
// Create an instance of a channel
TcpServerChannel serverChannel = new TcpServerChannel(properties,
null);
ChannelServices.RegisterChannel(serverChannel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(SampleObject),
"Unsecured.rem", WellKnownObjectMode.Singleton);
}
private static void StartSecure()
{
IDictionary properties = new Hashtable();
properties.Add("port", 8081);
properties.Add("secure", true);
properties.Add("name", "secure");
//properties.Add("impersonate", false);
// Create an instance of a channel
TcpServerChannel serverChannel = new TcpServerChannel(properties,
null);
ChannelServices.RegisterChannel(serverChannel, true);
// Register as an available service with the name HelloWorld
RemotingConfiguration.RegisterWellKnownServiceType(typeof(SampleObject2),
"Secured.rem", WellKnownObjectMode.Singleton);
}
static void Main(string[] args)
{
StartUnsecure();
StartSecure();
Console.WriteLine("Unsecure: 8080\n Secure: 8081");
Console.WriteLine("Press the enter key to exit...");
Console.ReadLine();
}
}
}
CLIENT TEST CODE
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Text;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
System.Console.Write("Press Enter to start.");
System.Console.ReadLine();
#region Secure Client
IDictionary propertiesSecure = new Hashtable();
propertiesSecure.Add("secure", true);
propertiesSecure.Add("name", "clientSecure");
propertiesSecure.Add("priority", 2);
TcpClientChannel clientSecure = new
TcpClientChannel(propertiesSecure, null);
ChannelServices.RegisterChannel(clientSecure, false);
SampleObject2 testSecure =
(SampleObject2)Activator.GetObject(typeof(SampleObject2),
"tcp://127.0.0.1:8081/Secured.rem");
System.Console.WriteLine("secure: " +
testSecure.GetTest2().ToLongTimeString());
//ChannelServices.UnregisterChannel(clientSecure);
#endregion
#region Unsecure Client
IDictionary properties = new Hashtable();
properties.Add("secure", false);
properties.Add("name", "clientUnsecure");
properties.Add("priority", 1);
TcpClientChannel clientUnsecure = new
TcpClientChannel(properties, null);
ChannelServices.RegisterChannel(clientUnsecure, false);
SampleObject test =
(SampleObject)Activator.GetObject(typeof(SampleObject),
"tcp://127.0.0.1:8080/Unsecured.rem");
System.Console.WriteLine("unsecure: " +
test.GetTest().ToLongTimeString());
//ChannelServices.UnregisterChannel(clientUnsecure);
#endregion
System.Console.WriteLine("Press ENTER to end");
System.Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication5
{
public class SampleObject : MarshalByRefObject
{
public DateTime GetTest()
{
return System.DateTime.Now;
}
public SampleObject()
{
}
}
public class SampleObject2 : MarshalByRefObject
{
public DateTime GetTest2()
{
return System.DateTime.Now;
}
public SampleObject2()
{
}
}
}
.
- References:
- Prev by Date: Re: Accessing secure and unsecure services from same app domain
- Next by Date: Secure and Unsecure channels in same app domain
- Previous by thread: Re: Accessing secure and unsecure services from same app domain
- Next by thread: Remoting and ilmerge
- Index(es):
Relevant Pages
|