简体   繁体   English

如何在WebSphere上为远程EJB调用启用Kerberos身份验证?

[英]How to enable Kerberos authentication for remote EJB call on WebSphere?

My application is a stand-alone Swing client invoking EJB Stateless Session beans thanks to classical JNDI lookup and RMI-IIOP method calls. 由于经典的JNDI查找和RMI-IIOP方法调用,我的应用程序是一个独立的Swing客户端调用EJB无状态会话bean。 It is started as a Java WebStart application. 它作为Java WebStart应用程序启动。 My aim is to retrieve the client user's identity from EJBContext with getCallerPrincipal method thanks to Kerberos SSO between the Windows workstation, ActiveDirectory and WebSphere server running on Linux. 我的目标是使用getCallerPrincipal方法从EJBContext检索客户端用户的身份,这要归功于Windows工作站,ActiveDirectory和Linux上运行的WebSphere服务器之间的Kerberos SSO。

I have already successfully configured my WebSphere cell in network deployment mode to support Kerberos authentication thanks to the infocenter documentation . 由于信息中心文档,我已经在网络部署模式下成功配置了我的WebSphere单元以支持Kerberos身份验证。

Both krb5.conf and krb5.keytab files are OK and tested with both Linux kinit , klist and wsadmin , $AdminTask validateKrbConfig answers true . krb5.confkrb5.keytab文件都可以使用Linux kinitklistwsadmin进行测试, $AdminTask validateKrbConfig回答为true

The client setup does only refer to a JAAS login.config file to enable with command system property. 客户端安装程序仅引用JAAS login.config文件以使用命令系统属性启用。 My intuition tells me it is probably not enough. 我的直觉告诉我这可能还不够。

But now, I find no more information to finalize the test case: 但现在,我找不到更多信息来完成测试用例:

  • how the JNDI initial context environment must be setup to trigger Kerberos negotiation ? 如何设置JNDI初始上下文环境以触发Kerberos协商?
  • if there are other requirements on server-side like protect my EJB with a role (JBoss does not require it for instance) ? 如果服务器端有其他要求,比如用角色保护我的EJB(例如JBoss不需要它)?

Update 更新

As not running JavaEE client container with ./launchClient , I have set in my JNLP the required properties to read sas.client.props and JAAS login configuration: 由于没有使用./launchClient运行JavaEE客户端容器,我在JNLP中设置了读取sas.client.props和JAAS登录配置所需的属性:

<property name="java.security.auth.login.config" value="C:\temp\wsjaas_client.config"/>
<property name="com.ibm.CORBA.ConfigURL" value="C:\temp\sas.client.props"/>

My wsjaas_client.config is for Oracle Java so it contains: 我的wsjaas_client.config适用于Oracle Java,因此它包含:

WSKRB5Login{
    com.sun.security.auth.module.Krb5LoginModule required
       debug=true useTicketCache=true doNotPrompt=true;
};

My sas.client.props contains: 我的sas.client.props包含:

com.ibm.CORBA.securityEnabled=true
com.ibm.CORBA.authenticationTarget=KRB5
com.ibm.CORBA.loginSource=krb5Ccache
com.ibm.CORBA.loginUserid=
com.ibm.CORBA.loginPassword=
com.ibm.CORBA.krb5CcacheFile=
com.ibm.CORBA.krb5ConfigFile=C:\\temp\\krb5.conf

At the moment, no Kerberos authentication is triggered: there is no TGS for the SPN WAS/myserver.mydomain.com in my kerberos cache (either from Windows or Linux workstations) and JNDI connection is still established anonymously. 目前,没有触发Kerberos身份验证:我的kerberos缓存(来自Windows或Linux工作站)中的SPN WAS/myserver.mydomain.com没有TGS,并且仍然匿名建立JNDI连接。

No error message, no warning and finally no principal. 没有错误消息,没有警告,最后没有委托人。 How do I diagnose what's wrong or lacking? 我如何诊断错误或缺乏?

Update 2012/06/20 更新2012/06/20

Here are some steps forward. 这是向前迈出的一步。 In my application JNLP running with Oracle Java, I have set the following properties to use IBM ORB and enable full trace and debug information: 在我的应用程序JNLP中运行Oracle Java,我已设置以下属性以使用IBM ORB并启用完整的跟踪和调试信息:

