uPortal4-UserInfoService扩展点

uPortal UserInfoServices通过UserInfo的map集合向portlets提供用户的属性信息,uPortal绑定的服务提供了向portlets添加用户目录属性、CAS proxy tickets和缓存凭据的能力。采纳者希望提供更多信息的UserInfo map集合可以使用这个API增加更多的属性。

要创建一个新的UserInfoService,需要实现org.apache.pluto.container.UserInfoService。一个很好的例子UserInfoService可能是的CachedPasswordUserInfoService。

一旦你创建新的服务后,将它写入

uportal-impl/src/main/resources/properties/contexts/portletContainerContext.xml。您将需要创建一个新的服务bean定义,然后将其添加到要合并的“userInfoService”bean的服务列表。

如下:

<bean id="userInfoService" 
class="org.jasig.portal.portlet.container.services.MergingUserInfoService">
	<property name="userInfoServices">
		<list>
			<ref bean="personDirectoryUserInfoService"/>
			<ref bean="casTicketUserInfoService"/>
			<ref bean="myNewUserInfoService"/>
		</list>
	</property>
</bean>
 
<bean id="myNewUserInfoService" 
class="org.jasig.portal.portlet.container.services.MyNewUserInfoService">
	<property name="portletWindowRegistry" ref="portletWindowRegistry" />
	<property name="portletEntityRegistry" ref="portletEntityRegistry" />
	<property name="portletDefinitionRegistry" ref="portletDefinitionRegistry" />
	<property name="portalRequestUtils" ref="portalRequestUtils" />
	<!-- Additional Spring resources required by your service -->
</bean>

修改portlet.xml加入下面的配置:

<user-attribute>
	<description>Username attribute name for uPortal user</description>
	<name>username</name>
</user-attribute>
<user-attribute>
	<description>Password attribute name for uPortal user</description>
	<name>userPassword</name>
</user-attribute>

注意:此用户属性的name值要和personDirectoryContext.xml配置一致,<user-attribute>标记要和<portlet>标记同级,不可放在<portlet></portlet>标记内。

然后在portlet的jsp中可以通过下面代码获得属性:

<%@page import="javax.portlet.PortletRequest,java.util.*" %>

Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);

String name = (String)userInfo.get("username ");

String pass = (String)userInfo.get("userPassword");

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shibushi114

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值