Skip to content

Commit 378eb5d

Browse files
Merge pull request #117 from brettchaldecott/feat/openapi-billing-updates
Feat/openapi billing updates
2 parents aa6adde + 56f38d1 commit 378eb5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+798
-284
lines changed

kinde-core/pom.xml

Lines changed: 108 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,119 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
44

5-
<parent>
6-
<groupId>com.kinde</groupId>
7-
<artifactId>kinde-parent-pom</artifactId>
8-
<version>2.0.1</version>
9-
</parent>
5+
<parent>
6+
<groupId>com.kinde</groupId>
7+
<artifactId>kinde-parent-pom</artifactId>
8+
<version>2.0.1</version>
9+
</parent>
1010

11-
<groupId>com.kinde</groupId>
12-
<artifactId>kinde-core</artifactId>
13-
<packaging>jar</packaging>
14-
<version>2.0.1</version>
15-
<name>kinde-core</name>
16-
<url>http://maven.apache.org</url>
11+
<artifactId>kinde-core</artifactId>
12+
<packaging>jar</packaging>
13+
<version>2.0.1</version>
14+
<name>kinde-core</name>
15+
<url>http://maven.apache.org</url>
1716

18-
<dependencies>
19-
<!-- https://mvnrepository.com/artifact/com.nimbusds/oauth2-oidc-sdk -->
20-
<dependency>
21-
<groupId>com.nimbusds</groupId>
22-
<artifactId>oauth2-oidc-sdk</artifactId>
23-
</dependency>
24-
<dependency>
25-
<groupId>com.nimbusds</groupId>
26-
<artifactId>nimbus-jose-jwt</artifactId>
27-
</dependency>
28-
<dependency>
29-
<groupId>junit</groupId>
30-
<artifactId>junit</artifactId>
31-
<scope>test</scope>
32-
</dependency>
33-
<!-- JUnit 5 API and Engine -->
34-
<dependency>
35-
<groupId>org.junit.jupiter</groupId>
36-
<artifactId>junit-jupiter-api</artifactId>
37-
<scope>test</scope>
38-
</dependency>
39-
<dependency>
40-
<groupId>org.junit.jupiter</groupId>
41-
<artifactId>junit-jupiter-engine</artifactId>
42-
<scope>test</scope>
43-
</dependency>
17+
<dependencies>
18+
<!-- https://mvnrepository.com/artifact/com.nimbusds/oauth2-oidc-sdk -->
19+
<dependency>
20+
<groupId>com.nimbusds</groupId>
21+
<artifactId>oauth2-oidc-sdk</artifactId>
22+
</dependency>
23+
<dependency>
24+
<groupId>com.fasterxml.jackson.core</groupId>
25+
<artifactId>jackson-databind</artifactId>
26+
<version>2.15.2</version>
27+
</dependency>
28+
<dependency>
29+
<groupId>com.nimbusds</groupId>
30+
<artifactId>nimbus-jose-jwt</artifactId>
31+
</dependency>
32+
<dependency>
33+
<groupId>junit</groupId>
34+
<artifactId>junit</artifactId>
35+
<scope>test</scope>
36+
</dependency>
37+
<!-- JUnit 5 API and Engine -->
38+
<dependency>
39+
<groupId>org.junit.jupiter</groupId>
40+
<artifactId>junit-jupiter-api</artifactId>
41+
<scope>test</scope>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.junit.jupiter</groupId>
45+
<artifactId>junit-jupiter-engine</artifactId>
46+
<scope>test</scope>
47+
</dependency>
4448

45-
<!-- Optional: For parameterized tests -->
46-
<dependency>
47-
<groupId>org.junit.jupiter</groupId>
48-
<artifactId>junit-jupiter-params</artifactId>
49-
<scope>test</scope>
50-
</dependency>
49+
<!-- Optional: For parameterized tests -->
50+
<dependency>
51+
<groupId>org.junit.jupiter</groupId>
52+
<artifactId>junit-jupiter-params</artifactId>
53+
<scope>test</scope>
54+
</dependency>
5155

52-
<!-- Mockito (if you are using it for mocking) -->
53-
<dependency>
54-
<groupId>org.mockito</groupId>
55-
<artifactId>mockito-core</artifactId>
56-
<scope>test</scope>
57-
</dependency>
56+
<!-- Mockito (if you are using it for mocking) -->
57+
<dependency>
58+
<groupId>org.mockito</groupId>
59+
<artifactId>mockito-core</artifactId>
60+
<scope>test</scope>
61+
</dependency>
5862

5963