<property name="org.omg.CORBA.ORBSingletonClass" value="com.ibm.rmi.corba.ORBSingleton"/>
<property name="org.omg.CORBA.ORBClass" value="com.ibm.CORBA.iiop.ORB"/>
<property name="traceSettingsFile" value="C:\temp\TraceSettings.properties"/>

The file TraceSettings.properties contains TraceSettings.properties文件包含

traceFileName=c:\\temp\\traces.log
ORBRas=all=enabled
SASRas=all=enabled
com.ibm.*=all=enabled

Even after reading large parts of WebSphere 7 Security IBM RedBook I still fail to get CSIv2 trigger Kerberos authentication from client-side. 即使在阅读了大量IBM 7安全性IBM RedBook之后,我仍然无法从客户端获得CSIv2触发Kerberos身份验证。

According to the GSS-API/Kerberos v5 Authentication guide you must authenticate to Kerberos before making your call to the JNDI context. 根据GSS-API / Kerberos v5身份验证指南,您必须在调用JNDI上下文之前对Kerberos进行身份验证。 Once you have performed the Kerberos configuration you configure the intial context as follows: 执行Kerberos配置后,您可以按如下方式配置初始上下文:

  • When creating the initial context, set the Context.SECURITY_AUTHENTICATION(in the API reference documentation) environment property to the string "GSSAPI". 创建初始上下文时,将Context.SECURITY_AUTHENTICATION(在API参考文档中)环境属性设置为字符串“GSSAPI”。

I have dealt with getting a Java Client to use Kerberos in the past (although not with JNDI). 我曾经处理过让Java客户端使用Kerberos(尽管没有使用JNDI)。 Here is my approach to remove the need for JVM options and local configuration files on the client side (invoke this code before the client attempts to authenticate): 这是我在客户端删除对JVM选项和本地配置文件的需求的方法(在客户端尝试进行身份验证之前调用此代码):

public static void initKerberosConfig() 
{                 
        System.setProperty("javax.security.auth.useSubjectCredsOnly", "false"); 
        System.setProperty("java.security.krb5.kdc", "host.name:88"); 
        System.setProperty("java.security.krb5.realm", "REALM"); 
        System.setProperty("sun.security.krb5.debug", "false");                                 
        Configuration progConfig = getProgramaticLoginConfig(); 
        Configuration.setConfiguration(progConfig); 
} 

private static Configuration getProgramaticLoginConfig() 
{ 
        HashMap<String, String> options = new HashMap<String, String>(); 
        options.put("useTicketCache", "true"); 
        options.put("doNotPrompt", "true");                                                 
        AppConfigurationEntry krb5LoginModule = new AppConfigurationEntry("com.sun.security.auth.module.Krb5LoginModule", LoginModuleControlFlag.REQUIRED, options); 
        final AppConfigurationEntry[] aces = new AppConfigurationEntry[]{krb5LoginModule}; 
        Configuration progConfig = new Configuration() 
        { 
                @Override 
                public AppConfigurationEntry[] getAppConfigurationEntry(String arg0) 
                {                                 
                        return aces; 
                } 

        }; 
        return progConfig; 
} 

You will probably need to tweak this for your context ( java.security.krb5.kdc and java.security.krb5.realm will not be correct) - but I hope it helps. 您可能需要针对您的上下文调整此值( java.security.krb5.kdcjava.security.krb5.realm将不正确) - 但我希望它有所帮助。 Turn sun.security.krb5.debug true for voluminous quantities of logging. 对于大量的日志记录, sun.security.krb5.debug true

Since you didn't specifically mentioned in steps you followed, have you configured your sas.client.props as in the client setup link you have provided? 由于您没有在后面的步骤中特别提及,您是否已按照您提供的客户端设置链接配置了sas.client.props?

You may check RedBook Implementing Kerberos in a WebSphere Application Server Environment for examples on how to make this configuration, as well as remaining configuration for Application Client. 您可以在WebSphere Application Server环境中检查RedBook 实现Kerberos,以获取有关如何进行此配置的示例,以及Application Client的其余配置。

Section 13.5 (13.5 Configuring the Java EE application client) gives examples for setting up your thick client runtime, including sas.client.props file. 第13.5节(13.5配置Java EE应用程序客户机)提供了设置胖客户机运行时的示例,包括sas.client.props文件。

