AquaLogic BPM 安全认证

摘要

AquaLogic BPM可以运行在主流的J2EE的应用平台(WebLogic, websphere,jboss等),在企业的应用环境中通常我们会基于J2EE平台,开发各种企业应用系统,基于ALBPM开发企业的业务流程管理系统。很多情况下我们需要实现这些应用之间的SSO(单点登录)。

在本文中,我将讲述AquaLogic BPM的安全认证,如何绑定J2EE容器的安全认证,并传递到AquaLogic BPM WorkSpace,如果我们的应用统一的基于J2EE容器的全局安全性,那么这些应用之间就可以方便的实现SSO。

ALBPM的BPM Server 引擎与ALBPM WorkSpace是完全分离的架构,ALBPM WorkSpace为一个标准的J2EE EAR或WAR包应用程序,WorkSpace可以发布到各种J2EE服务器。在上图中BPM Server使用ALBPM Directory(可以为数据库或LDAP)来存储用户的身份信息及用户的策略信息等。

在下面的例子中,我们将WorkSpace 发布到Tomcat或WebLogic或Websphere服务器。之后我们配置这些服务器启动全局安全性,来统一的负责应用程序的用户身份认证,J2EE服务器通过JNDI Realm来设置认证的数据源(可以为数据库或LDAP)。之后认证信息传递到ALBPM WorkSpace,并可以同步外部认证数据源数据到ALBPM Server使用的ALBPM Directory,这样的复制可以方便之后我们在ALBPM Directory中设置用户的策略信息。

设置J2EE服务器信任的用户数据源

以Tomcat为样例:

通过配置JNDI-Realm

在Server.xml 文件中,对JNDIRealm设置如下:

  <Engine  name="Standalone" defaultHost="localhost"  debug="0">

  …

  <Realm  className="org.apache.catalina.realm.JNDIRealm" debug="99"

  connectionURL="ldap://192.168.1.140/DC=scc,DC=labs,DC=fuegotech,

DC=com"

  connectionName="Administrator@scc.labs.fuegotech.com"

  connectionPassword="password"

  referrals="follow"

  userBase=""

  userSearch="(sAMAccountName={0})"

  userRoleName="memberOf"

  userSubtree="true"

  roleBase=""

  roleName="cn"

  roleSearch="(memberOf={0})"

  roleSubtree="true"

  />

  …

  </Engine>

JNDIRealm支持LDAP及数据库。上面的样例中使用的LDAP是Microsoft 的活动目录,对于其他的目录服务器,我们可以通过了解LDAP的Schema来做相关的设置,比如:对于Sun One Ldap,参考设置如下:

<Realm className="org.apache.catalina.realm.JNDIRealm" debug="99" connectionURL="ldap://localhost:389" connectionName="uid=liuxuzhong,ou=people,dc=liuxuzhong,dc=com" connectionPassword="password" userPattern="uid={0},ou=groups,dc=liuxuzhong,dc=com" roleBase="ou=groups,dc=liuxuzhong,dc=com" roleName="cn" roleSearch="(uniqueMember={0})" />

其中重要的设置为userPattern,roleBase,roleSearch。通过Ldapsearch工具我们就可以查看应该如何成功设置userPattern,roleBase,roleSearch。在Ldapsearch显示的界面中,我们就可以看到为什么roleSearch设置成 uniqueMember

测试:启动Tomcat,在log日志中我们就可以看到Tomcat与ldap的连接信息:

 2007-10-30 23:29:32  JNDIRealm[Catalina]: Closing directory context

    2007-10-30 23:30:44  JNDIRealm[Catalina]: Connecting to URL ldap:

//localhost:389

    2007-10-30 23:31:08  JNDIRealm[Catalina]: lookupUser(liuxuzhong)

    2007-10-30 23:31:08  JNDIRealm[Catalina]: dn=uid=liuxuzhong,

ou=groups,dc=liuxuzhong,dc=com

    2007-10-30 23:31:08  JNDIRealm[Catalina]: validating credentials

 by binding as the user

    2007-10-30 23:31:08  JNDIRealm[Catalina]: binding as

uid=liuxuzhong,ou=groups,dc=liuxuzhong,dc=com

    2007-10-30 23:31:08  JNDIRealm[Catalina]: Username liuxuzhong

