Websphere中JMX的编程身份验证

时间:2010-01-29 18:12:03

标签: spring authentication login websphere jmx

我们希望对Websphere Application Server中的其他已部署应用程序进行JMX调用。如果您在用户使用正确凭据登录的Web应用程序中执行此操作,则此方法可以正常工作。但是,如果您尝试从应用程序的计时器触发部分进行JMX调用,该部分与任何已登录用户没有任何关联,则会得到一个 javax.management.JMRuntimeException:ADMN0022E 说你没有权利使用JMX。

所以我的问题是:如何为JMX操作提供一些凭据?有没有办法以编程方式“模拟”登录,或某种方式提供身份验证主题,以便完成调用?如何避免将实际用户的用户名和密码放入代码/属性文件中?

如果重要:我们使用Websphere 6.1,并使用Spring。

1 个答案:

答案 0 :(得分:2)

IBM WebSphere Application Server V6.1 Security Handbook第9.6章启发了我:

CallbackHandler loginHandler = new com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl("username","password");
LoginContext lc = new LoginContext("WSLogin", loginHandler);
lc.login();
Subject subject = lc.getSubject();
PrivilegedAction<Whateverresulttype> action = new PrivilegedAction<Whateverresulttype>() {
    public Health run() {
        return Health.valueOf(mbean.whatevercall());
    }
};
Whateverresulttype res = (Whateverresulttype) com.ibm.websphere.security.auth.WSSubject.doAs(subject, action);

我现在唯一需要知道的是如何避免将实际用户的凭据放入代码中。 8 - )