Skip to content

Commit 67a93b3

Browse files
committed
feat(mtls): fix lint
1 parent 3a4bae6 commit 67a93b3

File tree

6 files changed

+31
-32
lines changed

6 files changed

+31
-32
lines changed

oauth2_http/java/com/google/auth/mtls/ContextAwareMetadataJson.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ public class ContextAwareMetadataJson extends GenericJson {
4545
public final ImmutableList<String> getCommands() {
4646
return ImmutableList.copyOf(commands);
4747
}
48-
}
48+
}

oauth2_http/java/com/google/auth/mtls/DefaultMtlsProviderFactory.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,27 @@
3131

3232
package com.google.auth.mtls;
3333

34-
import com.google.auth.mtls.CertificateSourceUnavailableException;
35-
import com.google.auth.mtls.X509Provider;
3634
import java.io.IOException;
3735

3836
public class DefaultMtlsProviderFactory {
3937

4038
/**
41-
* Creates an instance of {@link MtlsProvider}. It first attempts to create an
42-
* {@link X509Provider}. If the certificate source is unavailable, it falls back to creating a
43-
* {@link SecureConnectProvider}. If the secure connect provider also fails, it throws the
44-
* original {@link CertificateSourceUnavailableException}.
39+
* Creates an instance of {@link MtlsProvider}. It first attempts to create an {@link
40+
* com.google.auth.mtls.X509Provider}. If the certificate source is unavailable, it falls back to
41+
* creating a {@link SecureConnectProvider}. If the secure connect provider also fails, it throws
42+
* the original {@link com.google.auth.mtls.CertificateSourceUnavailableException}.
4543
*
4644
* @return an instance of {@link MtlsProvider}.
47-
* @throws CertificateSourceUnavailableException if neither provider can be created.
45+
* @throws com.google.auth.mtls.CertificateSourceUnavailableException if neither provider can be
46+
* created.
4847
* @throws IOException if an I/O error occurs during provider creation.
4948
*/
5049
public static MtlsProvider create() throws IOException {
5150
MtlsProvider mtlsProvider;
5251
try {
53-
mtlsProvider = new X509Provider();
54-
mtlsProvider.getKeyStore();
55-
return mtlsProvider;
52+
mtlsProvider = new X509Provider();
53+
mtlsProvider.getKeyStore();
54+
return mtlsProvider;
5655
} catch (CertificateSourceUnavailableException e) {
5756
try {
5857
mtlsProvider = new SecureConnectProvider();
@@ -64,4 +63,4 @@ public static MtlsProvider create() throws IOException {
6463
}
6564
}
6665
}
67-
}
66+
}

oauth2_http/java/com/google/auth/mtls/MtlsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@
3737
public interface MtlsProvider {
3838
/** Returns the mutual TLS key store. */
3939
KeyStore getKeyStore() throws IOException;
40-
}
40+
}

oauth2_http/java/com/google/auth/mtls/SecureConnectProvider.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* Provider class for mutual TLS. It is used to configure the mutual TLS in the transport with the
4949
* default client certificate on device.
5050
*/
51-
public class SecureConnectProvider implements MtlsProvider{
51+
public class SecureConnectProvider implements MtlsProvider {
5252
interface ProcessProvider {
5353
public Process createProcess(InputStream metadata) throws IOException;
5454
}
@@ -88,9 +88,11 @@ public KeyStore getKeyStore() throws IOException {
8888
} catch (InterruptedException e) {
8989
throw new IOException("Interrupted executing certificate provider command", e);
9090
} catch (GeneralSecurityException e) {
91-
throw new CertificateSourceUnavailableException("SecureConnect encountered GeneralSecurityException:", e);
91+
throw new CertificateSourceUnavailableException(
92+
"SecureConnect encountered GeneralSecurityException:", e);
9293
} catch (FileNotFoundException exception) {
93-
// If the metadata file doesn't exist, then there is no key store, so we will throw sentinel error
94+
// If the metadata file doesn't exist, then there is no key store, so we will throw sentinel
95+
// error
9496
throw new CertificateSourceUnavailableException("SecureConnect metadata does not exist.");
9597
}
9698
}
@@ -145,4 +147,4 @@ static int runCertificateProviderCommand(Process commandProcess, long timeoutMil
145147
commandProcess.destroy();
146148
throw new IOException("cert provider command timed out");
147149
}
148-
}
150+
}