successfully authenticated

    2007-10-30  23:31:08 JNDIRealm[Catalina]: getRoles(uid=liuxuzhong,

ou=people,dc=liuxuzhong,dc=com)

    2007-10-30  23:31:08 JNDIRealm[Catalina]: Searching  role base

 'ou=groups,dc=liuxuzhong,dc=com' for attribute 'cn'

    2007-10-30  23:31:08 JNDIRealm[Catalina]: With  filter expression

'(uniqueMember=uid=liuxuzhong,ou=people,dc=liuxuzhong,dc=com)'

    2007-10-30 23:31:08  JNDIRealm[Catalina]: retrieving values

for attribute cn

    2007-10-30 23:31:08  JNDIRealm[Catalina]: Returning 1 roles

    2007-10-30 23:31:08  JNDIRealm[Catalina]: Found role fuegos
                      

以Websphere为样例:

进入websphere控制台,启用全局安全性,配置相关的LDAP设置:

设置LDAP:

将应用服务器的安全认证关联到AquaLogic BPM的认证容器设置

本章讲述了如何集成AquaLogic BPM Enterprise Work Portal的认证到应用服务器连接到后台LDAP平台的JNDI认证。

我们需要编辑Work Portal的web.xml文件,文件位于($FUEGO_ENT/webapps/portal/WEB-INF/web.xml)。在web.xml文件中添加如下的tag标签。

对于以上的XML我们添加的TAG的解析:

· 我们使用了Form的方式进行认证。我们将可以自定义一个认证的表单样式来实现认证。在LDAP中通过认证的用户将传递到BPM的目录服务。对于认证表单使用J_security方式。这里我们使用了BPM自带的/jsp/loginContainer.jsp。实际上我们可以执行编写任何符合J_security规范的表单。

· 我们需要在ldap服务器中定义一个角色,然后在所有需要使用BPM平台的用户赋予相应的角色。

设置Work portal 使用容器认证:

设置ALBPM 的Directory Service 信任LDAP认证过的用户

在ALBPM Directory Service的数据库表“FUEGO_PARTTRUST”中,增加两条记录:

其中的SQLFDI51为我们在配置Directory Service的时候设置的数据库用户名。

测试

在ALBPM Workspace中使用LDAP里面的用户名登录,在这里我们在测试之前,需要手工的通过process administrator在BPM directory中增加需要登录的用户名。

当然我们也支持LDAP自动复制到BPM Directory的方式。

将之前的web.xml相应区域修成为以下的配置,同时增加userauthentication.properties文件。就实现了自动复制。

    #  User Replication Debug

    fuego.portal.containerAuthentication.userReplication.debug=true

    #  Fuego Directory Service Bindings to create new user.

    fuego.portal.containerAuthentication.userReplication.

dirServiceUser=root

    fuego.portal.containerAuthentication.userReplication.

dirServicePassword=password

    #  Fuego default roles to assign to new user.

These roles must exist in Fuego's  Directory

    Service.

    fuego.portal.containerAuthentication.userReplication.roles=R1;Run

    #  LDAP Bindings

    fuego.portal.containerAuthentication.userReplication.

additionalInfoFromLDAP=true
                      

某些情况下,我们不仅仅需要复制用户的ID,可以通过以下的参数配置实现:

    fuego.portal.containerAuthentication.userReplication.

userRetrievalDataClass=fuego.portal.

    servlet.deploy.UserPrincipalLoginUserJNDIRetrievalData

    fuego.portal.containerAuthentication.userReplication.

ldapConnectionFactory=com.sun.jndi.

    ldap.LdapCtxFactory

    fuego.portal.containerAuthentication.userReplication.

ldapURL=ldap://192.168.0.135:389/dc

    =victorysupport,dc=com

    fuego.portal.containerAuthentication.userReplication.

ldapConnectionUser=pvictory@victor

    ysupport.com

    fuego.portal.containerAuthentication.userReplication.

ldapConnectionPassword=pvictory

    fuego.portal.containerAuthentication.userReplication.

ldapAuthentication=simple

    fuego.portal.containerAuthentication.userReplication.

ldapReferrals=ignore

    #  LDAP Implementation User Attributes Names to retrieve

    fuego.portal.containerAuthentication.userReplication.

userIdentifierAttribute=sAMAccount

    Name

    fuego.portal.containerAuthentication.userReplication.

firstNameIdentifierAttribute=givenNa

    me

    fuego.portal.containerAuthentication.userReplication.

lastNameIdentifierAttribute=sn

    fuego.portal.containerAuthentication.userReplication.

emailIdentifierAttribute=userPrincipalName