-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ChamathNS/oidc-sdk-patch
Add OIDC SDK for Java
- Loading branch information
Showing
25 changed files
with
2,933 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
~ | ||
~ WSO2 Inc. licenses this file to you under the Apache License, | ||
~ Version 2.0 (the "License"); you may not use this file except | ||
~ in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, | ||
~ software distributed under the License is distributed on an | ||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
~ KIND, either express or implied. See the License for the | ||
~ specific language governing permissions and limitations | ||
~ under the License. | ||
--> | ||
|
||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>java-oidc-sdk</artifactId> | ||
<groupId>io.asgardio.java.oidc.sdk</groupId> | ||
<version>0.1.0</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>io.asgardio.java.oidc.sdk</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Asgardio - Java OIDC SDK</name> | ||
<url>http://asgardio.io</url> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>commons-lang.wso2</groupId> | ||
<artifactId>commons-lang</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.nimbusds</groupId> | ||
<artifactId>nimbus-jose-jwt</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.nimbusds</groupId> | ||
<artifactId>oauth2-oidc-sdk</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wso2.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-module-testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-inline</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mock-server</groupId> | ||
<artifactId>mockserver-netty</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mock-server</groupId> | ||
<artifactId>mockserver-client-java</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<sourceDirectory>src/main/java</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.0</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
67 changes: 67 additions & 0 deletions
67
io.asgardio.java.oidc.sdk/src/main/java/io/asgardio/java/oidc/sdk/OIDCManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. licenses this file to you under the Apache License, | ||
* Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package io.asgardio.java.oidc.sdk; | ||
|
||
import io.asgardio.java.oidc.sdk.bean.AuthenticationInfo; | ||
import io.asgardio.java.oidc.sdk.bean.User; | ||
import io.asgardio.java.oidc.sdk.exception.SSOAgentException; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
/** | ||
* OIDC manager service interface. | ||
*/ | ||
public interface OIDCManager { | ||
|
||
/** | ||
* Builds an authentication request and redirects. | ||
* | ||
* @param request Incoming {@link HttpServletRequest}. | ||
* @param response Outgoing {@link HttpServletResponse} | ||
* @param state State parameter for the session. | ||
* @throws SSOAgentException | ||
*/ | ||
void sendForLogin(HttpServletRequest request, HttpServletResponse response, String state) throws SSOAgentException; | ||
|
||
/** | ||
* Processes the OIDC callback response and extract the authorization code, builds a token request, sends the | ||
* token request and parse the token response where the authenticated user info and tokens would be added to the | ||
* {@link AuthenticationInfo} object and returned. | ||
* | ||
* @param request Incoming {@link HttpServletRequest}. | ||
* @param response Outgoing {@link HttpServletResponse} | ||
* @return {@link AuthenticationInfo} Object containing the authenticated {@link User}, AccessToken, RefreshToken | ||
* and IDToken. | ||
* @throws SSOAgentException Upon failed authentication. | ||
*/ | ||
AuthenticationInfo handleOIDCCallback(HttpServletRequest request, HttpServletResponse response) | ||
throws SSOAgentException; | ||
|
||
/** | ||
* Builds a logout request and redirects. | ||
* | ||
* @param authenticationInfo {@link AuthenticationInfo} of the logged in session. | ||
* @param response Outgoing {@link HttpServletResponse} | ||
* @param state State parameter for the session. | ||
* @throws SSOAgentException | ||
*/ | ||
void logout(AuthenticationInfo authenticationInfo, HttpServletResponse response, String state) | ||
throws SSOAgentException; | ||
} |
Oops, something went wrong.