-
Notifications
You must be signed in to change notification settings - Fork 6
Make path to oslcOAuthStore.xml configurable via ENV var. #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -76,7 +76,15 @@ public class AuthenticationApplication implements Application { | |||||||||||||||||||
| private AuthenticationApplication() { | ||||||||||||||||||||
| // Start of user code constructor_init | ||||||||||||||||||||
| // End of user code | ||||||||||||||||||||
| var AUTH_VAR = "OAUTH_STORE_FILE"; | ||||||||||||||||||||
| final Map<String, String> env = System.getenv(); | ||||||||||||||||||||
|
||||||||||||||||||||
| oslcConsumerStoreFilename= "./oslcOAuthStore.xml"; | ||||||||||||||||||||
|
||||||||||||||||||||
| oslcConsumerStoreFilename= "./oslcOAuthStore.xml"; | |
| oslcConsumerStoreFilename = "./oslcOAuthStore.xml"; |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variable value should be validated to ensure it's not empty or blank. Following the pattern used in ServletListener.getConfigurationPropertyFromEnvironment (line 184), consider checking if the value is null or blank using value.trim().isEmpty() before using it. An empty environment variable value could lead to a file not found error with an unclear cause.
| oslcConsumerStoreFilename = env.get(AUTH_VAR); | |
| log.debug("ENV variable '{}' found", AUTH_VAR); | |
| final String value = env.get(AUTH_VAR); | |
| if (value != null && !value.trim().isEmpty()) { | |
| oslcConsumerStoreFilename = value; | |
| log.debug("ENV variable '{}' found with non-blank value", AUTH_VAR); | |
| } else { | |
| log.warn("ENV variable '{}' is defined but blank; using default '{}'", AUTH_VAR, oslcConsumerStoreFilename); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -76,7 +76,15 @@ public class AuthenticationApplication implements Application { | |||||
| private AuthenticationApplication() { | ||||||
| // Start of user code constructor_init | ||||||
| // End of user code | ||||||
| var AUTH_VAR = "OAUTH_STORE_FILE"; | ||||||
|
||||||
| final Map<String, String> env = System.getenv(); | ||||||
|
||||||
| oslcConsumerStoreFilename= "./oslcOAuthStore.xml"; | ||||||
|
||||||
| oslcConsumerStoreFilename= "./oslcOAuthStore.xml"; | |
| oslcConsumerStoreFilename = "./oslcOAuthStore.xml"; |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variable value should be validated to ensure it's not empty or blank. Following the pattern used in ServletListener.getConfigurationPropertyFromEnvironment (line 184), consider checking if the value is null or blank using value.trim().isEmpty() before using it. An empty environment variable value could lead to a file not found error with an unclear cause.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -76,7 +76,15 @@ public class AuthenticationApplication implements Application { | |||||||||||||||||||
| private AuthenticationApplication() { | ||||||||||||||||||||
| // Start of user code constructor_init | ||||||||||||||||||||
| // End of user code | ||||||||||||||||||||
| var AUTH_VAR = "OAUTH_STORE_FILE"; | ||||||||||||||||||||
|
||||||||||||||||||||
| final Map<String, String> env = System.getenv(); | ||||||||||||||||||||
|
||||||||||||||||||||
| oslcConsumerStoreFilename= "./oslcOAuthStore.xml"; | ||||||||||||||||||||
|
||||||||||||||||||||
| oslcConsumerStoreFilename= "./oslcOAuthStore.xml"; | |
| oslcConsumerStoreFilename = "./oslcOAuthStore.xml"; |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map is referenced here (final Map<String, String> env = System.getenv();) but this file does not import java.util.Map, which will fail compilation. Either add the missing import (ideally in the user-code imports section) or avoid Map entirely by calling System.getenv(AUTH_VAR) directly.
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variable value should be validated to ensure it's not empty or blank. Following the pattern used in ServletListener.getConfigurationPropertyFromEnvironment (line 184), consider checking if the value is null or blank using value.trim().isEmpty() before using it. An empty environment variable value could lead to a file not found error with an unclear cause.
| oslcConsumerStoreFilename = env.get(AUTH_VAR); | |
| log.debug("ENV variable '{}' found", AUTH_VAR); | |
| final String envValue = env.get(AUTH_VAR); | |
| if (envValue != null && !envValue.trim().isEmpty()) { | |
| oslcConsumerStoreFilename = envValue; | |
| log.debug("ENV variable '{}' found, using value '{}'", AUTH_VAR, oslcConsumerStoreFilename); | |
| } else { | |
| log.warn("ENV variable '{}' is defined but empty or blank; using default store filename '{}'", AUTH_VAR, oslcConsumerStoreFilename); | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,7 +76,15 @@ public class AuthenticationApplication implements Application { | |
| private AuthenticationApplication() { | ||
| // Start of user code constructor_init | ||
| // End of user code | ||
| oslcConsumerStoreFilename= "./oslcOAuthStore.xml"; | ||
| var AUTH_VAR = "OAUTH_STORE_FILE"; | ||
|
||
| final Map<String, String> env = System.getenv(); | ||
|
||
| oslcConsumerStoreFilename = "./oslcOAuthStore.xml"; | ||
| if (env.containsKey(AUTH_VAR)) { | ||
| oslcConsumerStoreFilename = env.get(AUTH_VAR); | ||
|
Comment on lines
+82
to
+83
|
||
| log.debug("ENV variable '{}' found", AUTH_VAR); | ||
| } else { | ||
| log.debug("ENV variable '{}' not defined", AUTH_VAR); | ||
| } | ||
| oauth1TokenToApplicationConnector = new LRUCache<String, String>(2000); | ||
| // Start of user code constructor_finalize | ||
| // End of user code | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The local variable AUTH_VAR should follow Java naming conventions for constants. Since this is effectively a constant value, it should be declared as a static final field at the class level (like other constants in this class such as APPLICATION_NAME, OAUTH_REALM, etc.) rather than as a local variable with 'var'. Consider declaring it as: private static final String OAUTH_STORE_ENV_VAR = "OAUTH_STORE_FILE";