users@glassfish.java.net

Re: How to authenticate java web services from . net client

From: Scott Balmos <sbalmos_at_fastmail.fm>
Date: Thu, 30 Dec 2010 13:35:50 -0500

This is actually more a question about handling HTTP authentication from
a C# SOAP client than anything GF/JAAS related. I'm away from my C#
environment at the moment, but I think the following may be enough to
get started:

MyWebService svc = new MyWebService();
NetworkCredential creds = new NetworkCredential("user", "pass");
svc.Credentials = creds;
svc.doSomething();

--S

On 12/30/2010 4:13 AM, Thilini Amarasingha wrote:
> Hi,
>
> I'm trying to access java web service, protected with JAAS role based
> security from C Sharp .net client..
> They are implemented as stateless EJB and deploying to glassfish V2.
> I have been successful in configuring JAAS security for the rest of
> my J2EE Application and @rolesallowed annotation for ejb and it works
> well.
> Now I'm trying to set @rolesallowed annotation for my web services.
>
> Consider the following example:-
>
> @WebService()
> @Stateless()
> @BindingType(value =
> "http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/")
> public class DivService
> {
> @EJB
> private DivRemote ejb;
>
> @WebMethod(operationName = "getAllDivs")
> @RolesAllowed("Admin")
> public List<Division> getAllDivs() throws DAONotFoundException
> {
> return ejb.getAllDivs();
> }
>
> }
>
> I can invoke the above web services from C Sharp .net client Without
> setting @rolesallowed to them. When i try to invoke web services with
> the role based securtiy i get an error from the client side says that
> the user is unauthorized.
> So is there any way to authenticate web services from c sharp.net
> <http://sharp.net/> client by using the user credentials??
>
> Thanks & Best Regards,
> Thilini
>