Java Code Examples for org.jasypt.properties.PropertyValueEncryptionUtils

The following examples show how to use org.jasypt.properties.PropertyValueEncryptionUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: tessera   Source File: EncryptedStringResolver.java    License: Apache License 2.0 6 votes vote down vote up
public String resolve(final String textToDecrypt) {

        if (PropertyValueEncryptionUtils.isEncryptedValue(textToDecrypt)) {

            if (!isPasswordSet) {
                encryptor.setPasswordCharArray(
                        ConfigSecretReader.readSecretFromFile().orElseGet(ConfigSecretReader::readSecretFromConsole));
                isPasswordSet = true;
            }

            return PropertyValueEncryptionUtils.decrypt(textToDecrypt, encryptor);
        }

        LOGGER.warn(
                "Some sensitive values are being given as unencrypted plain text in config. "
                        + "Please note this is NOT recommended for production environment.");

        return textToDecrypt;
    }
 
Example 2
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 3
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 4
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 5
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 6
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 7
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 8
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 9
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 10
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 11
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 12
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 13
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 14
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 15
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 16
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 17
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 18
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 19
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 20
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 21
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 22
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 23
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 24
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 25
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 26
@Override
protected String convertPropertyValue(final String originalValue) {
	if (!PropertyValueEncryptionUtils.isEncryptedValue(originalValue)) {
		return originalValue;
	}
	if (this.stringEncryptor != null) {
		return PropertyValueEncryptionUtils.decrypt(originalValue,
				this.stringEncryptor);

	}
	return PropertyValueEncryptionUtils.decrypt(originalValue, this.textEncryptor);
}
 
Example 27
Source Project: seed   Source File: JasyptConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object getProperty(String name) {
    Object value = super.getProperty(name);
    if(value instanceof String){
        String stringValue = String.valueOf(value);
        //查看isEncryptedValue()源碼可看到它是根據ENC()判斷是否需要解密的
        if(PropertyValueEncryptionUtils.isEncryptedValue(stringValue)){
            value = PropertyValueEncryptionUtils.decrypt(stringValue, encryptor);
        }
    }
    //return super.getProperty(name);
    return value;
}
 
Example 28
public void configure(final Properties props) {
   
   final String encryptorRegisteredName = 
       props.getProperty(ParameterNaming.ENCRYPTOR_REGISTERED_NAME);
   
   final HibernatePBEEncryptorRegistry encryptorRegistry =
       HibernatePBEEncryptorRegistry.getInstance();
   final PBEStringEncryptor encryptor = 
       encryptorRegistry.getPBEStringEncryptor(encryptorRegisteredName);
   
   if (encryptor == null) {
       throw new EncryptionInitializationException(
               "No string encryptor registered for hibernate " +
               "with name \"" + encryptorRegisteredName + "\"");
   }

   // Get the original values, which may be encrypted
   final String driver = props.getProperty(AvailableSettings.DRIVER);
   final String url = props.getProperty(AvailableSettings.URL);
   final String user = props.getProperty(AvailableSettings.USER);
   final String password = props.getProperty(AvailableSettings.PASS);

   // Perform decryption operations as needed and store the new values
   if (PropertyValueEncryptionUtils.isEncryptedValue(driver)) {
       props.setProperty(
               AvailableSettings.DRIVER, 
               PropertyValueEncryptionUtils.decrypt(driver, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(url)) {
       props.setProperty(
               AvailableSettings.URL, 
               PropertyValueEncryptionUtils.decrypt(url, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(user)) {
       props.setProperty(
               AvailableSettings.USER, 
               PropertyValueEncryptionUtils.decrypt(user, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(password)) {
       props.setProperty(
               AvailableSettings.PASS, 
               PropertyValueEncryptionUtils.decrypt(password, encryptor));
   }
   
   // Let Hibernate do the rest
   super.configure(props);
   
}
 
Example 29
public void configure(final Properties props) {
   
   final String encryptorRegisteredName = 
       props.getProperty(ParameterNaming.ENCRYPTOR_REGISTERED_NAME);
   
   final HibernatePBEEncryptorRegistry encryptorRegistry =
       HibernatePBEEncryptorRegistry.getInstance();
   final PBEStringEncryptor encryptor = 
       encryptorRegistry.getPBEStringEncryptor(encryptorRegisteredName);
   
   if (encryptor == null) {
       throw new EncryptionInitializationException(
               "No string encryptor registered for hibernate " +
               "with name \"" + encryptorRegisteredName + "\"");
   }

   // Get the original values, which may be encrypted
   final String driver = props.getProperty(AvailableSettings.DRIVER);
   final String url = props.getProperty(AvailableSettings.URL);
   final String user = props.getProperty(AvailableSettings.USER);
   final String password = props.getProperty(AvailableSettings.PASS);

   // Perform decryption operations as needed and store the new values
   if (PropertyValueEncryptionUtils.isEncryptedValue(driver)) {
       props.setProperty(
               AvailableSettings.DRIVER, 
               PropertyValueEncryptionUtils.decrypt(driver, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(url)) {
       props.setProperty(
               AvailableSettings.URL, 
               PropertyValueEncryptionUtils.decrypt(url, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(user)) {
       props.setProperty(
               AvailableSettings.USER, 
               PropertyValueEncryptionUtils.decrypt(user, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(password)) {
       props.setProperty(
               AvailableSettings.PASS, 
               PropertyValueEncryptionUtils.decrypt(password, encryptor));
   }
   
   // Let Hibernate process
   super.configure(props);
   
}
 
Example 30
public void configure(final Properties props) {
   
   final String encryptorRegisteredName = 
       props.getProperty(ParameterNaming.ENCRYPTOR_REGISTERED_NAME);
   
   final HibernatePBEEncryptorRegistry encryptorRegistry =
       HibernatePBEEncryptorRegistry.getInstance();
   final PBEStringEncryptor encryptor = 
       encryptorRegistry.getPBEStringEncryptor(encryptorRegisteredName);
   
   if (encryptor == null) {
       throw new EncryptionInitializationException(
               "No string encryptor registered for hibernate " +
               "with name \"" + encryptorRegisteredName + "\"");
   }

   // Get the original values, which may be encrypted
   final String driver = props.getProperty(AvailableSettings.DRIVER);
   final String url = props.getProperty(AvailableSettings.URL);
   final String user = props.getProperty(AvailableSettings.USER);
   final String password = props.getProperty(AvailableSettings.PASS);

   // Perform decryption operations as needed and store the new values
   if (PropertyValueEncryptionUtils.isEncryptedValue(driver)) {
       props.setProperty(
               AvailableSettings.DRIVER, 
               PropertyValueEncryptionUtils.decrypt(driver, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(url)) {
       props.setProperty(
               AvailableSettings.URL, 
               PropertyValueEncryptionUtils.decrypt(url, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(user)) {
       props.setProperty(
               AvailableSettings.USER, 
               PropertyValueEncryptionUtils.decrypt(user, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(password)) {
       props.setProperty(
               AvailableSettings.PASS, 
               PropertyValueEncryptionUtils.decrypt(password, encryptor));
   }
   
   // Let Hibernate do the rest
   super.configure(props);
   
}