This is an automated email from the ASF dual-hosted git repository.

rmaucher pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 134b3dacc0 Add test for Jasper security classload
134b3dacc0 is described below

commit 134b3dacc093ff0e25e02efd52f8a9f9247b40fc
Author: remm <[email protected]>
AuthorDate: Tue Jun 30 16:00:43 2026 +0200

    Add test for Jasper security classload
    
    It is quite easy to break otherwise.
---
 .../apache/jasper/security/SecurityClassLoad.java  |  9 ++++++--
 .../jasper/security/TestSecurityClassLoad.java     | 27 ++++++++++++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/jasper/security/SecurityClassLoad.java 
b/java/org/apache/jasper/security/SecurityClassLoad.java
index 3faf2aa9d1..9fb3438124 100644
--- a/java/org/apache/jasper/security/SecurityClassLoad.java
+++ b/java/org/apache/jasper/security/SecurityClassLoad.java
@@ -26,9 +26,14 @@ import org.apache.juli.logging.LogFactory;
  */
 public final class SecurityClassLoad {
 
-    public static void securityClassLoad(ClassLoader loader) {
+    public static void securityClassLoad(ClassLoader loader) throws Exception {
+        securityClassLoad(loader, true);
+    }
+
+
+    static void securityClassLoad(ClassLoader loader, boolean 
requireSecurityManager) throws Exception {
 
-        if (System.getSecurityManager() == null) {
+        if (requireSecurityManager && System.getSecurityManager() == null) {
             return;
         }
 
diff --git a/test/org/apache/jasper/security/TestSecurityClassLoad.java 
b/test/org/apache/jasper/security/TestSecurityClassLoad.java
new file mode 100644
index 0000000000..e7992ec5db
--- /dev/null
+++ b/test/org/apache/jasper/security/TestSecurityClassLoad.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jasper.security;
+
+import org.junit.Test;
+
+public class TestSecurityClassLoad {
+
+    @Test
+    public void testLoad() throws Exception {
+        
SecurityClassLoad.securityClassLoad(Thread.currentThread().getContextClassLoader(),
 false);
+    }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to