• Stars
    star
    103
  • Rank 333,046 (Top 7 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 11 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This project is an implementation of OAuth2.0 written in Java.

oauth2-server

This project is an implementation for OAuth 2.0 Specification. Especially, the protocol of the server area is covered by this project.

Current supported Grant types

  • Authorization Code Grant
  • Resource Owner Password Credentials Grant
  • Client Credentials Grant

Current supported token types

How to use

This project is supporting some common processes to issue tokens. To use this framework, you have to provide an implementation of a DataHandler interface. The implementation class connects this framework to your databases or such storages.

Also, you have to implement a DataHandlerFactory interface to create your DataHandler instance.

Classes you have to implement are only above.

A class to handle a request to issue an access token is Token class. But, the Token class needs some helper classes. Therefore, you have to provide their instances to the Token instance. If you're using Spring Framework DI Container, you can inject them to the Token instance. Refer the applicationContext-token-schenario.xml file.

The way to use the Token class is simple. You can use it as the following snippet:

HttpServletRequest request = ...; // Provided by Servlet Container
HttpServletRequestAdapter adapter = new HttpServletRequestAdapter(request);
Token token = ...; // Injected
Token.Response response = token.handleRequest(adapter);
int code = response.getCode(); // 200, 400, 401, ...
String body = response.getBody(); // {"token_type":"Bearer","access_token":"...", ...}

An code for an integration test has the request and response contents of each grant type. Refer the test code TokenScenarioTest.

To check the request to access to each API endpoints, you can use ProtectedResource class. The following code snippet represents how to use its class:

HttpServletRequest request = ...; // Provided by Servlet Container
HttpServletRequestAdapter adapter = new HttpServletRequestAdapter(request);
ProtectedResource protectedResource = ...; // Injected
try {
    ProtectedResource.Response response = protectedResource.handleRequest(adapter);
    String remoteUser = response.getRemoteUser(); // User ID
    String clientId = response.getClientId(); // Client ID
    String scope = response.getScope(); // Scope string delimited by whitespace
    // do something
} catch(OAuthError e) {
    int httpStatusCode = e.getCode();
    String errorType = e.getType();
    String description = e.getDescription();
    // do something
}

If you build your application with Servlet API, then you can use the code above in your Filter class.

More Repositories

1

chrome_mysql_admin

ChromeMyAdmin provides you the administration GUI of MySQL server. It is like phpMyAdmin, Sequel Pro.
JavaScript
137
star
2

chromeos-filesystem-dropbox

This software provides an ability to access Dropbox for ChromeOS.
JavaScript
78
star
3

chromeos-filesystem-cifs

JavaScript
56
star
4

oauth2-firebase

This library provides OAuth2 server implementation for Firebase.
TypeScript
54
star
5

mindmap_tab

This software is a Chrome extension and allows you to draw your mindmap diagram easily and quickly.
JavaScript
52
star
6

mysql_js_driver

This project provides a library to connect, login and execute a query to MySQL.
JavaScript
34
star
7

lunakey

Lunakey - This is a brand for keyboards designed by Yoichiro Tanaka.
31
star
8

chromeos-filesystem-webdav

JavaScript
30
star
9

mixiAndroidSDKWrapper

mixi API SDK for Android(TM) をより便利に使用するためのラッパープロジェクトです。
Java
20
star
10

dialogflow-query-checker

This is an automated test tool to check conversations (test phrases and the result phrases) for Dialogflow.
Go
16
star
11

actions-tools

This provides you some useful tools to build your actions for Google Assistant.
TypeScript
14
star
12

semantic_inspector

JavaScript
13
star
13

generator-action

Yeoman Action Generator for generating a fulfillment code of an action for Google Assistant.
JavaScript
11
star
14

image_collector_extension

JavaScript
8
star
15

rock-paper-scissors-ja

Codelab: Build Actions with Interactive Canvas for the Google Assistant
JavaScript
7
star
16

url_shortener_extension

This project is the code set of "goo.gl URL Shortener extension" for Chrome.
JavaScript
7
star
17

chrome_mysql_console

JavaScript
7
star
18

mixi-staging

Erlang
5
star
19

gh-action-increment-value

This is a Github Action to increment a value and to commit it automatically.
JavaScript
5
star
20

rock-paper-scissors

Codelab: Build Actions with Interactive Canvas for the Google Assistant
JavaScript
4
star
21

mixiAndroidSDKWrapperTest

このプロジェクトは、mixi API SDK for Android(TM) をより便利に利用できるように機能拡張を行う ためのプロジェクトである「mixiAndroidSDKWrapper」のテストプロジェクトです。
Java
4
star
22

bitcoininfo

JavaScript
3
star
23

oauth2-nodejs

This library provides basic features to implement your OAuth2 server on node.js
TypeScript
3
star
24

codelabs

3
star
25

mgapistat

This project is the software to show you each statistics about mixi Graph API .
JavaScript
3
star
26

chromeos-filesystem-github

JavaScript
2
star
27

grpc-web-sample

JavaScript
2
star
28

mixi_check_for_chrome

JavaScript
2
star
29

docker-claat

Dockerfile
1
star
30

decode-cm06-demo1

HTML
1
star
31

mixi_page_crawler

Erlang
1
star
32

simple-fulfillment-azure-functions

JavaScript
1
star
33

aogdevs-jp

HTML
1
star
34

simple-servlet-app-gradle

This is a simple Java Servlet project deployed to Azure with Gradle plugin.
Java
1
star