Skip to content
This repository has been archived by the owner on Nov 24, 2024. It is now read-only.

Move code to Java 8 #31

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ target/
.settings/
bin
*.iml
.idea

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</distributionManagement>

<properties>
<javaVersion>7</javaVersion>
<javaVersion>8</javaVersion>
<sisuVersion>0.3.5</sisuVersion>
<project.build.outputTimestamp>2021-09-08T19:26:29Z</project.build.outputTimestamp>
</properties>
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/org/sonatype/plexus/components/cipher/Base64.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
*
*/

import java.util.Arrays;

/**
* <p>Provides Base64 encoding and decoding as defined by RFC 2045.</p>
*
Expand Down Expand Up @@ -114,9 +116,7 @@ public class Base64

// Populating the lookup and character arrays
static {
for (int i = 0; i < BASELENGTH; i++) {
base64Alphabet[i] = (byte) -1;
}
Arrays.fill(base64Alphabet, (byte) -1);
for (int i = 'Z'; i >= 'A'; i--) {
base64Alphabet[i] = (byte) (i - 'A');
}
Expand Down Expand Up @@ -174,8 +174,8 @@ public static boolean isArrayByteBase64(byte[] arrayOctect) {
// return false;
return true;
}
for (int i = 0; i < length; i++) {
if (!isBase64(arrayOctect[i])) {
for (byte b : arrayOctect) {
if (!isBase64(b)) {
return false;
}
}
Expand Down Expand Up @@ -454,15 +454,15 @@ static byte[] discardWhitespace(byte[] data) {
byte groomedData[] = new byte[data.length];
int bytesCopied = 0;

for (int i = 0; i < data.length; i++) {
switch (data[i]) {
for (byte datum : data) {
switch (datum) {
case (byte) ' ':
case (byte) '\n':
case (byte) '\r':
case (byte) '\t':
break;
default:
groomedData[bytesCopied++] = data[i];
groomedData[bytesCopied++] = datum;
}
}

Expand All @@ -486,9 +486,9 @@ static byte[] discardNonBase64(byte[] data) {
byte groomedData[] = new byte[data.length];
int bytesCopied = 0;

for (int i = 0; i < data.length; i++) {
if (isBase64(data[i])) {
groomedData[bytesCopied++] = data[i];
for (byte datum : data) {
if (isBase64(datum)) {
groomedData[bytesCopied++] = datum;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static String[] getServiceTypes()
result.add(key.substring(0, ix));
}
}
return result.toArray( new String[result.size()] );
return result.toArray(new String[0]);
}

/**
Expand Down Expand Up @@ -189,7 +189,7 @@ else if (key.startsWith("Alg.Alias." + serviceType + ".")) {
}
}
}
return result.toArray( new String[result.size()] );
return result.toArray(new String[0]);
}

// ---------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,13 @@ public void testDefaultAlgorithmExists()
assertNotNull( "No Cipher providers found in the current environment", res );

System.out.println( "\n=== Available ciphers :" );
for ( int i = 0; i < res.length; i++ )
{
System.out.println( res[i] );
for (String re : res) {
System.out.println(re);
}
System.out.println( "====================" );

for ( int i = 0; i < res.length; i++ )
{
String provider = res[i];
if ( PBECipher.KEY_ALG.equalsIgnoreCase( provider ) )
for (String provider : res) {
if (PBECipher.KEY_ALG.equalsIgnoreCase(provider))
return;
}

Expand All @@ -111,18 +108,13 @@ public void stestFindDefaultAlgorithm()
String[] impls = DefaultPlexusCipher.getCryptoImpls( "Cipher" );
assertNotNull( "No Cipher providers found in the current environment", impls );

for ( int i = 0; i < impls.length; i++ )
try
{
String provider = impls[i];

System.out.print( provider );
pc.encrypt( str, passPhrase );
System.out.println( "------------------> Success !!!!!!" );
}
catch ( Exception e )
{
System.out.println( e.getMessage() );
for (String impl : impls)
try {
System.out.print(impl);
pc.encrypt(str, passPhrase);
System.out.println("------------------> Success !!!!!!");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}

Expand Down