在 Java 中实现 OAuth 协议

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2797739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 22:53:17  来源:igfitidea点击:

Implementing OAuth protocol in Java

javajakarta-eeoauth

提问by Wasim

I'm looking for an open source library that implements the OAuth protocol , I need the server side implementation . Say I have a Social network system , and I want to give my users an OAuth abiliy to my API , like facebook.

我正在寻找一个实现 OAuth 协议的开源库,我需要服务器端实现。假设我有一个社交网络系统,并且我想为我的用户提供对我的 API 的 OAuth 能力,例如 facebook。

Do you have any suggestion , sure examples .

你有什么建议吗,肯定的例子。

采纳答案by ZZ Coder

There are few Java libraries list here,

这里列出的Java库很少,

http://oauth.net/code/

http://oauth.net/code/

You should use the first one. It's the only one with server support. You can find an example,

你应该使用第一个。它是唯一一个支持服务器的。你可以找到一个例子,

http://oauth.googlecode.com/svn/code/java/example/oauth-provider/

http://oauth.googlecode.com/svn/code/java/example/oauth-provider/

You might want also look at OAuth 2.0,

你可能还想看看 OAuth 2.0,

http://tools.ietf.org/html/draft-ietf-oauth-v2-02

http://tools.ietf.org/html/draft-ietf-oauth-v2-02

Which greatly simplifies OAuth flow and you don't really need a library to implement it.

这极大地简化了 OAuth 流程,您实际上并不需要一个库来实现它。

回答by rossa

You can try https://github.com/apifest/apifest-oauth20It's written in Java and uses Netty as a server. As a storage, it currently uses Hazelcast(by default), MongoDB or Redis. Also, you can easily add another backend storage.

你可以试试https://github.com/apifest/apifest-oauth20它是用Java编写的,使用Netty作为服务器。作为存储,它目前使用 Hazelcast(默认)、MongoDB 或 Redis。此外,您可以轻松添加另一个后端存储。

回答by Rakesh Waghela

If you are willing to implement oauth server using a Java Spring technologies.

如果您愿意使用 Java Spring 技术实现 oauth 服务器。

Here is an implementation using Spring Boot.

这是一个使用 Spring Boot 的实现。

https://github.com/dsyer/sparklr-boot

https://github.com/dsyer/sparklr-boot

回答by chris

http://code.google.com/p/oauth/is the reference library, or there's also http://github.com/fernandezpablo85/scribeas an alternative.

http://code.google.com/p/oauth/是参考库,或者还有http://github.com/fernandezpablo85/scribe作为替代。