mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-197: Remove unnecessary null/empty checks in setupRadiusAuthenticator, and throw exceptions instead of returning null.
This commit is contained in:
committed by
Nick Couchman
parent
d773614a79
commit
ba837cb31b
@@ -119,14 +119,11 @@ public class RadiusConnectionService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String radAuthName;
|
|
||||||
String caFile;
|
String caFile;
|
||||||
String caPassword;
|
String caPassword;
|
||||||
String caType;
|
String caType;
|
||||||
String keyFile;
|
String keyFile;
|
||||||
String keyPassword;
|
String keyPassword;
|
||||||
String keyType;
|
|
||||||
Boolean trustAll;
|
|
||||||
String innerProtocol;
|
String innerProtocol;
|
||||||
LocalEnvironment guacEnv;
|
LocalEnvironment guacEnv;
|
||||||
String basePath;
|
String basePath;
|
||||||
@@ -134,52 +131,42 @@ public class RadiusConnectionService {
|
|||||||
// Pull configuration parameters from guacamole.properties
|
// Pull configuration parameters from guacamole.properties
|
||||||
guacEnv = new LocalEnvironment();
|
guacEnv = new LocalEnvironment();
|
||||||
basePath = guacEnv.getGuacamoleHome().getAbsolutePath() + '/';
|
basePath = guacEnv.getGuacamoleHome().getAbsolutePath() + '/';
|
||||||
radAuthName = confService.getRadiusAuthProtocol();
|
|
||||||
caFile = confService.getRadiusCAFile();
|
caFile = confService.getRadiusCAFile();
|
||||||
caPassword = confService.getRadiusCAPassword();
|
caPassword = confService.getRadiusCAPassword();
|
||||||
caType = confService.getRadiusCAType();
|
|
||||||
keyFile = confService.getRadiusKeyFile();
|
keyFile = confService.getRadiusKeyFile();
|
||||||
keyPassword = confService.getRadiusKeyPassword();
|
keyPassword = confService.getRadiusKeyPassword();
|
||||||
keyType = confService.getRadiusKeyType();
|
|
||||||
trustAll = confService.getRadiusTrustAll();
|
|
||||||
innerProtocol = confService.getRadiusEAPTTLSInnerProtocol();
|
innerProtocol = confService.getRadiusEAPTTLSInnerProtocol();
|
||||||
|
|
||||||
RadiusAuthenticator radAuth = radiusClient.getAuthProtocol(radAuthName);
|
RadiusAuthenticator radAuth = radiusClient.getAuthProtocol(confService.getRadiusAuthProtocol());
|
||||||
if (radAuth == null)
|
if (radAuth == null)
|
||||||
return null;
|
throw new GuacamoleException("Could not get a valid RadiusAuthenticator for specified protocol: " + confService.getRadiusAuthProtocol());
|
||||||
|
|
||||||
// If we're using any of the TLS protocols, we need to configure them
|
// If we're using any of the TLS protocols, we need to configure them
|
||||||
if (radAuth instanceof PEAPAuthenticator ||
|
if (radAuth instanceof PEAPAuthenticator ||
|
||||||
radAuth instanceof EAPTLSAuthenticator ||
|
radAuth instanceof EAPTLSAuthenticator ||
|
||||||
radAuth instanceof EAPTTLSAuthenticator) {
|
radAuth instanceof EAPTTLSAuthenticator) {
|
||||||
|
|
||||||
if (caFile != null && !caFile.isEmpty())
|
if (caFile != null) {
|
||||||
((EAPTLSAuthenticator)radAuth).setCaFile(basePath + caFile);
|
((EAPTLSAuthenticator)radAuth).setCaFile(basePath + caFile);
|
||||||
|
((EAPTLSAuthenticator)radAuth).setCaFileType(confService.getRadiusCAType());
|
||||||
|
if (caPassword != null)
|
||||||
|
((EAPTLSAuthenticator)radAuth).setCaPassword(caPassword);
|
||||||
|
}
|
||||||
|
|
||||||
if (caType != null && !caType.isEmpty())
|
if (keyPassword != null)
|
||||||
((EAPTLSAuthenticator)radAuth).setCaFileType(caType);
|
|
||||||
|
|
||||||
if (caPassword != null && !caPassword.isEmpty())
|
|
||||||
((EAPTLSAuthenticator)radAuth).setCaPassword(caPassword);
|
|
||||||
|
|
||||||
if (keyFile != null && !keyFile.isEmpty())
|
|
||||||
((EAPTLSAuthenticator)radAuth).setKeyFile(basePath + keyFile);
|
|
||||||
|
|
||||||
if (keyType != null && !keyType.isEmpty())
|
|
||||||
((EAPTLSAuthenticator)radAuth).setKeyFileType(keyType);
|
|
||||||
|
|
||||||
if (keyPassword != null && !keyPassword.isEmpty())
|
|
||||||
((EAPTLSAuthenticator)radAuth).setKeyPassword(keyPassword);
|
((EAPTLSAuthenticator)radAuth).setKeyPassword(keyPassword);
|
||||||
|
|
||||||
((EAPTLSAuthenticator)radAuth).setTrustAll(trustAll);
|
((EAPTLSAuthenticator)radAuth).setKeyFile(basePath + keyFile);
|
||||||
|
((EAPTLSAuthenticator)radAuth).setKeyFileType(confService.getRadiusKeyType());
|
||||||
|
((EAPTLSAuthenticator)radAuth).setTrustAll(confService.getRadiusTrustAll());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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) {
|
||||||
|
|
||||||
if (innerProtocol == null || innerProtocol.isEmpty())
|
if (innerProtocol == null)
|
||||||
return null;
|
throw new GuacamoleException("Trying to use EAP-TTLS, but no inner protocol specified.");
|
||||||
|
|
||||||
((EAPTTLSAuthenticator)radAuth).setInnerProtocol(innerProtocol);
|
((EAPTTLSAuthenticator)radAuth).setInnerProtocol(innerProtocol);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user