Skip to content

Commit 1a392ea

Browse files
authored
refactor: Remove duplicate code (#25)
1 parent 44b38fb commit 1a392ea

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/main/java/com/mastercard/developer/utils/EncryptionUtils.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.security.spec.InvalidKeySpecException;
1414
import java.security.spec.PKCS8EncodedKeySpec;
1515

16+
import static com.mastercard.developer.utils.ByteUtils.concat;
1617
import static com.mastercard.developer.utils.EncodingUtils.base64Decode;
1718

1819
/**
@@ -102,7 +103,7 @@ private static PrivateKey readPkcs1PrivateKey(byte[] pkcs1Bytes) throws GeneralS
102103
0x30, 0xD, 0x6, 0x9, 0x2A, (byte) 0x86, 0x48, (byte) 0x86, (byte) 0xF7, 0xD, 0x1, 0x1, 0x1, 0x5, 0x0, // Sequence: 1.2.840.113549.1.1.1, NULL
103104
0x4, (byte) 0x82, (byte) ((pkcs1Length >> 8) & 0xff), (byte) (pkcs1Length & 0xff) // Octet string + length
104105
};
105-
byte[] pkcs8bytes = join(pkcs8Header, pkcs1Bytes);
106+
byte[] pkcs8bytes = concat(pkcs8Header, pkcs1Bytes);
106107
return readPkcs8PrivateKey(pkcs8bytes);
107108
}
108109

@@ -111,11 +112,4 @@ public static String sanitizeJson(String json) {
111112
.replace("\r", "")
112113
.replace("\t", "");
113114
}
114-
115-
private static byte[] join(byte[] byteArray1, byte[] byteArray2){
116-
byte[] bytes = new byte[byteArray1.length + byteArray2.length];
117-
System.arraycopy(byteArray1, 0, bytes, 0, byteArray1.length);
118-
System.arraycopy(byteArray2, 0, bytes, byteArray1.length, byteArray2.length);
119-
return bytes;
120-
}
121115
}

0 commit comments

Comments
 (0)