Java 创建LoginContext(JAAS)时没有LoginModule配置错误
创建了一个LoginContext对象并传递了一个名称,然后使用该条目创建了一个.conf文件。我在代码中设置了系统属性“java.security.auth.login.config”,以及conf文件的相对/绝对路径。当代码被执行时,我得到以下错误 javax.security.auth.login.LoginException:没有为示例配置LoginModule 有没有线索说明配置没有被提取?我错过什么了吗 感谢您的帮助 上面的代码Java 创建LoginContext(JAAS)时没有LoginModule配置错误,java,osgi,kerberos,jaas,Java,Osgi,Kerberos,Jaas,创建了一个LoginContext对象并传递了一个名称,然后使用该条目创建了一个.conf文件。我在代码中设置了系统属性“java.security.auth.login.config”,以及conf文件的相对/绝对路径。当代码被执行时,我得到以下错误 javax.security.auth.login.LoginException:没有为示例配置LoginModule 有没有线索说明配置没有被提取?我错过什么了吗 感谢您的帮助 上面的代码 System.setProperty("java.se
System.setProperty("java.security.auth.login.config","sampleConfig.conf");
loginContext = new LoginContext("Sample", new CustomCallbackHandler());
loginContext.login();
sampleConfig.conf
Sample {
com.sun.security.auth.module.Krb5LoginModule required;
};
文件似乎没有被提取出来。即使我更改了conf文件中的文件名/file path/do-any语法更改,我仍然只看到前面的错误
请注意,这是在OSGI包中完成的
有什么帮助吗?通过
org.osgi.framework.Bundle\getResource(String)
获取配置文件sampleConfig.conf
的具体URL
将此URL
作为值插入System.setProperty(“java.security.auth.login.config”,)中代码>
如果配置文件是OSGi框架的一部分,请使用框架捆绑包(id:0),否则请使用包含配置文件的捆绑包
编辑
可能使用对象而不是配置文件
见我对问题的回答:
然后创建customCallBackHandler和LoginModule。请描述测试代码的环境。你在用Equinox吗?您是否在Windows(任何版本)上进行测试?您是否打开了任何OSGI类加载器调试开关?特别是:org.eclipse.osgi/debug=true
和org.eclipse.osgi/debug/loader=true
。
public LoginContext(String name,
Subject subject,
CallbackHandler callbackHandler,
Configuration config)
throws LoginException
Sample {
sample.module.SampleLoginModule required debug=true;
};