/** * Returns the value of the specified property. * * @param name the name of the property to get. * @return the value of the specified property. */ public synchronized String getProperty(String name) { return getProperty(name, true); }
/** * Returns a list of names for all properties found in the XML file. * * @return Names for all properties in the file */ public List<String> getAllPropertyNames() { List<String> result = new ArrayList<>(); for (String propertyName : getChildPropertyNamesFor(document.getRootElement(), "")) { if (getProperty(propertyName) != null) { result.add(propertyName); } } return result; }
/** * Returns a local property. Local properties are stored in the file defined in * <tt>JIVE_CONFIG_FILENAME</tt> that exists in the <tt>home</tt> directory. * Properties are always specified as "foo.bar.prop", which would map to * the following entry in the XML file: * <pre> * <foo> * <bar> * <prop>some value</prop> * </bar> * </foo> * </pre> * * @param name the name of the property to return. * @return the property value specified by name. */ public static String getXMLProperty(String name) { if (openfireProperties == null) { loadOpenfireProperties(); } return openfireProperties.getProperty(name); }
/** * This method is called early during the setup process to * set a custom key for encrypting property values */ public static void setupPropertyEncryptionKey(String key) { // Get the old secret key and encryption type String oldAlg = securityProperties.getProperty(ENCRYPTION_ALGORITHM); String oldKey = securityProperties.getProperty(ENCRYPTION_KEY_CURRENT); if(StringUtils.isNotEmpty(oldKey) && !oldKey.equals(key) && StringUtils.isNotEmpty(oldAlg)) { // update encrypted properties updateEncryptionProperties(oldAlg, oldKey, oldAlg, key); } securityProperties.setProperty(ENCRYPTION_KEY_CURRENT, new AesEncryptor().encrypt(currentKey)); }
if (openfireProperties != null) { String [] localeArray; String localeProperty = openfireProperties.getProperty("locale"); if (localeProperty != null) { localeArray = localeProperty.split("_");
/** * This method is called early during the setup process to * set the algorithm for encrypting property values */ public static void setupPropertyEncryptionAlgorithm(String alg) { // Get the old secret key and encryption type String oldAlg = securityProperties.getProperty(ENCRYPTION_ALGORITHM); String oldKey = securityProperties.getProperty(ENCRYPTION_KEY_CURRENT); if(StringUtils.isNotEmpty(oldAlg) && !oldAlg.equals(alg) && StringUtils.isNotEmpty(oldKey)){ // update encrypted properties updateEncryptionProperties(oldAlg, oldKey, alg, oldAlg); } if (ENCRYPTION_ALGORITHM_AES.equalsIgnoreCase(alg)) { securityProperties.setProperty(ENCRYPTION_ALGORITHM, ENCRYPTION_ALGORITHM_AES); } else { securityProperties.setProperty(ENCRYPTION_ALGORITHM, ENCRYPTION_ALGORITHM_BLOWFISH); } }
/** * Returns a local property. Local properties are stored in the file defined in * <tt>JIVE_CONFIG_FILENAME</tt> that exists in the <tt>home</tt> directory. * Properties are always specified as "foo.bar.prop", which would map to * the following entry in the XML file: * <pre> * <foo> * <bar> * <prop>some value</prop> * </bar> * </foo> * </pre> * * If the specified property can't be found, the <tt>defaultValue</tt> will be returned. * * @param name the name of the property to return. * @param defaultValue the default value for the property. * @return the property value specified by name. */ public static String getXMLProperty(String name, String defaultValue) { if (openfireProperties == null) { loadOpenfireProperties(); } String value = openfireProperties.getProperty(name); if (value == null) { value = defaultValue; } return value; }
/** * Fetches the current value of the property encryption key. * * @return The property encryption key */ public static Encryptor getPropertyEncryptor() { if (securityProperties == null) { loadSecurityProperties(); } if (propertyEncryptor == null) { String algorithm = securityProperties.getProperty(ENCRYPTION_ALGORITHM); if (ENCRYPTION_ALGORITHM_AES.equalsIgnoreCase(algorithm)) { propertyEncryptor = new AesEncryptor(currentKey); } else { propertyEncryptor = new Blowfish(currentKey); } } return propertyEncryptor; }
String encryptedKey = securityProperties.getProperty(ENCRYPTION_KEY_CURRENT); if (encryptedKey == null || encryptedKey.isEmpty()) { currentKey = null; String newKey = securityProperties.getProperty(ENCRYPTION_KEY_NEW, false); if (newKey != null) { String oldKey = securityProperties.getProperty(ENCRYPTION_KEY_OLD); if (oldKey == null) { if (currentKey != null) { for (String xmlProp : openfireProperties.getAllPropertyNames()) { if (isPropertyEncrypted(xmlProp)) { openfireProps.put(xmlProp, openfireProperties.getProperty(xmlProp));
/** * Convenience routine to migrate an XML property into the database * storage method. Will check for the XML property being null before * migrating. * * @param name the name of the property to migrate. */ public void migrateProperty(String name) { final String xmlPropertyValue = getProperty(name); if (xmlPropertyValue != null) { final String databasePropertyValue = JiveGlobals.getProperty(name); if (databasePropertyValue == null) { Log.debug("JiveGlobals: Migrating XML property '" + name + "' into database."); JiveGlobals.setProperty(name, xmlPropertyValue); if (JiveGlobals.isXMLPropertyEncrypted(name)) { JiveGlobals.setPropertyEncrypted(name, true); } deleteProperty(name); } else if (databasePropertyValue.equals(xmlPropertyValue)) { Log.debug("JiveGlobals: Deleting duplicate XML property '" + name + "' that is already in database."); if (JiveGlobals.isXMLPropertyEncrypted(name)) { JiveGlobals.setPropertyEncrypted(name, true); } deleteProperty(name); } else if (!databasePropertyValue.equals(xmlPropertyValue)) { Log.warn("XML Property '" + name + "' differs from what is stored in the database. Please make property changes in the database instead of the configuration file."); } } }
static void clearXMLPropertyEncryptionEntry(String name) { if (isSetupMode()) { return; } if (securityProperties == null) { loadSecurityProperties(); } if (openfireProperties == null) { loadOpenfireProperties(); } // Note; only remove the encryption indicator from XML file if the (encrypted) property is not also defined in the XML file if (JiveGlobals.isXMLPropertyEncrypted(name) && openfireProperties.getProperty(name) == null) { securityProperties.removeFromList(ENCRYPTED_PROPERTY_NAMES, name); } }
/** * Returns the value of the specified property. * * @param name the name of the property to get. * @return the value of the specified property. */ public synchronized String getProperty(String name) { return getProperty(name, true); }
/** * Returns a list of names for all properties found in the XML file. * * @return Names for all properties in the file */ public List<String> getAllPropertyNames() { List<String> result = new ArrayList<>(); for (String propertyName : getChildPropertyNamesFor(document.getRootElement(), "")) { if (getProperty(propertyName) != null) { result.add(propertyName); } } return result; }
/** * Returns a local property. Local properties are stored in the file defined in * <tt>JIVE_CONFIG_FILENAME</tt> that exists in the <tt>home</tt> directory. * Properties are always specified as "foo.bar.prop", which would map to * the following entry in the XML file: * <pre> * <foo> * <bar> * <prop>some value</prop> * </bar> * </foo> * </pre> * * @param name the name of the property to return. * @return the property value specified by name. */ public static String getXMLProperty(String name) { if (openfireProperties == null) { loadOpenfireProperties(); } return openfireProperties.getProperty(name); }
/** * This method is called early during the setup process to * set the algorithm for encrypting property values */ public static void setupPropertyEncryptionAlgorithm(String alg) { // Get the old secret key and encryption type String oldAlg = securityProperties.getProperty(ENCRYPTION_ALGORITHM); String oldKey = securityProperties.getProperty(ENCRYPTION_KEY_CURRENT); if(StringUtils.isNotEmpty(oldAlg) && !oldAlg.equals(alg) && StringUtils.isNotEmpty(oldKey)){ // update encrypted properties updateEncryptionProperties(oldAlg, oldKey, alg, oldAlg); } if (ENCRYPTION_ALGORITHM_AES.equalsIgnoreCase(alg)) { securityProperties.setProperty(ENCRYPTION_ALGORITHM, ENCRYPTION_ALGORITHM_AES); } else { securityProperties.setProperty(ENCRYPTION_ALGORITHM, ENCRYPTION_ALGORITHM_BLOWFISH); } }
/** * This method is called early during the setup process to * set a custom key for encrypting property values */ public static void setupPropertyEncryptionKey(String key) { // Get the old secret key and encryption type String oldAlg = securityProperties.getProperty(ENCRYPTION_ALGORITHM); String oldKey = securityProperties.getProperty(ENCRYPTION_KEY_CURRENT); if(StringUtils.isNotEmpty(oldKey) && !oldKey.equals(key) && StringUtils.isNotEmpty(oldAlg)) { // update encrypted properties updateEncryptionProperties(oldAlg, oldKey, oldAlg, key); } securityProperties.setProperty(ENCRYPTION_KEY_CURRENT, new AesEncryptor().encrypt(currentKey)); }
/** * Returns a local property. Local properties are stored in the file defined in * <tt>JIVE_CONFIG_FILENAME</tt> that exists in the <tt>home</tt> directory. * Properties are always specified as "foo.bar.prop", which would map to * the following entry in the XML file: * <pre> * <foo> * <bar> * <prop>some value</prop> * </bar> * </foo> * </pre> * * If the specified property can't be found, the <tt>defaultValue</tt> will be returned. * * @param name the name of the property to return. * @param defaultValue the default value for the property. * @return the property value specified by name. */ public static String getXMLProperty(String name, String defaultValue) { if (openfireProperties == null) { loadOpenfireProperties(); } String value = openfireProperties.getProperty(name); if (value == null) { value = defaultValue; } return value; }
/** * Convenience routine to migrate an XML property into the database * storage method. Will check for the XML property being null before * migrating. * * @param name the name of the property to migrate. */ public void migrateProperty(String name) { if (getProperty(name) != null) { if (JiveGlobals.getProperty(name) == null) { Log.debug("JiveGlobals: Migrating XML property '"+name+"' into database."); JiveGlobals.setProperty(name, getProperty(name)); deleteProperty(name); } else if (JiveGlobals.getProperty(name).equals(getProperty(name))) { Log.debug("JiveGlobals: Deleting duplicate XML property '"+name+"' that is already in database."); deleteProperty(name); } else if (!JiveGlobals.getProperty(name).equals(getProperty(name))) { Log.warn("XML Property '"+name+"' differs from what is stored in the database. Please make property changes in the database instead of the configuration file."); } } }
/** * Fetches the current value of the property encryption key. * * @return The property encryption key */ public static Encryptor getPropertyEncryptor() { if (securityProperties == null) { loadSecurityProperties(); } if (propertyEncryptor == null) { String algorithm = securityProperties.getProperty(ENCRYPTION_ALGORITHM); if (ENCRYPTION_ALGORITHM_AES.equalsIgnoreCase(algorithm)) { propertyEncryptor = new AesEncryptor(currentKey); } else { propertyEncryptor = new Blowfish(currentKey); } } return propertyEncryptor; }
static void clearXMLPropertyEncryptionEntry(String name) { if (isSetupMode()) { return; } if (securityProperties == null) { loadSecurityProperties(); } if (openfireProperties == null) { loadOpenfireProperties(); } // Note; only remove the encryption indicator from XML file if the (encrypted) property is not also defined in the XML file if (JiveGlobals.isXMLPropertyEncrypted(name) && openfireProperties.getProperty(name) == null) { securityProperties.removeFromList(ENCRYPTED_PROPERTY_NAMES, name); } }