public boolean getHttpsEnabled() { if (httpsEnabled!=null) return httpsEnabled; httpsEnabled = managementContext.getConfig().getConfig(BrooklynWebConfig.HTTPS_REQUIRED); return httpsEnabled; }
@Override public Map getProperties() { return mgmt.getConfig().asMapWithStringKeys(); }
/** * accepts flags: port, * war (url of war file which is the root), * wars (map of context-prefix to url), * attrs (map of attribute-name : object pairs passed to the servlet) */ public BrooklynWebServer(Map flags, ManagementContext managementContext) { this.managementContext = managementContext; Map leftovers = FlagUtils.setFieldsFromFlags(flags, this); if (!leftovers.isEmpty()) log.warn("Ignoring unknown flags " + leftovers); String brooklynDataDir = checkNotNull(managementContext.getConfig().getConfig(BrooklynConfigKeys.BROOKLYN_DATA_DIR)); this.webappTempDir = new File(brooklynDataDir, "jetty"); }
private synchronized void initialize() { if (allowedUsers!=null) return; StringConfigMap properties = mgmt.getConfig(); allowedUsers = new LinkedHashSet<String>(); String users = properties.getConfig(BrooklynWebConfig.SECURITY_PROVIDER_EXPLICIT__USERS); if (users==null) { LOG.info("Web console allowing default user (admin)"); allowDefaultUsers = true; } else if ("*".equals(users)) { LOG.info("Web console allowing any users"); allowAnyUserWithValidPass = true; } else { LOG.info("Web console allowing users "+users); StringTokenizer t = new StringTokenizer(users, ","); while (t.hasMoreElements()) { allowedUsers.add((""+t.nextElement()).trim()); } } if (properties.getFirst(BrooklynServiceAttributes.BROOKLYN_AUTOLOGIN_USERNAME)!=null) { LOG.warn("Use of legacy AUTOLOGIN; replace with setting BrooklynSystemProperties.SECURITY_PROVIDER to "+AnyoneSecurityProvider.class.getCanonicalName()); allowAnyUser = true; } }
@SuppressWarnings("deprecation") private synchronized void initialize() { if (allowedUsers!=null) return; StringConfigMap properties = mgmt.getConfig(); allowedUsers = new LinkedHashSet<String>(); String users = properties.getConfig(BrooklynWebConfig.USERS); if (users==null) { users = properties.getConfig(BrooklynWebConfig.SECURITY_PROVIDER_EXPLICIT__USERS); if (users!=null) LOG.warn("Using deprecated config key "+BrooklynWebConfig.SECURITY_PROVIDER_EXPLICIT__USERS.getName()+"; " + "use "+BrooklynWebConfig.USERS.getName()+" instead"); } if (users==null) { LOG.warn("Web console has no users configured; no one will be able to log in!"); } else if ("*".equals(users)) { LOG.info("Web console allowing any user (so long as valid password is set)"); allowAnyUserWithValidPass = true; } else { StringTokenizer t = new StringTokenizer(users, ","); while (t.hasMoreElements()) { allowedUsers.add((""+t.nextElement()).trim()); } LOG.info("Web console allowing users: "+allowedUsers); } }
StringConfigMap brooklynProperties = mgmt.getConfig();
StringConfigMap brooklynProperties = mgmt.getConfig();
public String getInstallDir() { // Cache it; evaluate lazily (and late) to ensure managementContext.config is accessible and completed its setup // Caching has the benefit that the driver is usable, even if the entity is unmanaged (useful in some tests!) if (installDir == null) { String installBasedir = ((EntityInternal)entity).getManagementContext().getConfig().getFirst("brooklyn.dirs.install"); if (installBasedir == null) installBasedir = DEFAULT_INSTALL_BASEDIR; if (installBasedir.endsWith(File.separator)) installBasedir.substring(0, installBasedir.length()-1); installDir = elvis(entity.getConfig(SoftwareProcess.SUGGESTED_INSTALL_DIR), installBasedir+"/"+getEntityVersionLabel("/")); } return installDir; }
BrooklynProperties properties = (BrooklynProperties) mgmt.getConfig(); String actualP = properties.getConfig(BrooklynWebConfig.SECURITY_PROVIDER_EXPLICIT__PASSWORD(user)); if (actualP==null) {
public String processTemplateContents(String templateContents, Map<String,? extends Object> extraSubstitutions) { Map<String, Object> config = getEntity().getApplication().getManagementContext().getConfig().asMapWithStringKeys(); Map<String, Object> substitutions = ImmutableMap.<String, Object>builder() .putAll(config) .put("entity", entity) .put("driver", this) .put("location", getLocation()) .putAll(extraSubstitutions) .build(); return TemplateProcessor.processTemplateContents(templateContents, substitutions); /* try { Configuration cfg = new Configuration(); StringTemplateLoader templateLoader = new StringTemplateLoader(); templateLoader.putTemplate("config", templateContents); cfg.setTemplateLoader(templateLoader); Template template = cfg.getTemplate("config"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Writer out = new OutputStreamWriter(baos); template.process(substitutions, out); out.flush(); return new String(baos.toByteArray()); } catch (Exception e) { log.warn("Error creating configuration file for "+entity, e); throw Exceptions.propagate(e); } */ }
public String getRunDir() { if (runDir == null) { String runBasedir = ((EntityInternal)entity).getManagementContext().getConfig().getFirst("brooklyn.dirs.run"); if (runBasedir == null) runBasedir = DEFAULT_RUN_BASEDIR; if (runBasedir.endsWith(File.separator)) runBasedir.substring(0, runBasedir.length()-1); runDir = elvis(entity.getConfig(SoftwareProcess.SUGGESTED_RUN_DIR), runBasedir+"/"+entity.getApplication().getId()+"/"+"entities"+"/"+ getEntityVersionLabel()+"_"+entity.getId()); } return runDir; }
public LdapSecurityProvider(ManagementContext mgmt) { StringConfigMap properties = mgmt.getConfig(); ldapUrl = properties.getConfig(BrooklynWebConfig.LDAP_URL); Strings.checkNonEmpty(ldapUrl, "LDAP security provider configuration missing required property "+BrooklynWebConfig.LDAP_URL); ldapRealm = properties.getConfig(BrooklynWebConfig.LDAP_REALM); Strings.checkNonEmpty(ldapRealm, "LDAP security provider configuration missing required property "+BrooklynWebConfig.LDAP_REALM); }
/** serve given WAR at the given pathSpec; if not yet started, it is simply remembered until start; * if server already running, the context for this WAR is started. * @return the context created and added as a handler * (and possibly already started if server is started, * so be careful with any changes you make to it!) */ public WebAppContext deploy(String pathSpec, String warUrl) { String cleanPathSpec = pathSpec; while (cleanPathSpec.startsWith("/")) cleanPathSpec = cleanPathSpec.substring(1); boolean isRoot = cleanPathSpec.isEmpty(); WebAppContext context = new WebAppContext(); context.setAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT, managementContext); for (Map.Entry<String, Object> attributeEntry : attributes.entrySet()) { context.setAttribute(attributeEntry.getKey(), attributeEntry.getValue()); } try { File tmpWarFile = ResourceUtils.writeToTempFile(new CustomResourceLocator(managementContext.getConfig(), ResourceUtils.create(this)).getResourceFromUrl(warUrl), isRoot ? "ROOT" : ("embedded-" + cleanPathSpec), ".war"); context.setWar(tmpWarFile.getAbsolutePath()); } catch (Exception e) { log.error("Unabled to load WAR file from "+warUrl+"; launching run without WAR: "+e); log.debug("Detail on why running without WAR file: "+e, e); context.setWar("/dev/null"); } context.setContextPath("/" + cleanPathSpec); context.setParentLoaderPriority(true); deploy(context); return context; }
public LdapSecurityProvider(ManagementContext mgmt) { StringConfigMap properties = mgmt.getConfig(); ldapUrl = properties.getConfig(BrooklynWebConfig.LDAP_URL); Strings.checkNonEmpty(ldapUrl, "LDAP security provider configuration missing required property "+BrooklynWebConfig.LDAP_URL); ldapRealm = properties.getConfig(BrooklynWebConfig.LDAP_REALM); Strings.checkNonEmpty(ldapRealm, "LDAP security provider configuration missing required property "+BrooklynWebConfig.LDAP_REALM); }
ConfigMap namedLocationProps = mgmt.getConfig().submap(ConfigPredicates.startingWith(NAMED_LOCATION_PREFIX)); for (String k: namedLocationProps.asMapWithStringKeys().keySet()) { String name = k.substring(NAMED_LOCATION_PREFIX.length());
BrooklynProperties properties = (BrooklynProperties) mgmt.getConfig(); String actualP = properties.getConfig(BrooklynWebConfig.PASSWORD_FOR_USER(user)); if (actualP==null) {
/** extracts the values for the main brooklyn.ssh.config.* config keys (i.e. those declared in ConfigKeys) * as declared on the entity, and inserts them in a map using the unprefixed state, for ssh. */ /* currently this is computed for each call, which may be wasteful, but it is reliable in the face of config changes. * we could cache the Map. note that we do _not_ cache (or even own) the SshTool; * the SshTool is created or re-used by the SshMachineLocation making use of these properties */ protected Map<String, Object> getSshFlags() { Map<String, Object> result = Maps.newLinkedHashMap(); StringConfigMap globalConfig = ((EntityInternal)getEntity()).getManagementContext().getConfig(); Map<ConfigKey<?>, Object> mgmtConfig = globalConfig.getAllConfig(); Map<ConfigKey<?>, Object> entityConfig = ((EntityInternal)getEntity()).getAllConfig(); Map<ConfigKey<?>, Object> allConfig = MutableMap.<ConfigKey<?>, Object>builder().putAll(mgmtConfig).putAll(entityConfig).build(); for (ConfigKey<?> key : allConfig.keySet()) { if (key.getName().startsWith(SshTool.BROOKLYN_CONFIG_KEY_PREFIX)) { // have to use raw config to test whether the config is set Object val = ((EntityInternal)getEntity()).getConfigMap().getRawConfig(key); if (val!=null) { val = getEntity().getConfig(key); } else { val = globalConfig.getRawConfig(key); if (val!=null) val = globalConfig.getConfig(key); } if (val!=null) { result.put(ConfigUtils.unprefixedKey(SshTool.BROOKLYN_CONFIG_KEY_PREFIX, key).getName(), val); } } } return result; }