mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-197: Move RadiusClient object to a return value instead of class-level object; properly clean up RADIUS connections.
This commit is contained in:
@@ -160,9 +160,6 @@ public class AuthenticationProviderService {
|
|||||||
logger.debug("Error configuring RADIUS server.", e);
|
logger.debug("Error configuring RADIUS server.", e);
|
||||||
throw new GuacamoleInvalidCredentialsException("Authentication error.", CredentialsInfo.USERNAME_PASSWORD);
|
throw new GuacamoleInvalidCredentialsException("Authentication error.", CredentialsInfo.USERNAME_PASSWORD);
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
radiusService.disconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a response to a previous challenge, authenticate with that.
|
// This is a response to a previous challenge, authenticate with that.
|
||||||
@@ -177,9 +174,6 @@ public class AuthenticationProviderService {
|
|||||||
logger.debug("Error configuring RADIUS server.", e);
|
logger.debug("Error configuring RADIUS server.", e);
|
||||||
throw new GuacamoleInvalidCredentialsException("Authentication error.", CredentialsInfo.USERNAME_PASSWORD);
|
throw new GuacamoleInvalidCredentialsException("Authentication error.", CredentialsInfo.USERNAME_PASSWORD);
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
radiusService.disconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No RadiusPacket is returned, we've encountered an error.
|
// No RadiusPacket is returned, we've encountered an error.
|
||||||
|
@@ -63,11 +63,6 @@ public class RadiusConnectionService {
|
|||||||
private ConfigurationService confService;
|
private ConfigurationService confService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The RADIUS client;
|
|
||||||
*/
|
|
||||||
private RadiusClient radiusClient;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of RadiusClient, configured with parameters
|
* Creates a new instance of RadiusClient, configured with parameters
|
||||||
* from guacamole.properties.
|
* from guacamole.properties.
|
||||||
@@ -76,11 +71,11 @@ public class RadiusConnectionService {
|
|||||||
* If an error occurs while parsing guacamole.properties, or if the
|
* If an error occurs while parsing guacamole.properties, or if the
|
||||||
* configuration of RadiusClient fails.
|
* configuration of RadiusClient fails.
|
||||||
*/
|
*/
|
||||||
private void createRadiusConnection() {
|
private RadiusClient createRadiusConnection() {
|
||||||
|
|
||||||
// Create the RADIUS client with the configuration parameters
|
// Create the RADIUS client with the configuration parameters
|
||||||
try {
|
try {
|
||||||
radiusClient = new RadiusClient(InetAddress.getByName(confService.getRadiusServer()),
|
return new RadiusClient(InetAddress.getByName(confService.getRadiusServer()),
|
||||||
confService.getRadiusSharedSecret(),
|
confService.getRadiusSharedSecret(),
|
||||||
confService.getRadiusAuthPort(),
|
confService.getRadiusAuthPort(),
|
||||||
confService.getRadiusAcctPort(),
|
confService.getRadiusAcctPort(),
|
||||||
@@ -99,6 +94,8 @@ public class RadiusConnectionService {
|
|||||||
logger.debug("Failed to communicate with host.", e);
|
logger.debug("Failed to communicate with host.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,7 +107,8 @@ public class RadiusConnectionService {
|
|||||||
* with parameters from guacamole.properties, or null if
|
* with parameters from guacamole.properties, or null if
|
||||||
* configuration fails.
|
* configuration fails.
|
||||||
*/
|
*/
|
||||||
private RadiusAuthenticator setupRadiusAuthenticator() throws GuacamoleException {
|
private RadiusAuthenticator setupRadiusAuthenticator(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) {
|
||||||
@@ -196,7 +194,7 @@ public class RadiusConnectionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the RADIUS connection and set up the dictionary
|
// Create the RADIUS connection and set up the dictionary
|
||||||
createRadiusConnection();
|
RadiusClient radiusClient = createRadiusConnection();
|
||||||
AttributeFactory.loadAttributeDictionary("net.jradius.dictionary.AttributeDictionaryImpl");
|
AttributeFactory.loadAttributeDictionary("net.jradius.dictionary.AttributeDictionaryImpl");
|
||||||
|
|
||||||
// Client failed to set up, so we return null
|
// Client failed to set up, so we return null
|
||||||
@@ -204,7 +202,7 @@ public class RadiusConnectionService {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Set up the RadiusAuthenticator
|
// Set up the RadiusAuthenticator
|
||||||
RadiusAuthenticator radAuth = setupRadiusAuthenticator();
|
RadiusAuthenticator radAuth = setupRadiusAuthenticator(radiusClient);
|
||||||
if (radAuth == null)
|
if (radAuth == null)
|
||||||
throw new GuacamoleException("Unknown RADIUS authentication protocol.");
|
throw new GuacamoleException("Unknown RADIUS authentication protocol.");
|
||||||
|
|
||||||
@@ -248,6 +246,9 @@ public class RadiusConnectionService {
|
|||||||
logger.debug("Unknown RADIUS algorithm.", e);
|
logger.debug("Unknown RADIUS algorithm.", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
radiusClient.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RadiusPacket sendChallengeResponse(String username, String response, String state)
|
public RadiusPacket sendChallengeResponse(String username, String response, String state)
|
||||||
@@ -272,13 +273,4 @@ public class RadiusConnectionService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Disconnects the current RADIUS connection.
|
|
||||||
*/
|
|
||||||
public void disconnect() {
|
|
||||||
|
|
||||||
radiusClient.close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user