Skip to content

Commit

Permalink
fix code quality (#6727)
Browse files Browse the repository at this point in the history
  • Loading branch information
li-xiao-shuang committed Sep 16, 2021
1 parent 69c4f3c commit 8024ecf
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.alibaba.nacos.api.config;

import java.util.Objects;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand All @@ -31,7 +30,7 @@ public class CryptoExecutor {
/**
* chipher-AES-dataId.
*/
private static final String PREFIX = "chipher-";
private static final String PREFIX = "cipher-";

/**
* Execute encryption.
Expand All @@ -54,10 +53,7 @@ public static String executeEncrypt(BiFunction<String, String, String> biFunc, S
*/
public static String executeDecrypt(String dataId, String secretKey, String content) {
CryptoSpi cryptoSpi = cryptoInstance(dataId);
if (Objects.isNull(cryptoSpi)) {
return content;
}
return cryptoSpi.decrypt(secretKey, content);
return cryptoSpi == null ? content : cryptoSpi.decrypt(secretKey, content);
}

/**
Expand All @@ -67,8 +63,7 @@ public static String executeDecrypt(String dataId, String secretKey, String cont
* @return Encryption algorithm instance
*/
public static CryptoSpi cryptoInstance(String dataId) {
boolean result = checkCipher(dataId);
if (result) {
if (checkCipher(dataId)) {
String algorithmName = Stream.of(dataId.split("-")).collect(Collectors.toList()).get(1);
return CryptoManager.instance(algorithmName);
}
Expand Down

0 comments on commit 8024ecf

Please sign in to comment.