真的撕裂了我的头发就这一个。我已经配置了我的春天的webapp一个JAAS身份验证提供程序。我已经创建了它的bean定义如下:

 <beans:bean id="jaasAuthenticationProvider"
     class="org.springframework.security.providers.jaas.JaasAuthenticationProvider">
    <custom-authentication-provider />
    <beans:property name="loginConfig" value="file:webapps/mywebapp/WEB-INF/login.conf"/>
    <beans:property name="loginContextName" value="myWebapp"/>
    <beans:property name="callbackHandlers">
       <beans:list>
          <beans:bean class="org.springframework.security.providers.jaas.JaasNameCallbackHandler"/>
          <beans:bean class="org.springframework.security.providers.jaas.JaasPasswordCallbackHandler"/>
       </beans:list>
    </beans:property>
 </beans:bean>

有JAAS我login.conf的文件:

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

com.sun.security.jgss.initiate {
    com.sun.security.auth.module.Krb5LoginModule 
    required;
};

当弹簧初始化时,它正确地配置豆。当我尝试登录到我的web应用程序,但是,我得到以下错误:

DEBUG webapp.AuthenticationProcessingFilter - Authentication request failed: org.springframework.security.AuthenticationServiceException: I/O error while reading configuration file.; nested exception is javax.security.auth.login.LoginException: I/O error while reading configuration file.

我不能在春源代码的任何地方发现此错误信息,错误信息本身是没有帮助的。任何想法,这可能是造成这?

有帮助吗?

解决方案 2

找到了答案。 JAAS实际上是正确加载配置文件,但我错过了在我的本地JDK一个krb5.conf文件。该文件必须住在:

$JAVA_HOME/lib/security

示例:

[libdefaults]
  default_realm = DOMAIN.NET
  dns_lookup_kdc = true

[domain_realm]
  .domain.net = DOMAIN.NET

其中domain.net是Kerberos域的名称,和DOMAIN.NET是同一只大写。

其他提示

把你的文件在类路径而不是试图从WEB-INF目录下读取它。 /webapps/myapp/WEB-INF/classes/login.conf - 然后在Spring配置行更改为:

    <beans:property name="loginConfig" value="classpath:login.conf"/>

我不认为你得到一个春天的错误,但得到一个文件系统/ Java错误,你不能从目录WEB-INF阅读。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top