use of password.pwm.util.secure.PwmSecurityKey in project pwm by pwm-project.
the class AbstractOtpOperator method decryptAttributeValue.
/**
* Decrypt the given string using the PWM encryption key.
*/
public String decryptAttributeValue(final String encrypted) throws PwmUnrecoverableException, PwmOperationalException {
final PwmBlockAlgorithm pwmBlockAlgorithm = figureBlockAlg();
final PwmSecurityKey pwmSecurityKey = pwmApplication.getConfig().getSecurityKey();
return SecureEngine.decryptStringValue(encrypted, pwmSecurityKey, pwmBlockAlgorithm);
}
use of password.pwm.util.secure.PwmSecurityKey in project pwm by pwm-project.
the class AbstractOtpOperator method encryptAttributeValue.
/**
* Encrypt the given string using the PWM encryption key.
*/
public String encryptAttributeValue(final String unencrypted) throws PwmUnrecoverableException, PwmOperationalException {
final PwmBlockAlgorithm pwmBlockAlgorithm = figureBlockAlg();
final PwmSecurityKey pwmSecurityKey = pwmApplication.getConfig().getSecurityKey();
return SecureEngine.encryptToString(unencrypted, pwmSecurityKey, pwmBlockAlgorithm);
}
use of password.pwm.util.secure.PwmSecurityKey in project pwm by pwm-project.
the class CustomLinkValue method factory.
public static StoredValueFactory factory() {
return new StoredValueFactory() {
public CustomLinkValue fromJson(final String input) {
if (input == null) {
return new CustomLinkValue(Collections.emptyList());
} else {
List<CustomLinkConfiguration> srcList = JsonUtil.deserialize(input, new TypeToken<List<CustomLinkConfiguration>>() {
});
srcList = srcList == null ? Collections.emptyList() : srcList;
while (srcList.contains(null)) {
srcList.remove(null);
}
return new CustomLinkValue(Collections.unmodifiableList(srcList));
}
}
public CustomLinkValue fromXmlElement(final Element settingElement, final PwmSecurityKey key) throws PwmOperationalException {
final List valueElements = settingElement.getChildren("value");
final List<CustomLinkConfiguration> values = new ArrayList<>();
for (final Object loopValue : valueElements) {
final Element loopValueElement = (Element) loopValue;
final String value = loopValueElement.getText();
if (value != null && value.length() > 0 && loopValueElement.getAttribute("locale") == null) {
values.add(JsonUtil.deserialize(value, CustomLinkConfiguration.class));
}
}
return new CustomLinkValue(values);
}
};
}
use of password.pwm.util.secure.PwmSecurityKey in project pwm by pwm-project.
the class FileValue method factory.
public static StoredValueFactory factory() {
return new StoredValueFactory() {
public FileValue fromXmlElement(final Element settingElement, final PwmSecurityKey input) throws PwmOperationalException {
final List valueElements = settingElement.getChildren("value");
final Map<FileInformation, FileContent> values = new LinkedHashMap<>();
for (final Object loopValue : valueElements) {
final Element loopValueElement = (Element) loopValue;
final Element loopFileInformation = loopValueElement.getChild("FileInformation");
if (loopFileInformation != null) {
final String loopFileInformationJson = loopFileInformation.getText();
final FileInformation fileInformation = JsonUtil.deserialize(loopFileInformationJson, FileInformation.class);
final Element loopFileContentElement = loopValueElement.getChild("FileContent");
if (loopFileContentElement != null) {
final String fileContentString = loopFileContentElement.getText();
final FileContent fileContent;
try {
fileContent = FileContent.fromEncodedString(fileContentString);
values.put(fileInformation, fileContent);
} catch (IOException e) {
LOGGER.error("error reading file contents item: " + e.getMessage(), e);
}
}
}
}
return new FileValue(values);
}
public StoredValue fromJson(final String input) {
throw new IllegalStateException("not implemented");
}
};
}
use of password.pwm.util.secure.PwmSecurityKey in project pwm by pwm-project.
the class NumericValue method factory.
public static StoredValueFactory factory() {
return new StoredValueFactory() {
public NumericValue fromJson(final String value) {
return new NumericValue(JsonUtil.deserialize(value, Long.class));
}
public NumericValue fromXmlElement(final Element settingElement, final PwmSecurityKey input) {
final Element valueElement = settingElement.getChild("value");
final String value = valueElement.getText();
return new NumericValue(Long.parseLong(value));
}
};
}
Aggregations