java - Glassfish Web 服务授权

标签 java web-services security glassfish

我已经使用部署到 Glassfish 3.1.1 的 JAX-WS 设置了一个 Web 服务。我已经设法使用客户端证书设置 SSL(相互身份验证),但我不知道如何进行正确的授权。我喜欢为只读访问设置角色,以更新和删除数据。

Java EE 6 教程和 glassfish 安全指南指出,不能将用户添加到证书领域 Java EE Tutorial .那么在使用相互认证的同时授权用户的正确方法是什么?我必须在顶部使用用户名和密码吗?

最佳答案

看看http://docs.oracle.com/cd/E18930_01/html/821-2435/ggktf.html#gksdc

public class CertificateLM extends AppservCertificateLoginModule
{

    protected void authenticateUser() throws LoginException
    {
        // get the DN from the X500Principal.
        String dname = getX500Principal().getName();

        // retrieve the groups of the DN from an external source, e.g. from LDAP
        String[] groups = getGroupsFromLDAP( dname ); 

        if( groups != null ) {
             commitUserAuthentication( groups );
        }
        else {
             throw new LoginException( "DN is unknown." );
        }
    }
}

关于java - Glassfish Web 服务授权,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9065848/

相关文章:

java - AST 解析器出现问题

php - 通过 SoapClient 连接到 eBay Trading API 抛出 'The web service eBayAPI is not properly configured or not found and is disabled' 异常

ios - 在 iOS 中创建 JSON 字符串

java - Spring Web 服务 - 异常跳过 ExceptionResolver

php - 散列密码,从 splinter 的方法到现在最安全的方法

java - 同步方法可以满足同步块(synchronized block)可以达到的所有目的吗?

java - java中静态方法的同步问题

javascript - JavaScript 的客户端 DOM 打开重定向

iphone - 验证从移动 (iPhone) 应用程序到 ASP.Net Web API 的请求(对我的设计请求反馈)

Java For 循环和多态性