English 中文(简体)
Jaas需要 Java政策 我不知道如何提供。
原标题:Jaas needs a Java Policy I don t know how to provide it

I m trying to use Jaas, Java Authentication and Autorisation service. The server is App Engine so, it is impossible to edit web.xml. I m using a servlet filter like:

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 
    throws IOException, ServletException {
    try {
        LoginContext lc = new LoginContext("JaasSample", new AuthenticationCallbackHandler());
        lc.login();
        chain.doFilter(request, response);
        lc.logout();
    } catch (LoginException e) { /* lc.login() fails */}
}

要求LoginContext检查一项政策,并提出以下例外:

java.security.AccessControlException: 
access denied (javax.security.auth.AuthPermission createLoginContext.JaasSample)

The code I m using is from Oracle reference. They explain that in presence of a Security Manager, it is necessary to grant some rights in this fashion:

grant {
    permission javax.security.auth.AuthPermission "createLoginContext.JaasSample";
}

我不理解为什么要在联合调查报告中这样做。

我可以绕过这次检查——D-enable_all_permissions=true in the Rugiguration。 (待补)然后,Jaas配置文件在系统查询。 是否在项目资源中? 如何在地方/生产中发挥作用?

组合文件如下:

JaasSample {
    com.sun.security.auth.module.Krb5LoginModule required;
};

非常感谢。

ps. Spring Security can be use with Jaas and works on App Engine. pps. Spring Security can not be used because it starts Spring context which slow down App Engine startup. And the startup in this environment is done all the time.

最佳回答

问题完全存在于“Devot”模式中,一旦交付,就不存在这种例外。

因此,在Run Configuration中使用-D-enable_all_permissions=true就足够了。

问题回答

利用您的JAVA_HOME/bin名录提供许可。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签