/** * Read the cache configuration from the specified resource. * This function is intended to be overrideable to allow for programmatic * cache configuration. * @param configPath * @return Configuration * @throws IOException */ protected Configuration getConfiguration(String configPath) throws IOException { InputStream configStream = ResourceLoader.open(configPath); return ConfigurationFactory.parseConfiguration(configStream); }
/** * Read the cache configuration from the specified resource. * This function is intended to be overrideable to allow for programmatic * cache configuration. * @param configPath * @return Configuration * @throws IOException */ protected Configuration getConfiguration(String configPath) throws IOException { InputStream configStream = ResourceLoader.open(configPath); return ConfigurationFactory.parseConfiguration(configStream); }
/** * Read the cache configuration from the specified resource. * * This function is intended to be overrideable to allow for programmatic cache configuration. * * @param configPath * the path to the configuration file * @return Configuration the configuration object parsed from the configuration file * @throws IOException * if there was an error parsing the given configuration */ protected Configuration getConfiguration(String configPath) throws IOException { InputStream configStream = ResourceLoader.open(configPath); return ConfigurationFactory.parseConfiguration(configStream); }
/** * Read the cache configuration from the specified resource. * * This function is intended to be overrideable to allow for programmatic cache configuration. * * @param configPath * the path to the configuration file * @return Configuration the configuration object parsed from the configuration file * @throws IOException * if there was an error parsing the given configuration */ protected Configuration getConfiguration(String configPath) throws IOException { InputStream configStream = ResourceLoader.open(configPath); return ConfigurationFactory.parseConfiguration(configStream); }
/** * Read the cache configuration from the specified resource. * * This function is intended to be overrideable to allow for programmatic cache configuration. * * @param configPath * the path to the configuration file * @return Configuration the configuration object parsed from the configuration file * @throws IOException * if there was an error parsing the given configuration */ protected Configuration getConfiguration(String configPath) throws IOException { InputStream configStream = ResourceLoader.open(configPath); return ConfigurationFactory.parseConfiguration(configStream); }
private static Map<String, Object> jsonToMap(JSONObject json) { String[] keys = JSONObject.getNames(json); if (keys == null) { return ImmutableMap.of(); } Map<String, Object> values = new HashMap<String, Object>(json.length(), 1); for (String key : keys) { Object val = jsonToConfig(json.opt(key)); //If this is a string see if its a pointer to an external resource, and if so, load the resource if (val instanceof String) { String stringVal = (String) val; if (stringVal.startsWith(ResourceLoader.RESOURCE_PREFIX) || stringVal.startsWith(ResourceLoader.FILE_PREFIX)) { try { val = IOUtils.toString(ResourceLoader.open(stringVal), "UTF-8"); } catch (IOException e) { if (LOG.isLoggable(Level.WARNING)) { LOG.logp(Level.WARNING, classname, "jsonToMap", MessageKeys.READING_CONFIG, e); } } } } values.put(key, val); } return Collections.unmodifiableMap(values); }
private void loadDefaultKey(String signingKeyFile, String signingKeyName) { BasicOAuthStoreConsumerKeyAndSecret key = null; if (!StringUtils.isBlank(signingKeyFile)) { try { if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "loadDefaultKey", MessageKeys.LOAD_KEY_FILE_FROM, new Object[] {signingKeyFile}); } String privateKey = IOUtils.toString(ResourceLoader.open(signingKeyFile), "UTF-8"); privateKey = BasicOAuthStore.convertFromOpenSsl(privateKey); key = new BasicOAuthStoreConsumerKeyAndSecret(null, privateKey, KeyType.RSA_PRIVATE, signingKeyName, null); } catch (Throwable t) { if (LOG.isLoggable(Level.WARNING)) { LOG.logp(Level.WARNING, classname, "loadDefaultKey", MessageKeys.COULD_NOT_LOAD_KEY_FILE, new Object[] {signingKeyFile}); LOG.logp(Level.WARNING, classname, "loadDefaultKey", "",t); } } } if (key != null) { store.setDefaultKey(key); } else { if (LOG.isLoggable(Level.WARNING)) { LOG.logp(Level.WARNING, classname, "loadDefaultKey", MessageKeys.COULD_NOT_LOAD_SIGN_KEY, new Object[] {OAUTH_SIGNING_KEY_FILE,OAUTH_SIGNING_KEY_NAME}); } } }
private static Map<String, Object> jsonToMap(JSONObject json) { String[] keys = JSONObject.getNames(json); if (keys == null) { return ImmutableMap.of(); } Map<String, Object> values = new HashMap<String, Object>(json.length(), 1); for (String key : keys) { Object val = jsonToConfig(json.opt(key)); //If this is a string see if its a pointer to an external resource, and if so, load the resource if (val instanceof String) { String stringVal = (String) val; if (stringVal.startsWith(ResourceLoader.RESOURCE_PREFIX) || stringVal.startsWith(ResourceLoader.FILE_PREFIX)) { try { val = IOUtils.toString(ResourceLoader.open(stringVal), "UTF-8"); } catch (IOException e) { if (LOG.isLoggable(Level.WARNING)) { LOG.logp(Level.WARNING, classname, "jsonToMap", MessageKeys.READING_CONFIG, e); } } } } values.put(key, val); } return Collections.unmodifiableMap(values); }
private static Map<String, Object> jsonToMap(JSONObject json) { String[] keys = JSONObject.getNames(json); if (keys == null) { return ImmutableMap.of(); } Map<String, Object> values = new HashMap<String, Object>(json.length(), 1); for (String key : keys) { Object val = jsonToConfig(json.opt(key)); //If this is a string see if its a pointer to an external resource, and if so, load the resource if (val instanceof String) { String stringVal = (String) val; if (stringVal.startsWith(ResourceLoader.RESOURCE_PREFIX) || stringVal.startsWith(ResourceLoader.FILE_PREFIX)) { try { val = IOUtils.toString(ResourceLoader.open(stringVal), "UTF-8"); } catch (IOException e) { if (LOG.isLoggable(Level.WARNING)) { LOG.logp(Level.WARNING, classname, "jsonToMap", MessageKeys.READING_CONFIG, e); } } } } values.put(key, val); } return Collections.unmodifiableMap(values); }
private void loadDefaultKey(String signingKeyFile, String signingKeyName) { BasicOAuthStoreConsumerKeyAndSecret key = null; if (!StringUtils.isBlank(signingKeyFile)) { try { LOG.info("Loading OAuth signing key from " + signingKeyFile); String privateKey = IOUtils.toString(ResourceLoader.open(signingKeyFile), "UTF-8"); privateKey = BasicOAuthStore.convertFromOpenSsl(privateKey); key = new BasicOAuthStoreConsumerKeyAndSecret(null, privateKey, KeyType.RSA_PRIVATE, signingKeyName, null); } catch (Throwable t) { LOG.log(Level.WARNING, "Couldn't load key file " + signingKeyFile, t); } } if (key != null) { store.setDefaultKey(key); } else { LOG.log(Level.WARNING, "Couldn't load OAuth signing key. To create a key, run:\n" + " openssl req -newkey rsa:1024 -days 365 -nodes -x509 -keyout testkey.pem \\\n" + " -out testkey.pem -subj '/CN=mytestkey'\n" + " openssl pkcs8 -in testkey.pem -out oauthkey.pem -topk8 -nocrypt -outform PEM\n" + '\n' + "Then edit shindig.properties and add these lines:\n" + OAUTH_SIGNING_KEY_FILE + "=<path-to-oauthkey.pem>\n" + OAUTH_SIGNING_KEY_NAME + "=mykey\n"); } }
private void loadDefaultKey(String signingKeyFile, String signingKeyName) { BasicOAuthStoreConsumerKeyAndSecret key = null; if (!StringUtils.isBlank(signingKeyFile)) { try { LOG.info("Loading OAuth signing key from " + signingKeyFile); String privateKey = IOUtils.toString(ResourceLoader.open(signingKeyFile), "UTF-8"); privateKey = BasicOAuthStore.convertFromOpenSsl(privateKey); key = new BasicOAuthStoreConsumerKeyAndSecret(null, privateKey, KeyType.RSA_PRIVATE, signingKeyName, null); } catch (Throwable t) { LOG.log(Level.WARNING, "Couldn't load key file " + signingKeyFile, t); } } if (key != null) { store.setDefaultKey(key); } else { LOG.log(Level.WARNING, "Couldn't load OAuth signing key. To create a key, run:\n" + " openssl req -newkey rsa:1024 -days 365 -nodes -x509 -keyout testkey.pem \\\n" + " -out testkey.pem -subj '/CN=mytestkey'\n" + " openssl pkcs8 -in testkey.pem -out oauthkey.pem -topk8 -nocrypt -outform PEM\n" + '\n' + "Then edit shindig.properties and add these lines:\n" + OAUTH_SIGNING_KEY_FILE + "=<path-to-oauthkey.pem>\n" + OAUTH_SIGNING_KEY_NAME + "=mykey\n"); } }