JAX-WS,身份验证和授权 - 如何? [英] JAX-WS, Authentication and Authorization - How to?

查看:46
本文介绍了JAX-WS,身份验证和授权 - 如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Web 服务中进行身份验证和授权的最佳方法是什么?

What is the best way to do authentication and authorization in web services?

我正在开发一组 Web 服务,需要基于角色的访问控制.使用 Metro - SOAP,没有 EJB 的简单 java.

I am developing a set of web services, requiring role based access control. Using metro - SOAP, simple java without EJBs.

  • 我只想对用户进行一次身份验证,使用用户名和密码,与数据库匹配.在随后的调用中.
  • 我想使用某种会话管理.可能是一些会话 ID,在登录时检索到客户端,在所有调用.

到目前为止:

  • Read authentication using a database - but I want application level validation;
  • Read application authentication with jax-ws - but i don't want to do the authentication mechanism every time;

我想我可以使用 SOAP 处理程序来拦截所有消息,并在处理程序中进行授权控制,使用消息附带的一些会话标识符令牌,可以与保存的标识符进行匹配在数据库中,在登录网络方法中.

I think I can use a SOAP Handler, to intercept all the messages, and do the authorization control in the hander, using some session identifier token, that comes with the message, that can be matched against an identifier saved in the data base, in the login web method.

我还有一些问题:

  • 如何知道被调用的网络方法的名称?
  • 我应该使用什么样的令牌?
  • 如何在调用之间传递这个令牌?

编辑 2

因为@ag112 回答:

Because of @ag112 answer:

我使用的是 Glassfish.

I'm using Glassfish.

我使用 WS-Policy 和 WS-Security 对消息进行加密和签名.使用相互证书认证.我想补充应用程序之间的消息级别安全性,同时在消息级别对用户进行身份验证和授权.

I use WS-Policy and WS-Security to encrypt and sign the messages. Using Mutual Certificate Authentication. I would like to complement this message level security between applications, with the authentication and authorization for the users also in message level.

我只是在开发服务,我对客户几乎一无所知,只是知道它们可以用不同的语言创建.

I am just developing the services, and I don't know almost nothing the clients, just that they could be created in different languages.

在这一点上,我认为最重要的事情是做我需要做的事情来验证和验证用户,这是我为客户端应用程序实现的最简单的方法.

At this point I think the most important thing is to do what ever I need to do to authenticate and authentication the users, I the most easy way to be implemented for the client applications.

推荐答案

在得到所有帮助之后,我创建了这个答案以简化并总结讨论的所有想法.

After all the help, I create this answer to simplify, and summarize all the ideas that was discussed.

这些问题有两个必要条件:

The questions has 2 requisites:

  • 消息级安全;
  • 一次性身份验证.

在 ag112 的帮助下,这很难做到,或者以任何方式优雅.所以这里是结论:

With ag112 help, this is hard to do, or to elegant in any way. So here are to conclusions:

  • 为了消息级别的安全性,请发送用户每次都使用凭据(将其放在 SOAP 标头中);
  • 一次身份验证使用传输级安全,并执行会话管理.

我更喜欢第一个,因为消息级别是最大的必要条件.

I prefer the first one, because the message level was the biggest requisite.

这篇关于JAX-WS,身份验证和授权 - 如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