Caucho Forums  

This forum is permanently closed because of spam. For free community support, please visit Google Groups:


Go Back   Caucho Forums > Hessian

Reply
 
Thread Tools Display Modes
  #1  
Old 07-24-2012, 03:40 PM
nhinhi nhinhi is offline
Junior Member
 
Join Date: Aug 2011
Posts: 2
Default How to get user principal in home class?

Hi all,
I have a class which implements Service
public interface IMyService {
public void getWorkSpace();
}

public class MyServlet implements Service, IMyService {
public void getWorkSpace() {
//here, I need to get the user principal ???
//(something like request.getUserPrincipal())
//java.security.Principal userPrincipal = request.getUserPrincipal();
System.out.println("Current user princial: " + CURRENT_USER_PRINCIPAL.getName());
}
}

In my web.xml:
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.caucho.hessian.server.HessianServlet</servlet-class>
<init-param>
<param-name>home-api</param-name>
<param-value>IMyService</param-value>
</init-param>
<init-param>
<param-name>home-class</param-name>
<param-value>MyServlet</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/myservlet</url-pattern>
</servlet-mapping>
<security-constraint>
<display-name>My security</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/myservlet</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
<security-role>
<description>
All authenticated role
</description>
<role-name>user</role-name>
</security-role>

At client side:
HessianProxyFactory factory = new HessianProxyFactory();
factory.setUser("myUser&quot;
factory.setPassword("myPassword&quot;
...
IMyService myService = (IMyService)factory.create(IMyService.class, url);
myService.getWorkSpace();
//here, I need to output the line: "Current user principal: myUser" ????

My web application is deployed in websphere server. The WebSphere server will be responsible for authentication the user to myservlet.
My question is in the title, how can I get the authenticated user in MyServlet?
Thank you for your help
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:06 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.