基于令牌的java身份验证 [英] Token based authentication in java

查看:87
本文介绍了基于令牌的java身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您是否为RESTEasy API提供了一些基于令牌的身份验证。我想为登录和注销设计一些REST API URL。在使用有效的用户名和密码调用登录URL时,服务器将令牌分配给响应头。对于后续API调用,客户端必须将令牌发送到服务器。令牌也有一些消息。是否有任何现有框架可用?如果是,那么你能写一个像上面这样的例子吗?如果没有那么我该如何整合呢?



我尝试过的事情:



i尝试了这个链接http://howtodoinjava.com/resteasy/jax-rs-2-0-resteasy-3-0-2-final-security-tutorial/但我面临的问题就像导入org.glassfish .jersey.client无法解析。我已经包含了所有jar文件。

Do you have some token based authentication for RESTEasy APIs. I want to design some REST API URL for login and logout. On upon calling login URL with valid user name and password, the server will assign token to response header. For subsequent API call the client has to send the token to the server. Also the token has some expiery. Is there any some existing framework available? If yes then can you write one example like above? if not then how do I integrate it?

What I have tried:

i tried this link http://howtodoinjava.com/resteasy/jax-rs-2-0-resteasy-3-0-2-final-security-tutorial/ but i am facing the problem like The import org.glassfish.jersey.client cannot be resolved.I have already included all jar files.

推荐答案

您可以在服务器端用Java实现OAuth提供程序服务,然后使用它在客户端作为身份验证。此身份验证系统(OAuth)是您正在寻找(或正在考虑)的。



这项服务非常简单直接,标准解释了如何做到这一点。如果您愿意阅读该标准,请访问此处, http://tools.ietf.org/html/rfc5849 [ ^ ]。我没有做那么多Java编程,但是你去了:



Java中是否有OAuth 2.0 Provider实现? (不是oauth客户端) - 堆栈溢出 [ ^ ]

代码&安培; MDASH; OAuth [ ^ ](查看Java部分)

GitHub - OAuth-Apis / apis:OAuth授权即服务 [
You can implement the OAuth provider service in Java on your server side, and then use it on the client side as the authentication. This authentication system (OAuth) is what you are looking for (or are thinking about).

The service is very much simple and straight-forward, and the standard explains how to do that. If you are willing to read about that standard, please go here, http://tools.ietf.org/html/rfc5849[^]. I don't do that much Java programming, but here you go:

Is there an OAuth 2.0 Provider implementation in Java? (not oauth client) - Stack Overflow[^]
Code — OAuth[^] (Have a look at the Java section)
GitHub - OAuth-Apis/apis: OAuth Authorization as a Service[^]

The GitHub samples provide the samples for both, server as well as client. You can download the source code and run them as you want.


这篇关于基于令牌的java身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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