diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/encryption/EncryptionController.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/encryption/EncryptionController.java index 9a3965e4..11edac1d 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/encryption/EncryptionController.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/encryption/EncryptionController.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,10 +86,10 @@ public class EncryptionController { @ExceptionHandler(KeyFormatException.class) @ResponseBody public ResponseEntity> keyFormat() { - Map body = new HashMap(); + Map body = new HashMap<>(); body.put("status", "BAD_REQUEST"); body.put("description", "Key data not in correct format (PEM or jks keystore)"); - return new ResponseEntity>(body, HttpStatus.BAD_REQUEST); + return new ResponseEntity<>(body, HttpStatus.BAD_REQUEST); } @ExceptionHandler(KeyNotAvailableException.class) @@ -98,7 +98,7 @@ public class EncryptionController { Map body = new HashMap(); body.put("status", "NOT_FOUND"); body.put("description", "No public key available"); - return new ResponseEntity>(body, HttpStatus.NOT_FOUND); + return new ResponseEntity<>(body, HttpStatus.NOT_FOUND); } @RequestMapping(value = "encrypt/status", method = RequestMethod.GET) @@ -147,9 +147,11 @@ public class EncryptionController { checkEncryptorInstalled(name, profiles); try { String input = stripFormData(data, type, true); - String decrypted = this.helper.stripPrefix(this.encryptor.locate( - this.helper.getEncryptorKeys(name, profiles, input)).decrypt( - this.helper.stripPrefix(input))); + Map encryptorKeys = this.helper.getEncryptorKeys(name, + profiles, input); + TextEncryptor encryptor = this.encryptor.locate(encryptorKeys); + String encryptedText = this.helper.stripPrefix(input); + String decrypted = this.helper.stripPrefix(encryptor.decrypt(encryptedText)); logger.info("Decrypted cipher data"); return decrypted; } @@ -210,7 +212,7 @@ public class EncryptionController { Map body = new HashMap(); body.put("status", "NO_KEY"); body.put("description", "No key was installed for encryption service"); - return new ResponseEntity>(body, HttpStatus.NOT_FOUND); + return new ResponseEntity<>(body, HttpStatus.NOT_FOUND); } @ExceptionHandler(InvalidCipherException.class) @@ -219,7 +221,7 @@ public class EncryptionController { Map body = new HashMap(); body.put("status", "INVALID"); body.put("description", "Text not encrypted with this key"); - return new ResponseEntity>(body, HttpStatus.BAD_REQUEST); + return new ResponseEntity<>(body, HttpStatus.BAD_REQUEST); } }