oauth2_http/java/com/google/auth/mtls/X509Provider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* libraries, and the public facing methods may be changed without notice, and have no guarantee of
4949
* backwards compatability.
5050
*/
51-
public class X509Provider implements MtlsProvider{
51+
public class X509Provider implements MtlsProvider {
5252
static final String CERTIFICATE_CONFIGURATION_ENV_VARIABLE = "GOOGLE_API_CERTIFICATE_CONFIG";
5353
static final String WELL_KNOWN_CERTIFICATE_CONFIG_FILE = "certificate_config.json";
5454
static final String CLOUDSDK_CONFIG_DIRECTORY = "gcloud";

oauth2_http/javatests/com/google/auth/mtls/SecureConnectProviderTest.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
package com.google.auth.mtls;
3333

3434
import static org.junit.Assert.assertEquals;
35-
import static org.junit.Assert.assertFalse;
36-
import static org.junit.Assert.assertNull;
3735
import static org.junit.Assert.assertThrows;
3836
import static org.junit.Assert.assertTrue;
3937

@@ -113,16 +111,15 @@ public void testGetKeyStoreNonZeroExitCode()
113111
assertThrows(
114112
IOException.class,
115113
() -> SecureConnectProvider.getKeyStore(metadata, new TestProcessProvider(1)));
116-
assertTrue("expected to fail with nonzero exit code",
114+
assertTrue(
115+
"expected to fail with nonzero exit code",
117116
actual.getMessage().contains("Cert provider command failed with exit code: 1"));
118117
}
119118

120119
@Test
121120
public void testExtractCertificateProviderCommand() throws IOException {
122121
InputStream inputStream =
123-
this.getClass()
124-
.getClassLoader()
125-
.getResourceAsStream("mtls_context_aware_metadata.json");
122+
this.getClass().getClassLoader().getResourceAsStream("mtls_context_aware_metadata.json");
126123
List<String> command = SecureConnectProvider.extractCertificateProviderCommand(inputStream);
127124
assertEquals(2, command.size());
128125
assertEquals("some_binary", command.get(0));
@@ -143,19 +140,20 @@ public void testRunCertificateProviderCommandTimeout() throws InterruptedExcepti
143140
assertThrows(
144141
IOException.class,
145142
() -> SecureConnectProvider.runCertificateProviderCommand(certCommandProcess, 100));
146-
assertTrue("expected to fail with timeout",
143+
assertTrue(
144+
"expected to fail with timeout",
147145
actual.getMessage().contains("cert provider command timed out"));
148146
}
149147

150148
@Test
151-
public void testGetKeyStore_FileNotFoundException() throws IOException, GeneralSecurityException, InterruptedException {
152-
SecureConnectProvider provider = new SecureConnectProvider(new TestProcessProvider(0), "/invalid/metadata/path.json");
149+
public void testGetKeyStore_FileNotFoundException()
150+
throws IOException, GeneralSecurityException, InterruptedException {
151+
SecureConnectProvider provider =
152+
new SecureConnectProvider(new TestProcessProvider(0), "/invalid/metadata/path.json");
153153

154-
CertificateSourceUnavailableException exception = assertThrows(
155-
CertificateSourceUnavailableException.class,
156-
provider::getKeyStore
157-
);
154+
CertificateSourceUnavailableException exception =
155+
assertThrows(CertificateSourceUnavailableException.class, provider::getKeyStore);
158156

159157
assertEquals("SecureConnect metadata does not exist.", exception.getMessage());
160158
}
161-
}
159+
}

0 commit comments

Comments
 (0)