mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
GUACAMOLE-774: Clean up style and comments, improve readability.
This commit is contained in:
@@ -21,6 +21,7 @@ package org.apache.guacamole.auth.radius;
|
|||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.auth.radius.conf.ConfigurationService;
|
||||||
import org.apache.guacamole.environment.Environment;
|
import org.apache.guacamole.environment.Environment;
|
||||||
import org.apache.guacamole.environment.LocalEnvironment;
|
import org.apache.guacamole.environment.LocalEnvironment;
|
||||||
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
import org.apache.guacamole.net.auth.AuthenticationProvider;
|
||||||
|
@@ -45,8 +45,6 @@ import net.jradius.packet.AccessRequest;
|
|||||||
import net.jradius.packet.attribute.AttributeList;
|
import net.jradius.packet.attribute.AttributeList;
|
||||||
import net.jradius.client.auth.EAPTLSAuthenticator;
|
import net.jradius.client.auth.EAPTLSAuthenticator;
|
||||||
import net.jradius.client.auth.EAPTTLSAuthenticator;
|
import net.jradius.client.auth.EAPTTLSAuthenticator;
|
||||||
import net.jradius.client.auth.MSCHAPv1Authenticator;
|
|
||||||
import net.jradius.client.auth.MSCHAPv2Authenticator;
|
|
||||||
import net.jradius.client.auth.RadiusAuthenticator;
|
import net.jradius.client.auth.RadiusAuthenticator;
|
||||||
import net.jradius.client.auth.PEAPAuthenticator;
|
import net.jradius.client.auth.PEAPAuthenticator;
|
||||||
import net.jradius.packet.attribute.AttributeFactory;
|
import net.jradius.packet.attribute.AttributeFactory;
|
||||||
@@ -71,11 +69,17 @@ public class RadiusConnectionService {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Set up a new instance of this class, and check the provided
|
||||||
|
* authentication protocol. If the protocol requires MD4 support,
|
||||||
|
* this loads the required security providers.
|
||||||
*
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If guacamole.properties cannot be parsed or an invalid
|
||||||
|
* authentication protocol is provided.
|
||||||
*/
|
*/
|
||||||
public RadiusConnectionService() {
|
public RadiusConnectionService() throws GuacamoleException {
|
||||||
|
|
||||||
RadiusAuthenticationProtocol authProtocol = confService.getAuthenticationProtocol();
|
RadiusAuthenticationProtocol authProtocol = confService.getRadiusAuthProtocol();
|
||||||
|
|
||||||
// Check for MS-CHAP and add MD4 support
|
// Check for MS-CHAP and add MD4 support
|
||||||
if (authProtocol == RadiusAuthenticationProtocol.MSCHAPv1
|
if (authProtocol == RadiusAuthenticationProtocol.MSCHAPv1
|
||||||
@@ -83,7 +87,8 @@ public class RadiusConnectionService {
|
|||||||
|
|
||||||
Security.addProvider(new Provider("MD4", 0.00, "MD4 for MSCHAPv1/2 RADIUS") {
|
Security.addProvider(new Provider("MD4", 0.00, "MD4 for MSCHAPv1/2 RADIUS") {
|
||||||
{
|
{
|
||||||
this.put("MessageDigest.MD4", org.bouncycastle.jce.provider.JDKMessageDigest.MD4.class.getName());
|
this.put("MessageDigest.MD4",
|
||||||
|
org.bouncycastle.jce.provider.JDKMessageDigest.MD4.class.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -142,8 +147,8 @@ public class RadiusConnectionService {
|
|||||||
* not configured when the client is set up for a tunneled
|
* not configured when the client is set up for a tunneled
|
||||||
* RADIUS connection.
|
* RADIUS connection.
|
||||||
*/
|
*/
|
||||||
private RadiusAuthenticator setupRadiusAuthenticator(RadiusClient radiusClient)
|
private RadiusAuthenticator setupRadiusAuthenticator(
|
||||||
throws GuacamoleException {
|
RadiusClient radiusClient) throws GuacamoleException {
|
||||||
|
|
||||||
// If we don't have a radiusClient object, yet, don't go any further.
|
// If we don't have a radiusClient object, yet, don't go any further.
|
||||||
if (radiusClient == null) {
|
if (radiusClient == null) {
|
||||||
@@ -152,7 +157,9 @@ public class RadiusConnectionService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
RadiusAuthenticator radAuth = radiusClient.getAuthProtocol(confService.getRadiusAuthProtocol().toString());
|
RadiusAuthenticator radAuth = radiusClient.getAuthProtocol(
|
||||||
|
confService.getRadiusAuthProtocol().toString());
|
||||||
|
|
||||||
if (radAuth == null)
|
if (radAuth == null)
|
||||||
throw new GuacamoleException("Could not get a valid RadiusAuthenticator for specified protocol: " + confService.getRadiusAuthProtocol());
|
throw new GuacamoleException("Could not get a valid RadiusAuthenticator for specified protocol: " + confService.getRadiusAuthProtocol());
|
||||||
|
|
||||||
@@ -184,9 +191,11 @@ public class RadiusConnectionService {
|
|||||||
|
|
||||||
// If we're using EAP-TTLS, we need to define tunneled protocol
|
// If we're using EAP-TTLS, we need to define tunneled protocol
|
||||||
if (radAuth instanceof EAPTTLSAuthenticator) {
|
if (radAuth instanceof EAPTTLSAuthenticator) {
|
||||||
RadiusAuthenticationProtocol innerProtocol = confService.getRadiusEAPTTLSInnerProtocol();
|
RadiusAuthenticationProtocol innerProtocol =
|
||||||
|
confService.getRadiusEAPTTLSInnerProtocol();
|
||||||
|
|
||||||
if (innerProtocol == null)
|
if (innerProtocol == null)
|
||||||
throw new GuacamoleException("Trying to use EAP-TTLS, but no inner protocol specified.");
|
throw new GuacamoleException("Missing or invalid inner protocol for EAP-TTLS.");
|
||||||
|
|
||||||
((EAPTTLSAuthenticator)radAuth).setInnerProtocol(innerProtocol.toString());
|
((EAPTTLSAuthenticator)radAuth).setInnerProtocol(innerProtocol.toString());
|
||||||
}
|
}
|
||||||
@@ -263,14 +272,21 @@ public class RadiusConnectionService {
|
|||||||
|
|
||||||
radAuth.setupRequest(radiusClient, radAcc);
|
radAuth.setupRequest(radiusClient, radAcc);
|
||||||
radAuth.processRequest(radAcc);
|
radAuth.processRequest(radAcc);
|
||||||
RadiusResponse reply = radiusClient.sendReceive(radAcc, confService.getRadiusMaxRetries());
|
RadiusResponse reply = radiusClient.sendReceive(radAcc,
|
||||||
|
confService.getRadiusMaxRetries());
|
||||||
|
|
||||||
// We receive a Challenge not asking for user input, so silently process the challenge
|
// We receive a Challenge not asking for user input, so silently process the challenge
|
||||||
while((reply instanceof AccessChallenge) && (reply.findAttribute(Attr_ReplyMessage.TYPE) == null)) {
|
while((reply instanceof AccessChallenge)
|
||||||
|
&& (reply.findAttribute(Attr_ReplyMessage.TYPE) == null)) {
|
||||||
|
|
||||||
radAuth.processChallenge(radAcc, reply);
|
radAuth.processChallenge(radAcc, reply);
|
||||||
reply = radiusClient.sendReceive(radAcc, confService.getRadiusMaxRetries());
|
reply = radiusClient.sendReceive(radAcc,
|
||||||
|
confService.getRadiusMaxRetries());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return reply;
|
return reply;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (RadiusException e) {
|
catch (RadiusException e) {
|
||||||
logger.error("Unable to complete authentication.", e.getMessage());
|
logger.error("Unable to complete authentication.", e.getMessage());
|
||||||
@@ -309,8 +325,8 @@ public class RadiusConnectionService {
|
|||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If an error is encountered trying to talk to the RADIUS server.
|
* If an error is encountered trying to talk to the RADIUS server.
|
||||||
*/
|
*/
|
||||||
public RadiusPacket sendChallengeResponse(String username, String response, byte[] state)
|
public RadiusPacket sendChallengeResponse(String username, String response,
|
||||||
throws GuacamoleException {
|
byte[] state) throws GuacamoleException {
|
||||||
|
|
||||||
if (username == null || username.isEmpty()) {
|
if (username == null || username.isEmpty()) {
|
||||||
logger.error("Challenge/response to RADIUS requires a username.");
|
logger.error("Challenge/response to RADIUS requires a username.");
|
||||||
|
@@ -22,6 +22,7 @@ package org.apache.guacamole.auth.radius.conf;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.GuacamoleServerException;
|
||||||
import org.apache.guacamole.environment.Environment;
|
import org.apache.guacamole.environment.Environment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -323,6 +324,8 @@ public class ConfigurationService {
|
|||||||
if (authProtocol == RadiusAuthenticationProtocol.EAP_TTLS)
|
if (authProtocol == RadiusAuthenticationProtocol.EAP_TTLS)
|
||||||
throw new GuacamoleServerException("Invalid inner protocol specified for EAP-TTLS.");
|
throw new GuacamoleServerException("Invalid inner protocol specified for EAP-TTLS.");
|
||||||
|
|
||||||
|
return authProtocol;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ package org.apache.guacamole.auth.radius.conf;
|
|||||||
|
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.GuacamoleServerException;
|
import org.apache.guacamole.GuacamoleServerException;
|
||||||
|
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A GuacamoleProperty whose value is a RadiusAuthenticationProtocol.
|
* A GuacamoleProperty whose value is a RadiusAuthenticationProtocol.
|
||||||
|
Reference in New Issue
Block a user