60-
<dependency>
61-
<groupId>com.google.inject</groupId>
62-
<artifactId>guice</artifactId>
63-
<!-- {version} can be 6.0.0, 7.0.0, etc. -->
64-
<exclusions>
65-
<exclusion>
66-
<groupId>com.google.guava</groupId>
67-
<artifactId>guava</artifactId>
68-
</exclusion>
69-
</exclusions>
70-
</dependency>
71-
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
72-
<dependency>
73-
<groupId>com.google.guava</groupId>
74-
<artifactId>guava</artifactId>
75-
</dependency>
64+
<dependency>
65+
<groupId>com.google.inject</groupId>
66+
<artifactId>guice</artifactId>
67+
<!-- {version} can be 6.0.0, 7.0.0, etc. -->
68+
<exclusions>
69+
<exclusion>
70+
<groupId>com.google.guava</groupId>
71+
<artifactId>guava</artifactId>
72+
</exclusion>
73+
</exclusions>
74+
</dependency>
75+
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
76+
<dependency>
77+
<groupId>com.google.guava</groupId>
78+
<artifactId>guava</artifactId>
79+
</dependency>
7680

7781

78-
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
79-
<dependency>
80-
<groupId>org.projectlombok</groupId>
81-
<artifactId>lombok</artifactId>
82-
<scope>provided</scope>
83-
</dependency>
84-
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
85-
<dependency>
86-
<groupId>org.slf4j</groupId>
87-
<artifactId>slf4j-api</artifactId>
88-
</dependency>
89-
<dependency>
90-
<groupId>io.github.cdimascio</groupId>
91-
<artifactId>dotenv-java</artifactId>
92-
</dependency>
93-
<dependency>
94-
<groupId>org.wiremock</groupId>
95-
<artifactId>wiremock</artifactId>
96-
<scope>test</scope>
97-
</dependency>
98-
</dependencies>
99-
<build>
100-
<plugins>
101-
<plugin>
102-
<groupId>org.apache.maven.plugins</groupId>
103-
<artifactId>maven-surefire-plugin</artifactId>
104-
<version>3.5.2</version>
105-
<configuration>
106-
<parallel>none</parallel>
107-
</configuration>
108-
</plugin>
109-
<plugin>
110-
<groupId>org.sonatype.plugins</groupId>
111-
<artifactId>nexus-staging-maven-plugin</artifactId>
112-
</plugin>
113-
</plugins>
114-
</build>
82+
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
83+
<dependency>
84+
<groupId>org.projectlombok</groupId>
85+
<artifactId>lombok</artifactId>
86+
<scope>provided</scope>
87+
</dependency>
88+
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
89+
<dependency>
90+
<groupId>org.slf4j</groupId>
91+
<artifactId>slf4j-api</artifactId>
92+
</dependency>
93+
<dependency>
94+
<groupId>io.github.cdimascio</groupId>
95+
<artifactId>dotenv-java</artifactId>
96+
</dependency>
97+
<dependency>
98+
<groupId>org.wiremock</groupId>
99+
<artifactId>wiremock</artifactId>
100+
<scope>test</scope>
101+
</dependency>
102+
</dependencies>
103+
<build>
104+
<plugins>
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-surefire-plugin</artifactId>
108+
<version>3.5.2</version>
109+
<configuration>
110+
<parallel>none</parallel>
111+
</configuration>
112+
</plugin>
113+
<plugin>
114+
<groupId>org.sonatype.plugins</groupId>
115+
<artifactId>nexus-staging-maven-plugin</artifactId>
116+
</plugin>
117+
</plugins>
118+
</build>
115119
</project>

kinde-core/src/main/java/com/kinde/KindeClientSession.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package com.kinde;
22

3-
43
import com.kinde.authorization.AuthorizationUrl;
5-
import com.kinde.token.KindeToken;
64
import com.kinde.token.KindeTokens;
75
import com.kinde.user.UserInfo;
86

9-
import java.util.List;
107
import java.util.Map;
118

