Secure and Unsecure channels in same app domain
- From: jay@xxxxxxxxxxxxxxx
- Date: 22 Dec 2006 07:44:46 -0800
Hello
I posted a similar message a couple days ago, but made some headway.
Here's a simpler version.
I have a server app domain that registers a secure tcpserverchannel and
an unsecure tcpserverchannel. Each channel is bound to a object.
I have a client app domain that registers a secure tcpclientchannel and
an unsecure tcpclientchannel.
If I run this scenarion in the client, it works fine
register unsecure channel
test
register secure channel
test
If I run this scenario in the client, the unsecure test call fails with
"Authentication Failure".
register secure channel
test
register unsecure channel
test - fails!
The IsSecured property of the unsecured channel is set to false, so I
don't understand why it's authorizing. I also tried using the remote
object via RegisterActivatedClientType, but it failed the same way.
All help is appreciated.
Code follows.
CLIENT
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 Client
{
static string server = "localhost";
static void StartUnsecure()
{
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);
//ChannelServices.UnregisterChannel(clientUnsecure);
}
static void TestUnsecure()
{
System.Console.WriteLine("Test
Unsecured\n--------------------------------");
System.Console.WriteLine("IsSecured: " +
((TcpClientChannel)ChannelServices.GetChannel("clientUnsecure")).IsSecured.ToString());
SampleObject test =
(SampleObject)Activator.GetObject(typeof(SampleObject), "tcp://" +
server + ":8082/Unsecured.rem");
System.Console.WriteLine("unsecure: " +
test.GetTest().ToLongTimeString());
System.Console.WriteLine("\n");
}
static void StartSecure()
{
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, true);
//ChannelServices.UnregisterChannel(clientSecure);
}
static void TestSecure()
{
System.Console.WriteLine("Test
Secured\n--------------------------------");
System.Console.WriteLine("IsSecured: " +
((TcpClientChannel)ChannelServices.GetChannel("clientSecure")).IsSecured.ToString());
SampleObject2 testSecure =
(SampleObject2)Activator.GetObject(typeof(SampleObject2), "tcp://" +
server + ":8081/Secured.rem");
System.Console.WriteLine("secure: " +
testSecure.GetTest2().ToLongTimeString());
System.Console.WriteLine("\n");
}
static void Main(string[] args)
{
//System.Diagnostics.Debugger.Launch();
System.Console.Write("Press Enter to start.");
System.Console.ReadLine();
System.Console.WriteLine("\n\n");
if (false)
{
//this works because UNSECURE is registered first.
StartUnsecure();
TestUnsecure();
StartSecure();
TestSecure();
TestUnsecure();
}
else
{
StartSecure();
TestSecure();
StartUnsecure();
TestUnsecure();
}
System.Console.WriteLine("Press ENTER to end");
System.Console.ReadLine();
}
}
}
SERVER
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;
using System.Security;
namespace Server2
{
/// <summary>
/// 8082 - Unsecure
/// 8081 - Secure
/// </summary>
public class Server
{
private static void StartUnsecure()
{
IDictionary properties = new Hashtable();
properties.Add("port", 8082);
properties.Add("secure", false);
properties.Add("name", "unsecure");
//properties.Add("authenticationMode", "None");
//properties.Add("authorizationModule",
"Server2.AuthorizationDummy,Server2");
//properties.Add("tokenImpersonationLevel", "None");
//properties.Add("impersonate", false);
// Create an instance of a channel
TcpServerChannel serverChannel = new TcpServerChannel(properties,
null);
ChannelServices.RegisterChannel(serverChannel, false);
// Register as an available service with the name HelloWorld
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("authenticationMode", "IdentifyCallers");
//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)
{
StartSecure();
StartUnsecure();
Console.WriteLine("Unsecure: 8082\n Secure: 8081");
Console.WriteLine("Press the enter key to exit...");
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()
{
}
}
}
.
- Prev by Date: Re: Accessing secure and unsecure services from same app domain
- Next by Date: Re: Remoting Problem
- Previous by thread: Remoting Problem
- Next by thread: Re:
- Index(es):
Relevant Pages
|
Loading