为什么 Tomcat 管理器使用我的 LoginModule? [英] Why is Tomcat manager using my LoginModule?

查看:30
本文介绍了为什么 Tomcat 管理器使用我的 LoginModule?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 Tomcat 6.0.29 并创建了我自己的领域和登录模块.它们在 server.xml 中定义如下:

I'm running Tomcat 6.0.29 and created a realm and loginmodule of my own. They are defined in server.xml like so:

<Realm className="mycompany.tomcat.MyRepositoryRealm"appName="My_Realm"userClassNames="mycompany.tomcat.IdentityPrincipal"roleClassNames="mycompany.tomcat.RolePrincipal"useContextClassLoader="true"/>

我已将包含这些类的库添加到我的 tomcat/lib 文件夹中.除此之外,我没有更改 Tomcat 的默认配置.

I have added the library containing these classes to my tomcat/lib folder. Other than that, I have not changed Tomcat from it's default configuration.

当我在 http://localhost:9080/manager/html 上启动 Tomcat 管理器应用程序时,我无法登录,并且 tomcat 日志显示我的错误和堆栈跟踪登录模块.

When I go to fire up the Tomcat manager application at http://localhost:9080/manager/html, I can't log in and the tomcat log shows an error and stacktrace for my login module.

有什么想法吗?谢谢!

每个请求,这里是堆栈跟踪.我的领域连接到 JBoss 服务,所以这就是我收到 NamingContextFactory 错误的原因.

Per request, here is the stacktrace. My realm connects to a JBoss service, so that's why I get the NamingContextFactory error.

javax.security.auth.login.LoginException:无法实例化类:org.jnp.interfaces.NamingContextFactory在 mycompany.tomcat.MyRepositoryLoginModule.login(MyRepositoryLoginModule.java:88)在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)在 java.lang.reflect.Method.invoke(Method.java:597)在 javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)在 javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)在 javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)在 java.security.AccessController.doPrivileged(Native Method)在 javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)在 javax.security.auth.login.LoginContext.login(LoginContext.java:579)在 org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:410)在 org.apache.catalina.realm.JAASRealm.authenticate(JAASRealm.java:335)在 mycompany.tomcat.MyRepositoryRealm.authenticate(MyRepositoryRealm.java:34)在 org.apache.catalina.authenticator.BasicAuthenticator.authenticate(BasicAuthenticator.java:181)在 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:528)在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)在 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)在 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)在 org.apache.tomcat.util.net.JioEndpoint$Worker.run(JioEndpoint.java:489)在 java.lang.Thread.run(Thread.java:619)

推荐答案

我找到了问题所在.

可以为引擎、主机或上下文定义安全领域.我已经为整个主机定义了领域(在 server.xml 中),所以 tomcat 管理器应用程序试图使用它.我通过在 Web 应用程序内的 META-INF/context.xml 文件中定义领域解决了这个问题.

Security realms can be defined for an engine, host, or context. I had defined the realm for the whole host (in server.xml), so the tomcat manager application was trying to use it. I fixed the problem by defining the realm in a META-INF/context.xml file inside of my web application.

这篇关于为什么 Tomcat 管理器使用我的 LoginModule?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