...
You need to add to your portlet.xml something like
Code Block |
---|
| xml |
---|
| xml |
---|
title | Declaring a user attribute in portlet.xmlxml |
---|
|
<user-attribute>
<description>User Family Name</description>
<name>user.name.family</name>
</user-attribute>
|
...
Then from within your Portlet code you can access the values like this
Code Block |
---|
| java |
---|
| java |
---|
title | Accessing a user attribute from JSR-168 Java implementationjava |
---|
|
Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);
String surname = (String)userInfo.get("user.name.family");
|
...
In portletContainerContext.xml, enhance the existing declaration:
Code Block |
---|
| xml |
---|
| xml |
---|
title | userInfoService declaration in portletContainerContext.xml | xml |
---|
|
<bean id="userInfoService" class="org.jasig.portal.portlet.container.services.MergingUserInfoService">
<property name="userInfoServices">
<list>
<ref bean="personDirectoryUserInfoService"/>
<ref bean="casTicketUserInfoService"/>
</list>
</property>
</bean>
|
to additionally reference the cached password service:
Code Block |
---|
| xml |
---|
| xml |
---|
title | userInfoService declaration modified to reference the cached password service in portletContainerContext.xmlxml |
---|
|
<bean id="userInfoService" class="org.jasig.portal.portlet.container.services.MergingUserInfoService">
<property name="userInfoServices">
<list>
<ref bean="personDirectoryUserInfoService"/>
<ref bean="casTicketUserInfoService"/>
<ref bean="cachedPasswordUserInfoService"/>
</list>
</property>
</bean>
|
Of course, that reference needs to point at a bean declaration, so introduce a bean like this:
Code Block |
---|
| xml |
---|
| xml |
---|
title | introduce a cachedPasswordUserInfoService declaration in portletContainerContext.xml | xml |
---|
|
<bean id="cachedPasswordUserInfoService" class="org.jasig.portal.portlet.container.services.CachedPasswordUserInfoService">
<property name="portalRequestUtils" ref="portalRequestUtils" />
<property name="userInstanceManager" ref="userInstanceManager" />
<property name="portletWindowRegistry" ref="portletWindowRegistry" />
<property name="portletEntityRegistry" ref="portletEntityRegistry" />
<property name="portletDefinitionRegistry" ref="portletDefinitionRegistry" />
<property name="passwordKey" value="password"/>
</bean>
|
...
Consuming the attributes once available
Code Block |
---|
| xml |
---|
| xml |
---|
title | Declaring password user attribute in portlet.xmlxml |
---|
|
<user-attribute>
<description>Specially treated user attribute name that will be
populated with the end user's cached password, if available</description>
<name>password</name>
</user-attribute>
|
Then from within your Portlet code you can access the password like this
Code Block |
---|
| java |
---|
| java |
---|
title | Accessing a user attribute from JSR-168 Java implementationjava |
---|
|
Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);
String password = (String)userInfo.get("password");
|