用于wildfly中JASPI身份验证的自定义身份验证模块

时间:2017-07-11 06:50:51

标签: jboss wildfly-10 jaspic

我需要在wildfly中使用自定义身份验证模块进行JASPI身份验证。我的standalone-full.xml:

<security-domain name="testlogin" cache-type="default">
  <authentication-jaspi>
    <login-module-stack name="1m-stack">
      <login-module code="com.test.TestLoginModule" flag="required" module="in.hrworks.testmodule">
        <module-option name="dsJndiName" value="java:jboss/datasources/Appscale"/>        
      </login-module>
    </login-module-stack>
    <auth-module code="com.test.JASPILoginModule" login-module-stack-ref="1m-stack"/>
  </authentication-jaspi>
</security-domain>

我的jboss-web.xml:

 <security-domain>testlogin</security-domain> 
 <valve>
    <class-name>org.jboss.as.web.security.jaspi.WebJASPIAuthenticator</class-name>
 </valve>

当我请求应用程序URL时,我得到NoClassDefFoundError:

Context Path:
/hrworks

Servlet Path:
/index.jsp

Path Info:
null

Query String:
null

Stack Trace
java.lang.NoClassDefFoundError: Failed to link com/test/JASPILoginModule (Module "in.hrworks.testmodule:main" from local module loader @543788f3 (finder: local module finder @6d3af739 (roots: /usr/local/wildfly-10.1.0.Final/modules,/usr/local/wildfly-10.1.0.Final/modules/system/layers/base))): javax/security/auth/message/module/ServerAuthModule
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)        
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
org.jboss.modules.Module.loadModuleClass(Module.java:606)
org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

我还在in.hrworks.testmodule module.xml模块中添加了自定义模块org.jboss.as.security作为依赖项。但这似乎没有任何影响。

我犯了什么错误吗?

一些更新:

org.jboss.modules启用TRACE级别日志记录后,我发现我的模块错过了javax.security.auth.message.api的依赖项。但在添加此依赖项后,我得到了一个不同的错误:

2017-07-13 13:17:11,801 ERROR [io.undertow.request] (default task-2) UT005023: Exception handling request to /hrworks/: java.lang.NoClassDefFoundError: Could not initialize class com.test.JASPILoginModule
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jboss.security.auth.message.config.JBossServerAuthConfig.createSAM(JBossServerAuthConfig.java:245)
at org.jboss.security.auth.message.config.JBossServerAuthConfig.getAuthContext(JBossServerAuthConfig.java:178)
at org.jboss.security.plugins.auth.JASPIServerAuthenticationManager.secureResponse(JASPIServerAuthenticationManager.java:158)
at org.wildfly.extension.undertow.security.jaspi.JASPICSecureResponseHandler.handleRequest(JASPICSecureResponseHandler.java:35)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

任何想法可能是什么原因?

0 个答案:

没有答案