Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Current »

General support for user attributes

You need to add to your portlet.xml something like

Declaring a user attribute in portlet.xml
<user-attribute>
  <description>User Family Name</description>
  <name>user.name.family</name>
</user-attribute>

where the <name> attribute is the Key mapped within your PersonDirectory.xml or personDirs.xml (see manual chapter on user attributes).

Then from within your Portlet code you can access the values like this

Accessing a user attribute from JSR-168 Java implementation
Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);
String surname = (String)userInfo.get("user.name.family");

Special support for conveying the end user's password to the JSR-168 portlet

Cache and replay passwords only with sober consideration

Don't use uPortal's password caching and replay features unless you really want these behaviors! Don't expose end user passwords to portlets you don't trust. (Then again, don't install into your portal portlets you don't trust.)

The user attribute "password" is populated with the end user's cached password when a caching security context is used and off-by-default support for conveying those cached passwords via the JSR-168 user attribute API is turned on.

Enabling conveyance of passwords as user attributes

Configuring uPortal to cache the password at login

This is accomplished in security.properties. Rather than documenting how to do this here, this topic should be treated in the prior manual section on caching security contexts.

Configuring uPortal's portlet container to convey the password

In portletContainerContext.xml, enhance the existing declaration:

userInfoService declaration in portletContainerContext.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:

userInfoService declaration modified to reference the cached password service in portletContainerContext.xml
<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:

introduce a cachedPasswordUserInfoService declaration in portletContainerContext.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>

Requires uPortal 3.0.1

CachedPasswordUserInfoService was not included in uPortal 3 until 3.0.1, so if you're working with a prior release, this declaration won't work until you merge in that source code or class file that it requires. Upgrading to a later version than 3.0.0 is recommended.

Consuming the attributes once available

Declaring password user attribute in portlet.xml
<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

Accessing a user attribute from JSR-168 Java implementation
Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);
String password = (String)userInfo.get("password");
  • No labels