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


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 5d803af53d Code clean-up - formatting. No functional change.
5d803af53d is described below

commit 5d803af53db8423426a4014a5f8f31e35bc94928
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri May 23 11:49:52 2025 +0100

    Code clean-up - formatting. No functional change.
---
 .../util/security/ConcurrentMessageDigest.java     | 18 +++-----
 java/org/apache/tomcat/util/security/Escape.java   | 52 +++++++++-------------
 .../apache/tomcat/util/security/KeyStoreUtil.java  | 22 ++++-----
 .../apache/tomcat/util/security/MD5Encoder.java    | 15 +++----
 .../tomcat/util/security/PermissionCheck.java      | 19 ++++----
 .../PrivilegedSetAccessControlContext.java         |  2 +-
 6 files changed, 53 insertions(+), 75 deletions(-)

diff --git a/java/org/apache/tomcat/util/security/ConcurrentMessageDigest.java 
b/java/org/apache/tomcat/util/security/ConcurrentMessageDigest.java
index 45dc4ae48c..9404f55044 100644
--- a/java/org/apache/tomcat/util/security/ConcurrentMessageDigest.java
+++ b/java/org/apache/tomcat/util/security/ConcurrentMessageDigest.java
@@ -28,9 +28,8 @@ import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
- * A thread safe wrapper around {@link MessageDigest} that does not make use
- * of ThreadLocal and - broadly - only creates enough MessageDigest objects
- * to satisfy the concurrency requirements.
+ * A thread safe wrapper around {@link MessageDigest} that does not make use 
of ThreadLocal and - broadly - only creates
+ * enough MessageDigest objects to satisfy the concurrency requirements.
  */
 public class ConcurrentMessageDigest {
 
@@ -40,8 +39,7 @@ public class ConcurrentMessageDigest {
     private static final String MD5 = "MD5";
     private static final String SHA1 = "SHA-1";
 
-    private static final Map<String,Queue<MessageDigest>> queues =
-            new ConcurrentHashMap<>();
+    private static final Map<String,Queue<MessageDigest>> queues = new 
ConcurrentHashMap<>();
 
 
     private ConcurrentMessageDigest() {
@@ -56,7 +54,7 @@ public class ConcurrentMessageDigest {
             log.warn(sm.getString("concurrentMessageDigest.noDigest"), e);
         }
         try {
-           init(SHA1);
+            init(SHA1);
         } catch (NoSuchAlgorithmException e) {
             throw new 
IllegalArgumentException(sm.getString("concurrentMessageDigest.noDigest"), e);
         }
@@ -114,14 +112,12 @@ public class ConcurrentMessageDigest {
 
 
     /**
-     * Ensures that {@link #digest(String, byte[][])} will support the 
specified
-     * algorithm. This method <b>must</b> be called and return successfully
-     * before using {@link #digest(String, byte[][])}.
+     * Ensures that {@link #digest(String, byte[][])} will support the 
specified algorithm. This method <b>must</b> be
+     * called and return successfully before using {@link #digest(String, 
byte[][])}.
      *
      * @param algorithm The message digest algorithm to be supported
      *
-     * @throws NoSuchAlgorithmException If the algorithm is not supported by 
the
-     *                                  JVM
+     * @throws NoSuchAlgorithmException If the algorithm is not supported by 
the JVM
      */
     public static void init(String algorithm) throws NoSuchAlgorithmException {
         if (!queues.containsKey(algorithm)) {
diff --git a/java/org/apache/tomcat/util/security/Escape.java 
b/java/org/apache/tomcat/util/security/Escape.java
index 54e3835cae..5bdf8b8276 100644
--- a/java/org/apache/tomcat/util/security/Escape.java
+++ b/java/org/apache/tomcat/util/security/Escape.java
@@ -17,9 +17,8 @@
 package org.apache.tomcat.util.security;
 
 /**
- * Provides utility methods to escape content for different contexts. It is
- * critical that the escaping used is correct for the context in which the data
- * is to be used.
+ * Provides utility methods to escape content for different contexts. It is 
critical that the escaping used is correct
+ * for the context in which the data is to be used.
  */
 public class Escape {
 
@@ -29,19 +28,16 @@ public class Escape {
 
 
     /**
-     * Escape content for use in HTML. This escaping is suitable for the
-     * following uses:
+     * Escape content for use in HTML. This escaping is suitable for the 
following uses:
      * <ul>
-     * <li>Element content when the escaped data will be placed directly inside
-     *     tags such as &lt;p&gt;, &lt;td&gt; etc.</li>
-     * <li>Attribute values when the attribute value is quoted with &quot; or
-     *     &#x27;.</li>
+     * <li>Element content when the escaped data will be placed directly 
inside tags such as &lt;p&gt;, &lt;td&gt;
+     * etc.</li>
+     * <li>Attribute values when the attribute value is quoted with &quot; or 
&#x27;.</li>
      * </ul>
      *
-     * @param content   The content to escape
+     * @param content The content to escape
      *
-     * @return  The escaped content or {@code null} if the content was
-     *          {@code null}
+     * @return The escaped content or {@code null} if the content was {@code 
null}
      */
     public static String htmlElementContent(String content) {
         if (content == null) {
@@ -74,13 +70,12 @@ public class Escape {
 
 
     /**
-     * Convert the object to a string via {@link Object#toString()} and HTML
-     * escape the resulting string for use in HTML content.
+     * Convert the object to a string via {@link Object#toString()} and HTML 
escape the resulting string for use in HTML
+     * content.
      *
-     * @param obj       The object to convert to String and then escape
+     * @param obj The object to convert to String and then escape
      *
-     * @return The escaped content or <code>&quot;?&quot;</code> if obj is
-     *         {@code null}
+     * @return The escaped content or <code>&quot;?&quot;</code> if obj is 
{@code null}
      */
     public static String htmlElementContent(Object obj) {
         if (obj == null) {
@@ -93,10 +88,9 @@ public class Escape {
     /**
      * Escape content for use in XML.
      *
-     * @param content   The content to escape
+     * @param content The content to escape
      *
-     * @return  The escaped content or {@code null} if the content was
-     *          {@code null}
+     * @return The escaped content or {@code null} if the content was {@code 
null}
      */
     public static String xml(String content) {
         return xml(null, content);
@@ -106,11 +100,10 @@ public class Escape {
     /**
      * Escape content for use in XML.
      *
-     * @param ifNull    The value to return if content is {@code null}
-     * @param content   The content to escape
+     * @param ifNull  The value to return if content is {@code null}
+     * @param content The content to escape
      *
-     * @return  The escaped content or the value of {@code ifNull} if the
-     *          content was {@code null}
+     * @return The escaped content or the value of {@code ifNull} if the 
content was {@code null}
      */
     public static String xml(String ifNull, String content) {
         return xml(ifNull, false, content);
@@ -120,12 +113,11 @@ public class Escape {
     /**
      * Escape content for use in XML.
      *
-     * @param ifNull        The value to return if content is {@code null}
-     * @param escapeCRLF    Should CR and LF also be escaped?
-     * @param content       The content to escape
+     * @param ifNull     The value to return if content is {@code null}
+     * @param escapeCRLF Should CR and LF also be escaped?
+     * @param content    The content to escape
      *
-     * @return  The escaped content or the value of ifNull if the content was
-     *          {@code null}
+     * @return The escaped content or the value of ifNull if the content was 
{@code null}
      */
     public static String xml(String ifNull, boolean escapeCRLF, String 
content) {
         if (content == null) {
@@ -155,6 +147,6 @@ public class Escape {
             }
         }
 
-        return (sb.length() > content.length()) ? sb.toString(): content;
+        return (sb.length() > content.length()) ? sb.toString() : content;
     }
 }
diff --git a/java/org/apache/tomcat/util/security/KeyStoreUtil.java 
b/java/org/apache/tomcat/util/security/KeyStoreUtil.java
index 862ef22967..d4c7a0c9f0 100644
--- a/java/org/apache/tomcat/util/security/KeyStoreUtil.java
+++ b/java/org/apache/tomcat/util/security/KeyStoreUtil.java
@@ -32,23 +32,17 @@ public class KeyStoreUtil {
 
     /**
      * Loads a KeyStore from an InputStream working around the known JDK bug
-     * https://bugs.openjdk.java.net/browse/JDK-8157404.
+     * https://bugs.openjdk.java.net/browse/JDK-8157404. This code can be 
removed once the minimum Java version for
+     * Tomcat is 13.
      *
-     * This code can be removed once the minimum Java version for Tomcat is 13.
-     *
-     *
-     * @param keystore The KeyStore to load from the InputStream
-     * @param is The InputStream to use to populate the KeyStore
+     * @param keystore  The KeyStore to load from the InputStream
+     * @param is        The InputStream to use to populate the KeyStore
      * @param storePass The password to access the KeyStore
      *
-     * @throws IOException
-     *              If an I/O occurs reading from the given InputStream
-     * @throws CertificateException
-     *              If one or more certificates can't be loaded into the
-     *              KeyStore
-     * @throws NoSuchAlgorithmException
-     *              If the algorithm specified to validate the integrity of the
-     *              KeyStore cannot be found
+     * @throws IOException              If an I/O occurs reading from the 
given InputStream
+     * @throws CertificateException     If one or more certificates can't be 
loaded into the KeyStore
+     * @throws NoSuchAlgorithmException If the algorithm specified to validate 
the integrity of the KeyStore cannot be
+     *                                      found
      */
     public static void load(KeyStore keystore, InputStream is, char[] 
storePass)
             throws NoSuchAlgorithmException, CertificateException, IOException 
{
diff --git a/java/org/apache/tomcat/util/security/MD5Encoder.java 
b/java/org/apache/tomcat/util/security/MD5Encoder.java
index c42f3e3403..f038651a63 100644
--- a/java/org/apache/tomcat/util/security/MD5Encoder.java
+++ b/java/org/apache/tomcat/util/security/MD5Encoder.java
@@ -21,9 +21,8 @@ import org.apache.tomcat.util.buf.HexUtils;
 /**
  * Encode an MD5 digest into a String.
  * <p>
- * The 128 bit MD5 hash is converted into a 32 character long String.
- * Each character of the String is the hexadecimal representation of 4 bits
- * of the digest.
+ * The 128 bit MD5 hash is converted into a 32 character long String. Each 
character of the String is the hexadecimal
+ * representation of 4 bits of the digest.
  *
  * @author Remy Maucherat
  *
@@ -38,8 +37,8 @@ public final class MD5Encoder {
     }
 
 
-    private static final char[] hexadecimal = {'0', '1', '2', '3', '4', '5',
-        '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+    private static final char[] hexadecimal =
+            { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 
'd', 'e', 'f' };
 
 
     /**
@@ -57,11 +56,11 @@ public final class MD5Encoder {
 
         char[] buffer = new char[32];
 
-        for (int i=0; i<16; i++) {
+        for (int i = 0; i < 16; i++) {
             int low = binaryData[i] & 0x0f;
             int high = (binaryData[i] & 0xf0) >> 4;
-            buffer[i*2] = hexadecimal[high];
-            buffer[i*2 + 1] = hexadecimal[low];
+            buffer[i * 2] = hexadecimal[high];
+            buffer[i * 2 + 1] = hexadecimal[low];
         }
 
         return new String(buffer);
diff --git a/java/org/apache/tomcat/util/security/PermissionCheck.java 
b/java/org/apache/tomcat/util/security/PermissionCheck.java
index c2a9b86cbd..45fe418e12 100644
--- a/java/org/apache/tomcat/util/security/PermissionCheck.java
+++ b/java/org/apache/tomcat/util/security/PermissionCheck.java
@@ -19,15 +19,12 @@ package org.apache.tomcat.util.security;
 import java.security.Permission;
 
 /**
- * This interface is implemented by components to enable privileged code to
- * check whether the component has a given permission.
- * This is typically used when a privileged component (e.g. the container) is
- * performing an action on behalf of an untrusted component (e.g. a web
- * application) without the current thread having passed through a code source
- * provided by the untrusted component. Because the current thread has not
- * passed through a code source provided by the untrusted component the
- * SecurityManager assumes the code is trusted so the standard checking
- * mechanisms can't be used.
+ * This interface is implemented by components to enable privileged code to 
check whether the component has a given
+ * permission. This is typically used when a privileged component (e.g. the 
container) is performing an action on behalf
+ * of an untrusted component (e.g. a web application) without the current 
thread having passed through a code source
+ * provided by the untrusted component. Because the current thread has not 
passed through a code source provided by the
+ * untrusted component the SecurityManager assumes the code is trusted so the 
standard checking mechanisms can't be
+ * used.
  */
 public interface PermissionCheck {
 
@@ -36,8 +33,8 @@ public interface PermissionCheck {
      *
      * @param permission The permission to test
      *
-     * @return {@code false} if a SecurityManager is enabled and the component
-     *         does not have the given permission, otherwise {@code true}
+     * @return {@code false} if a SecurityManager is enabled and the component 
does not have the given permission,
+     *             otherwise {@code true}
      */
     boolean check(Permission permission);
 }
diff --git 
a/java/org/apache/tomcat/util/security/PrivilegedSetAccessControlContext.java 
b/java/org/apache/tomcat/util/security/PrivilegedSetAccessControlContext.java
index 9f9f4c9d74..1f9f3a2051 100644
--- 
a/java/org/apache/tomcat/util/security/PrivilegedSetAccessControlContext.java
+++ 
b/java/org/apache/tomcat/util/security/PrivilegedSetAccessControlContext.java
@@ -57,7 +57,7 @@ public class PrivilegedSetAccessControlContext implements 
PrivilegedAction<Void>
     public Void run() {
         try {
             if (field != null) {
-                field.set(t,  acc);
+                field.set(t, acc);
             }
         } catch (IllegalArgumentException | IllegalAccessException e) {
             
log.warn(sm.getString("privilegedSetAccessControlContext.setFailed"), e);


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to