com.ryaltech.utils.spring.encryption.YamlFileEncryptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-properties-encryption Show documentation
Show all versions of spring-properties-encryption Show documentation
Library containing encryption functionality
package com.ryaltech.utils.spring.encryption;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
public class YamlFileEncryptor extends FileEncryptor {
private DumperOptions dumperOptions;
public YamlFileEncryptor(Encryptor encryptor, Pattern[] includePatterns, Pattern[] excludePatterns) {
super(encryptor, includePatterns, excludePatterns);
dumperOptions = new DumperOptions();
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
dumperOptions.setIndent(4);
dumperOptions.setIndicatorIndent(2);
dumperOptions.setPrettyFlow(true);
}
@Override
public void encryptConfigFile(String fileName) {
Yaml yaml = new Yaml(dumperOptions);
try {
List