This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 995baba8cf59810a988b2f08a75956f0ce068b91 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 5d7e3765b7..46c4c96c5e 100644 --- a/java/org/apache/catalina/authenticator/jaspic/LocalStrings.properties +++ b/java/org/apache/catalina/authenticator/jaspic/LocalStrings.properties @@ -27,6 +27,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 3f9d8095f3..2b8c405ded 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -117,6 +117,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