org.jasypt.properties.PropertyValueEncryptionUtils Java Examples

The following examples show how to use org.jasypt.properties.PropertyValueEncryptionUtils. 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 File: EncryptedStringResolver.java    From tessera with 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
Source File: EncryptableServletContextPropertyPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: JasyptConfiguration.java    From seed with 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 #4
Source File: EncryptablePropertySourcesPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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 #5
Source File: EncryptablePropertyPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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 #6
Source File: EncryptablePropertyOverrideConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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
Source File: EncryptableServletContextPropertyPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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
Source File: EncryptablePreferencesPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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
Source File: EncryptablePropertyPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: EncryptablePropertyOverrideConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: EncryptableServletContextPropertyPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: EncryptablePreferencesPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: EncryptablePropertyPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: EncryptablePropertyOverrideConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: EncryptablePreferencesPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: EncryptablePreferencesPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: EncryptablePropertyPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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 #18
Source File: EncryptableServletContextPropertyPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: EncryptablePropertyOverrideConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: EncryptablePropertyPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
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
Source File: EncryptablePreferencesPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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 #22
Source File: EncryptableServletContextPropertyPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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
Source File: EncryptablePropertyOverrideConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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
Source File: EncryptablePropertyPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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
Source File: EncryptablePreferencesPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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
Source File: EncryptablePropertyOverrideConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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 File: EncryptablePropertySourcesPlaceholderConfigurer.java    From jasypt with Apache License 2.0 5 votes vote down vote up
@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 #28
Source File: EncryptedPasswordC3P0ConnectionProvider.java    From jasypt with Apache License 2.0 4 votes vote down vote up
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(Environment.DRIVER);
   final String url = props.getProperty(Environment.URL);
   final String user = props.getProperty(Environment.USER);
   final String password = props.getProperty(Environment.PASS);

   // Perform decryption operations as needed and store the new values
   if (PropertyValueEncryptionUtils.isEncryptedValue(driver)) {
       props.setProperty(
               Environment.DRIVER, 
               PropertyValueEncryptionUtils.decrypt(driver, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(url)) {
       props.setProperty(
               Environment.URL, 
               PropertyValueEncryptionUtils.decrypt(url, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(user)) {
       props.setProperty(
               Environment.USER, 
               PropertyValueEncryptionUtils.decrypt(user, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(password)) {
       props.setProperty(
               Environment.PASS, 
               PropertyValueEncryptionUtils.decrypt(password, encryptor));
   }
   
   // Let Hibernate do the rest
   super.configure(props);
   
}
 
Example #29
Source File: EncryptedPasswordDriverManagerConnectionProvider.java    From jasypt with Apache License 2.0 4 votes vote down vote up
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(Environment.DRIVER);
   final String url = props.getProperty(Environment.URL);
   final String user = props.getProperty(Environment.USER);
   final String password = props.getProperty(Environment.PASS);

   // Perform decryption operations as needed and store the new values
   if (PropertyValueEncryptionUtils.isEncryptedValue(driver)) {
       props.setProperty(
               Environment.DRIVER, 
               PropertyValueEncryptionUtils.decrypt(driver, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(url)) {
       props.setProperty(
               Environment.URL, 
               PropertyValueEncryptionUtils.decrypt(url, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(user)) {
       props.setProperty(
               Environment.USER, 
               PropertyValueEncryptionUtils.decrypt(user, encryptor));
   }
   if (PropertyValueEncryptionUtils.isEncryptedValue(password)) {
       props.setProperty(
               Environment.PASS, 
               PropertyValueEncryptionUtils.decrypt(password, encryptor));
   }
   
   // Let Hibernate process
   super.configure(props);
   
}
 
Example #30
Source File: EncryptedPasswordC3P0ConnectionProvider.java    From jasypt with Apache License 2.0 4 votes vote down vote up
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(Environment.DRIVER);
   final String url = props.getProperty(Environment.URL);
   final String user = props.getProperty(Environment.USER);
   final String password = props.getProperty(Environment.PASS);

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