最近在搞Cognos和Websphere的SSO,被折磨了多天,经过持续的努力,终于配置成功了,记录下来,算给自己一个念想,留个心路历程。
网上搜到些文档,都是介绍Cognos和Websphere portal的SSO集成,我的应用没那么复杂,所以不能完全按照网上的文档来配置,只有前半部分部署Servlet Gateway可以借鉴,当你没有了参考,而又不知道应该怎么做时,是最痛苦的。就像在一间黑暗的房间里找到出去的门,不知道方向,但是如果经验越丰富,越是高手,可能打开门的时间会越短,希望自己朝着这个方向迈进。
Cognos用户可以和LDAP集成,使用LDAP中的用户登录
Cognos可以匿名登录,这个可以方便开发,省去繁琐的登录,当然设计具有权限的报表除外。同时,提供多种方式的用户集成。比较常用的NTLM(windows系统),LDAP等方式。Cognos支持多种LDAP服务器,笔者使用AD和Tivoli DS都进行测试过。本例中以TDS为例进行介绍。具体配置TDS的过程本文略去,当TDS安装配置好后,需要在Cognos Configuration中进行相应设置。
在Cognos Configuration中的Security->Authentiaction中,点右键New Recource,即添加一个Namespace,输入一个名称,比如输入LDAP,然后类型列表中选择LDAP。
然后修改属性值,参考下表:
Host and port |
<LDAP server host>:<LDAP port> |
Base Distinguished Name |
Distinguished name For example: o=sample |
User lookup |
(cn=${userID}) |
Use external identity |
TRUE |
External identity mapping |
(cn=${environment(“REMOTE_USER”)}) |
Bind user DN and password |
specify cn=root |
Size limit |
20 |
Time out in seconds |
300 |
Use bind credentials for search |
FALSE |
Allow empty password |
FALSE |
Unique identifier |
dn |
Data encoding |
UTF-8 |
SSL certificate database |
|
Advanced properties |
|
Object class |
organizationalunit,organization,container |
Description |
description |
Name |
ou,o,cn |
Object class |
groupnames |
Description |
description |
Member |
member |
Name |
cn |
Account object class |
inetorgperson |
Business phone |
telephonenumber |
Content locale |
(Leave empty) |
Description |
description |
Email |
mail |
Fax/Phone |
facsimiletelephonenumber |
Given name |
givenname |
Home phone |
homephone |
Mobile phone |
mobile |
Name |
cn |
Pager phone |
pager |
Password |
userPassword |
Postal address |
postaladdress |
Product locale |
(Leave empty) |
Surname |
sn |
Username |
cn |
其中Use external identity和 External identity mapping一定要配置正确。
设置完成之后,可以点右键进行test,看看LDAP是否可以连接成功。
这些具体的每个属性的配置信息可以在IBM的Infocenter上查到,上面的文档很全,每种LDAP的服务器对应的配置都有介绍。
转到“Allow anonymous access”设置为False,即禁止匿名登录。
转到"Allow Namespace Override"设置为True
在部署 Websphere中 Cognos Servlet Gateway
首先找到Cognos的安装目录,在Install/war/gateway目录下,修改web.xml文件,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed Materials - Property of IBM
IBM Cognos Products: gate
(C) Copyright IBM Corp. 2005 2010
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
<!-- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved. -->
<!-- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated). -->
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>IBM Cognos Servlet Gateway</display-name>
<description>The IBM Cognos Servlet Gateway</description>
<servlet>
<servlet-name>ServletGateway</servlet-name>
<!-- CUSTOM CLASSLOADER RELATED CONFIGURATION. DO NOT CHANGE -->
<servlet-class>com.cognos.pogo.isolation.ServletWrapper</servlet-class>
<init-param>
<param-name>servlet-class</param-name>
<param-value>com.cognos.servletgateway.Gateway</param-value>
</init-param>
<init-param>
<param-name>classLoaderName</param-name>
<param-value>SGVeryOwnClassLoader</param-value>
</init-param>
<!-- END OF CUSTOM CLASSLOADER RELATED CONFIGURATION -->
<init-param>
<!-- Should the gateway encrypt passwords? -->
<param-name>encryptPassword</param-name>
<!-- "true" or "false" -->
<param-value>true</param-value>
</init-param>
<init-param>
<!-- The maximum number of connections
in the pool -->
<param-name>maxPoolSize</param-name>
<!-- A non-zero positive integer -->
<param-value>20</param-value>
</init-param>
<init-param>
<!-- The number of seconds between pings to dispatcher -->
<param-name>pingPeriod</param-name>
<!-- A non-zero positive integer -->
<param-value>180</param-value>
</init-param>
<init-param>
<!-- The number of seconds between checking the startup file for changed dis-patchers -->
<param-name>fileCheckPeriod</param-name>
<!-- A non-zero positive integer -->
<param-value>30</param-value>
</init-param>
<init-param>
<!-- Tell CAF that this is the gateway -->
<param-name>cafintegration</param-name>
<param-value>gateway</param-value>
</init-param>
<init-param>
<!-- Should the Gateway URL decode incoming cookies?
Use 'true' if you're running iPlanet or Sun ONE webserver
and 'false' otherwise -->
<param-name>urldecodeCookies</param-name>
<!-- "true" or "false" -->
<param-value>false</param-value>
</init-param>
<init-param>
<!-- Should the status page be available via "/status" PATH_INFO? -->
<param-name>enableStatusPage</param-name>
<!-- "true" or "false" -->
<param-value>false</param-value>
</init-param>
<!-- Override the dispatcher URL for debugging purposes
<init-param>
<param-name>dispatcherURLOverride</param-name>
<param-value>http://localhost:9300/p2pd/servlet/dispatch</param-value>
</init-param>
-->
<load-on-startup>1</load-on-startup>
<security-role-ref>
<description></description>
<role-name>security</role-name>
<role-link>security</role-link>
</security-role-ref>
</servlet>
<servlet-mapping>
<servlet-name>ServletGateway</servlet-name>
<url-pattern>/servlet/Gateway/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletGateway</servlet-name>
<url-pattern>/servlet/Gateway</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<security-constraint>
<display-name>security</display-name>
<web-resource-collection>
<web-resource-name>security</web-resource-name>
<description></description>
<url-pattern>/servlet/Gateway/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>security</description>
<role-name>security</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>security</role-name>
</security-role>
</web-app>
其中红色的部分为新添加的。
然后使用Cognos Configuration来build应用,生成ear包


