components/ciphertool/src/main/java/org/wso2/ciphertool/CipherTool.java
private static void changePassword(Cipher cipher) {
        Properties cipherTextProperties = Utils.loadProperties(System.getProperty(
                Constants.CIPHER_TEXT_PROPERTY_FILE_PROPERTY));
        List<String> keyValueList = new ArrayList<String>();
        int i = 1;
        for (Object key : cipherTextProperties.keySet()) {
            String passwordAlias = (String) key;
            aliasPasswordMap.put(passwordAlias, cipherTextProperties.getProperty(passwordAlias));
            keyValueList.add(passwordAlias);
            System.out.println("[" + i++ + "] " + passwordAlias);
        }
        boolean isModified = false;
        String value;
        while (!(value = Utils.getValueFromConsole(
                "Please enter the Number which is corresponding to the Password that is needed be changed "
                        + "[Press Enter to Skip] : ", false)).isEmpty()) {
            if (!value.trim().equals("")) {
                String selectedPasswordAlias = keyValueList.get(Integer.parseInt(value.trim()) - 1);
                String newEncryptedValue = getPasswordFromConsole(selectedPasswordAlias, cipher);
                aliasPasswordMap.put(selectedPasswordAlias, newEncryptedValue);
                isModified = true;
            }
        }

        if (isModified) {
            cipherTextProperties.putAll(aliasPasswordMap);
            Utils.writeToPropertyFile(cipherTextProperties,
                                      System.getProperty(Constants.CIPHER_TEXT_PROPERTY_FILE_PROPERTY));
        }
    }
/**
     * use to change an specific password.
     */
use to change an specific password.
use to change an specific password .
private static void changePassword(Cipher cipher) {
        Properties cipherTextProperties = Utils.loadProperties(System.getProperty(
                Constants.CIPHER_TEXT_PROPERTY_FILE_PROPERTY));
        List<String> keyValueList = new ArrayList<String>();
        int i = 1;
        for (Object key : cipherTextProperties.keySet()) {
            String passwordAlias = (String) key;
            aliasPasswordMap.put(passwordAlias, cipherTextProperties.getProperty(passwordAlias));
            keyValueList.add(passwordAlias);
            System.out.println("[" + i++ + "] " + passwordAlias);
        }
        boolean isModified = false;
        String value;
        while (!(value = Utils.getValueFromConsole(
                "Please enter the Number which is corresponding to the Password that is needed be changed "
                        + "[Press Enter to Skip] : ", false)).isEmpty()) {
            if (!value.trim().equals("")) {
                String selectedPasswordAlias = keyValueList.get(Integer.parseInt(value.trim()) - 1);
                String newEncryptedValue = getPasswordFromConsole(selectedPasswordAlias, cipher);
                aliasPasswordMap.put(selectedPasswordAlias, newEncryptedValue);
                isModified = true;
            }
        }
        if (isModified) {
            cipherTextProperties.putAll(aliasPasswordMap);
            Utils.writeToPropertyFile(cipherTextProperties,
                                      System.getProperty(Constants.CIPHER_TEXT_PROPERTY_FILE_PROPERTY));
        }
    }
private static void changePassword ( Cipher cipher ) { Properties cipherTextProperties = Utils . loadProperties ( System . getProperty ( Constants . CIPHER_TEXT_PROPERTY_FILE_PROPERTY ) ) ; List < String > keyValueList = new ArrayList < String > ( ) ; int i = 1 ; for ( Object key : cipherTextProperties . keySet ( ) ) { String passwordAlias = ( String ) key ; aliasPasswordMap . put ( passwordAlias , cipherTextProperties . getProperty ( passwordAlias ) ) ; keyValueList . add ( passwordAlias ) ; System . out . println ( "[" + i ++ + "] " + passwordAlias ) ; } boolean isModified = false ; String value ; while ( ! ( value = Utils . getValueFromConsole ( "Please enter the Number which is corresponding to the Password that is needed be changed " + "[Press Enter to Skip] : " , false ) ) . isEmpty ( ) ) { if ( ! value . trim ( ) . equals ( "" ) ) { String selectedPasswordAlias = keyValueList . get ( Integer . parseInt ( value . trim ( ) ) - 1 ) ; String newEncryptedValue = getPasswordFromConsole ( selectedPasswordAlias , cipher ) ; aliasPasswordMap . put ( selectedPasswordAlias , newEncryptedValue ) ; isModified = true ; } } if ( isModified ) { cipherTextProperties . putAll ( aliasPasswordMap ) ; Utils . writeToPropertyFile ( cipherTextProperties , System . getProperty ( Constants . CIPHER_TEXT_PROPERTY_FILE_PROPERTY ) ) ; } }
use to change an specific password.
use to change an specific password .