XAssetService extends XAssetServiceBase<XXAsset, VXAsset> { public String getConfigWithEncryptedPassword(String config,boolean isForced){ try { if (config != null && !config.isEmpty()) { Map<String, String> configMap = jsonUtil.jsonToMap(config); Entry<String, String> passwordEntry = getPasswordEntry(configMap); Entry<String, String> isEncryptedEntry = getIsEncryptedEntry(configMap); if (passwordEntry != null){ if(isEncryptedEntry==null || !"true".equalsIgnoreCase(isEncryptedEntry.getValue())||isForced==true){ String password=passwordEntry.getValue(); String encryptPassword=PasswordUtils.encryptPassword(password); String decryptPassword=PasswordUtils.decryptPassword(encryptPassword); if(decryptPassword != null && decryptPassword.equalsIgnoreCase(password)){ configMap.put(passwordEntry.getKey(), encryptPassword); configMap.put("isencrypted", "true"); } } } config = jsonUtil.readMapToString(configMap); } } catch (IOException e) { String errorMessage = "Password encryption error"; throw restErrorUtil.createRESTException(errorMessage, MessageEnums.INVALID_INPUT_DATA, null, null, e.getMessage()); } return config; } XAssetService(); void validateConfig(VXAsset vObj); List<XXTrxLog> getTransactionLog(VXAsset vResource, String action); List<XXTrxLog> getTransactionLog(VXAsset vObj, XXAsset mObj, String action); String getConfigWithEncryptedPassword(String config,boolean isForced); String getConfigWithDecryptedPassword(String config);  }
@Test public void test4GetConfigWithEncryptedPassword() { xAssetService.getConfigWithEncryptedPassword("testconfig", false); }