? ? 在Portal开发中,遇到需要获得用户、用户组信息时,就需要调用PUMA SPI(Portal User Management Architecture System programming interface)了。
详细解决方案
在WebSphere Portal中调用PUMA SPI治理用户、组
热度:406 发布时间:2012-06-30 17:20:12.0
? ? PUMA SPI提供获得当前及系统任何用户、组profile的方法,并可对用户和组进行增、删、改。
? ? PUMA SPI主要包括三个接口
? ? PumaProfile:可以获得当前或其他用户、组的属性值(profile)
? ? PumaLocator:可以查询任何用户、组的信息
? ? PumaController:可以新增、修改、删除用户和组的信息
? ? PUMA SPI的调用
? ? PUMA SPI可以在各种Portal应用中调用,不同类型的应用分别调用不同的home接口,包括
? ? 标准(JSR168)portlet
? ??com.ibm.portal.um.portletservice.PumaHome
? ? IBM portlet
? ??com.ibm.portal.um.portletservice.legacy.PumaHome?
? ? Portal应用(主要是theme和skin)
? ??com.ibm.portal.um.PumaHome?
? ? 以JSR 168 Portlet中调用为例,调用代码段如下所示,忽略异常处理,有异常就直接向上抛好了,反正这里也处理不了:
? ? PumaHome service;
? ? if ( service == null )
? ? {
????? ? InitialContext ctx = new InitialContext(); // 初始化上下文
????? ? PortletServceHome psh = ctx.lookup("portletservice/com.ibm.portal.um.portletservice.PumaHome"); // 获得Home接口
????? ??service = (PumaHome)psh.getPortletService(PumaHome.class);//获得服务接口?
????}
? ??PumaLocator locator = service.getLocator(request);//获得PumaLocator 接口?
? ??PumaProfile profile = service.getProfile(request);//获得PumaProfile接口?
? ??User user = profile.getCurrentUser();//获得当前用户?
? ??List groups = locator.findGroupsByPrincipal(user,true);//获得用户所处组?
? ??List userGroupNames = new ArrayList();//用于保存用户所处组的名称?
? ??List attr = new ArrayList();?
????attr.add("cn");//用于从Group对象中获得cn属性
? ? Group group = null;
? ? for ( Iterator it = groups.iterator(); it.hasNext() )
????{
? ? ? ? group = (Group) it.next();
????? ? userGroupNames.add(profile.getAttributes(group, attr).get("cn")); // 将Group对象列表中的组名置入一个新的List对象中
????}
? ? JavaDoc文档位于PortalServer安装路径的doc目录下.
? ??如/opt/IBM/WebSphere/PortalServer/doc/Javadoc/spi_docs
? ??如果使用RAD开发,IDE可以自动添加依赖的Portal包;如果不使用RAD,则开发时需要手工添加需要依赖的jar包到classpath以便进行编译,打包时则不要把这些jar包添加到war包中。相关jar包可以在/opt/IBM/WebSphere/PortalServer/shared/app目录中找到。在JSR 168的Portlet的开发环境中,需要依赖的包有wp.user.api.jar,wp.pe.api.standard.jar,wp.base.jar?
????
? ??哎,程序员容易吗?别人Happy的时候,我们还在TMD研究这些破技术。。。累了,上网看美女去。。。555
相关解决方案
- ibm websphere portal server如何安装
- websphere 对话超时消息中存在部分无关的文本?
- 新手:怎样进入ASP.NET Portal Starter Kit的管理页进行管理
- SharePoint Portal Server 2003 创建门户网站,失败了,这是日志,帮小弟我看看,这是什么原因
- websphere 6.1.0.0 Struts2 JSON传值的有关问题
- websphere 没法启动
- 求WebSphere portal 6 for AIX的上载地址
- WEBSPHERE 上加密有关问题请问
- websphere 集群解决方案
- websphere 中文乱码解决思路
- websphere mq for aix
- websphere application server控制台下如何如何更新程序?
- websphere portal 开发应用程序解决办法
- Liferay portal 安装配置tomcat的有关问题
- websphere 服务端wsdl资料的url
- websphere 6.1 没法将日志写入到日志文件
- websphere shtml有关问题
- :web server plugin for Websphere 7.0 安装错了,没有卸载,直接把安装目录删除了,怎么反此插件的其它信息删干净
- 跪求 IBM WebSphere 8.5!解决思路
- websphere 请问导出最新部署包
- websphere 数据源有关问题
- WebSphere MQ 安装,该怎么解决
- websphere 一个关于struts的bug 摆弄了几天了.解决方法
- ibm websphere enterperise develovper有关问题
- websphere 安装程序到底有多少种?解决方案
- WebSphere Integration Developer V6.0.2 能在win2003下运行么?解决方案
- WEBSPHERE HTTPSERVER SSL 高手指教解决方法
- websphere 7.0 访问403异常
- websphere 连接池的有关问题
- websphere 基本有关问题