From 54531edfb778d7e399cfffb5124f0fea861f7053 Mon Sep 17 00:00:00 2001 From: Rex Ijiekhuamen Date: Sat, 16 Mar 2024 18:07:08 +0000 Subject: [PATCH] added files being worked on --- .../keys/ApplicationKeySource.java | 7 ++++++ .../oauth2server/keys/context/KeyContext.java | 19 ++++++++++++++ .../token/granter/CompositeTokenGranter.java | 3 ++- .../token/granter/RefreshTokenGranter.java | 25 +++++++++++++++++++ .../oauth2server/api/constants/Endpoints.java | 9 +++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/main/java/dev/rexijie/oauth/oauth2server/keys/ApplicationKeySource.java create mode 100644 src/main/java/dev/rexijie/oauth/oauth2server/keys/context/KeyContext.java create mode 100644 src/main/java/dev/rexijie/oauth/oauth2server/token/granter/RefreshTokenGranter.java create mode 100644 src/test/java/dev/rexijie/oauth/oauth2server/api/constants/Endpoints.java diff --git a/src/main/java/dev/rexijie/oauth/oauth2server/keys/ApplicationKeySource.java b/src/main/java/dev/rexijie/oauth/oauth2server/keys/ApplicationKeySource.java new file mode 100644 index 0000000..a9e5aa3 --- /dev/null +++ b/src/main/java/dev/rexijie/oauth/oauth2server/keys/ApplicationKeySource.java @@ -0,0 +1,7 @@ +package dev.rexijie.oauth.oauth2server.keys; + +import com.nimbusds.jose.jwk.source.JWKSecurityContextJWKSet; + +public class ApplicationKeySource extends JWKSecurityContextJWKSet { + +} diff --git a/src/main/java/dev/rexijie/oauth/oauth2server/keys/context/KeyContext.java b/src/main/java/dev/rexijie/oauth/oauth2server/keys/context/KeyContext.java new file mode 100644 index 0000000..055470e --- /dev/null +++ b/src/main/java/dev/rexijie/oauth/oauth2server/keys/context/KeyContext.java @@ -0,0 +1,19 @@ +package dev.rexijie.oauth.oauth2server.keys.context; + +import com.nimbusds.jose.jwk.JWK; +import com.nimbusds.jose.proc.JWKSecurityContext; + +import java.util.List; + +public class KeyContext extends JWKSecurityContext { + + /** + * Constructs a {@code JWKSecurityContext} with the provided + * parameters. + * + * @param keys The list of keys. + */ + public KeyContext(List keys) { + super(keys); + } +} diff --git a/src/main/java/dev/rexijie/oauth/oauth2server/token/granter/CompositeTokenGranter.java b/src/main/java/dev/rexijie/oauth/oauth2server/token/granter/CompositeTokenGranter.java index 03a54b4..616890b 100644 --- a/src/main/java/dev/rexijie/oauth/oauth2server/token/granter/CompositeTokenGranter.java +++ b/src/main/java/dev/rexijie/oauth/oauth2server/token/granter/CompositeTokenGranter.java @@ -30,7 +30,8 @@ public CompositeTokenGranter(TokenServices tokenServices, this.tokenGranterMap = Collections.synchronizedMap(Map.of( AuthorizationGrantType.PASSWORD, new ResourceOwnerPasswordCredentialsTokenGranter(tokenServices, userAuthenticationManager), AuthorizationGrantType.AUTHORIZATION_CODE, new AuthorizationCodeTokenGranter(tokenServices, authorizationCodeServices), - AuthorizationGrantType.CLIENT_CREDENTIALS, new ClientCredentialsTokenGranter(tokenServices, clientAuthenticationManager) + AuthorizationGrantType.CLIENT_CREDENTIALS, new ClientCredentialsTokenGranter(tokenServices, clientAuthenticationManager), + AuthorizationGrantType.REFRESH_TOKEN, new RefreshTokenGranter(tokenServices) )); } diff --git a/src/main/java/dev/rexijie/oauth/oauth2server/token/granter/RefreshTokenGranter.java b/src/main/java/dev/rexijie/oauth/oauth2server/token/granter/RefreshTokenGranter.java new file mode 100644 index 0000000..a4dde59 --- /dev/null +++ b/src/main/java/dev/rexijie/oauth/oauth2server/token/granter/RefreshTokenGranter.java @@ -0,0 +1,25 @@ +package dev.rexijie.oauth.oauth2server.token.granter; + +import dev.rexijie.oauth.oauth2server.api.domain.AuthorizationRequest; +import dev.rexijie.oauth.oauth2server.services.token.TokenServices; +import org.springframework.security.core.Authentication; +import org.springframework.security.oauth2.core.OAuth2Token; +import reactor.core.publisher.Mono; + +// TODO (Implement) +public class RefreshTokenGranter implements TokenGranter { + + public RefreshTokenGranter(TokenServices tokenServices) { + + } + + @Override + public Mono validateRequest(Authentication authentication, AuthorizationRequest authorizationRequest) { + return null; + } + + @Override + public Mono grantToken(Authentication authentication, AuthorizationRequest authorizationRequest) { + return null; + } +} diff --git a/src/test/java/dev/rexijie/oauth/oauth2server/api/constants/Endpoints.java b/src/test/java/dev/rexijie/oauth/oauth2server/api/constants/Endpoints.java new file mode 100644 index 0000000..465b85d --- /dev/null +++ b/src/test/java/dev/rexijie/oauth/oauth2server/api/constants/Endpoints.java @@ -0,0 +1,9 @@ +package dev.rexijie.oauth.oauth2server.api.constants; + +public interface Endpoints { + String OAUTH_BASE_PATH = "/oauth"; + String OIDC_BASE = "/openid"; + String API_BASE = "/api"; + String CLIENT_API_BASE = "/clients"; + String USER_API_BASE = "/users"; +}