request.setContentLength(0);
String clientToken;
String continueToken;
byte[] continueTokenBytes;
SimpleHttpResponse response;
SecBufferDesc continueTokenBuffer;
while (true) {
clientToken = BaseEncoding.base64().encode(clientContext.getToken());
request.addHeader("Authorization", securityPackage + " " + clientToken);
response = new SimpleHttpResponse();
try {
authenticated = this.authenticator.authenticate(request, response, null);
} catch (final Exception e) {
NegotiateAuthenticatorTests.LOGGER.error("{}", e);
return;
}
if (authenticated) {
Assertions.assertThat(response.getHeaderNames().size()).isGreaterThanOrEqualTo(0);
break;
}
Assert.assertTrue(response.getHeader("WWW-Authenticate").startsWith(securityPackage + " "));
Assert.assertEquals("keep-alive", response.getHeader("Connection"));
Assert.assertEquals(2, response.getHeaderNames().size());
Assert.assertEquals(401, response.getStatus());
continueToken = response.getHeader("WWW-Authenticate").substring(securityPackage.length() + 1);
continueTokenBytes = BaseEncoding.base64().decode(continueToken);
Assertions.assertThat(continueTokenBytes.length).isGreaterThan(0);
continueTokenBuffer = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, continueTokenBytes);
clientContext.initialize(clientContext.getHandle(), continueTokenBuffer,
WindowsAccountImpl.getCurrentUsername());
}
Assert.assertTrue(authenticated);
} finally {