Skip to content

Commit

Permalink
checkstyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stoty committed Sep 30, 2024
1 parent 42d4d82 commit de8dd8d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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)));
Expand Down Expand Up @@ -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());
});
Expand All @@ -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 -> {
Expand All @@ -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());
});
Expand All @@ -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 -> {
Expand All @@ -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);
Expand Down Expand Up @@ -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));
});
Expand All @@ -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 {
Expand All @@ -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));
});
Expand All @@ -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 {
Expand All @@ -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));
});
Expand All @@ -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 {
Expand All @@ -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));
});
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit de8dd8d

Please sign in to comment.