List of usage examples for org.apache.commons.configuration PropertiesConfiguration clearProperty
public void clearProperty(String key)
From source file:com.linkedin.pinot.core.segment.creator.impl.SegmentColumnarIndexCreator.java
public static void removeColumnMetadataInfo(PropertiesConfiguration properties, String column) { properties.clearProperty(getKeyFor(column, CARDINALITY)); properties.clearProperty(getKeyFor(column, TOTAL_DOCS)); properties.clearProperty(getKeyFor(column, TOTAL_RAW_DOCS)); properties.clearProperty(getKeyFor(column, TOTAL_AGG_DOCS)); properties.clearProperty(getKeyFor(column, DATA_TYPE)); properties.clearProperty(getKeyFor(column, BITS_PER_ELEMENT)); properties.clearProperty(getKeyFor(column, DICTIONARY_ELEMENT_SIZE)); properties.clearProperty(getKeyFor(column, COLUMN_TYPE)); properties.clearProperty(getKeyFor(column, IS_SORTED)); properties.clearProperty(getKeyFor(column, HAS_NULL_VALUE)); properties.clearProperty(getKeyFor(column, HAS_DICTIONARY)); properties.clearProperty(getKeyFor(column, HAS_INVERTED_INDEX)); properties.clearProperty(getKeyFor(column, IS_SINGLE_VALUED)); properties.clearProperty(getKeyFor(column, MAX_MULTI_VALUE_ELEMTS)); properties.clearProperty(getKeyFor(column, TOTAL_NUMBER_OF_ENTRIES)); properties.clearProperty(getKeyFor(column, IS_AUTO_GENERATED)); properties.clearProperty(getKeyFor(column, DEFAULT_NULL_VALUE)); }
From source file:com.continuent.tungsten.common.security.SecurityHelper.java
/** * Delete a user and password from a file * //from ww w . ja v a 2 s . co m * @param authenticationInfo containing password file location */ public static void deleteUserFromAuthenticationInfo(AuthenticationInfo authenticationInfo) throws ServerRuntimeException { String username = authenticationInfo.getUsername(); String passwordFileLocation = authenticationInfo.getPasswordFileLocation(); try { PropertiesConfiguration props = new PropertiesConfiguration(passwordFileLocation); // --- Check that the user exists --- String usernameInFile = props.getString(username); if (usernameInFile == null) { throw new ServerRuntimeException(MessageFormat.format("Username does not exist: {0}", username)); } props.clearProperty(username); props.save(); } catch (org.apache.commons.configuration.ConfigurationException ce) { logger.error("Error while saving properties for file:" + authenticationInfo.getPasswordFileLocation(), ce); throw new ServerRuntimeException("Error while saving Credentials: " + ce.getMessage()); } }
From source file:com.impetus.ankush.agent.action.impl.PropertyFileManipulator.java
/** * Delete conf value.//from w ww . j av a2 s .c o m * * @param file * the file * @param propertyName * the property name * @return true, if successful */ @Override public boolean deleteConfValue(String file, String propertyName) { boolean status = false; try { // read conf file File confFile = new File(file); if (!confFile.exists()) { System.err.println("File " + file + " does not exists."); status = false; } PropertiesConfiguration props = new PropertiesConfiguration(file); props.getLayout().setSeparator(propertyName, "="); if (props.getProperty(propertyName) != null) { props.clearProperty(propertyName); props.save(); status = true; } } catch (Exception e) { System.err.println(e.getMessage()); } return status; }
From source file:gov.nih.nci.cacisweb.action.SecureFTPAction.java
/** * /*from w w w .j a va 2 s . c o m*/ * @return * @throws Exception */ public String delete() throws Exception { log.debug("delete() - START"); String secureFTPPropertyFileLocation = CaCISUtil .getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_PROPERTIES_FILE_LOCATION); String secureFTPKeystoreLocation = CaCISUtil.getPropertyFromPropertiesFile(secureFTPPropertyFileLocation, CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_TRUSTSTORE_LOCATION_PROP_NAME)); String secureFTPKeystorePassword = CaCISUtil.getPropertyFromPropertiesFile(secureFTPPropertyFileLocation, CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_TRUSTSTORE_PASSWORD_PROP_NAME)); try { CaCISUtil caCISUtil = new CaCISUtil(); KeyStore keystore = caCISUtil.getKeystore(secureFTPKeystoreLocation, CaCISWebConstants.COM_KEYSTORE_TYPE_JKS, secureFTPKeystorePassword); caCISUtil.releaseKeystore(); // Delete the certificate keystore.deleteEntry(secureFTPBean.getCertificateAlias()); // Save the new keystore contents FileOutputStream out = new FileOutputStream(new File(secureFTPKeystoreLocation)); keystore.store(out, secureFTPKeystorePassword.toCharArray()); out.close(); // delete the entry from FTP configuration properties file PropertiesConfiguration config = new PropertiesConfiguration( CaCISUtil.getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECFTP_CONFIG_FILE_LOCATION)); config.clearProperty(secureFTPBean.getCertificateAlias()); config.save(); } catch (KeystoreInstantiationException kie) { log.error(kie.getMessage()); addActionError(getText("exception.keystoreInstantiation")); return ERROR; } addActionMessage(getText("secureFTPBean.deleteCertificateSuccessful")); log.debug("delete() - END"); return SUCCESS; }
From source file:gov.nih.nci.cacisweb.action.SecureXDSNAVAction.java
/** * //from w w w . ja v a2 s . co m * @return * @throws Exception */ public String delete() throws Exception { log.debug("delete() - START"); String secureXDSNAVKeystoreLocation = CaCISUtil .getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECXDSNAV_RECEPIENT_TRUSTSTORE_LOCATION); try { CaCISUtil caCISUtil = new CaCISUtil(); KeyStore keystore = caCISUtil.getKeystore(secureXDSNAVKeystoreLocation, CaCISWebConstants.COM_KEYSTORE_TYPE_JKS, CaCISUtil.getProperty( CaCISWebConstants.COM_PROPERTY_NAME_SECXDSNAV_RECEPIENT_TRUSTSTORE_PASSWORD)); caCISUtil.releaseKeystore(); // Delete the certificate keystore.deleteEntry(secureXDSNAVBean.getCertificateAlias()); // Save the new keystore contents FileOutputStream out = new FileOutputStream(new File(secureXDSNAVKeystoreLocation)); keystore.store(out, CaCISUtil .getProperty( CaCISWebConstants.COM_PROPERTY_NAME_SECXDSNAV_RECEPIENT_TRUSTSTORE_PASSWORD) .toCharArray()); out.close(); // delete the entry from XDSNAV configuration properties file PropertiesConfiguration config = new PropertiesConfiguration(CaCISUtil .getProperty(CaCISWebConstants.COM_PROPERTY_NAME_SECXDSNAV_RECEPIENT_CONFIG_FILE_LOCATION)); config.clearProperty(secureXDSNAVBean.getCertificateAlias()); config.save(); } catch (KeystoreInstantiationException kie) { log.error(kie.getMessage()); addActionError(getText("exception.keystoreInstantiation")); return ERROR; } addActionMessage(getText("secureXDSNAVBean.deleteCertificateSuccessful")); log.debug("delete() - END"); return SUCCESS; }
From source file:com.mirth.connect.server.migration.Migrate3_1_0.java
private void migrateLog4jProperties() { PropertiesConfiguration log4jproperties = new PropertiesConfiguration(); log4jproperties.setDelimiterParsingDisabled(true); log4jproperties.setFile(new File(ClassPathResource.getResourceURI("log4j.properties"))); try {//from w w w. ja va2 s . co m log4jproperties.load(); String level = (String) log4jproperties.getProperty("log4j.logger.shutdown"); if (level != null) { log4jproperties.setProperty("log4j.logger.undeploy", level); log4jproperties.clearProperty("log4j.logger.shutdown"); Logger.getLogger("undeploy").setLevel(Level.toLevel(level)); } level = (String) log4jproperties .getProperty("log4j.logger.com.mirth.connect.donkey.server.channel.RecoveryTask"); if (StringUtils.isBlank(level)) { level = "INFO"; log4jproperties.setProperty("log4j.logger.com.mirth.connect.donkey.server.channel.RecoveryTask", level); Logger.getLogger("com.mirth.connect.donkey.server.channel.RecoveryTask") .setLevel(Level.toLevel(level)); } log4jproperties.save(); } catch (ConfigurationException e) { logger.error("Failed to migrate log4j properties."); } }
From source file:com.jaspersoft.buildomatic.crypto.MasterPropertiesObfuscator.java
@Override public void execute() throws BuildException { try {//from ww w . ja va 2 s .c o m //load master props PropertiesConfiguration config = new PropertiesConfiguration(new File(propsFile)); PropertiesConfigurationLayout configLayout = config.getLayout(); configLayout.setGlobalSeparator("="); Boolean encFlag = Boolean.parseBoolean(config.getString(ENCRYPT_FLAG)); Boolean encDoneFlag = Boolean.parseBoolean(config.getString(ENCRYPT_DONE_FLAG)); if (encFlag && !encDoneFlag) { String blockSzStr = config.getString(CRYPTO_BLOCK_SIZE_PARAM); EncryptionProperties encProps = new EncryptionProperties( blockSzStr != null ? Integer.parseInt(blockSzStr) : null, config.getString(CRYPTO_TRANSFORMATION_PARAM)); List<Object> propsToEncryptList = config.getList(PROPS_TO_ENCRYPT_PARAM, Arrays.<Object>asList(PROPS_TO_ENCRYPT_DEF)); log("Encrypt " + StringUtils.join(propsToEncryptList.toArray(), ','), Project.MSG_INFO); log("Encryption block size: " + encProps.getBlockSize(), Project.MSG_DEBUG); log("Encryption mode: " + encProps.getCipherTransformation(), Project.MSG_DEBUG); //obtain Keystore Manager KeystoreManager.init(this.ksp); KeystoreManager ksManager = KeystoreManager.getInstance(); //obtain key Key secret = ksManager.getBuildKey(); Set<String> paramSet = new HashSet<String>(propsToEncryptList.size()); for (Object prop : propsToEncryptList) { String propNameToEnc = prop.toString().trim(); if (paramSet.contains(propNameToEnc)) continue; //was already encrypted once paramSet.add(propNameToEnc); String pVal = config.getString(propNameToEnc); if (pVal != null) { if (EncryptionEngine.isEncrypted(pVal)) log("encrypt=true was set, but param " + propNameToEnc + " was found already encrypted. " + " Skipping its encryption.", Project.MSG_WARN); else { String ct = EncryptionEngine.encrypt(secret, pVal, encProps); config.setProperty(propNameToEnc, ct); } } } //set encryption to done config.clearProperty(ENCRYPT_FLAG); config.setProperty(ENCRYPT_DONE_FLAG, "true"); //write master props back config.save(); } else if (encDoneFlag) { log("The master properties have already been encrypted. To re-enable the encryption, " + "make sure the passwords are in plain text, set master property " + "encrypt to true and remove encrypt.done.", Project.MSG_INFO); } } catch (Exception e) { throw new BuildException(e, getLocation()); } }
From source file:es.bsc.servicess.ide.editors.ImplementationFormPage.java
/** * Delete a orchestration class from the project metadata * @param classToDelete Orchestration class to be deleted * @throws ConfigurationException// w ww .j a va 2s . c o m */ protected void deleteClassFromMetadataFile(String classToDelete) throws ConfigurationException { IFile f = ((ServiceFormEditor) getEditor()).getMetadataFile(); PropertiesConfiguration config = new PropertiesConfiguration(f.getRawLocation().toOSString()); String[] classes = config.getStringArray("service.class"); config.clearProperty("service.class"); for (String c : classes) { if (!c.equals(classToDelete)) { config.addProperty("service.class", c); } } config.save(); }
From source file:com.mirth.connect.server.migration.ServerMigrator.java
private void runConfigurationMigrator(ConfigurationMigrator configurationMigrator, PropertiesConfiguration mirthConfig, Version version) { configurationMigrator.updateConfiguration(mirthConfig); HashMap<String, Object> addedProperties = new LinkedHashMap<String, Object>(); Map<String, Object> propertiesToAdd = configurationMigrator.getConfigurationPropertiesToAdd(); if (propertiesToAdd != null) { for (Entry<String, Object> propertyToAdd : propertiesToAdd.entrySet()) { if (!mirthConfig.containsKey(propertyToAdd.getKey())) { PropertiesConfigurationLayout layout = mirthConfig.getLayout(); String key = propertyToAdd.getKey(); Object value;// w w w. j a va2 s . c om String comment = ""; if (propertyToAdd.getValue() instanceof Pair) { // If a pair is used, get both the value and comment Pair<Object, String> pair = (Pair<Object, String>) propertyToAdd.getValue(); value = pair.getLeft(); comment = pair.getRight(); } else { // Only the value was specified value = propertyToAdd.getValue(); } mirthConfig.setProperty(key, value); // If this is the first added property, add a general comment about the added properties before it if (addedProperties.isEmpty()) { if (StringUtils.isNotEmpty(comment)) { comment = "\n\n" + comment; } comment = "The following properties were automatically added on startup for version " + version + comment; } if (StringUtils.isNotEmpty(comment)) { // When a comment is specified, always put a blank line before it layout.setBlancLinesBefore(key, 1); layout.setComment(key, comment); } addedProperties.put(key, value); } } } List<String> removedProperties = new ArrayList<String>(); String[] propertiesToRemove = configurationMigrator.getConfigurationPropertiesToRemove(); if (propertiesToRemove != null) { for (String propertyToRemove : propertiesToRemove) { if (mirthConfig.containsKey(propertyToRemove)) { mirthConfig.clearProperty(propertyToRemove); removedProperties.add(propertyToRemove); } } } if (!addedProperties.isEmpty() || !removedProperties.isEmpty()) { if (!addedProperties.isEmpty()) { logger.info("Adding properties in mirth.properties: " + addedProperties); } if (!removedProperties.isEmpty()) { logger.info("Removing properties in mirth.properties: " + removedProperties); } try { mirthConfig.save(); } catch (ConfigurationException e) { logger.error("There was an error updating mirth.properties.", e); if (!addedProperties.isEmpty()) { logger.error("The following properties should be added to mirth.properties manually: " + addedProperties.toString()); } if (!removedProperties.isEmpty()) { logger.error("The following properties should be removed from mirth.properties manually: " + removedProperties.toString()); } } } }
From source file:org.sakuli.utils.SakuliPropertyPlaceholderConfigurer.java
@PreDestroy public void restoreProperties() { try {/*from w w w . j av a 2 s . co m*/ for (Map.Entry<String, Map<String, Object>> entry : modifiedSahiConfigProps.entrySet()) { String propFile = entry.getKey(); logger.debug("restore properties file '{}' with properties '{}'", propFile, entry.getValue()); PropertiesConfiguration propConfig = new PropertiesConfiguration(propFile); propConfig.setAutoSave(true); for (Map.Entry<String, Object> propEntry : entry.getValue().entrySet()) { String propKey = propEntry.getKey(); if (propConfig.containsKey(propKey)) { propConfig.clearProperty(propKey); } propConfig.addProperty(propKey, propEntry.getValue()); } } } catch (ConfigurationException e) { logger.error("Error in restore sahi config properties", e); } }