From version 6.5.1 of CMS Fiona, user properties provided, for example, by a
directory service can be accessed in a portlet by means of the javax.portlet.PortletRequest.USER_INFO
request attribute.
The attributes provided by the portal are listed in the portlet.xml
file. In the following example, this is shown for two attributes:
<user-attribute> <name>user.name.real</name> </user-attribute> <user-attribute> <name>user.business-info.online.email</name> </user-attribute>
However, in most cases these attributes will not be provided under their standard names. Therefore, the Portal Manager offers the possibility to map standard names to the names under which they are made accessible. For this, the userAttributeMapper
property in the portletContainer
bean defined in the pm.xml
file needs to be set.
This is shown in the following example for mapping the attributes above to two attributes that also exist in the Content Manager:
<property name="userAttributeMapper"> <bean class="com.infopark.pm.user.SimpleAttributeMapper"> <property name="mapping"> <value> user.business-info.online.email = email user.name.real = realName </value> </property> </bean> </property>
By means of this configuration, a portlet can access the email
user property using the following code:
Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO); String email = (String)userInfo.get("user.business-info.online.email");