Re: (tomcat) 01/06: Remove unused code - thanks to UCDetector

2024-04-15 Thread Christopher Schultz

Mark,

On 4/15/24 11:13, Mark Thomas wrote:

On 05/04/2024 12:55, Mark Thomas wrote:

5 Apr 2024 04:33:42 Christopher Schultz :


Mark,

Can't this entire class be replaced with calls to 
java.util.Base64.get*Encoder and java.util.Base64.get*Decoder 
wherever necessary?


Now that 9.0.x is oldest, we should be able to use java.util.Base64 
from Java 1.8+


Possibly. There is a commit from 2.0.x that does that that we could 
back port.


The one thing I wanted to check was that the Tomcat one was stricter 
for URL safe Vs non URL safe. I wasn't sure how that applied here.


My main concern was aligning 9.0.x through 11.0.x which is now done. 
Improvements like this were next on the TODO list for File upload.


I've done more checks and it was the commons implementation that used 
the same decoder for standard and URL-safe. The Java implementation has 
specific decoders for each.


It looks like we can remove the o.a.tomcat.util.codec.binary package 
completely. I'll take a look. If it is possible then the plan would be 
remove in 11.0.x and deprecate in 10.1.x and earlier just in case 
someone is using the Tomcat internals directly.


+1

-chris

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



Re: (tomcat) 01/06: Remove unused code - thanks to UCDetector

2024-04-15 Thread Mark Thomas

On 05/04/2024 12:55, Mark Thomas wrote:

5 Apr 2024 04:33:42 Christopher Schultz :


Mark,

Can't this entire class be replaced with calls to 
java.util.Base64.get*Encoder and java.util.Base64.get*Decoder wherever 
necessary?


Now that 9.0.x is oldest, we should be able to use java.util.Base64 
from Java 1.8+


Possibly. There is a commit from 2.0.x that does that that we could back 
port.


The one thing I wanted to check was that the Tomcat one was stricter for 
URL safe Vs non URL safe. I wasn't sure how that applied here.


My main concern was aligning 9.0.x through 11.0.x which is now done. 
Improvements like this were next on the TODO list for File upload.


I've done more checks and it was the commons implementation that used 
the same decoder for standard and URL-safe. The Java implementation has 
specific decoders for each.


It looks like we can remove the o.a.tomcat.util.codec.binary package 
completely. I'll take a look. If it is possible then the plan would be 
remove in 11.0.x and deprecate in 10.1.x and earlier just in case 
someone is using the Tomcat internals directly.


Mark

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



Re: (tomcat) 01/06: Remove unused code - thanks to UCDetector

2024-04-05 Thread Mark Thomas

5 Apr 2024 04:33:42 Christopher Schultz :


Mark,

Can't this entire class be replaced with calls to 
java.util.Base64.get*Encoder and java.util.Base64.get*Decoder wherever 
necessary?


Now that 9.0.x is oldest, we should be able to use java.util.Base64 
from Java 1.8+


Possibly. There is a commit from 2.0.x that does that that we could back 
port.


The one thing I wanted to check was that the Tomcat one was stricter for 
URL safe Vs non URL safe. I wasn't sure how that applied here.


My main concern was aligning 9.0.x through 11.0.x which is now done. 
Improvements like this were next on the TODO list for File upload.


Mark




?

-chris

On 4/4/24 15:52, ma...@apache.org wrote:

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 1a2f722e405ec17c5dab5fac43ae2fe63eb8fbce
Author: Mark Thomas 
AuthorDate: Fri Jun 17 12:29:10 2022 +0100
 Remove unused code - thanks to UCDetector
---
  .../apache/tomcat/util/codec/binary/Base64.java    | 155 
-
  .../tomcat/util/codec/binary/BaseNCodec.java   |  88 


  2 files changed, 243 deletions(-)
diff --git a/java/org/apache/tomcat/util/codec/binary/Base64.java 
b/java/org/apache/tomcat/util/codec/binary/Base64.java

index a733df9937..e38bf3df17 100644
--- a/java/org/apache/tomcat/util/codec/binary/Base64.java
+++ b/java/org/apache/tomcat/util/codec/binary/Base64.java
@@ -16,9 +16,6 @@
   */
  package org.apache.tomcat.util.codec.binary;
  -import java.math.BigInteger;