通过以上步骤就生成了ServletGateway.ear包,然后把它部署到Websphere中。
登录到WebSphere Admin console,进入Applications -> Install new Application
安装ServletGateway.ear包。
安装完成后修改security config,如图所示:

把Special subjects 设置为 “All Authenticated in Applications Realm”

转到Security > Global security 页面
确认“Enable application security”要被选中

在WebSphere中创建一个library path
转到Application Servers页面,打开部署ServletGateway的server,
进入Process Definition->Enviornment Entries


新创建一个Entry

Name输入PATH,Value输入<COGNOS_ROOT>/bin
然后重新启动WebSphere的服务。
打开Cognos Configuration, 进入Local Configuration > Environment, 把"Gateway URI"这一属性修改为 http://<server>:<port>/ServletGateway/servlet/Gateway
注意:<server>要使用如下格式 <hostname>.<domain>
保存所作的修改,重新启动Cognos服务。
现在可以测试一下Servlet Gateway
http://<server>:<port>/ServletGateway/servlet/Gateway
如果你的应用和Cognos Servlet Gateway都部署在同一个Websphere的profile中,那么SSO的配置就到此完成了。你可以试验一下SSO是否可以工作。
如果你的应用和Cognos Servlet Gateway部署在不同Websphere中,那么还需要进行如下配置。
也就是说需要两个Websphere之间的通信能SSO,目前主要有两种技术,一个是Shared secret,另一个是LTPA Token。下面讲解一下如何使用LTPA Token方式。
其实配置起来并不复杂,主要的步骤就是从一个Websphere中导出LTPA key,这个key实际上一个文件,然后把这个文件再导入到另一个Websphere,这样两个Websphere共用相同的LTPA key,就可以SSO了,就像把两个Websphere连接了起来,省去了logon.
这里要注意的是导入和导出的Websphere的Realm name必须一致,如下图所示:

好了,到此所有的配置都完成了。