Skip to content

Commit 5d455fe

Browse files
author
J Plasmeier
committed
Add Checkstyle and configure it for star imports. Remove star imports so Checkstyle passes
1 parent 37a8479 commit 5d455fe

File tree

5 files changed

+54
-7
lines changed

5 files changed

+54
-7
lines changed

pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@
134134
</execution>
135135
</executions>
136136
</plugin>
137+
<plugin>
138+
<groupId>org.apache.maven.plugins</groupId>
139+
<artifactId>maven-checkstyle-plugin</artifactId>
140+
<version>3.2.0</version>
141+
<configuration>
142+
<configLocation>utils/checkstyle.xml</configLocation>
143+
</configuration>
144+
<executions>
145+
<execution>
146+
<goals>
147+
<goal>check</goal>
148+
</goals>
149+
</execution>
150+
</executions>
151+
</plugin>
137152
</plugins>
138153
</build>
139154

src/main/java/software/amazon/encryption/s3/S3EncryptionClient.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package software.amazon.encryption.s3;
22

3-
import java.security.*;
3+
import java.security.KeyPair;
44
import java.util.Map;
55
import java.util.function.Consumer;
66
import javax.crypto.SecretKey;
@@ -17,7 +17,13 @@
1717
import software.amazon.awssdk.services.s3.model.PutObjectResponse;
1818
import software.amazon.encryption.s3.internal.GetEncryptedObjectPipeline;
1919
import software.amazon.encryption.s3.internal.PutEncryptedObjectPipeline;
20-
import software.amazon.encryption.s3.materials.*;
20+
import software.amazon.encryption.s3.materials.AesKeyring;
21+
import software.amazon.encryption.s3.materials.CryptographicMaterialsManager;
22+
import software.amazon.encryption.s3.materials.DefaultCryptoMaterialsManager;
23+
import software.amazon.encryption.s3.materials.Keyring;
24+
import software.amazon.encryption.s3.materials.KmsKeyring;
25+
import software.amazon.encryption.s3.materials.PartialRsaKeyPair;
26+
import software.amazon.encryption.s3.materials.RsaKeyring;
2127

2228
/**
2329
* This client is a drop-in replacement for the S3 client. It will automatically encrypt objects

src/main/java/software/amazon/encryption/s3/materials/RsaKeyring.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package software.amazon.encryption.s3.materials;
22

33
import java.nio.charset.StandardCharsets;
4-
import java.security.*;
4+
import java.security.GeneralSecurityException;
5+
import java.security.Key;
6+
import java.security.SecureRandom;
57
import java.security.spec.MGF1ParameterSpec;
68
import java.util.Arrays;
79
import java.util.HashMap;
@@ -18,8 +20,6 @@
1820
*/
1921
public class RsaKeyring extends S3Keyring {
2022

21-
private static final String KEY_ALGORITHM = "RSA";
22-
2323
private final PartialRsaKeyPair _partialRsaKeyPair;
2424

2525
private final DecryptDataKeyStrategy _rsaEcbStrategy = new DecryptDataKeyStrategy() {
@@ -71,7 +71,7 @@ public String keyProviderInfo() {
7171

7272
@Override
7373
public byte[] encryptDataKey(SecureRandom secureRandom,
74-
EncryptionMaterials materials) throws GeneralSecurityException {
74+
EncryptionMaterials materials) throws GeneralSecurityException {
7575
final Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
7676
cipher.init(Cipher.WRAP_MODE, _partialRsaKeyPair.getPublicKey(), OAEP_PARAMETER_SPEC, secureRandom);
7777

src/test/java/software/amazon/encryption/s3/S3EncryptionClientTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import software.amazon.awssdk.core.sync.RequestBody;
66
import software.amazon.awssdk.services.s3.S3Client;
77
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
8-
import software.amazon.awssdk.services.s3.model.PutObjectRequest;
98

109
import javax.crypto.KeyGenerator;
1110
import javax.crypto.SecretKey;

utils/checkstyle.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<module name="Checker">
7+
<!--
8+
If you set the basedir property below, then all reported file
9+
names will be relative to the specified directory. See
10+
https://checkstyle.org/config.html#Checker
11+
<property name="basedir" value="${basedir}"/>
12+
-->
13+
<property name="severity" value="error"/>
14+
15+
<property name="fileExtensions" value="java, properties, xml"/>
16+
17+
<module name="TreeWalker">
18+
<!-- Checks for imports -->
19+
<!-- See https://checkstyle.org/config_imports.html -->
20+
<module name="AvoidStarImport"/>
21+
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
22+
<module name="RedundantImport"/>
23+
<module name="UnusedImports">
24+
<property name="processJavadoc" value="false"/>
25+
</module>
26+
</module>
27+
</module>

0 commit comments

Comments
 (0)