Skip to content

Commit

Permalink
Upgraded Alpine to 1.4.2. Fixed NPE when saving encrypted password. F…
Browse files Browse the repository at this point in the history
…ixed JS rest to convert '' to null. #220
  • Loading branch information
stevespringett committed Nov 12, 2018
1 parent 4ed7c4f commit 44e25da
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>us.springett</groupId>
<artifactId>alpine-parent</artifactId>
<version>1.4.1</version>
<version>1.4.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,19 @@ public Response updateConfigProperty(ConfigProperty json) {
return Response.status(Response.Status.BAD_REQUEST).entity("The config property expected a UUID but a valid UUID was not sent.").build();
}
} else if (configProperty.getPropertyType() == ConfigProperty.PropertyType.ENCRYPTEDSTRING) {
try {
// Determine if the value of the encrypted property value is that of the placeholder. If so, the value has not been modified and should not be saved.
if (ENCRYPTED_PLACEHOLDER.equals(json.getPropertyValue())) {
return Response.notModified().build();
if (json.getPropertyValue() == null) {
configProperty.setPropertyValue(null);
} else {
try {
// Determine if the value of the encrypted property value is that of the placeholder. If so, the value has not been modified and should not be saved.
if (ENCRYPTED_PLACEHOLDER.equals(json.getPropertyValue())) {
return Response.notModified().build();
}
configProperty.setPropertyValue(DataEncryption.encryptAsString(json.getPropertyValue()));
} catch (Exception e) {
LOGGER.error("An error occurred while encrypting config property value", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("An error occurred while encrypting config property value. Check log for details.").build();
}
configProperty.setPropertyValue(DataEncryption.encryptAsString(json.getPropertyValue()));
} catch (Exception e) {
LOGGER.error("An error occurred while encrypting config property value", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity("An error occurred while encrypting config property value. Check log for details.").build();
}
} else {
configProperty.setPropertyValue(json.getPropertyValue());
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/assets/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1960,6 +1960,9 @@ $rest.updateConfigProperty = function updateConfigProperty(groupName, propertyNa
if ($common.isEmpty(groupName) || $common.isEmpty(propertyName)) {
return;
}
if (propertyValue === '') {
propertyValue = null;
}
$.ajax({
url: $rest.contextPath() + URL_CONFIG_PROPERTY,
contentType: CONTENT_TYPE_JSON,
Expand Down

0 comments on commit 44e25da

Please sign in to comment.