To sum up the context: our deployment is in production since years with IBM WebSphere running on Linux and application deployed thanks to Java WebStart running on Sun JavaSE 6 with IBM ORB included and configured to connect without any authentication. 总结上下文:我们的部署已经投入生产多年,IBM在WebSphere上运行并部署了应用程序,这要归功于在Java Java 6上运行的Java WebStart,其中包含IBM ORB并配置为无需任何身份验证即可进行连接。 Now we want to enable Kerberos authentication and single-sign-on over RMI-IIOP, supported since WebSphere 6 (I think). 现在,我们希望在WebSphere 6(我认为)以来支持RMI-IIOP上启用Kerberos身份验证和单点登录。

Here are now pieces of answer. 现在这里有一些答案。

Since WebSphere 7, a new concept has been introduced to configure security aspects on a per server basis: security domain . 从WebSphere 7开始,引入了一个新概念来基于每个服务器配置安全性方面: 安全域 Theoretically any option that has not been changed in a security domain inherits from the global security section. 从理论上讲,安全域中未更改的任何选项都继承自全局安全性部分。

When testing Kerberos setup, we have created a dedicated security domain for our test server, to avoid troubles with other servers running in the cell. 在测试Kerberos设置时,我们为测试服务器创建了一个专用安全域,以避免在单元中运行的其他服务器出现问题。

BUT even if Kerberos is enabled in global security , it is not inherited/enabled for a server configured with its own security domain . 即使在全局安全性中启用了Kerberos,也不会为配置了自己的安全域的服务器继承/启用它。

As soon as we run our test server with the default global security where Kerberos options are visible and enabled, then Kerberos authentication has began to work with IBM JavaSE 6 executed from a cmd bat script with usual ClassPath and all properties declared in documentation. 一旦我们使用默认的全局安全性运行我们的测试服务器,其中Kerberos选项可见并启用,那么Kerberos身份验证已开始与使用通常ClassPath的cmd bat脚本执行的IBM JavaSE 6以及文档中声明的所有属性一起使用。

To note: the JNDI Context.SECURITY_AUTHENTICATION option is never set. 注意:永远不会设置JNDI Context.SECURITY_AUTHENTICATION选项。 After decompilation, the only available values for IBM ORB are none , simple and strong but strong has no implementation yet. 在反编译之后,IBM ORB的唯一可用值是nonesimplestrongstrong尚未实现。

Another point: according to generated log, IBM ORB is not able to work with file:/C:/temp/sas.client.config as value for com.ibm.CORBA.ConfigURL . 另一点:根据生成的日志,IBM ORB无法使用file:/C:/temp/sas.client.config作为com.ibm.CORBA.ConfigURL值。 It MUST be an URI and not a file path. 必须是URI而不是文件路径。 We even got DNS lookup failure to resolve C hostname ! 我们甚至无法解析C主机名的DNS查找! Arff. ARFF。 All documentation examples are Unix based with file:/path/to/sas.client.config so we made many trials before delivering that file from an HTTP server. 所有文档示例都是基于Unix的file:/path/to/sas.client.config因此我们在从HTTP服务器传递该文件之前进行了许多试验。

Now the Java WebStart part of the deployment: 现在部署的Java WebStart部分

  • the same original JNLP without any security and no Kerberos settings works perfectly with both Oracle JavaSE 6 and IBM Java 6 没有任何安全性且没有Kerberos设置的原始JNLP与Oracle JavaSE 6和IBM Java 6完美配合

  • with WebSphere security enabled and Kerberos in JNLP (and only that change set), IBM ORB running on IBM Java 6 complains with NoClassDefFoundError about ffdc log manager implementation that is (still/always) available in ClassPath. 在启用了WebSphere安全性和JNLP中的Kerberos(以及只有该更改集)的情况下,在IBM Java 6上运行的IBM ORB向NoClassDefFoundError抱怨在ClassPath中(仍然/始终)可用的ffdc日志管理器实现。 It really sounds like a code incompatibility with Java WebStart secured ClassLoader hierarchy. 这听起来像是与Java WebStart安全的ClassLoader层次结构不兼容的代码。

  • with Kerberos JNLP, IBM ORB running on Oracle JavaSE 6 seems to simply ignore security settings and connects anonymously as usual. 使用Kerberos JNLP,在Oracle JavaSE 6上运行的IBM ORB似乎只是忽略安全设置并像往常一样匿名连接。

So a first step is now working: IBM Java 6 started from command-line but investigations are not over to reach our goal: Kerberos with Oracle JavaSE 6 in Java WebStart context. 因此,第一步现在正在发挥作用:IBM Java 6从命令行开始,但尚未完成调查以实现我们的目标:在Java WebStart上下文中使用Oracle JavaSE 6的Kerberos。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM