100100import com .atomgraph .linkeddatahub .server .factory .ServiceFactory ;
101101import com .atomgraph .linkeddatahub .server .filter .request .OntologyFilter ;
102102import com .atomgraph .linkeddatahub .server .filter .request .AuthorizationFilter ;
103- import com .atomgraph .linkeddatahub .server .filter .request .auth .IDTokenFilter ;
104103import com .atomgraph .linkeddatahub .server .filter .request .ContentLengthLimitFilter ;
105- import com .atomgraph .linkeddatahub .server .filter .request .auth .ORCIDTokenFilter ;
106104import com .atomgraph .linkeddatahub .server .filter .request .auth .ProxiedWebIDFilter ;
107105import com .atomgraph .linkeddatahub .server .filter .response .CORSFilter ;
108106import com .atomgraph .linkeddatahub .server .filter .response .ResponseHeadersFilter ;
@@ -286,6 +284,7 @@ public class Application extends ResourceConfig
286284 private final List <Locale > supportedLanguages ;
287285 private final ExpiringMap <URI , Model > webIDmodelCache = ExpiringMap .builder ().expiration (1 , TimeUnit .DAYS ).build (); // TO-DO: config for the expiration period?
288286 private final ExpiringMap <String , Model > oidcModelCache = ExpiringMap .builder ().variableExpiration ().build ();
287+ private final ExpiringMap <String , jakarta .json .JsonObject > jwksCache = ExpiringMap .builder ().expiration (1 , TimeUnit .DAYS ).build (); // Cache JWKS responses
289288 private final Map <URI , XsltExecutable > xsltExecutableCache = new ConcurrentHashMap <>();
290289 private final MessageDigest messageDigest ;
291290 private final boolean enableWebIDSignUp ;
@@ -1002,11 +1001,24 @@ protected void configure()
10021001 protected void registerResourceClasses ()
10031002 {
10041003 register (Dispatcher .class );
1005- // OAuth endpoints - system-level resources not tied to dataspaces
1006- register (com .atomgraph .linkeddatahub .resource .oauth2 .google .Authorize .class );
1007- register (com .atomgraph .linkeddatahub .resource .oauth2 .google .Login .class );
1008- // register(com.atomgraph.linkeddatahub.resource.admin.oauth2.orcid.Authorize.class);
1009- // register(com.atomgraph.linkeddatahub.resource.admin.oauth2.orcid.Login.class);
1004+
1005+ // Conditionally register Google OAuth endpoints if configured
1006+ if (getProperty (com .atomgraph .linkeddatahub .vocabulary .Google .clientID .getURI ()) != null &&
1007+ getProperty (com .atomgraph .linkeddatahub .vocabulary .Google .clientSecret .getURI ()) != null )
1008+ {
1009+ register (com .atomgraph .linkeddatahub .resource .oauth2 .google .Authorize .class );
1010+ register (com .atomgraph .linkeddatahub .resource .oauth2 .google .Login .class );
1011+ if (log .isDebugEnabled ()) log .debug ("Google OAuth endpoints registered" );
1012+ }
1013+
1014+ // Conditionally register ORCID OAuth endpoints if configured
1015+ if (getProperty (com .atomgraph .linkeddatahub .vocabulary .ORCID .clientID .getURI ()) != null &&
1016+ getProperty (com .atomgraph .linkeddatahub .vocabulary .ORCID .clientSecret .getURI ()) != null )
1017+ {
1018+ register (com .atomgraph .linkeddatahub .resource .oauth2 .orcid .Authorize .class );
1019+ register (com .atomgraph .linkeddatahub .resource .oauth2 .orcid .Login .class );
1020+ if (log .isDebugEnabled ()) log .debug ("ORCID OAuth endpoints registered" );
1021+ }
10101022 }
10111023
10121024 /**
@@ -1018,11 +1030,25 @@ protected void registerContainerRequestFilters()
10181030 register (ApplicationFilter .class );
10191031 register (OntologyFilter .class );
10201032 register (ProxiedWebIDFilter .class );
1021- register (IDTokenFilter .class );
1022- register (ORCIDTokenFilter .class );
10231033 register (AuthorizationFilter .class );
10241034 if (getMaxContentLength () != null ) register (new ContentLengthLimitFilter (getMaxContentLength ()));
10251035 register (new RDFPostMediaTypeInterceptor ()); // for application/x-www-form-urlencoded
1036+
1037+ // Conditionally register Google OAuth filter if configured
1038+ if (getProperty (com .atomgraph .linkeddatahub .vocabulary .Google .clientID .getURI ()) != null &&
1039+ getProperty (com .atomgraph .linkeddatahub .vocabulary .Google .clientSecret .getURI ()) != null )
1040+ {
1041+ register (com .atomgraph .linkeddatahub .server .filter .request .auth .google .IDTokenFilter .class );
1042+ if (log .isDebugEnabled ()) log .debug ("Google OAuth filter registered" );
1043+ }
1044+
1045+ // Conditionally register ORCID OAuth filter if configured
1046+ if (getProperty (com .atomgraph .linkeddatahub .vocabulary .ORCID .clientID .getURI ()) != null &&
1047+ getProperty (com .atomgraph .linkeddatahub .vocabulary .ORCID .clientSecret .getURI ()) != null )
1048+ {
1049+ register (com .atomgraph .linkeddatahub .server .filter .request .auth .orcid .IDTokenFilter .class );
1050+ if (log .isDebugEnabled ()) log .debug ("ORCID OAuth filter registered" );
1051+ }
10261052 }
10271053
10281054 /**
@@ -2050,18 +2076,29 @@ public ExpiringMap<URI, Model> getWebIDModelCache()
20502076 /**
20512077 * A map of cached OpenID connect agent graphs.
20522078 * User ID (ID token subject) is the cache key. Entries expire after the configured period of time.
2053- *
2079+ *
20542080 * @return URI to model map
20552081 */
20562082 public ExpiringMap <String , Model > getOIDCModelCache ()
20572083 {
20582084 return oidcModelCache ;
20592085 }
2060-
2086+
2087+ /**
2088+ * A map of cached JWKS (JSON Web Key Set) responses for JWT verification.
2089+ * JWKS endpoint URI is the cache key. Entries expire after 1 day.
2090+ *
2091+ * @return JWKS endpoint to JsonObject map
2092+ */
2093+ public ExpiringMap <String , jakarta .json .JsonObject > getJWKSCache ()
2094+ {
2095+ return jwksCache ;
2096+ }
2097+
20612098 /**
20622099 * A map of cached (compiled) XSLT stylesheets.
20632100 * Stylesheet URI is the cache key.
2064- *
2101+ *
20652102 * @return URI to stylesheet map
20662103 */
20672104 public Map <URI , XsltExecutable > getXsltExecutableCache ()
0 commit comments