GUACAMOLE-197: More style tweaks, update comments, fix typos

This commit is contained in:
Nick Couchman
2017-07-14 21:52:29 -04:00
parent e341e48c2a
commit f0b36ca5b1

View File

@@ -141,19 +141,16 @@ public class AuthenticationProviderService {
if (credentials.getPassword() == null || credentials.getPassword().isEmpty()) if (credentials.getPassword() == null || credentials.getPassword().isEmpty())
return null; return null;
// Grab the HTTP Request from the credentials object // Grab HTTP request object and a response to a challenge.
HttpServletRequest request = credentials.getRequest(); HttpServletRequest request = credentials.getRequest();
// Try to get parameters to see if this is a post-challenge attempt
String challengeResponse = request.getParameter(RadiusChallengeResponseField.PARAMETER_NAME); String challengeResponse = request.getParameter(RadiusChallengeResponseField.PARAMETER_NAME);
// RadiusPacket object to store response from server. // RadiusPacket object to store response from server.
RadiusPacket radPack; RadiusPacket radPack;
// We do not have a challenge response, proceed with username/password authentication. // No challenge response, proceed with username/password authentication.
if (challengeResponse == null) { if (challengeResponse == null) {
// Attempt RADIUS authentication with username/password.
try { try {
radPack = radiusService.authenticate(credentials.getUsername(), radPack = radiusService.authenticate(credentials.getUsername(),
credentials.getPassword()); credentials.getPassword());
@@ -164,20 +161,19 @@ public class AuthenticationProviderService {
throw new GuacamoleInvalidCredentialsException("Authentication error.", CredentialsInfo.USERNAME_PASSWORD); throw new GuacamoleInvalidCredentialsException("Authentication error.", CredentialsInfo.USERNAME_PASSWORD);
} }
// If no RadiusPacket is returned, we've encountered an error. // No RadiusPacket is returned, we've encountered an error.
if (radPack == null) { if (radPack == null) {
logger.debug("Nothing in the RADIUS packet."); logger.debug("Nothing in the RADIUS packet.");
throw new GuacamoleInvalidCredentialsException("Authentication error.", CredentialsInfo.USERNAME_PASSWORD); throw new GuacamoleInvalidCredentialsException("Authentication error.", CredentialsInfo.USERNAME_PASSWORD);
} }
// If we get back an AccessReject packet, login is denied. // Received AccessReject packet, login is denied.
else if (radPack instanceof AccessReject) { else if (radPack instanceof AccessReject) {
logger.debug("Login has been rejected by RADIUS server."); logger.debug("Login has been rejected by RADIUS server.");
throw new GuacamoleInvalidCredentialsException("Authentication failed.", CredentialsInfo.USERNAME_PASSWORD); throw new GuacamoleInvalidCredentialsException("Authentication failed.", CredentialsInfo.USERNAME_PASSWORD);
} }
// If we receive an AccessChallenge package, the server needs more information - // Received AccessChallenge packet, more credentials required to complete authentication
// We create a new form/field with the challenge message.
else if (radPack instanceof AccessChallenge) { else if (radPack instanceof AccessChallenge) {
CredentialsInfo expectedCredentials = getRadiusChallenge(radPack); CredentialsInfo expectedCredentials = getRadiusChallenge(radPack);
@@ -187,7 +183,7 @@ public class AuthenticationProviderService {
throw new GuacamoleInsufficientCredentialsException("LOGIN.INFO_RADIUS_ADDL_REQUIRED", expectedCredentials); throw new GuacamoleInsufficientCredentialsException("LOGIN.INFO_RADIUS_ADDL_REQUIRED", expectedCredentials);
} }
// If we receive AccessAccept, authentication has succeeded // Received AccessAccept, authentication has succeeded
else if (radPack instanceof AccessAccept) { else if (radPack instanceof AccessAccept) {
try { try {
AuthenticatedUser authenticatedUser = authenticatedUserProvider.get(); AuthenticatedUser authenticatedUser = authenticatedUserProvider.get();
@@ -206,10 +202,9 @@ public class AuthenticationProviderService {
} }
} }
// The user responded to the challenge, send that back to the server // This is a response to a challenge, so authenticate with that response
else { else {
// Attempt to authenticate with response to challenge.
try { try {
radPack = radiusService.authenticate(credentials.getUsername(), radPack = radiusService.authenticate(credentials.getUsername(),
request.getParameter(RadiusStateField.PARAMETER_NAME), request.getParameter(RadiusStateField.PARAMETER_NAME),
@@ -224,14 +219,14 @@ public class AuthenticationProviderService {
radiusService.disconnect(); radiusService.disconnect();
} }
// Check the server response, see if we get accepted or not // Received AccessAccept, authentication succeeded.
if (radPack instanceof AccessAccept) { if (radPack instanceof AccessAccept) {
AuthenticatedUser authenticatedUser = authenticatedUserProvider.get(); AuthenticatedUser authenticatedUser = authenticatedUserProvider.get();
authenticatedUser.init(credentials); authenticatedUser.init(credentials);
return authenticatedUser; return authenticatedUser;
} }
// Authentication failed // Authentication failed.
else { else {
logger.warn("RADIUS Challenge/Response authentication failed."); logger.warn("RADIUS Challenge/Response authentication failed.");
logger.debug("Received something other than AccessAccept packet from the RADIUS server."); logger.debug("Received something other than AccessAccept packet from the RADIUS server.");