jspheaderhttp-headershttpresponseopenam

How to get header attributes in OpenAM?


What did I do?

1) Installed OpenAM 6.5.

2) Created Webagent in OpenAM.

3) Installed Apache HTTP Server to route the request.

4) Installed Webagent over Apache HTTP Server.

5) Protected a test application and trying to access through Webagent and getting a login page of OpenAM.

6) After putting credentials, the application is working fine.

I want User Details like - Username, Groups, Roles, isMemberOf, memberOf, REMOTE_USER, USER_ID, REMOTE_PORT, REMOTE_USER_GROUP into that test application over the browser.

That test application is just a simple JSP application just to view some header attributes of the User using request like this <%=request.getHeader("REMOTE_USER")%> but, I'm getting a response NULL with this.

So, Please help me to get the User Details through the Header Attribute.

There is an option into the OpenAM Console > Authorisation > Policy Set > Default Policy Set > Response.

Here I chose the required Response Attributes like - "uid, cn, dn, givenName, distinguishedName, sn, isMemberOf, memberOf" but it didn't help me out.

This is the jsp code used in test.jsp file.

<%@ page import="java.io.*,java.util.*" %>

Connection = <%=request.getHeader("Connection")%>

Cookie = <%=request.getHeader("Cookie")%>

uid = <%=request.getHeader("uid")%>

givenName = <%=request.getHeader("givenName")%>

dn = <%=request.getHeader("dn")%>

cn = <%=request.getHeader("cn")%>

userGroup = <%=request.getHeader("userGroup")%>

REMOTE_USER = <%=request.getHeader("REMOTE_USER")%>

Response:

uid = null 

givenName = null 

dn = null 

inetUserStatus = null 

cn = null 

userGroup = null 

REMOTE_USER = null

Solution

  • You need to configure 'profile attributes mapping' in the Agent profile (https://backstage.forgerock.com/docs/openam-web-policy-agents/5.6/web-agents-guide/#web-agent-profile-attributes-processing-properties). You may also make sure add additional 'user attributes' in the identity store of the realm used to authenticate the users (https://backstage.forgerock.com/docs/am/6.5/maintenance-guide/#sec-maint-datastore-customattr).