Java 容器认证服务提供程序接口 (JASPIC)

Java™ Authentication Service Provider Interface for Containers (JASPIC) 规范定义服务提供者接口 (SPI)。 可将实现消息认证机制的认证提供程序集成到客户机或服务器消息处理容器或运行时中。

关于此任务

通过 JASPIC 接口集成的认证提供程序对其调用容器提供的网络消息执行操作。 提供程序变换外发消息,以便消息源可以由接收容器进行认证,而消息的接收方可以由消息发送方进行认证。 入局消息将进行认证并返回到其调用容器,这是由于消息认证而建立的身份。

JSR 196 定义了标准 SPI ,并将认证模块集成到 Java EE 容器中的方式标准化。 提供了客户机和服务器上多个交互点的消息处理模型和详细信息。 兼容的 Web 容器在这些点使用 SPI 将相应的消息安全处理委派给服务器认证模块 (SAM)。

Liberty 支持使用符合 jaspic-1.1中指定的 servlet 容器的第三方认证提供程序。 servlet 容器定义安全运行时环境与 Web 容器协作使用的接口。 这些在应用程序处理 Web 请求之前和之后启动认证模块。 仅当在安全性配置中启用了 JASPIC 时,才会使用使用 JASPIC 模块的认证。

过程

  1. 创建 OSGi 捆绑软件项目 以开发 Java 类。
    您的项目可能有编译错误。 要修正这些错误,需要导入两个软件包 javax.security.auth.messagecom.ibm.wsspi.security.jaspi。 必须编辑目标平台以将缺少的 JAR 添加到 <cics_install>/wlp/lib 目录中的列表 com.ibm.ws.security.jaspic<cics_install>/wlp/dev/api/spec 目录中的 com.ibm.ws.javaee.jaspic.<version_number> 。 将这些文件通过 FTP 传输到开发系统,并将其添加到构建路径。

    编辑文件 MANIFEST.MF 以导入缺少的包。

    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: com.example.myjaspic.osgiBundle
    Bundle-SymbolicName: com.example.myjaspic.osgiBundle
    Bundle-Version: 1.0.0
    Bundle-RequiredExecutionEnvironment: JavaSE-1.7
    Import-Package: com.ibm.wsspi.security.jaspi;version="1.0.13",
    javax.security.auth.message;version="1.0.0",
    javax.security.auth.message.callback;version="1.0.0",
    javax.security.auth.message.config;version="1.0.0",
    javax.security.auth.message.module;version="1.0.0",
    javax.servlet;version="2.7.0",
    javax.servlet.http;version="2.7.0"
    Service-Component: myjaspicExampleComponent.xml

    服务组件 XML 的示例 myjaspicExampleComponent.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.example.myjaspic.osgiBundle">
        <implementation class="com.example.myjaspic.osgiBundle.TestJASPICProviderService"/>
        <service>
            <provide interface="com.ibm.wsspi.security.jaspi.ProviderService"/>
        </service>
    </scr:component>
  2. 在功能部件清单文件中的 Subsystem-Content 下,创建 Liberty 功能部件项目以将先前的 OSGi 捆绑软件添加到用户 Liberty 功能部件。
  3. 编辑功能部件清单以添加必需的 OSGi 子系统内容: com.ibm.websphere.appserver.jaspic-1.1; type="osgi.subsystem.feature"
    Subsystem-ManifestVersion: 1.0
    IBM-Feature-Version: 2
    IBM-ShortName: jaspic11CICSLiberty-1.0
    Subsystem-SymbolicName: com.example.myjaspic.libertyFeature;visibility:=public
    Subsystem-Version: 1.0.0.201611081617
    Subsystem-Type: osgi.subsystem.feature
    Subsystem-Content: com.example.myjaspic.osgiBundle;version="1.0.0",
      com.ibm.websphere.appserver.jaspic-1.1;type="osgi.subsystem.feature",
      com.ibm.websphere.appserver.servlet-3.0;ibm.tolerates:="3.1";type="osgi.subsystem.feature"
    Manifest-Version: 1.0

    如果需要再添加一个 Subsystem-Content ,那么必须在输入内容之前至少添加一个 space 。 如果不添加 space,那么 CICS® 将返回 java.lang.IllegalArgumentException

  4. 将 Liberty 功能部件项目导出为 Liberty 功能部件 (ESA) 文件。
  5. 通过 FTP 将 ESA 文件传输到 zFS。
  6. 使用 installUtility 来安装 ESA 文件。
    ./wlpenv installUtility install myFeature.esa
  7. jaspic-1.1 功能部件和包含 JASPIC 提供程序的 ESA 文件作为用户功能部件添加到 server.xml
    <feature>jaspic-1.1</feature>
    <feature>usr:jaspic11CICSLiberty-1.0</feature>