我已经使用部署到 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/