GUAC-587: Serve static resources within /app/ext/[namespace]/[declared/path/to/resource].

This commit is contained in:
Michael Jumper
2015-05-17 15:02:35 -07:00
parent 06011cac62
commit 79e6c31035

View File

@@ -30,6 +30,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import net.sourceforge.guacamole.net.basic.BasicFileAuthenticationProvider;
import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.GuacamoleServerException;
@@ -278,6 +279,19 @@ public class ExtensionModule extends ServletModule {
for (Class<AuthenticationProvider> authenticationProvider : authenticationProviders)
bindAuthenticationProvider(authenticationProvider);
// Add all static resources under namespace-derived prefix
String staticResourcePrefix = "/app/ext/" + extension.getNamespace() + "/";
for (Map.Entry<String, Resource> staticResource : extension.getStaticResources().entrySet()) {
// Get path and resource from path/resource pair
String path = staticResource.getKey();
Resource resource = staticResource.getValue();
// Serve within namespace-derived path
serve(staticResourcePrefix + path).with(new ResourceServlet(resource));
}
// Log successful loading of extension by name
logger.info("Extension \"{}\" loaded.", extension.getName());