Hello,
I am in the process of creating the channels and routers for my JMS implementation of CSLA.NET. I was able to do this on CSLA.NET 1.1x version but now I am trying to fit it on the channel and router pattern.
The problem I have is that I am using windows-based authentication on the client. The server components are running on a Java Virtual Machine (JMS) which has it's own security/authentication mechanism, but I can have a routine on the server business components to log-in as a valid Domain Account so that windows authentication/role checking can be accomplished.
Looked at the DataPortal.Client.DataPortal module and noticed that the GetPrincipal is returning "nothing" if it is Windows authentication. How can I elegantly work around this? I need the ApplicationContext.User to be passed in during the creation of the Server.DataPortalContext so that on the server-side I know who the user is.
By the way, I was able to accomplish this on the CSLA.NET 1.1X by serializing the Principal object as a base 64 encoded string and passing it as part of the criteria object, then deserializing it back in the server component.. Kind of a hack since I bypassed the DataPortalContext.
This time I want to be legit and want to try to use the DataPortalContext.
Thank you.
Rocky,
Sweet! Thank you sir. Never thought of this approach. Aaah, the version in 1.x I used never had the ApplicationContext then..it predates the 1.52...never had the chance to update it with the newer releases.
Again, thank you!
Rocky,
Sorry, but I have to ask this questions so it becomes clear.
1) Where is the most likely place for me to call ApplicationContext.ClientContext.Add("ClientPrincipal", Serialize(GetPrincipal()))? Should it be on the initialization phase (eg. Form Load or main()) of a UI or should it be during the Initialize() phase of my business object (override Core.BusinessBase.Initialize())?
2) When I check for authorization should I check for it on the ClientContext like the example on DataPortal_xyz:
if not (Ctype( Deserialize(ApplicationContext.ClientContext.Item("ClientPrincipal"), IPrincipal).IsInRole("SomeRole") then
throw some exception
end if
The reason I asked is on the server-side, ApplicationContext.User would return the user that is used to start my server-side component, not the client's principal since Server.DataPortal.SetContext does not set the ApplicationContext.User to the client's principal (In the first place Client.DataPortal's GetPrincipal return's nothing on "Windows" authentication).
During my first stab in the 1.x version I used to set the Principal to the client's principal.
I guess this is a trade-off for marrying different worlds of technology.
Thanks.
You are right, JMS does not have a mechanism to let the client Windows credentials through to the server for impersonation.
The .NET server run by a JMS process is running as a windows account though, since the JVM is run as a windows service.
Everytime a message comes in (one of the DataPortal_xxx method), a thread is created and I need this thread to be set to the client Windows principal so that I can use authorization checking by using the Thread.CurrentPrincipal.
I got it to work with 1.x but there has been a big change with 2.x. I might have to go with a RequestParam object (similar to the DTO in the web service portal) that contains the client's principal and the criteria object and the dpContext. I worry about using the ApplicationContext.ClientContext because of thread safety if I create an ASP.NET client UI, although I might be wrong.
Thanks.
slabanum:Everytime a message comes in (one of the DataPortal_xxx method), a thread is created and I need this thread to be set to the client Windows principal so that I can use authorization checking by using the Thread.CurrentPrincipal.
I got it to work with 1.x but there has been a big change with 2.x. I might have to go with a RequestParam object (similar to the DTO in the web service portal) that contains the client's principal and the criteria object and the dpContext. I worry about using the ApplicationContext.ClientContext because of thread safety if I create an ASP.NET client UI, although I might be wrong.
Copyright (c) Marimer LLC