mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUAC-587: Include and validate Guacamole version in manifest.
This commit is contained in:
@@ -289,6 +289,18 @@ public class Extension {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the Guacamole web application for which this
|
||||
* extension was built.
|
||||
*
|
||||
* @return
|
||||
* The version of the Guacamole web application for which this
|
||||
* extension was built.
|
||||
*/
|
||||
public String getGuacamoleVersion() {
|
||||
return manifest.getGuacamoleVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this extension, as declared in the extension's
|
||||
* manifest.
|
||||
|
@@ -33,6 +33,13 @@ import org.codehaus.jackson.annotate.JsonProperty;
|
||||
*/
|
||||
public class ExtensionManifest {
|
||||
|
||||
/**
|
||||
* The version of Guacamole for which this extension was built.
|
||||
* Compatibility rules built into the web application will guard against
|
||||
* incompatible extensions being loaded.
|
||||
*/
|
||||
private String guacamoleVersion;
|
||||
|
||||
/**
|
||||
* The name of the extension associated with this manifest. The extension
|
||||
* name is human-readable, and used for display purposes only.
|
||||
@@ -65,6 +72,30 @@ public class ExtensionManifest {
|
||||
*/
|
||||
private Collection<String> authProviders;
|
||||
|
||||
/**
|
||||
* Returns the version of the Guacamole web application for which the
|
||||
* extension was built, such as "0.9.6".
|
||||
*
|
||||
* @return
|
||||
* The version of the Guacamole web application for which the extension
|
||||
* was built.
|
||||
*/
|
||||
public String getGuacamoleVersion() {
|
||||
return guacamoleVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the version of the Guacamole web application for which the
|
||||
* extension was built, such as "0.9.6".
|
||||
*
|
||||
* @param guacamoleVersion
|
||||
* The version of the Guacamole web application for which the extension
|
||||
* was built.
|
||||
*/
|
||||
public void setGuacamoleVersion(String guacamoleVersion) {
|
||||
this.guacamoleVersion = guacamoleVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the extension associated with this manifest. The
|
||||
* name is human-readable, for display purposes only, and is defined within
|
||||
|
@@ -27,9 +27,13 @@ import com.google.inject.servlet.ServletModule;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.sourceforge.guacamole.net.basic.BasicFileAuthenticationProvider;
|
||||
import org.glyptodon.guacamole.GuacamoleException;
|
||||
import org.glyptodon.guacamole.GuacamoleServerException;
|
||||
import org.glyptodon.guacamole.environment.Environment;
|
||||
import org.glyptodon.guacamole.net.auth.AuthenticationProvider;
|
||||
import org.glyptodon.guacamole.net.basic.properties.BasicGuacamoleProperties;
|
||||
@@ -53,6 +57,15 @@ public class ExtensionModule extends ServletModule {
|
||||
*/
|
||||
private final Logger logger = LoggerFactory.getLogger(ExtensionModule.class);
|
||||
|
||||
/**
|
||||
* The version strings of all Guacamole versions whose extensions are
|
||||
* compatible with this release.
|
||||
*/
|
||||
private static final List<String> ALLOWED_GUACAMOLE_VERSIONS =
|
||||
Collections.unmodifiableList(Arrays.asList(
|
||||
"0.9.6"
|
||||
));
|
||||
|
||||
/**
|
||||
* The name of the directory within GUACAMOLE_HOME containing any .jars
|
||||
* which should be included in the classpath of all extensions.
|
||||
@@ -188,6 +201,21 @@ public class ExtensionModule extends ServletModule {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given version of Guacamole is compatible with this
|
||||
* version of Guacamole as far as extensions are concerned.
|
||||
*
|
||||
* @param guacamoleVersion
|
||||
* The version of Guacamole the extension was built for.
|
||||
*
|
||||
* @return
|
||||
* true if the given version of Guacamole is compatible with this
|
||||
* version of Guacamole, false otherwise.
|
||||
*/
|
||||
private boolean isCompatible(String guacamoleVersion) {
|
||||
return ALLOWED_GUACAMOLE_VERSIONS.contains(guacamoleVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureServlets() {
|
||||
|
||||
@@ -229,6 +257,14 @@ public class ExtensionModule extends ServletModule {
|
||||
// Load extension from file
|
||||
Extension extension = new Extension(getParentClassLoader(), extensionFile);
|
||||
|
||||
// Validate Guacamole version of extension
|
||||
if (!isCompatible(extension.getGuacamoleVersion())) {
|
||||
logger.debug("Declared Guacamole version \"{}\" of extension \"{}\" is not compatible with this version of Guacamole.",
|
||||
extension.getGuacamoleVersion(), extensionFile.getName());
|
||||
throw new GuacamoleServerException("Extension \"" + extension.getName() + "\" is not "
|
||||
+ "compatible with this version of Guacamole.");
|
||||
}
|
||||
|
||||
// Add any JavaScript / CSS resources
|
||||
javaScriptResources.addAll(extension.getJavaScriptResources());
|
||||
cssResources.addAll(extension.getCSSResources());
|
||||
|
Reference in New Issue
Block a user