认证用户以连接至消息传递引擎

必须验证用户凭证以便用户获认证来连接至消息传递引擎。

过程

  1. 配置用户注册表。
    在 Liberty 中,支持下列类型的注册表:
    • QuickStartSecurity(仅支持一个用户)。

      此选项是指定用户名和密码来认证应用程序连接的最简单方法。可以使用 <quickStartSecurity> 元素来对 Liberty 启用简单(单用户)安全性设置。在 server.xml 文件中定义以下 <quickStartSecurity> 元素。

      在以下示例中,使用 <quickStartSecurity> 元素来定义单个用户,用户名为 liberty 且密码为 liberty123
      <quickStartSecurity userName="liberty" userPassword="liberty123"/>
      注: 确保没有在 server.xml 文件中指定原始密码(例如,liberty123)。要对密码进行编码,请使用随 Liberty 提供的安全实用程序工具。
      <WLP_HOME>\wlp\bin>securityUtility encode "liberty123"

      有关保护密码的更多信息,请参阅 Liberty:securityUtility 命令

    • 基本用户注册表(支持多个用户以及声明用户组)。
      可以配置 Liberty 以使用基本用户注册表来认证和授权用户。可在 Liberty 服务器的 server.xml 文件中设置基本用户注册表以及配置多个角色映射。
      注: <basicRegistry> 的配置会覆盖 <quickStartSecurity> 注册表。
      <basicRegistry id="basic" realm="customRealm">
      			<user name="user1" password="user1pwd" />
      			<user name="user2" password="user2pwd" />
      	<user name="user3" password="user3pwd" />
      	<user name="user4" password="user4pwd" />
      	<user name="user5" password="user5pwd" />
      	<user name="user6" password="user6pwd" />
      	<user name="user7" password="user7pwd" />
      	<user name="user8" password="user8pwd" />
      	<group name="Developers">
      		<member name="user2" />
      		<member name="user4" />
      	</group>
      	<group name="Testers">
      		<member name="user8" />
      		<member name="user7" />
      	</group>
      </basicRegistry>
    • 轻量级目录访问协议 (LDAP) 注册表(外部注册表,例如 Microsoft Active Directory 和 IBM Directory Server)。
      可以使用 Liberty 来配置 LDAP 服务器以进行认证。
      <ldapRegistry id="LDAP" realm="SampleLdapIDSRealm" host="ctldap1.austin.ibm.com" port="389"
          ignoreCase="true" baseDN="o=ibm,c=us"
          ldapType="IBM Tivoli Directory Server"
          idsFilters="ibm_dir_server"
          searchTimeout="8m">
              <failoverServers name="failoverLdapServers">
              		<server host="ralwang.rtp.raleigh.ibm.com" port="389"/>
              	</failoverServers>
      </ldapRegistry>
      Notes:
      • 可以在连接工厂中指定 LDAP 注册表中所指定的任何用户名和密码。
      • server.xml 文件中只能定义一种注册表类型(基本注册表或 LDAP 注册表)。
    有关配置注册表的更多信息,请参阅在 Liberty 中配置用户注册表
  2. 配置应用程序认证。
    根据 server.xml 文件中所指定的用户注册表,您可以通过下列方式来配置应用程序:
    • 在 JMS 资源中指定用户名和密码(即,连接工厂和激活规范属性)。
      根据连接工厂中指定的用户名和密码来认证使用连接工厂的应用程序。
      <jmsQueueConnectionFactory jndiName="myQCF" connectionManagerRef="ConMgr4">
      		<properties.wasJms userName="liberty" password="liberty123"       
      				remoteServerAddress="localhost:7276:BootstrapBasicMessaging">
      	</properties>
      </jmsQueueConnectionFactory>
      <connectionManager id="ConMgr4" maxPoolSize="2"/>

      在先前的示例中,根据对所配置注册表定义的用户名 liberty 和密码 liberty123 来自动地认证查找 myQCF 队列连接工厂的应用程序。

      注: 指定连接属性在路径 jms/myQCF 而不是路径 java:comp/env/jms/myQCF 中查找 myQCF
    • 在 JMS 应用程序中指定用户名和密码。
      注: 在 JMS 应用程序中指定的用户名和密码会覆盖在连接工厂中定义的用户名和密码。
      应用程序会查找连接工厂属性,并传递用户名和密码以认证凭证。
      server.xml                                                                      
      --------------------
      <jmsQueueConnectionFactory jndiName="myQCF" connectionManagerRef="ConMgr4">
      	<properties.wasJms
      				remoteServerAddress="localhost:7276:BootstrapBasicMessaging">
      	</properties>
      </jmsQueueConnectionFactory>
      <connectionManager id="ConMgr4" maxPoolSize="2"/>
      
      Application snippets
      ------------------
      QueueConnectionFactory qcf = (QueueConnectionFactory) new InitialContext().lookup("myQCF");
      QueueConnection qCon = qcf.createQueueConnection(“liberty”, “liberty123”);
    • 在 <containerAuthDataRef> 元素中指定用户名和密码。
      如果绑定未使用 res-auth=CONTAINER 指定资源引用的认证别名,那么容器管理的认证的缺省认证数据适用。必须定义 <authData> 元素,且该元素必须由服务集成总线资源进行引用,如下所示:
      <authData id="auth1" user="liberty" password="liberty123"/>
      
      <jmsQueueConnectionFactory jndiName="myQCF"
      		containerAuthDataRef=”auth1” connectionManagerRef="ConMgr4">
            <properties.wasJms/>
      </jmsQueueConnectionFactory>
      <connectionManager id="ConMgr4" maxPoolSize="2"/>
      
       web.xml
       ----------
         <resource-ref>
          <res-ref-name>jndi/myQCF</res-ref-name>
          <res-auth>Container</res-auth>        <res-type>javax.jms.QueueConnectionFactory</res-type>
          <lookup-name>jndi/myQCF</lookup-name>
        </resource-ref>
    在配置之后,需要对已认证用户分配角色以便其安全地访问消息传递资源。请参阅 授权用户来连接至消息传递引擎

用于指示主题类型的图标 任务主题



时间戳记图标 最近一次更新时间: Tuesday, 6 December 2016
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twlp_msg_sec_authenticate
文件名:twlp_msg_sec_authenticate.html