定制应用程序登录以使用 JAAS 来执行身份断言

使用 Java™ 认证和授权服务 (JAAS) 登录框架,可创建用于执行登录至身份断言的 JAAS 登录配置。

开始之前

可允许应用程序或系统提供程序来执行带有信任验证的身份断言。为此,请使用 JAAS 登录框架,将在一个登录模块中完成信任验证,而在另一个模块中完成凭证创建。这两个定制登录模块允许您创建可用来执行登录到身份断言的 JAAS 登录配置。
需要两个定制登录模块:
用户实现的信任关联登录模块(信任验证)
用户实现的信任关联登录模块执行用户需要的任何信任验证。进行信任验证时,必须在登录模块处于共享状态时将信任验证状态与登录身份放入一个图中,以使凭证创建登录模块可以使用该信息。此图应存储在属性中:

com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.state
      (它包括如下项)

com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.trusted
      (如果可信,那么设为 true,如果不可信,那么设为 false

com.ibm.wsspi.security.common.auth.module.IdenityAssertionLoginModule.principal
       (包含身份的主体)

com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.certificates
       (包含身份的证书)

身份断言登录模块(凭证创建)
com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule 执行凭证创建。此模块依赖于处于登录上下文共享状态的信任状态信息。此登录模块受以下各项的 Java 2 安全性运行时许可权保护:
  • com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.initialize
  • com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.login
身份断言登录模块查找共享状态属性 com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.state 中的信任信息,该属性包含信任状态和要登录的身份,并且应包括:

com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.trusted
       (为 true 时指示可信,为 false 时指示不可信)

com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.principal
       (包含要登录的身份的主体,如果使用主体的话)

com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.certificates
       (包含一组证书链,而该证书链包含要登录的身份,如果使用证书的话)

如果缺少状态、信任或标识信息,那么会返回 WSLoginFailedException。然后,登录模块执行身份登录,并且该主体集将包含新身份

过程

  1. 将信任验证委托给用户实现的插入点。 信任验证必须在定制登录模块中完成。此定制登录模块应执行必需的任何信任验证,然后在共享状态下设置要传递到身份断言登录模块的信任信息和身份信息。共享状态键 com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.state 中需要一个图。如果缺少状态,那么 IdentityAssertionLoginModule 会抛出 WSLoginFailedException。此图必须包括:
    • 信任键 com.ibm.wsspi.secuirty.common.auth.module.IdentityAssertionLoginModule.trust。如果键设为 true,那么会建立信任。如果键设为 false 则不会建立信任。如果信任键未设为 true,那么 IdentityAssertionLoginModule 将抛出 WSLoginFailedException。
    • • 设置身份键:可在 com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.principal 键中设置 java.security.Principal。
    • 或者,可在 com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.certficates 键中设置 java.security.cert.X509Certificate[]。
    如果同时提供了主体和证书,那么会使用主体并发出警告。
  2. 为应用程序登录创建新的 JAAS 配置 JAAS 配置将包含用户实现的信任验证定制模块和 IdentityAssertionLoginModule。接下来,为了配置应用程序登录配置,请在管理控制台上执行以下操作:
    1. 展开安全性 > 全局安全性
    2. 展开 Java 认证和授权服务 > 应用程序登录
    3. 选择新建
    4. 对 JAAS 配置指定别名。
    5. 单击应用
    6. 选择 JAAS 登录模块
    7. 选择新建
    8. 输入用户实现的信任验证定制登录模块的模块类名
    9. 单击应用
    10. 输入 com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule 的模块类名
    11. 确保模块类名类的顺序正确。在列表中,用户实现的信任验证登录模块应该是第一个类,而 IdentityAssertionLoginModule 应该是第二个类。
    12. 单击保存
    应用程序将使用此 JAAS 配置来执行身份断言。
  3. 执行可编程身份断言。 现在,程序可以使用 JAAS 登录配置来执行程序化身份断言。应用程序可对第 2 步中创建的 JAAS 配置创建登录上下文,然后使用它们将声明的身份登录至该登录上下文。如果登录成功,就会在当前运行进程中设置该身份。以下是这类代码如何操作的示例:
    MyCallbackHandler handler = new MyCallbackHandler(new MyPrincipal(“Joe”));
    LoginContext lc = new LoginContext(“MyAppLoginConfig”, handler);
    lc.login();  //assume successful
    Subject s = lc.getSubject();
    WSSubject.setRunAsSubject(s);
    // From here on , the runas identity is “Joe”

结果

通过使用 JAAS 登录框架和两个用户实现的登录模块,可创建用于执行登录至身份断言的 JAAS 登录配置。

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



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