public StringPool getStringPool() { return (stringEncryptionEnabledCheckBox.isSelected() && stringPoolCheckBox.isSelected()) ? new StringPool(new StringEncryptionSetup(stringExclusions)) : null; }
private List<StringEncryption> getStringEncryptionTransformers() { Object o = map.get(ConfigurationSettings.STRING_ENCRYPTION.getValue()); if (o == null) return null; if (!(o instanceof Map)) throw new IllegalConfigurationValueException(ConfigurationSettings.STRING_ENCRYPTION.getValue(), Map.class, o.getClass()); Map<String, Object> settings = (Map) o; if (!(boolean) settings.get("Enabled")) return null; String s = (String) settings.get("Mode"); if (!"Light".equals(s) && !"Normal".equals(s) && !"Heavy".equals(s)) throw new IllegalConfigurationValueException("Expected Light, Normal or Heavy as mode for string " + "encryption. Got " + s + " instead."); boolean pool = (boolean) settings.getOrDefault("StringPool", false); List<String> exclusions = (List) settings.getOrDefault("Exclusions", new ArrayList<String>()); ArrayList<StringEncryption> things = new ArrayList<>(); things.add(StringEncryption.getTransformerFromString(s, new StringEncryptionSetup(exclusions))); if (pool) things.add(new StringPool(new StringEncryptionSetup(exclusions))); return things; }
public StringEncryption getStringEncryption() { if (stringEncryptionEnabledCheckBox.isSelected()) { StringEncryptionSetup setup = new StringEncryptionSetup(stringExclusions); StringEncryption encryptionTransformer; switch (stringEncryptionTypeSelector.getSelectedIndex()) { case 0: { encryptionTransformer = new LightStringEncryption(setup); break; } case 1: { encryptionTransformer = new NormalStringEncryption(setup); break; } case 2: { encryptionTransformer = new HeavyStringEncryption(setup); break; } default: { throw new IllegalStateException(String.format("Bad string encryption type %d.", stringEncryptionTypeSelector.getSelectedIndex())); } } return encryptionTransformer; } else { return null; } }