This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit a731053ef7b17afba2cda86612b8fad5112c5430 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Sep 19 14:57:29 2024 +0100 Create dirs if required when persisting Jakarta Auth provider config Unlikely to be required when running in Tomcat. Is required when running the TCK since the persistence mechanism is used outside of Tomcat and the dirs don.t exist. --- .../apache/catalina/authenticator/jaspic/LocalStrings.properties | 1 + .../authenticator/jaspic/PersistentProviderRegistrations.java | 7 +++++++ webapps/docs/changelog.xml | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/java/org/apache/catalina/authenticator/jaspic/LocalStrings.properties b/java/org/apache/catalina/authenticator/jaspic/LocalStrings.properties index 1930492629..7a3b0ece4a 100644 --- a/java/org/apache/catalina/authenticator/jaspic/LocalStrings.properties +++ b/java/org/apache/catalina/authenticator/jaspic/LocalStrings.properties @@ -29,6 +29,7 @@ jaspicAuthenticator.authenticate=Authenticating request for [{0}] via JASPIC persistentProviderRegistrations.deleteFail=The temporary file [{0}] cannot be deleted persistentProviderRegistrations.existsDeleteFail=The temporary file [{0}] already exists and cannot be deleted +persistentProviderRegistrations.mkdirsFail=The directory for the persistent provider registrations [{0}] cannot be created persistentProviderRegistrations.moveFail=Failed to move [{0}] to [{1}] persistentProviderRegistrations.xmlFeatureEncoding=Exception configuring JASPIC to permit java encoding names in XML configuration files. Only IANA encoding names will be supported. diff --git a/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java b/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java index 40845783a0..2766807d9d 100644 --- a/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java +++ b/java/org/apache/catalina/authenticator/jaspic/PersistentProviderRegistrations.java @@ -94,6 +94,7 @@ public final class PersistentProviderRegistrations { static void writeProviders(Providers providers, File configFile) { File configFileOld = new File(configFile.getAbsolutePath() + ".old"); File configFileNew = new File(configFile.getAbsolutePath() + ".new"); + File configParent = configFileNew.getParentFile(); // Remove left over temporary files if present if (configFileOld.exists()) { @@ -108,6 +109,12 @@ public final class PersistentProviderRegistrations { configFileNew.getAbsolutePath())); } } + if (!configParent.exists()) { + if (!configParent.mkdirs()) { + throw new SecurityException(sm.getString("persistentProviderRegistrations.mkdirsFail", + configParent.getAbsolutePath())); + } + } // Write out the providers to the temporary new file try (OutputStream fos = new FileOutputStream(configFileNew); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 310f6fd041..8fade95db0 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -122,6 +122,11 @@ explicitly set the HTTP response status to 500 as the <code>ServerAuthContext</code> may not have set it. (markt) </fix> + <fix> + When persisting the Jakarta Authentication provider configuration, + create any necessary parent directories that don't already exist. + (markt) + </fix> </changelog> </subsection> </section> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org