cancel
Showing results for 
Search instead for 
Did you mean: 

how to get current user of portal in jsp/servlet

Former Member
0 Kudos

Hi expert,

I know exactly how to get current user in WDJ, and I also know how to get current user in portal application. But now is the case, I need to get current user in a j2ee project, I tried request.getRemoteUser() & request.getUserPrinciple().getName(), all failed. I have already packge this jsp page into iview & logon portal, but all I get are always null.

Please give me some hint.

Thank you.

William

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Does request.getRemoteUser() return null?

Have you configured security settings in J2EE project you are developing?

I have created a J2EE app with a Web Module with one JSP that returns "request.getRemoteUser" and is working fine. I have made the following settings in file Web.xml (Using NWDS):

1. In general Tab, I have selected BASIC as login configuration / Realm Name = testUser

2. In Security Roles Tab:

- Create a new security role "Access"

3. In security Tab I have created a new Security Constraint

- Add URL pattern * in Web Resource Collection"

- Add role "Access" in Auth Constraint

Settings in web-j2ee-engine.xml:

4. In security Tab

- Specify context root of your app in Security policy domain (my case is /testUser

5. Finally you have to map UME Users to security role in Visual Administrator:

- Service "Security Provider" -> Policy Configurations -> Security Roles

Web.xml source:

<web-app>
	<display-name>WEB APP</display-name>
	<description>WEB APP description</description>
	<servlet>
		<servlet-name>TestUser.jsp</servlet-name>
		<jsp-file>/TestUser.jsp</jsp-file>
	</servlet>
	<security-constraint>
		<display-name>SecurityConstraint</display-name>
		<web-resource-collection>
			<web-resource-name>WebResource</web-resource-name>
			<url-pattern>*</url-pattern>
		</web-resource-collection>
		<auth-constraint>
			<description>Access</description>
			<role-name>Access</role-name>
		</auth-constraint>
	</security-constraint>
	<login-config>
		<auth-method>BASIC</auth-method>
		<realm-name>testUser</realm-name>
	</login-config>
	<security-role>
		<role-name>Access</role-name>
	</security-role>
</web-app>

Web-j2ee-engine.xml source:

<web-j2ee-engine>
	<security-role-map>
		<role-name>Access</role-name>
	</security-role-map>
	<login-module-configuration>
		<password-change-config/>
	</login-module-configuration>
	<security-policy-domain>/testUser</security-policy-domain>
</web-j2ee-engine>

Best Regards,

Jorge Linares

Former Member
0 Kudos

Thank you Jorge, your solution works fine.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

i have do it how Jorge sais, and run ok, but my problem is that now i have 2 logins:

1) Login in the Portal

2) Login in jsp

How can i do to have only 1 login (portal login) and obtain portal user?

Thank you