129
public interface KindeClientSession {
@@ -25,5 +22,7 @@ public interface KindeClientSession {
2522

2623
AuthorizationUrl logout() throws Exception;
2724

25+
AuthorizationUrl generatePortalUrl(String domain, String returnUrl, String subNav);
26+
2827
UserInfo retrieveUserInfo();
2928
}

kinde-core/src/main/java/com/kinde/authorization/AuthorizationUrl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.nimbusds.oauth2.sdk.pkce.CodeVerifier;
44
import lombok.AllArgsConstructor;
5-
import lombok.Data;
65
import lombok.Getter;
76

87
import java.net.URL;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.kinde.exceptions;
2+
3+
public class KindeClientSessionException extends Exception {
4+
public KindeClientSessionException(String message) {
5+
super(message);
6+
}
7+
8+
public KindeClientSessionException(String message, Throwable cause) {
9+
super(message, cause);
10+
}
11+
12+
public KindeClientSessionException(Throwable cause) {
13+
super(cause);
14+
}
15+
}

kinde-core/src/main/java/com/kinde/session/KindeClientCodeSessionImpl.java

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
import com.kinde.client.OidcMetaData;
66
import com.kinde.config.KindeConfig;
77
import com.kinde.guice.KindeAnnotations;
8-
import com.kinde.token.*;
8+
import com.kinde.token.AccessToken;
9+
import com.kinde.token.IDToken;
10+
import com.kinde.token.KindeTokens;
11+
import com.kinde.token.RefreshToken;
912
import com.kinde.user.UserInfo;
1013
import com.nimbusds.oauth2.sdk.*;
1114
import com.nimbusds.oauth2.sdk.auth.ClientAuthentication;
@@ -17,18 +20,15 @@
1720
import com.nimbusds.oauth2.sdk.token.BearerAccessToken;
1821
import com.nimbusds.openid.connect.sdk.UserInfoRequest;
1922
import com.nimbusds.openid.connect.sdk.UserInfoResponse;
20-
import com.nimbusds.openid.connect.sdk.token.OIDCTokens;
2123
import lombok.SneakyThrows;
2224

2325
import javax.annotation.Nullable;
2426
import java.net.URI;
25-
import java.util.Arrays;
26-
import java.util.List;
2727

2828
public class KindeClientCodeSessionImpl extends KindeClientSessionImpl {
2929

30-
private String code;
31-
private AuthorizationUrl authorizationUrl;
30+
private final String code;
31+
private final AuthorizationUrl authorizationUrl;
3232
private AccessToken accessToken;
3333

3434
@Inject
@@ -37,7 +37,7 @@ public KindeClientCodeSessionImpl(
3737
OidcMetaData oidcMetaData,
3838
@KindeAnnotations.KindeCode String code,
3939
@KindeAnnotations.AuthorizationUrl @Nullable AuthorizationUrl authorizationUrl) {
40-
super(kindeConfig,oidcMetaData);
40+
super(kindeConfig, oidcMetaData);
4141
this.code = code;
4242
this.authorizationUrl = authorizationUrl;
4343
}
@@ -48,7 +48,7 @@ public KindeTokens retrieveTokens() {
4848
AuthorizationCode code = new AuthorizationCode(this.code);
4949
URI callback = new URI(this.kindeConfig.redirectUri());
5050
AuthorizationGrant codeGrant = this.authorizationUrl == null ? new AuthorizationCodeGrant(code, callback) :
51-
new AuthorizationCodeGrant(code, callback,this.authorizationUrl.getCodeVerifier());
51+
new AuthorizationCodeGrant(code, callback, this.authorizationUrl.getCodeVerifier());
5252

5353
ClientID clientID = new ClientID(this.kindeConfig.clientId());
5454
Secret clientSecret = new Secret(this.kindeConfig.clientSecret());
@@ -57,18 +57,16 @@ public KindeTokens retrieveTokens() {
5757

5858
TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, codeGrant);
5959
HTTPRequest httpRequest = request.toHTTPRequest();
60-
httpRequest.setHeader("Kinde-SDK","Java/2.0.1");
60+
httpRequest.setHeader("Kinde-SDK", "Java/2.0.1");
6161

6262
TokenResponse response = TokenResponse.parse(httpRequest.send());
63-
System.out.println(response.toString());
6463

65-
if (! response.indicatesSuccess()) {
66-
// We got an error response...
64+
if (!response.indicatesSuccess()) {
6765
throw new Exception(response.toErrorResponse().toString());
6866
}
6967
AccessTokenResponse successResponse = response.toSuccessResponse();
7068

71-
String idTokenStr = (String)successResponse.getCustomParameters().get("id_token");
69+
String idTokenStr = (String) successResponse.getCustomParameters().get("id_token");
7270

7371
IDToken idToken = null;
7472
if (idTokenStr != null) {
@@ -82,7 +80,7 @@ public KindeTokens retrieveTokens() {
8280
refreshToken = com.kinde.token.RefreshToken.init(successResponse.getTokens().getRefreshToken().getValue(), true);
8381
}
8482

85-
return new KindeTokens(this.kindeConfig.scopes(),idToken,this.accessToken,refreshToken);
83+
return new KindeTokens(this.kindeConfig.scopes(), idToken, this.accessToken, refreshToken);
8684
}
8785

8886
@Override
@@ -91,17 +89,15 @@ public UserInfo retrieveUserInfo() {
9189
if (this.accessToken == null) {
9290
retrieveTokens();
9391
}
94-
URI userInfoEndpoint; // The UserInfoEndpoint of the OpenID provider
95-
BearerAccessToken token = new BearerAccessToken(this.accessToken.token()); // The access token
92+
BearerAccessToken token = new BearerAccessToken(this.accessToken.token());
9693

9794
HTTPResponse httpResponse = new UserInfoRequest(this.oidcMetaData.getOpMetadata().getUserInfoEndpointURI(), token)
9895
.toHTTPRequest()
9996
.send();
10097

10198
UserInfoResponse userInfoResponse = UserInfoResponse.parse(httpResponse);
10299

103-
if (! userInfoResponse.indicatesSuccess()) {
104-
// We got an error response...
100+
if (!userInfoResponse.indicatesSuccess()) {
105101
throw new Exception(userInfoResponse.toErrorResponse().toString());
106102
}
107103

0 commit comments

Comments
 (0)