@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { String encryptionPassword = (String)options.get(ENCRYPTION_PASSWORD); String passwordEnvName = options.get(PASSWORD_ENV_NAME) != null ? (String)options.get(PASSWORD_ENV_NAME) : DEFAULT_PASSWORD_ENV_NAME; String passwordAlgorithm = options.get(PASSWORD_ALGORITHM) != null ? (String)options.get(PASSWORD_ALGORITHM) : DEFAULT_PASSWORD_ALGORITHM; EnvironmentStringPBEConfig envConfig = new EnvironmentStringPBEConfig(); envConfig.setAlgorithm(passwordAlgorithm); //If the password was set, use it //else look up the password from the environment if (encryptionPassword == null) { envConfig.setPasswordEnvName(passwordEnvName); } else { envConfig.setPassword(encryptionPassword); } configurationEncryptor.setConfig(envConfig); EncryptableProperties encryptableOptions = new EncryptableProperties(configurationEncryptor); encryptableOptions.putAll(options); super.initialize(subject, callbackHandler, sharedState, encryptableOptions); }
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); keyChanger.initEncryptor(encryptor, oldMSKey); dbProps = new EncryptableProperties(encryptor); PropertiesConfiguration backupDBProps = null;
/** * Loads the Encrypted configuration BotMill configuration properties file. * In order for this to work, you need a botmill.properties file on the * classpath. If you have a Maven project, just make sure to place it in the * resources folder. * * @param encryptor * the encryptor */ public static void setEncryptedPropertiesEncryptor(PBEStringCleanablePasswordEncryptor encryptor) { try { if (encryptedConfiguration == null) { encryptedConfiguration = new EncryptableProperties(encryptor); } encryptedConfiguration.load(ConfigurationUtils.class.getClassLoader().getResourceAsStream(CONFIG_PATH)); } catch (Exception e) { logger.error("Error while loading BotMill properties file ({})", CONFIG_PATH, e); } }
/** * <p> * Obtains the property value for the specified key (see * {@link Properties#getProperty(String)}), decrypting it if needed. * </p> * * @param key the property key * @return the (decrypted) value */ public String getProperty(final String key) { return decode(super.getProperty(key)); }
/** The mongodb ops. */ /* (non-Javadoc) * @see co.aurasphere.botmill.core.datastore.adapter.DataAdapter#setup() */ public void setup() { MongoCredential credential = MongoCredential.createCredential( ConfigurationUtils.getEncryptedConfiguration().getProperty("mongodb.username"), ConfigurationUtils.getEncryptedConfiguration().getProperty("mongodb.database"), ConfigurationUtils.getEncryptedConfiguration().getProperty("mongodb.password").toCharArray()); ServerAddress serverAddress = new ServerAddress( ConfigurationUtils.getEncryptedConfiguration().getProperty("mongodb.server"), Integer.valueOf(ConfigurationUtils.getEncryptedConfiguration().getProperty("mongodb.port"))); MongoClient mongoClient = new MongoClient(serverAddress, Arrays.asList(credential)); SimpleMongoDbFactory simpleMongoDbFactory = new SimpleMongoDbFactory(mongoClient, ConfigurationUtils.getEncryptedConfiguration().getProperty("mongodb.database")); MongoTemplate mongoTemplate = new MongoTemplate(simpleMongoDbFactory); this.source = (MongoOperations) mongoTemplate; }
/** * Uses jasypt to parse the properties * * @param props the properties currently read * @return an instance of {@link org.jasypt.properties.EncryptableProperties} */ @Override protected Properties parseProperties(Properties props) { return new EncryptableProperties(props, encryptor); } }
/** * Loads the Encrypted configuration BotMill configuration properties file. * In order for this to work, you need a botmill.properties file on the * classpath. If you have a Maven project, just make sure to place it in the * resources folder. * * @param encryptor * the encryptor. * @param classpathProperties * the classpath properties */ public static void loadEncryptedConfigurationFile(PBEStringCleanablePasswordEncryptor encryptor, String classpathProperties) { try { if (encryptedConfiguration == null) { encryptedConfiguration = new EncryptableProperties(encryptor); } encryptedConfiguration .load(ConfigurationUtils.class.getClassLoader().getResourceAsStream(classpathProperties)); } catch (Exception e) { logger.error("Error while loading BotMill properties file ({})", CONFIG_PATH, e); } }
void setStringEncryptor(final EncryptableProperties prop, final StringEncryptor encryptor) { this.stringEncryptors.put(prop.getIdent(), encryptor); }
/** * <p> * Obtains the property value for the specified key (see * {@link Properties#getProperty(String)}), decrypting it if needed. * </p> * * @param key the property key * @return the (decrypted) value */ public String getProperty(final String key) { return decode(super.getProperty(key)); }
/** * Builds the Fb bot config. * * @throws BotMillMissingConfigurationException * the bot mill missing configuration exception */ private void buildFbBotConfig() { FbBotMillContext.getInstance().setup( ConfigurationUtils.getEncryptedConfiguration().getProperty(FB_BOTMILL_PAGE_TOKEN), ConfigurationUtils.getEncryptedConfiguration().getProperty(FB_BOTMILL_VALIDATION_TOKEN)); } }
protected static Properties wrapEncryption(Properties dbProps) throws IOException { EncryptionSecretKeyChecker checker = new EncryptionSecretKeyChecker(); checker.check(dbProps); if (EncryptionSecretKeyChecker.useEncryption()) { return dbProps; } else { EncryptableProperties encrProps = new EncryptableProperties(EncryptionSecretKeyChecker.getEncryptor()); encrProps.putAll(dbProps); return encrProps; } }
rslt = new EncryptableProperties(encryptor);
/** * <p> * Obtains the property value for the specified key (see * {@link Properties#getProperty(String)}), decrypting it if needed. * </p> * * @param key the property key * @return the (decrypted) value */ public String getProperty(final String key) { return decode(super.getProperty(key)); }
/** * Instantiates a new bot mill session. */ private BotMillSession() { // check the data adapter type from the properties. // map, hsql, mongodb, rdbms String dataAdapterType = ConfigurationUtils.getEncryptedConfiguration().getProperty("data.adapter.type"); if(dataAdapterType == null || dataAdapterType.equals("map")) { defineDataAdapter(DataAdapterType.MAP); }else if(dataAdapterType.equals("mongodb")){ defineDataAdapter(DataAdapterType.MONGODB); }else if(dataAdapterType.equals("hsql")) { defineDataAdapter(DataAdapterType.HSQL); }else if(dataAdapterType.equals("rdbms")) { defineDataAdapter(DataAdapterType.RBDMS); }else { logger.info("No Data Adapter Type specified on the botmill.properties, defaulting to Map"); defineDataAdapter(DataAdapterType.MAP); } }
EncryptableProperties encrDbProps = new EncryptableProperties(encryptor); encrDbProps.putAll(dbProps); dbProps = encrDbProps;
/** * <p> * Obtains the property value for the specified key (see * {@link Properties#getProperty(String)}), decrypting it if needed. * </p> * <p> * If no value is found for the specified key, the default value will * be returned (decrypted if needed). * </p> * * @param key the property key * @param defaultValue the default value to return * @return the (decrypted) value */ public String getProperty(final String key, final String defaultValue) { return decode(super.getProperty(key, defaultValue)); }
private static Properties processProperties(final Properties props, final TextEncryptor encryptor) { if (props == null) { return null; } if (props instanceof EncryptableProperties) { throw new IllegalArgumentException( "Properties object already is an " + EncryptableProperties.class.getName() + " object. No encryptor should be specified."); } final EncryptableProperties encryptableProperties = new EncryptableProperties(encryptor); encryptableProperties.putAll(props); return encryptableProperties; }