-import java.util.Objects;
-
  /**
   * Provides Base64 encoding and decoding as defined by href="http://www.ietf.org/rfc/rfc2045.txt;>RFC 2045.

   *
@@ -141,20 +138,6 @@ public class Base64 extends BaseNCodec {
  // The private member fields below are used with the new 
streaming approach, which requires
  // some state be preserved between calls of encode() and 
decode().

  -    /**
- * Decodes Base64 data into octets.
- * 
- * Note: this method seamlessly handles data encoded in 
URL-safe or normal mode.

- * 
- *
- * @param base64Data
- *    Byte array containing Base64 data
- * @return Array containing decoded data.
- */
-    public static byte[] decodeBase64(final byte[] base64Data) {
-    return decodeBase64(base64Data, 0, base64Data.length);
-    }
-
  public  static byte[] decodeBase64(
  final byte[] base64Data, final int off, final int len) {
  return new Base64().decode(base64Data, off, len);
@@ -180,29 +163,6 @@ public class Base64 extends BaseNCodec {
  }
    // Implementation of integer encoding used for crypto
-    /**
- * Decodes a byte64-encoded integer according to crypto standards 
such as W3C's XML-Signature.

- *
- * @param pArray
- *    a byte array containing base64 character data
- * @return A BigInteger
- * @since 1.4
- */
-    public static BigInteger decodeInteger(final byte[] pArray) {
-    return new BigInteger(1, decodeBase64(pArray));
-    }
-
-    /**
- * Encodes binary data using the base64 algorithm but does not 
chunk the output.

- *
- * @param binaryData
- *    binary data to encode
- * @return byte[] containing Base64 characters in their UTF-8 
representation.

- */
-    public static byte[] encodeBase64(final byte[] binaryData) {
-    return encodeBase64(binaryData, false);
-    }
-
  /**
   * Encodes binary data using the base64 algorithm, optionally 
chunking the output into 76 character blocks.

   *
@@ -272,17 +232,6 @@ public class Base64 extends BaseNCodec {
  return b64.encode(binaryData);
  }
  -    /**
- * Encodes binary data using the base64 algorithm and chunks the 
encoded output into 76 character blocks

- *
- * @param binaryData
- *    binary data to encode
- * @return Base64 characters chunked in 76 character blocks
- */
-    public static byte[] encodeBase64Chunked(final byte[] binaryData) 
{

-    return encodeBase64(binaryData, true);
-    }
-
  /**
   * Encodes binary data using the base64 algorithm but does not 
chunk the output.

   *
@@ -298,19 +247,6 @@ public class Base64 extends BaseNCodec {
  return StringUtils.newStringUsAscii(encodeBase64(binaryData, 
false));

  }
  -    /**
- * Encodes binary data using a URL-safe variation of the base64 
algorithm but does not chunk the output. The
- * url-safe variation emits - and _ instead of + and / 
characters.

- * Note: no padding is added.
- * @param binaryData
- *    binary data to encode
- * @return byte[] containing Base64 characters in their UTF-8 
representation.

- * @since 1.4
- */
-    public static byte[] encodeBase64URLSafe(final byte[] binaryData) 
{

-    return encodeBase64(binaryData, false, true);
-    }
-
  /**
   * 

Re: (tomcat) 01/06: Remove unused code - thanks to UCDetector

2024-04-04 Thread Christopher Schultz

Mark,

Can't this entire class be replaced with calls to 
java.util.Base64.get*Encoder and java.util.Base64.get*Decoder wherever 
necessary?


Now that 9.0.x is oldest, we should be able to use java.util.Base64 from 
Java 1.8+


?

-chris

On 4/4/24 15:52, ma...@apache.org wrote:

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 1a2f722e405ec17c5dab5fac43ae2fe63eb8fbce
Author: Mark Thomas 
AuthorDate: Fri Jun 17 12:29:10 2022 +0100

 Remove unused code - thanks to UCDetector
---
  .../apache/tomcat/util/codec/binary/Base64.java| 155 -
  .../tomcat/util/codec/binary/BaseNCodec.java   |  88 
  2 files changed, 243 deletions(-)

diff --git a/java/org/apache/tomcat/util/codec/binary/Base64.java 
b/java/org/apache/tomcat/util/codec/binary/Base64.java
index a733df9937..e38bf3df17 100644
--- a/java/org/apache/tomcat/util/codec/binary/Base64.java
+++ b/java/org/apache/tomcat/util/codec/binary/Base64.java
@@ -16,9 +16,6 @@
   */
  package org.apache.tomcat.util.codec.binary;
  
-import java.math.BigInteger;

-import java.util.Objects;
-
  /**
   * Provides Base64 encoding and decoding as defined by http://www.ietf.org/rfc/rfc2045.txt;>RFC 2045.
   *
@@ -141,20 +138,6 @@ public class Base64 extends BaseNCodec {
  // The private member fields below are used with the new streaming 
approach, which requires
  // some state be preserved between calls of encode() and decode().
  
-/**

- * Decodes Base64 data into octets.
- * 
- * Note: this method seamlessly handles data encoded in URL-safe or 
normal mode.
- * 
- *
- * @param base64Data
- *Byte array containing Base64 data
- * @return Array containing decoded data.
- */
-public static byte[] decodeBase64(final byte[] base64Data) {
-return decodeBase64(base64Data, 0, base64Data.length);
-}
-
  public  static byte[] decodeBase64(
  final byte[] base64Data, final int off, final int len) {
  return new Base64().decode(base64Data, off, len);
@@ -180,29 +163,6 @@ public class Base64 extends BaseNCodec {
  }
  
  // Implementation of integer encoding used for crypto

-/**
- * Decodes a byte64-encoded integer according to crypto standards such as 
W3C's XML-Signature.
- *
- * @param pArray
- *a byte array containing base64 character data
- * @return A BigInteger
- * @since 1.4
- */
-public static BigInteger decodeInteger(final byte[] pArray) {
-return new BigInteger(1, decodeBase64(pArray));
-}
-
-/**
- * Encodes binary data using the base64 algorithm but does not chunk the 
output.
- *
- * @param binaryData
- *binary data to encode
- * @return byte[] containing Base64 characters in their UTF-8 
representation.
- */
-public static byte[] encodeBase64(final byte[] binaryData) {
-return encodeBase64(binaryData, false);
-}
-
  /**
   * Encodes binary data using the base64 algorithm, optionally chunking 
the output into 76 character blocks.
   *
@@ -272,17 +232,6 @@ public class Base64 extends BaseNCodec {
  return b64.encode(binaryData);
  }
  
-/**

- * Encodes binary data using the base64 algorithm and chunks the encoded 
output into 76 character blocks
- *
- * @param binaryData
- *binary data to encode
- * @return Base64 characters chunked in 76 character blocks
- */
-public static byte[] encodeBase64Chunked(final byte[] binaryData) {
-return encodeBase64(binaryData, true);
-}
-
  /**
   * Encodes binary data using the base64 algorithm but does not chunk the 
output.
   *
@@ -298,19 +247,6 @@ public class Base64 extends BaseNCodec {
  return StringUtils.newStringUsAscii(encodeBase64(binaryData, false));
  }
  
-/**

- * Encodes binary data using a URL-safe variation of the base64 algorithm 
but does not chunk the output. The
- * url-safe variation emits - and _ instead of + and / characters.
- * Note: no padding is added.
- * @param binaryData
- *binary data to encode
- * @return byte[] containing Base64 characters in their UTF-8 
representation.
- * @since 1.4
- */
-public static byte[] encodeBase64URLSafe(final byte[] binaryData) {
-return encodeBase64(binaryData, false, true);
-}
-
  /**
   * Encodes binary data using a URL-safe variation of the base64 algorithm 
but does not chunk the output. The
   * url-safe variation emits - and _ instead of + and / characters.
@@ -324,97 +260,6 @@ public class Base64 extends BaseNCodec {
  return StringUtils.newStringUsAscii(encodeBase64(binaryData, false, 
true));
  }
  
-/**

- * Encodes to a byte64-encoded integer according to crypto standards 

(tomcat) 01/06: Remove unused code - thanks to UCDetector

2024-04-04 Thread markt
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 1a2f722e405ec17c5dab5fac43ae2fe63eb8fbce
Author: Mark Thomas 
AuthorDate: Fri Jun 17 12:29:10 2022 +0100

Remove unused code - thanks to UCDetector
---
 .../apache/tomcat/util/codec/binary/Base64.java| 155 -
 .../tomcat/util/codec/binary/BaseNCodec.java   |  88 
 2 files changed, 243 deletions(-)

diff --git a/java/org/apache/tomcat/util/codec/binary/Base64.java 
b/java/org/apache/tomcat/util/codec/binary/Base64.java
index a733df9937..e38bf3df17 100644
--- a/java/org/apache/tomcat/util/codec/binary/Base64.java
+++ b/java/org/apache/tomcat/util/codec/binary/Base64.java
@@ -16,9 +16,6 @@
  */
 package org.apache.tomcat.util.codec.binary;
 
-import java.math.BigInteger;
-import java.util.Objects;
-
 /**
  * Provides Base64 encoding and decoding as defined by http://www.ietf.org/rfc/rfc2045.txt;>RFC 2045.
  *
@@ -141,20 +138,6 @@ public class Base64 extends BaseNCodec {
 // The private member fields below are used with the new streaming 
approach, which requires
 // some state be preserved between calls of encode() and decode().
 
-/**
- * Decodes Base64 data into octets.
- * 
- * Note: this method seamlessly handles data encoded in URL-safe or 
normal mode.
- * 
- *
- * @param base64Data
- *Byte array containing Base64 data
- * @return Array containing decoded data.
- */
-public static byte[] decodeBase64(final byte[] base64Data) {
-return decodeBase64(base64Data, 0, base64Data.length);
-}
-
 public  static byte[] decodeBase64(
 final byte[] base64Data, final int off, final int len) {
 return new Base64().decode(base64Data, off, len);
@@ -180,29 +163,6 @@ public class Base64 extends BaseNCodec {
 }
 
 // Implementation of integer encoding used for crypto
-/**
- * Decodes a byte64-encoded integer according to crypto standards such as 
W3C's XML-Signature.
- *
- * @param pArray
- *a byte array containing base64 character data
- * @return A BigInteger
- * @since 1.4
- */
-public static BigInteger decodeInteger(final byte[] pArray) {
-return new BigInteger(1, decodeBase64(pArray));
-}
-
-/**
- * Encodes binary data using the base64 algorithm but does not chunk the 
output.
- *
- * @param binaryData
- *binary data to encode
- * @return byte[] containing Base64 characters in their UTF-8 
representation.
- */
-public static byte[] encodeBase64(final byte[] binaryData) {
-return encodeBase64(binaryData, false);
-}
-
 /**
  * Encodes binary data using the base64 algorithm, optionally chunking the 
output into 76 character blocks.
  *
@@ -272,17 +232,6 @@ public class Base64 extends BaseNCodec {
 return b64.encode(binaryData);
 }
 
-/**
- * Encodes binary data using the base64 algorithm and chunks the encoded 
output into 76 character blocks
- *
- * @param binaryData
- *binary data to encode
- * @return Base64 characters chunked in 76 character blocks
- */
-public static byte[] encodeBase64Chunked(final byte[] binaryData) {
-return encodeBase64(binaryData, true);
-}
-
 /**
  * Encodes binary data using the base64 algorithm but does not chunk the 
output.
  *
@@ -298,19 +247,6 @@ public class Base64 extends BaseNCodec {
 return StringUtils.newStringUsAscii(encodeBase64(binaryData, false));
 }
 
-/**
- * Encodes binary data using a URL-safe variation of the base64 algorithm 
but does not chunk the output. The
- * url-safe variation emits - and _ instead of + and / characters.
- * Note: no padding is added.
- * @param binaryData
- *binary data to encode
- * @return byte[] containing Base64 characters in their UTF-8 
representation.
- * @since 1.4
- */
-public static byte[] encodeBase64URLSafe(final byte[] binaryData) {
-return encodeBase64(binaryData, false, true);
-}
-
 /**
  * Encodes binary data using a URL-safe variation of the base64 algorithm 
but does not chunk the output. The
  * url-safe variation emits - and _ instead of + and / characters.
@@ -324,97 +260,6 @@ public class Base64 extends BaseNCodec {
 return StringUtils.newStringUsAscii(encodeBase64(binaryData, false, 
true));
 }
 
-/**
- * Encodes to a byte64-encoded integer according to crypto standards such 
as W3C's XML-Signature.
- *
- * @param bigInteger
- *a BigInteger
- * @return A byte array containing base64 character data
- * @throws NullPointerException
- * if null is passed in
- * @since 1.4
- */
-public static byte[] encodeInteger(final BigInteger