package de.bwlehrpool.bwlp_guac; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.environment.Environment; import org.apache.guacamole.environment.LocalEnvironment; import org.apache.guacamole.properties.StringGuacamoleProperty; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SlxConfig { private static final Logger LOGGER = LoggerFactory.getLogger(SlxConfig.class); private static final Environment ENVIRONMENT; private static final StringGuacamoleProperty CLIENTS_URL = new StringGuacamoleProperty() { @Override public String getName() { return "slx-client-list-url"; } }; private static final StringGuacamoleProperty LOGO_URL = new StringGuacamoleProperty() { @Override public String getName() { return "slx-logo-url"; } }; private static final StringGuacamoleProperty LOGO_PRIMARY = new StringGuacamoleProperty() { @Override public String getName() { return "slx-logo-primary"; } }; static { Environment e; try { e = new LocalEnvironment(); } catch (GuacamoleException ex) { LOGGER.warn("Cannot create LocalEnvironment", ex); e = null; } ENVIRONMENT = e; } public static String clientListUrl() { try { return ENVIRONMENT.getProperty(CLIENTS_URL); } catch (GuacamoleException e) { LOGGER.warn("Cannot get client list url from properties", e); return null; } } public static String logoUrl() { try { String url = ENVIRONMENT.getProperty(LOGO_URL); if (url == null) return ""; return url; } catch (GuacamoleException e) { return ""; } } public static boolean logoPrimary() { try { String primary = ENVIRONMENT.getProperty(LOGO_PRIMARY); return primary != null && primary.equals("true"); } catch (GuacamoleException e) { return false; } } }