Skip to content

Commit 0e87c0f

Browse files
author
zihluwang
committed
style: reformatted codes
1 parent 022c1c2 commit 0e87c0f

File tree

11 files changed

+81
-46
lines changed

11 files changed

+81
-46
lines changed

common-toolbox/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# Module `devkit-utils`
1+
# Common Toolbox
22

33
## Introduction
44

5-
This module provides a set of utilities to streamline Java codes.
5+
Common Toolbox is a Java SE utility library, that provides a collection of utility to streamline
6+
your Java coding experience.
67

78
## Features
89

common-toolbox/src/main/java/com/onixbyte/common/util/CollectionUtil.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ private CollectionUtil() {
6161
* {@code maxSize} is less than zero, or
6262
* {@code collectionFactory} is {@code null}
6363
*/
64-
public static <T, C extends Collection<T>> List<C> chunk(C originalCollection,
65-
int maxSize,
66-
Supplier<C> collectionFactory) {
64+
public static <T, C extends Collection<T>> List<C> chunk(
65+
C originalCollection,
66+
int maxSize,
67+
Supplier<C> collectionFactory
68+
) {
6769
// check inputs
6870
if (Objects.isNull(originalCollection)) {
6971
throw new IllegalArgumentException("Collection must not be null.");

common-toolbox/src/main/java/com/onixbyte/common/util/RangeUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public static IntStream range(int start, int end) {
122122
return IntStream.range(start, end);
123123
} else {
124124
// Descending range (exclusive of end)
125-
return IntStream.iterate(start, n -> n > end, n -> n - 1);
125+
return IntStream.iterate(start, (n) -> n > end, (n) -> n - 1);
126126
}
127127
}
128128

crypto-toolbox/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# KeyLoader
1+
# Crypto Toolbox
22

3-
KeyLoader provides utility methods to load keys from pem-formatted key texts.
3+
Crypto Toolbox provides methods to simplify your codes on key pairs.
44

55
## ECDSA-based algorithm
66

@@ -110,4 +110,4 @@ pzDq72a2Rhws+dbrH0gqsg1lsLDfhhui2FomuBpDZUtHq0Jz/IEvd3X45XvegSH8
110110
t8+yL/pFK3+YpDVtj/IzMSwL+izvnXFALvZOO+8CABeyKuSjLh/6LbAzrvoftql5
111111
gQIDAQAB
112112
-----END PUBLIC KEY-----
113-
```
113+
```

crypto-toolbox/src/main/java/com/onixbyte/crypto/PrivateKeyLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
import java.security.PrivateKey;
2626

2727
/**
28-
* The {@code PrivateKeyLoader} interface provides utility methods for loading keys pairs from
29-
* PEM-formatted key text. This class supports loading both private and public keys.
28+
* The {@code PrivateKeyLoader} provides utility methods for loading private keys from
29+
* PEM-formatted key text.
3030
*
3131
* @author zihluwang
3232
* @author siujamo

crypto-toolbox/src/main/java/com/onixbyte/crypto/PublicKeyLoader.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,19 @@
2929
import java.security.interfaces.RSAPublicKey;
3030

3131
/**
32+
* The {@code PublicKeyLoader} provides utility methods for loading public keys from PEM-formatted
33+
* key text.
3234
*
35+
* @author zihluwang
3336
* @author siujamo
3437
* @version 3.0.0
3538
*/
3639
public interface PublicKeyLoader {
3740

3841
/**
39-
* Load public key from pem-formatted key text.
42+
* Load public key from PEM-formatted key text.
4043
*
41-
* @param pemKeyText pem-formatted key text
44+
* @param pemKeyText PEM-formatted key text
4245
* @return loaded private key
4346
*/
4447
PublicKey loadPublicKey(String pemKeyText);

crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPrivateKeyLoader.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,28 @@
2626
import com.onixbyte.crypto.exception.KeyLoadingException;
2727
import com.onixbyte.crypto.util.CryptoUtil;
2828

29-
import java.math.BigInteger;
30-
import java.security.AlgorithmParameters;
3129
import java.security.KeyFactory;
3230
import java.security.NoSuchAlgorithmException;
3331
import java.security.interfaces.ECPrivateKey;
34-
import java.security.interfaces.ECPublicKey;
3532
import java.security.spec.*;
3633
import java.util.Base64;
37-
import java.util.HashSet;
38-
import java.util.Set;
3934

4035
/**
41-
* Key pair loader for loading key pairs for ECDSA-based algorithms.
36+
* A class responsible for loading private ECDSA keys from PEM formatted text.
4237
* <p>
43-
* <b>Example usage:</b>
44-
* <pre>{@code
45-
* PrivateKeyLoader keyLoader = new ECPrivateKeyLoader();
46-
* String pemPrivateKey = """
47-
* -----BEGIN EC PRIVATE KEY-----
48-
* ...
49-
* -----END EC PRIVATE KEY-----""";
50-
* ECPrivateKey privateKey = PrivateKeyLoader.loadEcdsaPrivateKey(pemPrivateKey);
51-
* }</pre>
38+
* This class implements the {@link PrivateKeyLoader} interface and provides methods to load private
39+
* RSA keys. The keys are expected to be in the standard PEM format, which includes Base64-encoded
40+
* key content surrounded by header and footer lines. The class handles the decoding of Base64
41+
* content and the generation of keys using the RSA key factory.
42+
* <p>
43+
* Any exceptions encountered during the loading process are encapsulated in a
44+
* {@link KeyLoadingException}, allowing for flexible error handling.
5245
*
5346
* @author zihluwang
47+
* @author siujamo
5448
* @version 3.0.0
49+
* @see PrivateKeyLoader
50+
* @see KeyLoadingException
5551
*/
5652
public class ECPrivateKeyLoader implements PrivateKeyLoader {
5753

crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/ecdsa/ECPublicKeyLoader.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package com.onixbyte.crypto.algorithm.ecdsa;
2424

25+
import com.onixbyte.crypto.PrivateKeyLoader;
2526
import com.onixbyte.crypto.PublicKeyLoader;
2627
import com.onixbyte.crypto.exception.KeyLoadingException;
2728
import com.onixbyte.crypto.util.CryptoUtil;
@@ -38,7 +39,21 @@
3839
import java.util.Set;
3940

4041
/**
42+
* A class responsible for loading public ECDSA keys from PEM formatted text.
43+
* <p>
44+
* This class implements the {@link PublicKeyLoader} interface and provides methods to load private
45+
* RSA keys. The keys are expected to be in the standard PEM format, which includes Base64-encoded
46+
* key content surrounded by header and footer lines. The class handles the decoding of Base64
47+
* content and the generation of keys using the RSA key factory.
48+
* <p>
49+
* Any exceptions encountered during the loading process are encapsulated in a
50+
* {@link KeyLoadingException}, allowing for flexible error handling.
4151
*
52+
* @author zihluwang
53+
* @author siujamo
54+
* @version 3.0.0
55+
* @see PrivateKeyLoader
56+
* @see KeyLoadingException
4257
*/
4358
public class ECPublicKeyLoader implements PublicKeyLoader {
4459

crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPrivateKeyLoader.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,19 @@
3535
import java.util.Base64;
3636

3737
/**
38-
* A class responsible for loading RSA keys from PEM formatted text.
38+
* A class responsible for loading private RSA keys from PEM formatted text.
3939
* <p>
40-
* This class implements the {@link PrivateKeyLoader} interface and provides methods to load both
41-
* private and public RSA keys. The keys are expected to be in the standard PEM format, which
42-
* includes Base64-encoded key content surrounded by header and footer lines. The class handles
43-
* the decoding of Base64 content and the generation of keys using the RSA key factory.
40+
* This class implements the {@link PrivateKeyLoader} interface and provides methods to load private
41+
* RSA keys. The keys are expected to be in the standard PEM format, which includes Base64-encoded
42+
* key content surrounded by header and footer lines. The class handles the decoding of Base64
43+
* content and the generation of keys using the RSA key factory.
4444
* <p>
4545
* Any exceptions encountered during the loading process are encapsulated in a
4646
* {@link KeyLoadingException}, allowing for flexible error handling.
4747
*
4848
* @author zihluwang
4949
* @author siujamo
50+
* @version 3.0.0
5051
* @see PrivateKeyLoader
5152
* @see KeyLoadingException
5253
*/

crypto-toolbox/src/main/java/com/onixbyte/crypto/algorithm/rsa/RSAPublicKeyLoader.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
package com.onixbyte.crypto.algorithm.rsa;
2424

25+
import com.onixbyte.crypto.PrivateKeyLoader;
2526
import com.onixbyte.crypto.PublicKeyLoader;
2627
import com.onixbyte.crypto.exception.KeyLoadingException;
2728
import com.onixbyte.crypto.util.CryptoUtil;
@@ -37,7 +38,21 @@
3738
import java.util.Base64;
3839

3940
/**
41+
* A class responsible for loading public RSA keys from PEM formatted text.
42+
* <p>
43+
* This class implements the {@link PublicKeyLoader} interface and provides methods to load public
44+
* RSA keys. The keys are expected to be in the standard PEM format, which includes Base64-encoded
45+
* key content surrounded by header and footer lines. The class handles the decoding of Base64
46+
* content and the generation of keys using the RSA key factory.
47+
* <p>
48+
* Any exceptions encountered during the loading process are encapsulated in a
49+
* {@link KeyLoadingException}, allowing for flexible error handling.
4050
*
51+
* @author zihluwang
52+
* @author siujamo
53+
* @version 3.0.0
54+
* @see PrivateKeyLoader
55+
* @see KeyLoadingException
4156
*/
4257
public class RSAPublicKeyLoader implements PublicKeyLoader {
4358

0 commit comments

Comments
 (0)