
com.github.mowedgrass.jasyptgradleboot.task.ConfiguredEncryptorFactory.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jasypt-gradle-boot-plugin Show documentation
Show all versions of jasypt-gradle-boot-plugin Show documentation
jasypt spring boot gradle plugin
The newest version!
package com.github.mowedgrass.jasyptgradleboot.task
import com.github.mowedgrass.jasyptgradleboot.encryptor.EncryptorFactory
import com.github.mowedgrass.jasyptgradleboot.encryptor.configuration.provider.DefaultConfigurationProvider
import com.github.mowedgrass.jasyptgradleboot.encryptor.configuration.provider.FileConfigurationProvider
import com.github.mowedgrass.jasyptgradleboot.password.DirectPasswordProvider
import com.github.mowedgrass.jasyptgradleboot.password.PasswordProvider
import com.github.mowedgrass.jasyptgradleboot.password.PropertyPasswordProvider
import com.github.mowedgrass.jasyptgradleboot.password.property.PropertyResolver
import org.jasypt.encryption.StringEncryptor
import org.springframework.core.env.StandardEnvironment
class ConfiguredEncryptorFactory {
public PasswordProvider createPasswordProvider(String password) {
return (password) ?
new DirectPasswordProvider(password) :
new PropertyPasswordProvider(new PropertyResolver(new StandardEnvironment()))
}
public StringEncryptor createEncryptor(File configurationFile, PasswordProvider passwordProvider) {
def configurationProvider = configurationFile ?
new FileConfigurationProvider(new FileInputStream(configurationFile.path)) :
new DefaultConfigurationProvider()
new EncryptorFactory().create(passwordProvider, configurationProvider)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy