From de8dd8d29ccd737f7654e47562c232c0b48df5d5 Mon Sep 17 00:00:00 2001 From: Istvan Toth Date: Mon, 30 Sep 2024 08:19:03 +0200 Subject: [PATCH] checkstyle fixes --- .../testing/sync/TestSpnegoScheme.java | 34 +++++++++---------- .../client5/http/impl/auth/GSSchemeBase.java | 8 ++--- .../http/impl/classic/ProtocolExec.java | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestSpnegoScheme.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestSpnegoScheme.java index 50c7952ca..7a8100169 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestSpnegoScheme.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestSpnegoScheme.java @@ -153,7 +153,7 @@ private static class SPNEGOMutualService implements HttpRequestHandler { final boolean sendMutualToken; final byte[] encodedMutualAuthToken; - SPNEGOMutualService (final boolean sendMutualToken, final byte[] encodedMutualAuthToken){ + SPNEGOMutualService (final boolean sendMutualToken, final byte[] encodedMutualAuthToken) { this.sendMutualToken = sendMutualToken; this.encodedMutualAuthToken = encodedMutualAuthToken; } @@ -170,9 +170,9 @@ public void handle( response.addHeader(new BasicHeader("WWW-Authenticate", StandardAuthScheme.SPNEGO)); response.addHeader(new BasicHeader("Connection", "Keep-Alive")); response.setEntity(new StringEntity("auth required ")); - } else if(callCount == 2) { + } else if (callCount == 2) { callCount++; - if(request.getHeader("Authorization").getValue().contains(GOOD_TOKEN_B64)) { + if (request.getHeader("Authorization").getValue().contains(GOOD_TOKEN_B64)) { response.setCode(HttpStatus.SC_OK); if (sendMutualToken) { response.addHeader(new BasicHeader("WWW-Authenticate", StandardAuthScheme.SPNEGO + " " + new String(encodedMutualAuthToken))); @@ -293,7 +293,7 @@ public AuthScheme create(final HttpContext context) { * the server still keep asking for a valid ticket. */ @Test - public void testDontTryToAuthenticateEndlessly() throws Exception { + void testDontTryToAuthenticateEndlessly() throws Exception { configureServer(t -> { t.register("*", new PleaseNegotiateService()); }); @@ -308,7 +308,7 @@ public void testDontTryToAuthenticateEndlessly() throws Exception { t.setDefaultCredentialsProvider(jaasCredentialsProvider); }); - final HttpHost target = startServer(); + final HttpHost target = startServer(); final String s = "/path"; final HttpGet httpget = new HttpGet(s); client().execute(target, httpget, response -> { @@ -323,7 +323,7 @@ public void testDontTryToAuthenticateEndlessly() throws Exception { * if no token is generated. Client should be able to deal with this response. */ @Test - public void testNoTokenGeneratedError() throws Exception { + void testNoTokenGeneratedError() throws Exception { configureServer(t -> { t.register("*", new PleaseNegotiateService()); }); @@ -339,7 +339,7 @@ public void testNoTokenGeneratedError() throws Exception { }); - final HttpHost target = startServer(); + final HttpHost target = startServer(); final String s = "/path"; final HttpGet httpget = new HttpGet(s); client().execute(target, httpget, response -> { @@ -354,11 +354,11 @@ public void testNoTokenGeneratedError() throws Exception { * Test the success case for mutual auth */ @Test - public void testMutualSuccess() throws Exception { + void testMutualSuccess() throws Exception { configureServer(t -> { t.register("*", new SPNEGOMutualService(true, GOOD_MUTUAL_AUTH_TOKEN_B64_BYTES)); }); - final HttpHost target = startServer(); + final HttpHost target = startServer(); final MutualNegotiateSchemeWithMockGssManager mockAuthScheme = new MutualNegotiateSchemeWithMockGssManager(true, true); final AuthSchemeFactory nsf = new TestAuthSchemeFactory(mockAuthScheme); @@ -388,7 +388,7 @@ public void testMutualSuccess() throws Exception { * No mutual auth response token sent by server. */ @Test - public void testMutualFailureNoToken() throws Exception { + void testMutualFailureNoToken() throws Exception { configureServer(t -> { t.register("*", new SPNEGOMutualService(false, null)); }); @@ -407,7 +407,7 @@ public void testMutualFailureNoToken() throws Exception { final HttpClientContext context = new HttpClientContext(); context.setCredentialsProvider(jaasCredentialsProvider); - final HttpHost target = startServer(); + final HttpHost target = startServer(); final String s = "/path"; final HttpGet httpget = new HttpGet(s); try { @@ -430,7 +430,7 @@ public void testMutualFailureNoToken() throws Exception { * Server sends a "valid" token, but we mock the established status to false */ @Test - public void testMutualFailureEstablishedStatusFalse() throws Exception { + void testMutualFailureEstablishedStatusFalse() throws Exception { configureServer(t -> { t.register("*", new SPNEGOMutualService(true, GOOD_MUTUAL_AUTH_TOKEN_B64_BYTES)); }); @@ -448,7 +448,7 @@ public void testMutualFailureEstablishedStatusFalse() throws Exception { final HttpClientContext context = new HttpClientContext(); context.setCredentialsProvider(jaasCredentialsProvider); - final HttpHost target = startServer(); + final HttpHost target = startServer(); final String s = "/path"; final HttpGet httpget = new HttpGet(s); try { @@ -471,7 +471,7 @@ public void testMutualFailureEstablishedStatusFalse() throws Exception { * Server sends a "valid" token, but we mock the mutual auth status to false */ @Test - public void testMutualFailureMutualStatusFalse() throws Exception { + void testMutualFailureMutualStatusFalse() throws Exception { configureServer(t -> { t.register("*", new SPNEGOMutualService(true, GOOD_MUTUAL_AUTH_TOKEN_B64_BYTES)); }); @@ -489,7 +489,7 @@ public void testMutualFailureMutualStatusFalse() throws Exception { final HttpClientContext context = new HttpClientContext(); context.setCredentialsProvider(jaasCredentialsProvider); - final HttpHost target = startServer(); + final HttpHost target = startServer(); final String s = "/path"; final HttpGet httpget = new HttpGet(s); try { @@ -512,7 +512,7 @@ public void testMutualFailureMutualStatusFalse() throws Exception { * Server sends a "bad" token, and GSS throws an exception. */ @Test - public void testMutualFailureBadToken() throws Exception { + void testMutualFailureBadToken() throws Exception { configureServer(t -> { t.register("*", new SPNEGOMutualService(true, BAD_MUTUAL_AUTH_TOKEN_B64_BYTES)); }); @@ -532,7 +532,7 @@ public void testMutualFailureBadToken() throws Exception { final HttpClientContext context = new HttpClientContext(); context.setCredentialsProvider(jaasCredentialsProvider); - final HttpHost target = startServer(); + final HttpHost target = startServer(); final String s = "/path"; final HttpGet httpget = new HttpGet(s); try { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/GSSchemeBase.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/GSSchemeBase.java index 4758d062f..c68b0a1a5 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/GSSchemeBase.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/GSSchemeBase.java @@ -131,14 +131,14 @@ public void processChallenge( return; } - final byte[] challengeToken = Base64.decodeBase64(authChallenge== null ? null : authChallenge.getValue()); + final byte[] challengeToken = Base64.decodeBase64(authChallenge == null ? null : authChallenge.getValue()); final String gssHostname; String hostname = host.getHostName(); - if (config.getUseCanonicalHostname() != KerberosConfig.Option.DISABLE){ + if (config.getUseCanonicalHostname() != KerberosConfig.Option.DISABLE) { try { hostname = dnsResolver.resolveCanonicalHostname(host.getHostName()); - } catch (final UnknownHostException ignore){ + } catch (final UnknownHostException ignore) { } } if (config.getStripPort() != KerberosConfig.Option.DISABLE) { @@ -170,7 +170,7 @@ public void processChallenge( case TOKEN_SENT: if (challenged) { state = State.TOKEN_READY; - } else if (mutualAuth){ + } else if (mutualAuth) { // We should have received a valid mutualAuth token if (!gssContext.isEstablished()) { if (LOG.isDebugEnabled()) { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java index 9c1c7b7eb..41517e2e6 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java @@ -270,7 +270,7 @@ private boolean needAuthentication( final HttpHost target, final String pathPrefix, final HttpResponse response, - final HttpClientContext context) throws AuthenticationException, MalformedChallengeException { + final HttpClientContext context) throws AuthenticationException, MalformedChallengeException { final RequestConfig config = context.getRequestConfigOrDefault(); if (config.isAuthenticationEnabled()) { final boolean targetAuthRequested = authenticator.isChallenged(