Skip to content

Commit

Permalink
Merge pull request #1 from ChamathNS/oidc-sdk-patch
Browse files Browse the repository at this point in the history
Add OIDC SDK for Java
  • Loading branch information
darshanasbg authored Nov 3, 2020
2 parents 6ab7dab + 80e97e5 commit 28db80f
Show file tree
Hide file tree
Showing 25 changed files with 2,933 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
# Mobile Tools for Java (J2ME)
.mtj.tmp/

# IDE
.idea/
*.iml

# Package Files #
*.jar
*.war
Expand All @@ -21,3 +25,6 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Ignore everything in this directory
target
110 changes: 110 additions & 0 deletions io.asgardio.java.oidc.sdk/pom.xml
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>
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;
}
Loading

0 comments on commit 28db80f

Please sign in to comment.