nscendoni commented on code in PR #32:
URL: 
https://github.com/apache/sling-org-apache-sling-auth-oauth-client/pull/32#discussion_r2451720677


##########
src/main/java/org/apache/sling/auth/oauth_client/impl/OidcConnectionImpl.java:
##########
@@ -57,11 +67,56 @@ String webconsole_configurationFactory_nameHint() default
 
     private final Config cfg;
     private final OidcProviderMetadataRegistry metadataRegistry;
+    private final String authorizationEndpoint;
+    private final String tokenEndpoint;
+    private final String userInfoUrl;
+    private final String jwkSetURL;
+    private final String issuer;
+    private final boolean hasBaseUrl;
 
     @Activate
     public OidcConnectionImpl(Config cfg, @Reference 
OidcProviderMetadataRegistry metadataRegistry) {
         this.cfg = cfg;
         this.metadataRegistry = metadataRegistry;
+        this.authorizationEndpoint = cfg.authorizationEndpoint();
+        this.tokenEndpoint = cfg.tokenEndpoint();
+        this.userInfoUrl = cfg.userInfoUrl();
+        this.jwkSetURL = cfg.jwkSetURL();
+        this.issuer = cfg.issuer();
+
+        // Validate configuration: either baseUrl is provided OR all explicit 
endpoints are provided
+        hasBaseUrl = !isNullOrEmpty(cfg.baseUrl());
+
+        if (hasBaseUrl
+                && !isNullOrEmpty(tokenEndpoint)
+                && !isNullOrEmpty(authorizationEndpoint)
+                && !isNullOrEmpty(userInfoUrl)
+                && !isNullOrEmpty(jwkSetURL)
+                && !isNullOrEmpty(issuer)) {
+            throw new IllegalArgumentException(
+                    "Either baseUrl OR explicit endpoints "
+                            + "(authorizationEndpoint, tokenEndpoint, 
userInfoUrl, jwkSetURL, issuer) must be provided, not both");
+        }
+
+        if (!hasBaseUrl
+                && isNullOrEmpty(tokenEndpoint)
+                && isNullOrEmpty(authorizationEndpoint)
+                && isNullOrEmpty(userInfoUrl)
+                && isNullOrEmpty(jwkSetURL)
+                && isNullOrEmpty(issuer)) {

Review Comment:
   Thanks @anchela ! I addressed this comment, I did a small refactoring and 
increased test coverage
   
   
   
   
   
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to