diff --git a/java-base64-2.3.8-elasticsearch.patch b/java-base64-2.3.8-elasticsearch.patch new file mode 100644 index 0000000..79b70ca --- /dev/null +++ b/java-base64-2.3.8-elasticsearch.patch @@ -0,0 +1,148 @@ +--- base64/src/main/java/net/iharder/Base64.java 2010-03-29 20:54:45.000000000 +0200 ++++ base64/src/main/java/net/iharder/Base64.java.elasticsearch 2015-02-18 23:43:01.174030315 +0100 +@@ -1,5 +1,8 @@ + package net.iharder; + ++import java.nio.charset.Charset; ++import java.util.Locale; ++ + /** + *

Encodes and decodes to and from Base64 notation.

+ *

Homepage: http://iharder.net/base64.

+@@ -208,7 +211,7 @@ + + + /** Preferred encoding. */ +- private final static String PREFERRED_ENCODING = "US-ASCII"; ++ public final static Charset PREFERRED_ENCODING = Charset.forName("US-ASCII"); + + + private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding +@@ -690,13 +693,7 @@ + } // end finally + + // Return value according to relevant encoding. +- try { +- return new String( baos.toByteArray(), PREFERRED_ENCODING ); +- } // end try +- catch (java.io.UnsupportedEncodingException uue){ +- // Fall back to some Java default +- return new String( baos.toByteArray() ); +- } // end catch ++ return new String(baos.toByteArray(), PREFERRED_ENCODING); + + } // end encode + +@@ -831,12 +828,7 @@ + byte[] encoded = encodeBytesToBytes( source, off, len, options ); + + // Return value according to relevant encoding. +- try { +- return new String( encoded, PREFERRED_ENCODING ); +- } // end try +- catch (java.io.UnsupportedEncodingException uue) { +- return new String( encoded ); +- } // end catch ++ return new String(encoded, PREFERRED_ENCODING); + + } // end encodeBytes + +@@ -899,7 +891,7 @@ + + if( off + len > source.length ){ + throw new IllegalArgumentException( +- String.format( "Cannot have offset of %d and length of %d with array of length %d", off,len,source.length)); ++ String.format(Locale.ROOT, "Cannot have offset of %d and length of %d with array of length %d", off, len, source.length)); + } // end if: off < 0 + + +@@ -1039,12 +1031,12 @@ + throw new NullPointerException( "Destination array was null." ); + } // end if + if( srcOffset < 0 || srcOffset + 3 >= source.length ){ +- throw new IllegalArgumentException( String.format( +- "Source array with length %d cannot have offset of %d and still process four bytes.", source.length, srcOffset ) ); ++ throw new IllegalArgumentException(String.format(Locale.ROOT, ++ "Source array with length %d cannot have offset of %d and still process four bytes.", source.length, srcOffset)); + } // end if + if( destOffset < 0 || destOffset +2 >= destination.length ){ +- throw new IllegalArgumentException( String.format( +- "Destination array with length %d cannot have offset of %d and still store three bytes.", destination.length, destOffset ) ); ++ throw new IllegalArgumentException(String.format(Locale.ROOT, ++ "Destination array with length %d cannot have offset of %d and still store three bytes.", destination.length, destOffset)); + } // end if + + +@@ -1153,8 +1145,8 @@ + throw new NullPointerException( "Cannot decode null source array." ); + } // end if + if( off < 0 || off + len > source.length ){ +- throw new IllegalArgumentException( String.format( +- "Source array with length %d cannot have offset of %d and process %d bytes.", source.length, off, len ) ); ++ throw new IllegalArgumentException(String.format(Locale.ROOT, ++ "Source array with length %d cannot have offset of %d and process %d bytes.", source.length, off, len)); + } // end if + + if( len == 0 ){ +@@ -1191,15 +1183,26 @@ + + // If that was the equals sign, break out of 'for' loop + if( source[i] == EQUALS_SIGN ) { ++ // check if the equals sign is somewhere in between ++ if (i + 1 < len + off) { ++ throw new java.io.IOException(String.format(Locale.ROOT, ++ "Found equals sign at position %d of the base64 string, not at the end", i)); ++ } + break; + } // end if: equals sign + } // end if: quartet built ++ else { ++ if (source[i] == EQUALS_SIGN && len + off > i && source[i + 1] != EQUALS_SIGN) { ++ throw new java.io.IOException(String.format(Locale.ROOT, ++ "Found equals sign at position %d of the base64 string, not at the end", i)); ++ } // enf if: equals sign and next character not as well ++ } // end else: + } // end if: equals sign or better + } // end if: white space, equals sign or better + else { + // There's a bad input character in the Base64 stream. +- throw new java.io.IOException( String.format( +- "Bad Base64 input character decimal %d in array position %d", ((int)source[i])&0xFF, i ) ); ++ throw new java.io.IOException(String.format(Locale.ROOT, ++ "Bad Base64 input character decimal %d in array position %d", ((int) source[i]) & 0xFF, i)); + } // end else: + } // each input character + +@@ -1243,13 +1246,7 @@ + throw new NullPointerException( "Input string was null." ); + } // end if + +- byte[] bytes; +- try { +- bytes = s.getBytes( PREFERRED_ENCODING ); +- } // end try +- catch( java.io.UnsupportedEncodingException uee ) { +- bytes = s.getBytes(); +- } // end catch ++ byte[] bytes = s.getBytes(PREFERRED_ENCODING); + // + + // Decode +@@ -1282,7 +1279,7 @@ + + } // end try + catch( java.io.IOException e ) { +- e.printStackTrace(); ++ // e.printStackTrace(); + // Just return originally-decoded bytes + } // end catch + finally { +@@ -1359,7 +1356,7 @@ + @Override + public Class resolveClass(java.io.ObjectStreamClass streamClass) + throws java.io.IOException, ClassNotFoundException { +- Class c = Class.forName(streamClass.getName(), false, loader); ++ Class c = Class.forName(streamClass.getName(), false, loader); + if( c == null ){ + return super.resolveClass(streamClass); + } else { diff --git a/java-base64.spec b/java-base64.spec new file mode 100644 index 0000000..b606c2c --- /dev/null +++ b/java-base64.spec @@ -0,0 +1,60 @@ +Name: java-base64 +Version: 2.3.8 +Release: 15 +Summary: A Java class providing Base64 encoding and decoding +License: Public Domain +URL: http://iharder.net/base64/ +Source0: https://github.com/omalley/base64/archive/release-%{version}.tar.gz +Patch0: %{name}-2.3.8-elasticsearch.patch + +BuildArch: noarch +BuildRequires: junit maven-local +Provides: base64 = %{version}-%{release} + +%description +This is a Public Domain Java class providing very fast Base64 encoding +and decoding in the form of convenience methods and input/output +streams. + +%package help +Summary: Javadoc for %{name} + +Provides: %{name}-javadoc = %{version}-%{release} +Obsoletes: %{name}-javadoc < %{version}-%{release} + +%description help +The java-base64-help package contains related documents. + +%prep +%autosetup -n base64-release-%{version} -p1 + +sed -i "s|2.3.9-SNAPSHOT|%{version}|" pom.xml + +%pom_remove_plugin :maven-release-plugin +%pom_remove_plugin :maven-scm-plugin +%pom_remove_plugin :maven-source-plugin +%pom_remove_plugin :maven-javadoc-plugin + +%mvn_file :base64 java-base64 +%mvn_file :base64 base64 + +%build + +%mvn_build + +%install +%mvn_install + +( + cd %{buildroot}%{_javadocdir} + ln -sf %{name} base64 +) + +%files -f .mfiles + +%files help -f .mfiles-javadoc +%{_javadocdir}/base64 + +%changelog +* Sat Dec 14 2019 Jiangping Hu - 2.3.8-15 +- Package init diff --git a/release-2.3.8.tar.gz b/release-2.3.8.tar.gz new file mode 100644 index 0000000..5b8ccb8 Binary files /dev/null and b/release-2.3.8.tar.gz differ