This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new b0d0efa885 Follow-up to o.a.c.realm code review
b0d0efa885 is described below
commit b0d0efa8854a66913d1b54f7a2c41b38ce2c7675
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Jun 15 20:53:38 2026 +0100
Follow-up to o.a.c.realm code review
---
java/org/apache/catalina/realm/JAASRealm.java | 3 +--
java/org/apache/catalina/realm/JNDIRealm.java | 7 +++++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/catalina/realm/JAASRealm.java
b/java/org/apache/catalina/realm/JAASRealm.java
index afd3521c72..ef6efb16ee 100644
--- a/java/org/apache/catalina/realm/JAASRealm.java
+++ b/java/org/apache/catalina/realm/JAASRealm.java
@@ -633,16 +633,15 @@ public class JAASRealm extends RealmBase {
try (ConfigurationSource.Resource configFileResource =
ConfigFileLoader.getSource().getResource(configFile)) {
config =
constructor.newInstance(configFileResource.getURI());
- this.jaasConfigurationLoaded = true;
} catch (IOException ioe) {
throw new
RuntimeException(sm.getString("jaasRealm.configFileNotFound", configFile));
}
} else {
URI uri = resource.toURI();
config = constructor.newInstance(uri);
- this.jaasConfigurationLoaded = true;
}
this.jaasConfiguration = config;
+ this.jaasConfigurationLoaded = true;
return this.jaasConfiguration;
}
} catch (InvocationTargetException ex) {
diff --git a/java/org/apache/catalina/realm/JNDIRealm.java
b/java/org/apache/catalina/realm/JNDIRealm.java
index 874d2258f0..824db3f127 100644
--- a/java/org/apache/catalina/realm/JNDIRealm.java
+++ b/java/org/apache/catalina/realm/JNDIRealm.java
@@ -19,6 +19,7 @@ package org.apache.catalina.realm;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.Principal;
@@ -2325,8 +2326,10 @@ public class JNDIRealm extends RealmBase {
while (e.hasMore()) {
Object value = e.next();
String valueString;
- if (value instanceof byte[]) {
- valueString = new String((byte[]) value);
+ if (value == null) {
+ valueString = null;
+ } else if (value instanceof byte[]) {
+ valueString = new String((byte[]) value,
StandardCharsets.UTF_8);
} else {
valueString = value.toString();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]