Commit f63488dc authored by gavin2lee's avatar gavin2lee
Browse files

#2046 add encryption service

Showing with 36 additions and 2 deletions
+36 -2
......@@ -48,6 +48,7 @@ import com.webank.wecube.platform.core.jpa.PluginConfigInterfaceRepository;
import com.webank.wecube.platform.core.service.dme.EntityOperationRootCondition;
import com.webank.wecube.platform.core.service.dme.StandardEntityOperationService;
import com.webank.wecube.platform.core.service.plugin.PluginInstanceService;
import com.webank.wecube.platform.core.service.workflow.EncryptionService;
import com.webank.wecube.platform.core.support.plugin.PluginServiceStub;
import com.webank.wecube.platform.core.support.plugin.dto.PluginResponse.ResultData;
import com.webank.wecube.platform.core.support.plugin.dto.PluginResponseStationaryOutput;
......@@ -55,7 +56,6 @@ import com.webank.wecube.platform.core.utils.Constants;
import com.webank.wecube.platform.core.utils.JsonUtils;
@Service
@Transactional
public class BatchExecutionService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
......@@ -77,9 +77,13 @@ public class BatchExecutionService {
@Autowired
@Qualifier("userJwtSsoTokenRestTemplate")
private RestTemplate userJwtSsoTokenRestTemplate;
@Autowired
private EncryptionService encryptionService;
private ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
@Transactional
public Map<String, ExecutionJobResponseDto> handleBatchExecutionJob(BatchExecutionRequestDto batchExecutionRequest)
throws IOException {
verifyParameters(batchExecutionRequest.getInputParameterDefinitions());
......@@ -189,7 +193,7 @@ public class BatchExecutionService {
return executionJobParameters;
}
public ResultData<?> performExecutionJob(ExecutionJob exeJob) throws IOException {
protected ResultData<?> performExecutionJob(ExecutionJob exeJob) throws IOException {
if (exeJob == null) {
throw new WecubeCoreException("3002", "execution job as input argument cannot be null.");
}
......
package com.webank.wecube.platform.core.service.workflow;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.webank.wecube.platform.core.utils.EncryptionUtils;
@Service
public class EncryptionService {
private static final String AES_SEED = "platform-aes-seed-2020";
private static final String AES_SALT = "platform-aes-salt-2020";
public String encodeToAesBase64(String raw) {
if(StringUtils.isBlank(raw)) {
return raw;
}
return EncryptionUtils.encryptWithAes(raw, AES_SEED, AES_SALT);
}
public String decodeFromAesBase64(String aesBase64) {
if(StringUtils.isBlank(aesBase64)) {
return aesBase64;
}
return EncryptionUtils.decryptWithAes(aesBase64, AES_SEED, AES_SALT);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment