- Substituted by java embedded mechanisms and some from guava pkg.
- org.janusgraph.janusgraph-core and org.janusgraph.janusgraph-cassandra still keeps commons-codecs
- dependency to distribution-client in version 1.4.1 - first we need to publish that image
Change-Id: I800012bf98702aa8808ddc766ebdb53acb8ab86a
Issue-ID: SDC-2504
Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>${commons-codec}</version>
- <scope>compile</scope>
- </dependency>
-
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
<scope>compile</scope>
</dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${apache-poi.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
-normal['version'] ="1.5.0"
+normal['version'] ="1.5.1"
package org.openecomp.sdc.asdctool.main;
+import com.google.common.hash.Hashing;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.openecomp.sdc.asdctool.enums.SchemaZipFileEnum;
import org.openecomp.sdc.asdctool.impl.EsToCassandraDataMigrationConfig;
byte[] fileBytes = baos.toByteArray();
Date date = new Date();
- String md5Hex = DigestUtils.md5Hex(fileBytes);
+ String md5Hex = Hashing.md5().hashBytes(fileBytes).toString();
SdcSchemaFilesData schemeFileData = new SdcSchemaFilesData(sdcReleaseNum, date, conformanceLevel, FILE_NAME, fileBytes, md5Hex);
CassandraOperationStatus saveSchemaFile = schemaFilesCassandraDao.saveSchemaFile(schemeFileData);
<artifactId>jersey-bean-validation</artifactId>
</dependency>
- <!-- http client -->
+ <!-- http client -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
<scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>${commons-codec}</version>
- <scope>compile</scope>
- </dependency>
<!-- http client END -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
</exclusions>
</dependency>
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import fj.data.Either;
-import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
private Either<List<HeatParameterDefinition>, ResponseFormat> extractHeatParameters(String artifactType,
String fileName, byte[] content, boolean is64Encoded) {
// extract heat parameters
- String heatDecodedPayload = is64Encoded ? new String(Base64.decodeBase64(content)) : new String(content);
+ String heatDecodedPayload = is64Encoded ? new String(Base64.getDecoder().decode(content)) : new String(content);
Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils
.getHeatParamsWithoutImplicitTypes(heatDecodedPayload, artifactType);
if (heatParameters.isRight()) {
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import fj.data.Either;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
private Either<Boolean, ResponseFormat> extractHeatParameters(ArtifactDefinition artifactInfo) {
// extract heat parameters
if (artifactInfo.getPayloadData() != null) {
- String heatDecodedPayload = new String(Base64.decodeBase64(artifactInfo.getPayloadData()));
+ String heatDecodedPayload = new String(Base64.getDecoder().decode(artifactInfo.getPayloadData()));
Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils.getHeatParamsWithoutImplicitTypes(heatDecodedPayload, artifactInfo
.getArtifactType());
if (heatParameters.isRight() && (!heatParameters.right()
.getEsId());
if (eitherArtifactData.isLeft()) {
byte[] data = eitherArtifactData.left().value().getDataAsArray();
- data = Base64.encodeBase64(data);
+ data = Base64.getEncoder().encode(data);
payloadWrapper.setInnerElement(data);
}
else {
@SuppressWarnings("unchecked")
private void validateEnvVsHeat(Wrapper<ResponseFormat> errorWrapper, ArtifactDefinition envArtifact, ArtifactDefinition heatArtifact, byte[] heatPayloadData) {
- String envPayload = new String(Base64.decodeBase64(envArtifact.getPayloadData()));
+ String envPayload = new String(Base64.getDecoder().decode(envArtifact.getPayloadData()));
Map<String, Object> heatEnvToscaJson = (Map<String, Object>) new Yaml().load(envPayload);
- String heatDecodedPayload = new String(Base64.decodeBase64(heatPayloadData));
+ String heatDecodedPayload = new String(Base64.getDecoder().decode(heatPayloadData));
Map<String, Object> heatToscaJson = (Map<String, Object>) new Yaml().load(heatDecodedPayload);
Either<Map<String, Object>, ResultStatusEnum> eitherHeatEnvProperties = ImportUtils.findFirstToscaMapElement(heatEnvToscaJson, TypeUtils.ToscaTagNamesEnum.PARAMETERS);
if (payload != null && payload.length != 0) {
// the generated artifacts were already decoded by the handler
- decodedPayload = artifactInfo.getGenerated() ? payload : Base64.decodeBase64(payload);
+ decodedPayload = artifactInfo.getGenerated() ? payload : Base64.getDecoder().decode(payload);
if (decodedPayload.length == 0) {
log.debug("Failed to decode the payload.");
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
if (artifactContent != null) {
log.debug("payload is encoded. perform decode");
- String encodedPayload = Base64.encodeBase64String(artifactContent);
+ String encodedPayload = Base64.getEncoder().encodeToString(artifactContent);
json.put(Constants.ARTIFACT_PAYLOAD_DATA, encodedPayload);
}
json.put(Constants.ARTIFACT_DISPLAY_NAME, displayName);
import static org.openecomp.sdc.be.tosca.CsarUtils.VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.regex.Pattern;
import fj.data.Either;
-import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections4.ListUtils;
if (!foundArtifact.getArtifactChecksum().equals(currNewArtifact.getArtifactChecksum())) {
foundArtifact.setPayload(currNewArtifact.getPayloadData());
foundArtifact.setPayloadData(
- Base64.encodeBase64String(currNewArtifact.getPayloadData()));
+ Base64.getEncoder().encodeToString(currNewArtifact.getPayloadData()));
foundArtifact.setArtifactChecksum(GeneralUtility
.calculateMD5Base64EncodedByByteArray(currNewArtifact.getPayloadData()));
artifactsToUpdate.add(foundArtifact);
package org.openecomp.sdc.be.datamodel.utils;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.openecomp.sdc.be.info.ArtifactTemplateInfo;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
json.put(Constants.ARTIFACT_DESCRIPTION, description);
json.put(Constants.IS_FROM_CSAR, isFromCsar);
- String encodedPayload = Base64.encodeBase64String(artifactContentent);
+ String encodedPayload = Base64.getEncoder().encodeToString(artifactContentent);
json.put(Constants.ARTIFACT_PAYLOAD_DATA, encodedPayload);
json.put(Constants.ARTIFACT_DISPLAY_NAME, displayName);
json.put(Constants.ARTIFACT_DESCRIPTION, "created from csar");
json.put(Constants.IS_FROM_CSAR, isFromcsar);
- String encodedPayload = Base64.encodeBase64String(artifactContentent);
+ String encodedPayload = Base64.getEncoder().encodeToString(artifactContentent);
json.put(Constants.ARTIFACT_PAYLOAD_DATA, encodedPayload);
String displayName = artifactName;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import fj.data.Either;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.openecomp.sdc.be.components.impl.ConsumerBusinessLogic;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.impl.ComponentsUtils;
if ("Basic".equalsIgnoreCase(basic)) {
try {
- String credentials = new String(Base64.decodeBase64(st.nextToken()), "UTF-8");
+ String credentials = new String(Base64.getDecoder().decode(st.nextToken()), "UTF-8");
log.debug("Credentials: {}", credentials);
checkUserCredentials(requestContext, credentials);
} catch (UnsupportedEncodingException e) {
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
+import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
-import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
Response errorResp = buildErrorResponse(responseFormat);
responseWrapper.setInnerElement(errorResp);
}
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
uploadResourceInfoWrapper.setPayloadData(payloadData);
responseWrapper.setInnerElement(errorResponse);
} else {
String toscaPayload = resourceInfo.getPayloadData();
- String decodedPayload = new String(Base64.decodeBase64(toscaPayload));
+ String decodedPayload = new String(Base64.getDecoder().decode(toscaPayload));
yamlStringWrapper.setInnerElement(decodedPayload);
}
return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_NOT_FOUND, csarUUID));
}
- byte[] decodedPayload = Base64.decodeBase64(payloadData.getBytes(StandardCharsets.UTF_8));
+ byte[] decodedPayload = Base64.getDecoder().decode(payloadData.getBytes(StandardCharsets.UTF_8));
if (decodedPayload == null) {
log.info("Failed to decode received csar", csarUUID);
return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_NOT_FOUND, csarUUID));
import javax.ws.rs.core.Context;\r
import javax.ws.rs.core.MediaType;\r
import javax.ws.rs.core.Response;\r
-import org.apache.commons.codec.binary.Base64;\r
+import java.util.Base64;\r
import org.apache.commons.lang3.tuple.ImmutablePair;\r
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;\r
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;\r
response = buildErrorResponse(actionResult.right().value());\r
} else {\r
byte[] file = actionResult.left().value().getRight();\r
- String base64Contents = new String(Base64.encodeBase64(file));\r
+ String base64Contents = new String(Base64.getEncoder().encode(file));\r
String artifactName = actionResult.left().value().getLeft();\r
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);\r
ArtifactUiDownloadData artifactUiDownloadData = new ArtifactUiDownloadData();\r
package org.openecomp.sdc.be.switchover.detector;
import com.google.common.annotations.VisibleForTesting;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
private void setAuthorizationProperties() {
String userInfo = switchoverDetectorConfig.getChangePriorityUser() + ":" + switchoverDetectorConfig.getChangePriorityPassword();
- String auth = "Basic " + new String(new Base64().encode(userInfo.getBytes()));
+ String auth = "Basic " + new String(Base64.getEncoder().encode(userInfo.getBytes()));
authHeader = new Properties();
authHeader.put("Authorization", auth);
}
import fj.data.Either;
-import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.lang.WordUtils;
parsedCsarArtifactPath[1], collectedWarningMessages));
artifact.setArtifactName(
ValidationUtils.normalizeFileName(parsedCsarArtifactPath[parsedCsarArtifactPath.length - 1]));
- artifact.setPayloadData(Base64.encodeBase64String(entry.getValue()));
+ artifact.setPayloadData(Base64.getEncoder().encodeToString(entry.getValue()));
artifact.setArtifactDisplayName(artifact.getArtifactName().lastIndexOf('.') > 0
? artifact.getArtifactName().substring(0, artifact.getArtifactName().lastIndexOf('.'))
: artifact.getArtifactName());
}
this.artifactLabel = ValidationUtils.normalizeArtifactLabel(artifactName);
if (payloadData != null) {
- this.payloadData = Base64.encodeBase64String(payloadData);
+ this.payloadData = Base64.getEncoder().encodeToString(payloadData);
this.artifactChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(payloadData);
}
this.artifactUniqueId = artifactUniqueId;
package org.openecomp.sdc;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.apache.commons.io.output.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
String zipFileName = "/src/test/resources/config/config.zip";
- zipFileName = "C:\\Git_work\\D2-SDnC\\catalog-be\\src\\test\\resources\\config\\config.zip";
zipFileName = "src/test/resources/config/config.zip";
Path path = Paths.get(zipFileName);
byte[] zipAsBytes = Files.readAllBytes(path);
// encode to base
- byte[] decodedMd5 = Base64.encodeBase64(zipAsBytes);
+ byte[] decodedMd5 = Base64.getEncoder().encode(zipAsBytes);
String decodedStr = new String(decodedMd5);
- zipAsBytes = Base64.decodeBase64(decodedStr.getBytes());
+ zipAsBytes = Base64.getDecoder().decode(decodedStr.getBytes());
// String str = new String(zipAsBytes);
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import fj.data.Either;
-import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.http.HttpStatus;
import org.junit.Before;
when(artifactInfo.getEsId()).thenReturn(esId);
final Wrapper<byte[]> payloadWrapper = new Wrapper<>();
final byte[] payloadArtifactData = "testArtifactData".getBytes();
- final byte[] base64PayloadArtifactData = Base64.decodeBase64(payloadArtifactData);
+ final byte[] base64PayloadArtifactData = Base64.getDecoder().decode(payloadArtifactData);
final ESArtifactData artifactData = Mockito.mock(ESArtifactData.class);
when(artifactData.getDataAsArray()).thenReturn(base64PayloadArtifactData);
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import fj.data.Either;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
import mockit.Deencapsulation;
-import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Assert;
import org.junit.Before;
artifactDefinition.setArtifactType(ArtifactTypeEnum.TOSCA_TEMPLATE.getType());
artifactDefinition.setArtifactLabel(ARTIFACT_LABEL);
artifactDefinition.setEsId(ES_ARTIFACT_ID);
- artifactDefinition.setPayload(PAYLOAD);
+ artifactDefinition.setPayload(Base64.getEncoder().encode(PAYLOAD));
artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.TOSCA);
when(graphLockOperation.lockComponent(any(), any())).thenReturn(StorageOperationStatus.OK);
artifactInfo.setArtifactName(artifactName);
artifactInfo.setArtifactType(artifactType.getType());
artifactInfo.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
- artifactInfo.setPayload(Base64.encodeBase64(payload));
+ artifactInfo.setPayload(Base64.getEncoder().encode(payload));
return artifactInfo;
}
package org.openecomp.sdc.be.servlets;
import fj.data.Either;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.junit.Test;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
try {
path = Paths.get(rootPath + "/src/test/resources/valid_vf.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
UploadResourceInfo resourceInfo = new UploadResourceInfo();
resourceInfo.setPayloadName(payloadName);
resourceInfo.setPayloadData(payloadData);
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import fj.data.Either;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.text.StrSubstitutor;
import org.apache.http.HttpStatus;
}
private void encodeAndSetPayload(UploadResourceInfo mdJson, String payload) {
- byte[] encodedBase64Payload = Base64.encodeBase64(payload.getBytes());
+ byte[] encodedBase64Payload = Base64.getEncoder().encode(payload.getBytes());
mdJson.setPayloadData(new String(encodedBase64Payload));
}
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-all</artifactId>
<version>3.11.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
<scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>${commons-codec}</version>
- <scope>compile</scope>
- </dependency>
<!-- http client END -->
<dependency>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<!-- System metrics -->
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
<scope>provided</scope>
</dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
<scope>provided</scope>
</dependency>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>${commons-codec}</version>
- <scope>provided</scope>
- </dependency>
-
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
package org.openecomp.sdc.common.http.client.api;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.apache.http.HttpHeaders;
import java.nio.charset.StandardCharsets;
public class RestUtils {
public static void addBasicAuthHeader(Properties headers, String username, String password) {
- byte[] credentials = Base64.encodeBase64((username + ":" + password).getBytes(StandardCharsets.UTF_8));
+ byte[] credentials = Base64.getEncoder().encode((username + ":" + password).getBytes(StandardCharsets.UTF_8));
headers.setProperty(HttpHeaders.AUTHORIZATION, "Basic " + new String(credentials, StandardCharsets.UTF_8));
}
package org.openecomp.sdc.common.rest.impl.validator;
-import org.apache.commons.codec.binary.Base64;
+import com.google.common.hash.Hashing;
+import java.util.Base64;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
}
// calculate MD5 on the data
- String md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(encodedData);
- byte[] encodedMd5 = Base64.encodeBase64(md5.getBytes());
+ String md5 = Hashing.md5().hashBytes(encodedData).toString();
+ byte[] encodedMd5 = Base64.getEncoder().encode(md5.getBytes());
// read the Content-MD5 header
String origMd5 = request.getHeader(Constants.MD5_HEADER);
package org.openecomp.sdc.common.util;
-import org.apache.commons.codec.binary.Base64;
+import com.google.common.hash.Hashing;
+import java.util.Base64;
import org.apache.commons.io.FileUtils;
import org.openecomp.sdc.common.api.Constants;
* The methods contained in other common libraries do the same.
*/
public static boolean isBase64Encoded(byte[] data) {
- return Base64.isBase64(data);
+ try {
+ Base64.getDecoder().decode(data);
+ }catch (Exception e){
+ return false;
+ }
+ return true;
}
/**
if (isEncoded) {
// If no exception is caught, then it is possibly a base64
// encoded string
- byte[] data = Base64.decodeBase64(str);
+ Base64.getDecoder().decode(str);
}
} catch (Exception e) {
}
public static String calculateMD5Base64EncodedByByteArray(byte[] payload) {
- String decodedMd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(payload);
- byte[] encodeMd5 = Base64.encodeBase64(decodedMd5.getBytes());
+ String decodedMd5 = Hashing.md5().hashBytes(payload).toString();
+ byte[] encodeMd5 = Base64.getEncoder().encode(decodedMd5.getBytes());
return new String(encodeMd5);
}
- /**
- * @param data
- * @return
- */
public static String calculateMD5Base64EncodedByString(String data) {
- String calculatedMd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(data);
+ String calculatedMd5 = Hashing.md5().hashBytes(data.getBytes()).toString();
// encode base-64 result
- byte[] encodeBase64 = Base64.encodeBase64(calculatedMd5.getBytes());
+ byte[] encodeBase64 = Base64.getEncoder().encode(calculatedMd5.getBytes());
return new String(encodeBase64);
}
- /**
- * @param String
- * @return String is null or Empty
- */
public static boolean isEmptyString(String str) {
return str == null || str.trim().isEmpty();
}
package org.openecomp.sdc.common.util;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.openecomp.sdc.be.config.Configuration.ApplicationL1CacheConfig;
import org.openecomp.sdc.be.config.Configuration.ApplicationL2CacheConfig;
import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig;
static {
- org.yaml.snakeyaml.constructor.Constructor deConstructor = new org.yaml.snakeyaml.constructor.Constructor(
- DistributionEngineConfiguration.class);
+ org.yaml.snakeyaml.constructor.Constructor deConstructor =
+ new org.yaml.snakeyaml.constructor.Constructor(DistributionEngineConfiguration.class);
TypeDescription deDescription = new TypeDescription(DistributionEngineConfiguration.class);
deDescription.putListPropertyType("distributionStatusTopic", DistributionStatusTopicConfig.class);
deDescription.putListPropertyType("distribNotifServiceArtifactTypes", ComponentArtifactTypesConfig.class);
yamls.put(DistributionEngineConfiguration.class.getName(), yaml);
// FE conf
- org.yaml.snakeyaml.constructor.Constructor feConfConstructor = new org.yaml.snakeyaml.constructor.Constructor(
- org.openecomp.sdc.fe.config.Configuration.class);
+ org.yaml.snakeyaml.constructor.Constructor feConfConstructor =
+ new org.yaml.snakeyaml.constructor.Constructor(org.openecomp.sdc.fe.config.Configuration.class);
TypeDescription feConfDescription = new TypeDescription(org.openecomp.sdc.fe.config.Configuration.class);
feConfDescription.putListPropertyType("systemMonitoring", FeMonitoringConfig.class);
feConfConstructor.addTypeDescription(feConfDescription);
yamls.put(org.openecomp.sdc.fe.config.Configuration.class.getName(), new Yaml(feConfConstructor));
// BE conf
- org.yaml.snakeyaml.constructor.Constructor beConfConstructor = new org.yaml.snakeyaml.constructor.Constructor(
- org.openecomp.sdc.be.config.Configuration.class);
+ org.yaml.snakeyaml.constructor.Constructor beConfConstructor =
+ new org.yaml.snakeyaml.constructor.Constructor(org.openecomp.sdc.be.config.Configuration.class);
TypeDescription beConfDescription = new TypeDescription(org.openecomp.sdc.be.config.Configuration.class);
beConfConstructor.addTypeDescription(beConfDescription);
beConfConstructor.addTypeDescription(esDescription);
// resourceDeploymentArtifacts and serviceDeploymentArtifacts
- beConfDescription.putMapPropertyType("resourceDeploymentArtifacts", String.class,
- ArtifactTypeConfig.class);
- beConfDescription.putMapPropertyType("serviceDeploymentArtifacts", String.class,
- ArtifactTypeConfig.class);
+ beConfDescription.putMapPropertyType("resourceDeploymentArtifacts", String.class, ArtifactTypeConfig.class);
+ beConfDescription.putMapPropertyType("serviceDeploymentArtifacts", String.class, ArtifactTypeConfig.class);
// onboarding
beConfDescription.putListPropertyType("onboarding", OnboardingConfig.class);
yamls.put(org.openecomp.sdc.be.config.Configuration.class.getName(), new Yaml(beConfConstructor));
// HEAT deployment artifact
- org.yaml.snakeyaml.constructor.Constructor depArtHeatConstructor = new org.yaml.snakeyaml.constructor.Constructor(
- DeploymentArtifactHeatConfiguration.class);
+ org.yaml.snakeyaml.constructor.Constructor depArtHeatConstructor =
+ new org.yaml.snakeyaml.constructor.Constructor(DeploymentArtifactHeatConfiguration.class);
PropertyUtils propertyUtils = new PropertyUtils();
// Skip properties which are found in YAML but not found in POJO
propertyUtils.setSkipMissingProperties(true);
config = convert(fullFileName, className);
} catch (Exception e) {
- log.error(EcompLoggerErrorCode.UNKNOWN_ERROR, "", "", "Failed to convert yaml file {} to object.", configFileName, e);
+ log.error(EcompLoggerErrorCode.UNKNOWN_ERROR, "", "", "Failed to convert yaml file {} to object.",
+ configFileName, e);
}
return config;
}
public class MyYamlConstructor extends org.yaml.snakeyaml.constructor.Constructor {
+
private HashMap<String, Class<?>> classMap = new HashMap<>();
public MyYamlConstructor(Class<? extends Object> theRoot) {
File f = new File(fullFileName);
if (!f.exists()) {
- log.warn(EcompLoggerErrorCode.UNKNOWN_ERROR, "", "", "The file {} cannot be found. Ignore reading configuration.", fullFileName);
+ log.warn(EcompLoggerErrorCode.UNKNOWN_ERROR, "", "",
+ "The file {} cannot be found. Ignore reading configuration.", fullFileName);
return null;
}
in = Files.newInputStream(Paths.get(fullFileName));
// System.out.println(config.toString());
} catch (Exception e) {
- log.error(EcompLoggerErrorCode.UNKNOWN_ERROR, "", "", "Failed to convert yaml file {} to object.", fullFileName, e);
+ log.error(EcompLoggerErrorCode.UNKNOWN_ERROR, "", "", "Failed to convert yaml file {} to object.",
+ fullFileName, e);
} finally {
if (in != null) {
try {
public boolean isValidYamlEncoded64(byte[] fileContents) {
log.trace("Received Base64 data - decoding before validating...");
- byte[] decodedFileContents = Base64.decodeBase64(fileContents);
-
- return isValidYaml(decodedFileContents);
+ try {
+ byte[] decodedFileContents = Base64.getDecoder().decode(fileContents);
+ return isValidYaml(decodedFileContents);
+ } catch (IllegalArgumentException e) {
+ return false;
+ }
}
@SuppressWarnings("unchecked")
}
} catch (Exception e) {
- log.error(EcompLoggerErrorCode.UNKNOWN_ERROR, "", "", "Failed to convert yaml file to object - yaml is invalid", e);
+ log.error(EcompLoggerErrorCode.UNKNOWN_ERROR, "", "",
+ "Failed to convert yaml file to object - yaml is invalid", e);
return false;
}
return true;
package org.openecomp.sdc.common.test;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openecomp.sdc.common.util.YamlToObjectConverter;
@Test
public void testValidYamlBase64() {
- assertTrue(yamlToObjectConverter.isValidYamlEncoded64(Base64.encodeBase64(validYaml.getBytes())));
+ assertTrue(yamlToObjectConverter.isValidYamlEncoded64(Base64.getEncoder().encode(validYaml.getBytes())));
}
@Test
public void testInvalidYamlBase64() {
- assertFalse(yamlToObjectConverter.isValidYamlEncoded64(Base64.encodeBase64(invalidYaml.getBytes())));
+ assertFalse(yamlToObjectConverter.isValidYamlEncoded64(Base64.getEncoder().encode(invalidYaml.getBytes())));
}
}
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import com.google.common.collect.Lists;
+import com.google.common.hash.Hashing;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
public class GeneralUtilityTest {
- @Test
- public void validateGenerateTextFileReturnsTrueIfGeneratesTextFile() throws IOException {
+ @Test
+ public void validateGenerateTextFileReturnsTrueIfGeneratesTextFile() throws IOException {
- final String fileName = "test.txt";
- final String fileData = "test data";
- final File expectedFile = new File(fileName);
+ final String fileName = "test.txt";
+ final String fileData = "test data";
+ final File expectedFile = new File(fileName);
- boolean result = GeneralUtility.generateTextFile(fileName, fileData);
+ boolean result = GeneralUtility.generateTextFile(fileName, fileData);
- String createdFileData = FileUtils.readFileToString(expectedFile);
+ String createdFileData = FileUtils.readFileToString(expectedFile);
- assertTrue(result);
- assertEquals(createdFileData ,fileData);
+ assertTrue(result);
+ assertEquals(createdFileData, fileData);
- FileUtils.forceDelete(expectedFile);
- }
+ FileUtils.forceDelete(expectedFile);
+ }
- @Test
- public void validateIsBase64EncodedReturnsProperResponseFromByteArray() {
+ @Test
+ public void validateIsBase64EncodedReturnsProperResponseFromByteArray() {
- final String testString = "testDataToEncode";
- final byte[] testBytes = testString.getBytes();
- final byte[] testEncodedBytes = Base64.getEncoder().encode(testBytes);
+ final String testString = "testDataToEncode";
+ final byte[] testBytes = testString.getBytes();
+ final byte[] testEncodedBytes = Base64.getEncoder().encode(testBytes);
- boolean result = GeneralUtility.isBase64Encoded(testEncodedBytes);
+ boolean result = GeneralUtility.isBase64Encoded(testEncodedBytes);
- assertTrue(result);
- }
+ assertTrue(result);
+ }
- @Test
- public void validateIsBase64EncodedReturnsProperResponseFromString() {
+ @Test
+ public void validateIsBase64EncodedReturnsProperResponseFromString() {
- final String testString = "testDataToEncode";
- final byte[] testBytes = testString.getBytes();
- final byte[] testEncodedBytes = Base64.getEncoder().encode(testBytes);
- final String testEncodedString = new String(testEncodedBytes);
+ final String testString = "testDataToEncode";
+ final byte[] testBytes = testString.getBytes();
+ final byte[] testEncodedBytes = Base64.getEncoder().encode(testBytes);
+ final String testEncodedString = new String(testEncodedBytes);
- boolean result = GeneralUtility.isBase64Encoded(testEncodedString);
+ boolean result = GeneralUtility.isBase64Encoded(testEncodedString);
- assertTrue(result);
- }
+ assertTrue(result);
+ }
- @Test
- public void validateIsExceedingLimitReturnsFalseIfStringIsShorterThenLimit() {
+ @Test
+ public void validateIsExceedingLimitReturnsFalseIfStringIsShorterThenLimit() {
- final String testString = "test";
- final int limit = 5;
+ final String testString = "test";
+ final int limit = 5;
- boolean result = GeneralUtility.isExceedingLimit(testString, limit);
+ boolean result = GeneralUtility.isExceedingLimit(testString, limit);
- assertFalse(result);
- }
+ assertFalse(result);
+ }
- @Test
- public void validateIsExceedingLimitReturnsFalseIfStringIsNull() {
+ @Test
+ public void validateIsExceedingLimitReturnsFalseIfStringIsNull() {
- final String testString = null;
- final int limit = 5;
+ final String testString = null;
+ final int limit = 5;
- boolean result = GeneralUtility.isExceedingLimit(testString, limit);
+ boolean result = GeneralUtility.isExceedingLimit(testString, limit);
- assertFalse(result);
- }
+ assertFalse(result);
+ }
- @Test
- public void validateIsExceedingLimitReturnsFalseIfStringLengthIsEqualToLimit() {
+ @Test
+ public void validateIsExceedingLimitReturnsFalseIfStringLengthIsEqualToLimit() {
- final String testString = "test";
- final int limit = 4;
+ final String testString = "test";
+ final int limit = 4;
- boolean result = GeneralUtility.isExceedingLimit(testString, limit);
+ boolean result = GeneralUtility.isExceedingLimit(testString, limit);
- assertFalse(result);
- }
+ assertFalse(result);
+ }
- @Test
- public void validateIsExceedingLimitReturnsTrueIfStringExceedsLimit() {
+ @Test
+ public void validateIsExceedingLimitReturnsTrueIfStringExceedsLimit() {
- final String testString = "test";
- final int limit = 3;
+ final String testString = "test";
+ final int limit = 3;
- boolean result = GeneralUtility.isExceedingLimit(testString, limit);
+ boolean result = GeneralUtility.isExceedingLimit(testString, limit);
- assertTrue(result);
- }
+ assertTrue(result);
+ }
- @Test
- public void validateIsExceedingLimitWithDelimiterReturnsFalseIfSumOfAllElementsLengthAndDelimiterLengthIsSmallerThenLimit() {
+ @Test
+ public void validateIsExceedingLimitWithDelimiterReturnsFalseIfSumOfAllElementsLengthAndDelimiterLengthIsSmallerThenLimit() {
- final List<String> testString = Lists.newArrayList("testing","list");
- final int limit = 15;
- final int delimiterLength = 2;
+ final List<String> testString = Lists.newArrayList("testing", "list");
+ final int limit = 15;
+ final int delimiterLength = 2;
- boolean result = GeneralUtility.isExceedingLimit(testString, limit, delimiterLength);
+ boolean result = GeneralUtility.isExceedingLimit(testString, limit, delimiterLength);
- assertFalse(result);
- }
+ assertFalse(result);
+ }
- @Test
- public void validateIsExceedingLimitWithDelimiterReturnsFalseIfListIsNull() {
+ @Test
+ public void validateIsExceedingLimitWithDelimiterReturnsFalseIfListIsNull() {
- final List<String> testString = null;
- final int limit = 15;
- final int delimiterLength = 2;
+ final List<String> testString = null;
+ final int limit = 15;
+ final int delimiterLength = 2;
- boolean result = GeneralUtility.isExceedingLimit(testString, limit, delimiterLength);
+ boolean result = GeneralUtility.isExceedingLimit(testString, limit, delimiterLength);
- assertFalse(result);
- }
+ assertFalse(result);
+ }
- @Test
- public void validateIsExceedingLimitWithDelimiterReturnsFalseIfSumOfAllElementsLengthAndDelimiterLengthIsEqualThenLimit() {
+ @Test
+ public void validateIsExceedingLimitWithDelimiterReturnsFalseIfSumOfAllElementsLengthAndDelimiterLengthIsEqualThenLimit() {
- final List<String> testString = Lists.newArrayList("testing","list","equal");
- final int limit = 18;
- final int delimiterLength = 1;
+ final List<String> testString = Lists.newArrayList("testing", "list", "equal");
+ final int limit = 18;
+ final int delimiterLength = 1;
- boolean result = GeneralUtility.isExceedingLimit(testString, limit, delimiterLength);
+ boolean result = GeneralUtility.isExceedingLimit(testString, limit, delimiterLength);
- assertFalse(result);
- }
+ assertFalse(result);
+ }
- @Test
- public void validateIsExceedingLimitWithDelimiterReturnsTrueIfSumOfAllElementsLengthAndDelimiterLengthIsBiggerThenLimit() {
+ @Test
+ public void validateIsExceedingLimitWithDelimiterReturnsTrueIfSumOfAllElementsLengthAndDelimiterLengthIsBiggerThenLimit() {
- final List<String> testString = Lists.newArrayList("long","testing","list","of","strings");
- final int limit = 20;
- final int delimiterLength = 2;
+ final List<String> testString = Lists.newArrayList("long", "testing", "list", "of", "strings");
+ final int limit = 20;
+ final int delimiterLength = 2;
- boolean result = GeneralUtility.isExceedingLimit(testString, limit, delimiterLength);
+ boolean result = GeneralUtility.isExceedingLimit(testString, limit, delimiterLength);
- assertTrue(result);
- }
+ assertTrue(result);
+ }
- @Test
- public void validateGetFilenameExtensionReturnsProperExtension() {
+ @Test
+ public void validateGetFilenameExtensionReturnsProperExtension() {
- final String testFile = "test.yaml";
+ final String testFile = "test.yaml";
- String extension = GeneralUtility.getFilenameExtension(testFile);
+ String extension = GeneralUtility.getFilenameExtension(testFile);
- assertEquals(extension, "yaml");
- }
+ assertEquals(extension, "yaml");
+ }
- @Test
- public void validateCalculateMD5Base64EncodedByByteArrayReturnsCorrectString() {
+ @Test
+ public void validateCalculateMD5Base64EncodedByByteArrayReturnsCorrectString() {
- final String testStringToEncode = "testString";
+ final String testStringToEncode = "testString";
- String result = GeneralUtility.calculateMD5Base64EncodedByByteArray(testStringToEncode.getBytes());
+ String result = GeneralUtility.calculateMD5Base64EncodedByByteArray(testStringToEncode.getBytes());
- final String encodedString =
- org.apache.commons.codec.digest.DigestUtils.md5Hex(testStringToEncode.getBytes());
+ final String encodedString = Hashing.md5().hashBytes(testStringToEncode.getBytes()).toString();
- assertArrayEquals(encodedString.getBytes(), Base64.getDecoder().decode(result));
- }
+ assertArrayEquals(encodedString.getBytes(), Base64.getDecoder().decode(result));
+ }
- @Test
- public void validateCalculateMD5Base64EncodedByStringReturnsCorrectString() {
+ @Test
+ public void validateCalculateMD5Base64EncodedByStringReturnsCorrectString() {
- final String testStringToEncode = "testString";
+ final String testStringToEncode = "testString";
- String result = GeneralUtility.calculateMD5Base64EncodedByString(testStringToEncode);
+ String result = GeneralUtility.calculateMD5Base64EncodedByString(testStringToEncode);
- final String encodedString =
- org.apache.commons.codec.digest.DigestUtils.md5Hex(testStringToEncode.getBytes());
+ final String encodedString = Hashing.md5().hashBytes(testStringToEncode.getBytes()).toString();
- assertArrayEquals(encodedString.getBytes(), Base64.getDecoder().decode(result));
- }
+ assertArrayEquals(encodedString.getBytes(), Base64.getDecoder().decode(result));
+ }
- @Test
- public void validateIsEmptyStringReturnTrueIfStringIsEmpty() {
+ @Test
+ public void validateIsEmptyStringReturnTrueIfStringIsEmpty() {
- final String empty = "";
+ final String empty = "";
- boolean result = GeneralUtility.isEmptyString(empty);
+ boolean result = GeneralUtility.isEmptyString(empty);
- assertTrue(result);
- }
+ assertTrue(result);
+ }
- @Test
- public void validateIsEmptyStringReturnTrueIfStringIsContainingOnlyWightSpaces() {
+ @Test
+ public void validateIsEmptyStringReturnTrueIfStringIsContainingOnlyWightSpaces() {
- final String empty = " \t ";
+ final String empty = " \t ";
- boolean result = GeneralUtility.isEmptyString(empty);
+ boolean result = GeneralUtility.isEmptyString(empty);
- assertTrue(result);
- }
+ assertTrue(result);
+ }
- @Test
- public void validateIsEmptyStringReturnFalseIfStringIsNotEmpty() {
+ @Test
+ public void validateIsEmptyStringReturnFalseIfStringIsNotEmpty() {
- final String empty = "test";
+ final String empty = "test";
- boolean result = GeneralUtility.isEmptyString(empty);
+ boolean result = GeneralUtility.isEmptyString(empty);
- assertFalse(result);
- }
+ assertFalse(result);
+ }
- @Test
- public void validateIsEmptyStringReturnFalseIfStringIsNotEmptyAndSurroundedWithWightSpaces() {
+ @Test
+ public void validateIsEmptyStringReturnFalseIfStringIsNotEmptyAndSurroundedWithWightSpaces() {
- final String empty = " \ttest ";
+ final String empty = " \ttest ";
- boolean result = GeneralUtility.isEmptyString(empty);
+ boolean result = GeneralUtility.isEmptyString(empty);
- assertFalse(result);
- }
+ assertFalse(result);
+ }
}
*/
package org.openecomp.sdc.common.util;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.junit.Before;
import org.junit.Test;
import org.openecomp.sdc.be.config.Configuration;
private final String filePath = "./src/test/resources/config/common/";
private final String fileName = "configuration.yaml";
- private final String testYaml = "--- \n" +
- "object: \n" +
- " key: value";
+ private final String testYaml = "--- \n" + "object: \n" + " key: value";
private YamlToObjectConverter yamlToObjectConverter;
@Test
public void validateIsValidYamlEncoded64ReturnsTrueIfGivenYamlIsEncoded64() {
- boolean result = yamlToObjectConverter.isValidYamlEncoded64(Base64.encodeBase64(testYaml.getBytes()));
+ boolean result = yamlToObjectConverter.isValidYamlEncoded64(Base64.getEncoder().encode(testYaml.getBytes()));
assertTrue(result);
}
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${jackson.version}</version>
</dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>${commons.codec.version}</version>
- </dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${http.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
import static org.openecomp.sdc.action.util.ActionUtil.actionLogPostProcessor;
import static org.openecomp.sdc.action.util.ActionUtil.getUtcDateStringFromTimestamp;
+import com.google.common.hash.Hashing;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Map;
-import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import org.openecomp.core.utilities.file.FileUtils;
private static String calculateCheckSum(byte[] input) {
String checksum = null;
if (input != null) {
- checksum = DigestUtils.md5Hex(input);
+ checksum = Hashing.md5().hashBytes(input).toString().toUpperCase();
}
return checksum;
}
private String CalcMD5CheckSum(byte[] input) {
String checksum = null;
if (input != null) {
- checksum = DigestUtils.md5Hex(input).toUpperCase();
+ checksum = Hashing.md5().hashBytes(input).toString().toUpperCase();
System.out.println("checksum : " + checksum);
}
return checksum;
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${http.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
<version>${http.client.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${http.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${http.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${http.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${http.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- Java Stuff -->
<version>2.9.9</version>
</dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.11</version>
- </dependency>
-
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
package org.openecomp.sdc.securityutil;
import java.security.SecureRandom;
+import java.util.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
-import org.apache.commons.codec.binary.Base64;
public class CipherUtil {
private static Logger log = LoggerFactory.getLogger( CipherUtil.class.getName());
log.error("encrypt failed", ex);
throw new CipherUtilException(ex);
}
- return Base64.encodeBase64String(addAll(iv, finalByte));
+ return Base64.getEncoder().encodeToString(addAll(iv, finalByte));
}
/**
*/
public static String decryptPKC(String message, String base64key) throws CipherUtilException {
- byte[] encryptedMessage = Base64.decodeBase64(message);
+ byte[] encryptedMessage = Base64.getDecoder().decode(message);
Cipher cipher;
byte[] decrypted;
try {
}
private static SecretKeySpec getSecretKeySpec(String keyString) {
- byte[] key = Base64.decodeBase64(keyString);
+ byte[] key = Base64.getDecoder().decode(keyString);
return new SecretKeySpec(key, ALGORITHM);
}
* ============LICENSE_END=========================================================
*/
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.apache.commons.lang.RandomStringUtils;
import org.junit.Test;
import org.openecomp.sdc.securityutil.CipherUtil;
@Test
public void encryptDecryptPKC() throws CipherUtilException {
String generatedKey = RandomStringUtils.randomAlphabetic(16);
- String base64Key = Base64.encodeBase64String(generatedKey.getBytes());
+ String base64Key = Base64.getEncoder().encodeToString(generatedKey.getBytes());
String encrypted = CipherUtil.encryptPKC(DATA, base64Key);
assertNotEquals(DATA, encrypted);
String decrypted = CipherUtil.decryptPKC(encrypted, base64Key);
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>${commons.codec.version}</version>
- </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>${http.client.version}</version>
+ <version>${http.client.version}</version>
<scope>provided</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
# yarn lockfile v1
-"@angular/common@~2.4.8":
- version "2.4.10"
- resolved "https://registry.yarnpkg.com/@angular/common/-/common-2.4.10.tgz#a3a682d2228fa30ec23dd0eb57c8e887fba26997"
-
-"@angular/core@~2.4.8":
- version "2.4.10"
- resolved "https://registry.yarnpkg.com/@angular/core/-/core-2.4.10.tgz#0b8320a65065965d998645b1f5cd3cf769b441ea"
-
-"@angular/forms@~2.4.8":
- version "2.4.10"
- resolved "https://registry.yarnpkg.com/@angular/forms/-/forms-2.4.10.tgz#062133aaade1f3b3c962f1593208c541b622fd06"
-
-"@angular/http@^2.4.8":
- version "2.4.10"
- resolved "https://registry.yarnpkg.com/@angular/http/-/http-2.4.10.tgz#ff6beade5b39c989ebf2393c49b34eebd43e9555"
-
-"@angular/platform-browser-dynamic@~2.4.8":
- version "2.4.10"
- resolved "https://registry.yarnpkg.com/@angular/platform-browser-dynamic/-/platform-browser-dynamic-2.4.10.tgz#8df25dec2b06adc690cc9bc26448deccaebcd8ec"
-
-"@angular/platform-browser@~2.4.8":
- version "2.4.10"
- resolved "https://registry.yarnpkg.com/@angular/platform-browser/-/platform-browser-2.4.10.tgz#cbf25608148fb4ffef96cc5005ba5d7b3e093906"
-
-"@angular/router@~3.2.1":
- version "3.2.4"
- resolved "https://registry.yarnpkg.com/@angular/router/-/router-3.2.4.tgz#dfec71ad072ec031364ba5d08bd6fe03fd5beadc"
-
-"@angular/upgrade@^2.4.8":
- version "2.4.10"
- resolved "https://registry.yarnpkg.com/@angular/upgrade/-/upgrade-2.4.10.tgz#b69a3ee324d4450eb1696ddc9bded1a6ec06ca52"
-
"@babel/code-frame@7.0.0-beta.44":
version "7.0.0-beta.44"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9"
version "1.0.1"
resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.1.tgz#928f5d0f470d49342651ea6794b0857c100693f7"
-onap-ui-common@1.0.100:
- version "1.0.100"
- resolved "https://registry.yarnpkg.com/onap-ui-common/-/onap-ui-common-1.0.100.tgz#c0dae1d3d1c3fd2b866340d27a1179ed10a3a860"
- integrity sha512-d+eaYgVgrj9B8/3iVDlkxO2jiE7wXFrvMogxxHsyM8E0Fa7wXGEGwohA4JD5nGydT84dU2vPzwkby7SZNgGpKA==
+onap-ui-common@1.0.101:
+ version "1.0.101"
+ resolved "https://registry.yarnpkg.com/onap-ui-common/-/onap-ui-common-1.0.101.tgz#c79b8fb903b7d2d3f959e3b5c27b561b563d961b"
-onap-ui-react@^0.1.1:
- version "0.1.1"
- resolved "https://registry.yarnpkg.com/onap-ui-react/-/onap-ui-react-0.1.1.tgz#3640bdb9fb10f85104ad9dd57a9f320b0703abf3"
- integrity sha512-hax7WzSMIPll9fHvKVjFbn2dIOh39fWuiy0VQKONq/ccU3f/y08Y6EzJo7rzWcwjt8bp2KDhqNZky0HwIquc6w==
+onap-ui-common@^1.0.101:
+ version "1.0.105"
+ resolved "https://registry.yarnpkg.com/onap-ui-common/-/onap-ui-common-1.0.105.tgz#099ca3229a5cf3bd81339d737a71b1b0d24d8fa2"
+
+onap-ui-react@^1.0.0:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/onap-ui-react/-/onap-ui-react-1.0.2.tgz#e99dc5a924f84a991c71a3e9c05a44a915830168"
dependencies:
"@storybook/react" "^3.1.5"
http-loader "0.0.1"
- onap-ui-common "1.0.100"
+ onap-ui-common "1.0.101"
prop-types "^15.6.0"
react "15.6.2"
react-dom "15.6.2"
version "4.1.0"
resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782"
-rxjs@5.4.2:
- version "5.4.2"
- resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.2.tgz#2a3236fcbf03df57bae06fd6972fd99e5c08fcf7"
- dependencies:
- symbol-observable "^1.0.1"
-
rxjs@^5.5.2:
version "5.5.11"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.11.tgz#f733027ca43e3bec6b994473be4ab98ad43ced87"
js-base64 "^2.1.8"
source-map "^0.4.2"
-sdc-ui@1.6.62:
- version "1.6.62"
- resolved "https://registry.yarnpkg.com/sdc-ui/-/sdc-ui-1.6.62.tgz#738b14d3e2d2280f9be69b1fdb91b7c815e60dca"
- dependencies:
- "@angular/common" "~2.4.8"
- "@angular/core" "~2.4.8"
- "@angular/forms" "~2.4.8"
- "@angular/http" "^2.4.8"
- "@angular/platform-browser" "~2.4.8"
- "@angular/platform-browser-dynamic" "~2.4.8"
- "@angular/router" "~3.2.1"
- "@angular/upgrade" "^2.4.8"
- "@storybook/react" "^3.1.5"
- http-loader "0.0.1"
- prop-types "^15.6.0"
- react "15.6.2"
- react-dom "15.6.2"
- reflect-metadata "^0.1.3"
- rxjs "5.4.2"
- svg-react-loader "^0.4.4"
- zone.js "^0.8.18"
-
select-hose@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca"
version "1.0.1"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4"
-symbol-observable@^1.0.1, symbol-observable@^1.0.3, symbol-observable@^1.1.0:
+symbol-observable@^1.0.3, symbol-observable@^1.1.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
text-table "^0.2.0"
through2 "^2.0.0"
yeoman-environment "^2.0.5"
-
-zone.js@^0.8.18:
- version "0.8.26"
- resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.8.26.tgz#7bdd72f7668c5a7ad6b118148b4ea39c59d08d2d"
<!-- logback -->
<logback.version>1.2.3</logback.version>
<slf4j-api.version>1.7.25</slf4j-api.version>
- <commons-codec>1.10</commons-codec>
<commons-logging>1.2</commons-logging>
<janino.version>3.0.6</janino.version>
<maven-surefire-plugin.version>2.22.0</maven-surefire-plugin.version>
<!-- parser-->
- <sdc-tosca-parser.version>1.3.5</sdc-tosca-parser.version>
+ <sdc-tosca-parser.version>1.6.2</sdc-tosca-parser.version>
<!-- sonar -->
<sonar.language>java</sonar.language>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>${commons-codec}</version>
- <scope>compile</scope>
- </dependency>
-
<!-- Gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
<scope>compile</scope>
</dependency>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.onap.sdc.sdc-tosca</groupId>
<artifactId>sdc-tosca</artifactId>
- <version>1.4.6</version>
+ <version>1.6.2</version>
<scope>compile</scope>
</dependency>
</dependency>
<dependency>
- <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
+ <groupId>org.onap.sdc.sdc-distribution-client</groupId>
<artifactId>sdc-distribution-client</artifactId>
- <version>1.2.2 </version>
+ <version>1.4.1</version>
<scope>test</scope>
</dependency>
package org.openecomp.sdc.ci.tests.execute.artifacts;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.elements.HeatParameterDataDefinition;
ArtifactUiDownloadData artifactUiDownloadData = ResponseParser.parseToObject(heatEnvDownloadResponse.getResponse(), ArtifactUiDownloadData.class);
byte[] fromUiDownload = artifactUiDownloadData.getBase64Contents().getBytes();
- byte[] decodeBase64 = Base64.decodeBase64(fromUiDownload);
+ byte[] decodeBase64 = Base64.getDecoder().decode(fromUiDownload);
Yaml yaml = new Yaml();
InputStream inputStream = new ByteArrayInputStream(decodeBase64);
package org.openecomp.sdc.ci.tests.execute.devCI;
-import org.apache.commons.codec.digest.DigestUtils;
+import com.google.common.hash.Hashing;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.openecomp.sdc.ci.tests.datatypes.GroupHeatMetaDefinition;
// md5Hex converts an array of bytes into an array of characters representing the hexadecimal values of each byte in order.
// The returned array will be double the length of the passed array, as it takes two characters to represent any given byte.
- crunchifyValue = DigestUtils.md5Hex(IOUtils.toByteArray(crunchifyInputStream));
+ crunchifyValue = Hashing.md5().hashBytes(IOUtils.toByteArray(crunchifyInputStream)).toString();
} catch (IOException e) {
e.printStackTrace();
} finally {
package org.openecomp.sdc.ci.tests.execute.distribution;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
String actualContents = restResponse.getResponse();
// Contents - comparing decoded content
- AssertJUnit.assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
+ AssertJUnit.assertEquals(artifactDetails.getPayload(), Base64.getEncoder().encodeToString(actualContents.getBytes()));
// validating checksum
String actualPayloadChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(actualContents.getBytes());
String actualContents = restResponse.getResponse();
- assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
+ assertEquals(artifactDetails.getPayload(), Base64.getEncoder().encodeToString(actualContents.getBytes()));
// validating checksum
byte[] bytes = actualContents.getBytes();
package org.openecomp.sdc.ci.tests.execute.externalapi;
import com.google.gson.Gson;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
String payloadName = "VF_RI2_G4_withArtifacts.csar";
Path path = Paths.get(rootPath + "/src/main/resources/ci/VF_RI2_G4_withArtifacts.csar");
byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
resourceDetailsVF_01.setPayloadData(payloadData);
resourceDetailsVF_01.setPayloadName(payloadName);
//US505653
package org.openecomp.sdc.ci.tests.execute.general;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.dao.api.ActionStatus;
@Test
public void sendAuthenticatedRequestTest_InvalidHeader() throws Exception, Exception {
String userCredentials = USER + ":" + PASSWORD;
- byte[] encodeBase64 = Base64.encodeBase64(userCredentials.getBytes());
+ byte[] encodeBase64 = Base64.getEncoder().encode(userCredentials.getBytes());
String encodedUserCredentials = new String(encodeBase64);
Map<String, String> authorizationHeader = new HashMap<String, String>();
authorizationHeader.put(HttpHeaderEnum.AUTHORIZATION.getValue(), encodedUserCredentials);
package org.openecomp.sdc.ci.tests.execute.imports;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
assertNotNull(artifactUiDownloadData);
byte[] fromUiDownload = artifactUiDownloadData.getBase64Contents().getBytes();
- byte[] decodeBase64 = Base64.decodeBase64(fromUiDownload);
+ byte[] decodeBase64 = Base64.getDecoder().decode(fromUiDownload);
return decodeBase64;
}
import com.google.gson.Gson;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
-import org.apache.commons.codec.binary.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
String payloadData = null;
path = Paths.get(rootPath + "/src/test/resources/CI/csars/jsonPropertyTypeTest.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setCsarUUID(payloadName);
resourceDetails.setPayloadName(payloadName);
ArtifactUiDownloadData artifactUiDownloadData = ResponseParser.parseToObject(toscaTemplate.getResponse(),
ArtifactUiDownloadData.class);
byte[] fromUiDownload = artifactUiDownloadData.getBase64Contents().getBytes();
- byte[] decodeBase64 = Base64.decodeBase64(fromUiDownload);
+ byte[] decodeBase64 = Base64.getDecoder().decode(fromUiDownload);
Yaml yaml = new Yaml();
InputStream inputStream = new ByteArrayInputStream(decodeBase64);
package org.openecomp.sdc.ci.tests.execute.imports;
import com.google.gson.Gson;
-import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.WordUtils;
import org.junit.Rule;
import org.junit.rules.TestName;
path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
// create new resource from Csar
// change composition (resource should be updated)
path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_b.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
// change name
resourceDetails.setName("test1");
// wrong RI (without node types, resource shouldn't be updated)
path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_c.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
// change name
resourceDetails.setName("test3");
resourceDetails = ElementFactory.getDefaultImportResource();
path = Paths.get(rootPath + "/src/main/resources/ci/VF_RI2_G4_withArtifacts.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setPayloadName("VF_RI2_G4_withArtifacts.csar");
resourceDetails.setName("test4");
resourceDetails.setCsarUUID("VF_RI2_G4_withArtifacts_b.csar");
path = Paths.get(rootPath + "/src/main/resources/ci/VF_RI2_G4_withArtifacts_b.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setPayloadName("VF_RI2_G4_withArtifacts_b.csar");
resourceDetails.setName("test5");
path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
// create new resource from Csar
// change composition and update resource
path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_b.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setUniqueId(resource.getUniqueId());
// change name
// shouldn't be updated)
path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_c.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
// change name
resourceDetails.setName("test3");
path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
// create new resource from Csar
// change composition (add new RI with specified property values)
path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_d.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
// change name
resourceDetails.setName("test1");
// change composition (add new specified property values to existing RI)
path = Paths.get(rootPath + "/src/main/resources/ci/valid_vf_f.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
// change name
resourceDetails.setName("test2");
path = Paths.get(rootPath + "/src/test/resources/CI/csars/vmmc_relate_by_cap_name.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
// create new resource from Csar
path = Paths.get(rootPath + "/src/test/resources/CI/csars/vf_relate_by_cap_name.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
// create new resource from Csar
String payloadName = "ImportArtifactsToVFC.csar";
Path path = Paths.get(rootPath + "/src/test/resources/CI/csars/ImportArtifactsToVFC.csar");
byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setPayloadName(payloadName);
resourceDetails.setResourceType(ResourceTypeEnum.VF.name());
payloadName = "ImportArtifactsToVFC_empty.csar";
path = Paths.get(rootPath + "/src/test/resources/CI/csars/ImportArtifactsToVFC_empty.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setName(resourceDetails.getName()+"2");
resourceDetails.setPayloadData(payloadData);
resourceDetails.setPayloadName(payloadName);
package org.openecomp.sdc.ci.tests.execute.imports;
import com.google.gson.Gson;
-import org.apache.commons.codec.binary.Base64;
import org.apache.http.HttpStatus;
import org.junit.Rule;
import org.junit.rules.TestName;
+ " org.openecomp.resource.importResource4test:\r\n" + " derived_from: tosca.nodes.Root\r\n"
+ " description: someDesc";
- String encodedPayload = new String(Base64.encodeBase64(payload.getBytes()));
+ String encodedPayload = new String(Base64.getEncoder().encode(payload.getBytes()));
String json = "{\r\n" + " \"resourceName\": \"importResource4test\",\r\n"
+ " \"payloadName\": \"importResource4test.yml\",\r\n"
package org.openecomp.sdc.ci.tests.execute.imports;
import com.google.gson.Gson;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Rule;
import org.junit.rules.TestName;
ImportReqDetails resourceDetails = ElementFactory.getDefaultImportResource();
Path path = Paths.get(rootPath + "/src/test/resources/CI/csars/vf_with_cap_prop_override_cap_type_prop.csar");
byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setPayloadName(payloadName);
Path path = Paths
.get(rootPath + "/src/test/resources/CI/csars/vf_with_cap_prop_override_cap_type_prop_failed.csar");
byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setPayloadName(payloadName);
resourceDetails = ElementFactory.getDefaultImportResource();
Path path = Paths.get(rootPath + "/src/test/resources/CI/csars/vf_with_cap_prop_override_cap_type_prop1.csar");
byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setPayloadName(payloadName);
Path path = Paths
.get(rootPath + "/src/test/resources/CI/csars/vf_with_cap_prop_override_cap_type_prop1_failed.csar");
byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setPayloadName(payloadName);
Path path = Paths.get(rootPath + "/src/test/resources/CI/csars/" + payloadName);
byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setPayloadName(payloadName);
package org.openecomp.sdc.ci.tests.execute.imports;
import com.google.gson.Gson;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
String rootPath = System.getProperty("user.dir");
Path path = Paths.get(rootPath + csarFolderPath + "orig2G.csar");
byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setPayloadName(payloadName);
resourceDetails.setName("TEST01");
// update scar with new artifacts
path = Paths.get(rootPath + csarFolderPath + "orig2G_update.csar");
data = Files.readAllBytes(path);
- payloadData = Base64.encodeBase64String(data);
+ payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setDescription("update");
resourceDetails.setCsarVersion("2");
updateResource = ResourceRestUtils.updateResource(resourceDetails, sdncModifierDetails,
Path path = Paths.get(rootPath + csarFolderPath + payloadName);
byte[] data = Files.readAllBytes(path);
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setPayloadName(payloadName);
package org.openecomp.sdc.ci.tests.utils;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
ArtifactUiDownloadData artifactUiDownloadData = ResponseParser.parseToObject(csarResponse.getResponse(),
ArtifactUiDownloadData.class);
byte[] fromUiDownload = artifactUiDownloadData.getBase64Contents().getBytes();
- return Base64.decodeBase64(fromUiDownload);
+ return Base64.getDecoder().decode(fromUiDownload);
}
public static List<TypeHeatMetaDefinition> getListTypeHeatMetaDefinition(File csarFileLocation) throws Exception {
package org.openecomp.sdc.ci.tests.utils;
-import org.apache.commons.codec.binary.Base64;
-
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
+import java.util.Base64;
public class Decoder {
public static String encode(byte[] byteArrayToEncode) {
- byte[] bytesEncoded = Base64.encodeBase64(byteArrayToEncode);
+ byte[] bytesEncoded = Base64.getEncoder().encode(byteArrayToEncode);
String strEncoded = new String(bytesEncoded);
return strEncoded;
}
public static String decode(String strEncoded) throws IOException {
- byte[] byteDecoded = Base64.decodeBase64(strEncoded);
+ byte[] byteDecoded = Base64.getDecoder().decode(strEncoded);
String decoded = new String(byteDecoded);
return decoded;
String acceptHeaderDate = "application/json";
public Utils() {
- /*
- * super();
- *
- * StartTest.enableLogger(); logger =
- * Logger.getLogger(Utils.class.getName());
- */
-
}
- // public String serviceTopologyPattern = "/topology/topology/%s";
- // public String serviceTopologyTemplatePattern =
- // "/topologytemplate/topologytemplate/%s";
- //
- // public String serviceTopologySearchPattern =
- // "topology/topology/_search?q=%s";
- // public String serviceTopologyTemplateSearchPattern =
- // "topologytemplate/topologytemplate/_search?q=%s";
- //
- // public ArtifactTypeEnum getFileTypeByExtension(String fileName) {
- //
- // String fileExtension = null;
- // if (fileName.matches("(.*)\\.(.*)")) {
- // System.out.println(fileName.substring(fileName.lastIndexOf(".") + 1));
- // fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1);
- // }
- //
- // switch (fileExtension) {
- // case "sh":
- // return ArtifactTypeEnum.SHELL_SCRIPT;
- // case "png":
- // return ArtifactTypeEnum.ICON;
- // case "ppp":
- // return ArtifactTypeEnum.PUPPET;
- // case "yang":
- // return ArtifactTypeEnum.YANG;
- // default:
- // return ArtifactTypeEnum.UNKNOWN;
- // }
- //
- // }
- //
- // public ArrayList<String> getScriptList (List<UploadArtifactInfo>
- // artifactsList){
- //
- // ArrayList<String> scriptNameArray = new ArrayList<>();
- // if (artifactsList != null){
- // for (UploadArtifactInfo fileInArtifactsList : artifactsList){
- // String artifactFileName = fileInArtifactsList.getArtifactName();
- // ArtifactTypeEnum artifactFileType =
- // fileInArtifactsList.getArtifactType();
- // if (! artifactFileType.equals(ArtifactTypeEnum.ICON)){
- // scriptNameArray.add(artifactFileName);
- // }
- // continue;
- // }
- // return scriptNameArray;
- // }
- // return null;
- // }
- //
- //
- // public String getYamlFileLocation(File testResourcesPath) {
- // File[] files = testResourcesPath.listFiles();
- // if (files.length == 0){
- // return null;
- // }else{
- // for (int i = 0; i < files.length; i++){
- // if (files[i].isFile()){
- // return files[i].getAbsoluteFile().toString();
- // }
- // }
- // }
- // return null;
- // }
- //
- // public String readFileContentToString (String fileName) throws
- // IOException {
- //
- // Path path = Paths.get(fileName);
- // String stringFromFile = new String(Files.readAllBytes(path));
- // return stringFromFile;
- //
- //
- // }
- //
@SuppressWarnings("unchecked")
public ToscaNodeTypeInfo parseToscaNodeYaml(String fileContent) {
return result;
}
- //
- //
- // public ArtifactsMetadata getArtifactsMetadata(String response){
- // ArtifactsMetadata artifactsMetadata = new ArtifactsMetadata();
- //
- // artifactsMetadata.setId(getJsonObjectValueByKey(response, "id"));
- // artifactsMetadata.setName(getJsonObjectValueByKey(response, "name"));
- // artifactsMetadata.setType(getJsonObjectValueByKey(response, "type"));
- //
- // artifactsMetadata.setCreator(getJsonObjectValueByKey(response,
- // "creator"));
- // artifactsMetadata.setCreationTime(getJsonObjectValueByKey(response,
- // "creationTime"));
- // artifactsMetadata.setLastUpdateTime(getJsonObjectValueByKey(response,
- // "lastUpdateTime"));
- // artifactsMetadata.setChecksum(getJsonObjectValueByKey(response,
- // "checksum"));
- // artifactsMetadata.setDescription(getJsonObjectValueByKey(response,
- // "description"));
- // artifactsMetadata.setLastUpdater(getJsonObjectValueByKey(response,
- // "lastUpdater"));
- //
- // return artifactsMetadata;
- // }
- //
public static String getJsonObjectValueByKey(String metadata, String key) {
JsonElement jelement = new JsonParser().parse(metadata);
}
return config;
}
- // public void uploadNormativeTypes() throws IOException{
- // Config config = getConfig();
- // String[] normativeTypes = {"root", "compute", "blockStorage",
- // "softwareComponent", "DBMS", "database", "network", "objectStorage",
- // "webServer", "webApplication"};
- // for( String normativeType : normativeTypes ){
- // uploadComponent(config.getComponentsConfigDir()+File.separator+"normativeTypes"+File.separator+normativeType);
- // }
- //
- // }
- //
- // public void uploadApacheComponent() throws IOException{
- // Config config = getConfig();
- // uploadComponent(config.getComponentsConfigDir()+File.separator+"apache");
- // }
- //
- // public void uploadComponent(String componentDir) throws IOException{
- //
- // //*********************************************upload*************************************************************
- // Config config = getConfig();
- // ZipDirectory zipDirectory = new ZipDirectory();
- // System.out.println(config.getEsHost());
- //
- // List<UploadArtifactInfo> artifactsList = new
- // ArrayList<UploadArtifactInfo>();
- //
- //// read test resources and zip it as byte array
- // byte[] zippedAsByteArray = zipDirectory.zip(componentDir, artifactsList);
- //
- //// encode zipped directory using base64
- // String payload = Decoder.encode(zippedAsByteArray);
- //
- //// zip name build as testName with ".zip" extension
- // String payloadZipName = getPayloadZipName(componentDir);
- //
- //// build json
- // UploadResourceInfo resourceInfo = new UploadResourceInfo(payload,
- // payloadZipName, "description", "category/mycategory", null,
- // artifactsList);
- // String json = new Gson().toJson(resourceInfo);
- //
- //// calculate md5 on the content of json
- // String jsonMd5 =
- // org.apache.commons.codec.digest.DigestUtils.md5Hex(json);
- //
- //// encode the md5 to base64, sent as header in post http request
- // String encodedMd5 = Decoder.encode(jsonMd5.getBytes());
- //
- //// upload component to Elastic Search DB
- // String url = null;
- // HttpRequest http = new HttpRequest();
- //
- // url = String.format(Urls.UPLOAD_ZIP_URL, config.getCatalogFeHost(),
- // config.getCatalogFePort());
- //
- //// Prepare headers to post upload component request
- // HeaderData headerData = new HeaderData(encodedMd5, "application/json",
- // "att", "test", "testIvanovich", "RoyalSeal", "Far_Far_Away",
- // "getResourceArtifactListTest");
- //
- // MustHeaders headers = new MustHeaders(headerData);
- // System.out.println("headers:"+headers.getMap());
- //
- // RestResponse response = http.httpSendPost(url, json, headers.getMap());
- //
- // assertEquals("upload component failed with code " +
- // response.getErrorCode().intValue(),response.getErrorCode().intValue(),
- // 204);
- // }
- //
- // private String getPayloadZipName(String componentDir) {
- // String payloadName;
- // if( componentDir.contains( File.separator) ){
- // String delimiter = null;
- // if( File.separator.equals("\\")){
- // delimiter ="\\\\";
- // }
- // else{
- // delimiter = File.separator;
- // }
- // String[] split = componentDir.split(delimiter);
- // payloadName = split[split.length-1];
- // }
- // else{
- // payloadName = componentDir;
- // }
- // return payloadName+".zip";
- // }
- //
- //
- //
- // public List<UploadArtifactInfo> createArtifactsList(String srcDir) {
- //
- // List<UploadArtifactInfo> artifactsList = new
- // ArrayList<UploadArtifactInfo>();
- // File srcFile = new File(srcDir);
- // addFileToList(srcFile, artifactsList);
- //
- // return artifactsList;
- // }
- //
- // public void addFileToList(File srcFile, List<UploadArtifactInfo>
- // artifactsList) {
- //
- // File[] files = srcFile.listFiles();
- //
- // for (int i = 0; i < files.length; i++) {
- // // if the file is directory, use recursion
- // if (files[i].isDirectory()) {
- // addFileToList(files[i], artifactsList);
- // continue;
- // }
- //
- // String fileName = files[i].getName();
- // String artifactPath = fileName;
- //
- // if ( ! files[i].getName().matches("(.*)\\.y(?)ml($)")) {
- // UploadArtifactInfo uploadArtifactInfo = new UploadArtifactInfo();
- // uploadArtifactInfo.setArtifactName(files[i].getName());
- // String parent = files[i].getParent();
- //
- // if (parent != null) {
- // System.out.println(parent);
- // int lastSepartor = parent.lastIndexOf(File.separator);
- // if (lastSepartor > -1) {
- // String actualParent = parent.substring(lastSepartor + 1);
- // artifactPath = actualParent + "/" + artifactPath;
- // }
- // }
- //
- // uploadArtifactInfo.setArtifactPath(artifactPath);
- // uploadArtifactInfo.setArtifactType(getFileTypeByExtension(fileName));
- // uploadArtifactInfo.setArtifactDescription("description");
- // artifactsList.add(uploadArtifactInfo);
- //
- // System.out.println("artifact list: " + artifactsList);
- //
- // }
- //
- // }
- // }
- //
- //
- // public String buildArtifactListUrl (String nodesType, String
- // templateVersion, String artifactName) throws FileNotFoundException{
- // //"http://172.20.43.132/sdc2/v1/catalog/resources/tosca.nodes.Root/1.0.0.wd03-SNAPSHOT/artifacts/wxs_baseline_compare.sh"
- // Config config = getConfig();
- // return "\"http://" + config.getCatalogBeHost() + ":" +
- // config.getCatalogBePort() + "/sdc2/v1/catalog/resources/" +nodesType +
- // "/" + templateVersion + "/artifacts/" + artifactName +"\"";
- // }
- //
- //
- // public void addTopologyToES(String testFolder, String
- // serviceTopologyPattern) throws IOException{
- // Config config = getConfig();
- // String url = String.format(Urls.ES_URL, config.getEsHost(),
- // config.getEsPort()) + serviceTopologyPattern;
- // String sourceDir =
- // config.getResourceConfigDir()+File.separator+testFolder;
- // Path filePath = FileSystems.getDefault().getPath(sourceDir,
- // "topology.txt");
- // postFileContentsToUrl(url, filePath);
- // }
- //
- // public void addTopologyTemplateToES(String testFolder, String
- // serviceTopologyTemplatePattern) throws IOException{
- // Config config = getConfig();
- // String url = String.format(Urls.ES_URL, config.getEsHost(),
- // config.getEsPort()) + serviceTopologyTemplatePattern;
- // String sourceDir =
- // config.getResourceConfigDir()+File.separator+testFolder;
- // Path filePath = FileSystems.getDefault().getPath(sourceDir,
- // "topologyTemplate.txt");
- // postFileContentsToUrl(url, filePath);
- // }
- //
- //
- // public void postFileContentsToUrl(String url, Path filePath) throws
- // IOException {
- // HttpClientContext localContext = HttpClientContext.create();
- // CloseableHttpResponse response = null;
- //
- // byte[] fileContent = Files.readAllBytes(filePath);
- //
- // try(CloseableHttpClient httpClient = HttpClients.createDefault()){
- // HttpPost httpPost = new HttpPost(url);
- // StringEntity entity = new StringEntity(new String(fileContent) ,
- // ContentType.APPLICATION_JSON);
- // httpPost.setEntity(entity);
- // response = httpClient.execute(httpPost, localContext);
- //
- // }
- // finally{
- // response.close();
- // }
- //
- //
- // }
- //
- //
- //// public boolean isPatternInEsDb(String patternToSearch)throws
- // IOException{
- //// Config config = getConfig();
- //// String url = String.format(Urls.GET_SEARCH_DATA_FROM_ES,
- // config.getEsHost(), config.getEsPort(),patternToSearch);
- //// HttpRequest httpRequest = new HttpRequest();
- //// RestResponse restResponse = httpRequest.httpSendGet(url);
- //// if (restResponse.getErrorCode() == 200){
- //// return true;
- //// }
- //// if (restResponse.getErrorCode() == 404){
- //// return false;
- //// }
- ////
- //// return false;
- //// }
- //
- // public static RestResponse deleteAllDataFromEs() throws IOException{
- // return deleteFromEsDbByPattern("_all");
- // }
- //
- //
- // public List<String> buildIdArrayListByTypesIndex (String index, String
- // types) throws IOException{
- //
- // Config config = getConfig();
- // HttpRequest http = new HttpRequest();
- // RestResponse getResponce =
- // http.httpSendGet(String.format(Urls.GET_ID_LIST_BY_INDEX_FROM_ES,
- // config.getEsHost(), config.getEsPort(), index, types), null);
- //
- // List <String> idArray = new ArrayList<String>();
- //
- // JsonElement jelement = new JsonParser().parse(getResponce.getResponse());
- // JsonObject jobject = jelement.getAsJsonObject();
- // JsonObject hitsObject = (JsonObject) jobject.get("hits");
- // JsonArray hitsArray = (JsonArray) hitsObject.get("hits");
- // for (int i = 0; i < hitsArray.size(); i ++){
- // JsonObject idObject = (JsonObject) hitsArray.get(i);
- // String id = idObject.get("_id").toString();
- // id = id.replace("\"", "");
- // idArray.add(id);
- // }
- //
- // return idArray;
- // }
- //
- // public List<String> buildCategoriesTagsListFromJson(String
- // categoriesTagsJson){
- //
- // ArrayList<String> categoriesTagsArray = new ArrayList<>();
- // JsonElement jelement = new JsonParser().parse(categoriesTagsJson);
- // JsonArray jArray = jelement.getAsJsonArray();
- // for (int i = 0; i < jArray.size(); i ++){
- // JsonObject categoriesTagsObject = (JsonObject) jArray.get(i);
- // String categories = categoriesTagsObject.get("name").toString();
- // categoriesTagsArray.add(categories);
- // }
- //
- // return categoriesTagsArray;
- // }
- //
- // public ArrayList <String> getCategoriesFromDb() throws Exception{
- //
- // ArrayList<String> categoriesFromDbArrayList = new ArrayList<>();
- // RestResponse restResponse = new RestResponse();
- // String contentTypeHeaderData = "application/json";
- // String acceptHeaderDate = "application/json";
- //
- // Map<String, String> headersMap = new HashMap<String,String>();
- // headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(),contentTypeHeaderData);
- // headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
- //
- // HttpRequest httpRequest = new HttpRequest();
- // String url = String.format(Urls.QUERY_NEO4J,
- // Config.instance().getNeoHost(), Config.instance().getNeoPort());
- // String body = "{\"statements\" : [ { \"statement\" : \"MATCH
- // (category:category) return (category)\"} ]}";
- // restResponse = httpRequest.httpSendPostWithAuth(url, body, headersMap,
- // Config.instance().getNeoDBusername(),
- // Config.instance().getNeoDBpassword());
- //
- // if (restResponse.getResponse()==null){
- // return categoriesFromDbArrayList;
- // }else{
- // JsonElement jelement = new
- // JsonParser().parse(restResponse.getResponse());
- // JsonObject jobject = jelement.getAsJsonObject();
- // JsonArray resultsArray = (JsonArray) jobject.get("results");
- // JsonObject resObject = (JsonObject) resultsArray.get(0);
- // JsonArray dataArray = (JsonArray) resObject.get("data");
- // for (int i = 0; i < dataArray.size(); i ++){
- // JsonObject rowObject = (JsonObject) dataArray.get(i);
- // JsonArray rowArray = (JsonArray) rowObject.get("row");
- // JsonObject nameObject = (JsonObject) rowArray.get(0);
- // String name = nameObject.get("name").toString();
- //// name = name.replace("\"", "");
- // categoriesFromDbArrayList.add(name);
- // }
- //
- //
- // }
- //
- // return categoriesFromDbArrayList;
- // }
- //
public static void compareArrayLists(List<String> actualArraylList, List<String> expectedArrayList,
String message) {
import com.aventstack.extentreports.Status;
import com.google.gson.Gson;
import fj.data.Either;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONException;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
Path path = Paths.get(csarFilePath + File.separator + csarFileName);
byte[] data = Files.readAllBytes(path);
String payloadName = csarFileName;
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setCsarUUID(payloadName);
resourceDetails.setPayloadName(payloadName);
Path path = Paths.get(csarFilePath + File.separator + csarFileName);
data = Files.readAllBytes(path);
String payloadName = csarFileName;
- String payloadData = Base64.encodeBase64String(data);
+ String payloadData = Base64.getEncoder().encodeToString(data);
ImportReqDetails resourceDetails = new ImportReqDetails(resource, payloadName, payloadData);
resourceDetails.setPayloadData(payloadData);
resourceDetails.setCsarUUID(payloadName);
import com.google.gson.Gson;
import fj.data.Either;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
@SuppressWarnings("unchecked")
Map<String, String> fromJson = gson.fromJson(payload, Map.class);
String string = fromJson.get("base64Contents").toString();
- byte[] byteArray = Base64.decodeBase64(string.getBytes(StandardCharsets.UTF_8));
+ byte[] byteArray = Base64.getDecoder().decode(string.getBytes(StandardCharsets.UTF_8));
File downloadedFile = new File(file.getAbsolutePath());
FileOutputStream fos = new FileOutputStream(downloadedFile);
fos.write(byteArray);
package org.openecomp.sdc.ci.tests.utils.rest;
+import com.google.common.hash.Hashing;
import com.google.gson.Gson;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
}
public static String calculateMD5 (String data){
- String calculatedMd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(data);
+ String calculatedMd5 = Hashing.md5().hashBytes(data.getBytes()).toString();
// encode base-64 result
- byte[] encodeBase64 = Base64.encodeBase64(calculatedMd5.getBytes());
+ byte[] encodeBase64 = Base64.getEncoder().encode(calculatedMd5.getBytes());
String encodeBase64Str = new String(encodeBase64);
return encodeBase64Str;
package org.openecomp.sdc.ci.tests.utils.rest;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
public static final String acceptJsonHeader = "application/json";
public static final String acceptOctetHeader = "application/octet-stream";
public static final String acceptMultipartHeader = "application/octet-stream";
- public static final String authorizationHeader = "Basic " + Base64.encodeBase64String("ci:123456".getBytes());
+ public static final String authorizationHeader = "Basic " + Base64.getEncoder().encodeToString("ci:123456".getBytes());
public static final String acceptOctetStream = "application/octet-stream";
public static final String ecomp = "ecomp";
public static final String authorizationPrefixString = "Basic ";
public static Map<String, String> addAuthorizeHeader(String userName, String password) {
String userCredentials = userName + ":" + password;
- encodeBase64 = Base64.encodeBase64(userCredentials.getBytes());
+ encodeBase64 = Base64.getEncoder().encode(userCredentials.getBytes());
String encodedUserCredentials = authorizationPrefixString + new String(encodeBase64);
Map<String, String> authorizationHeader = new HashMap<>();
authorizationHeader.put(HttpHeaderEnum.AUTHORIZATION.getValue(), encodedUserCredentials);
package org.openecomp.sdc.ci.tests.utils.rest;
-//import com.fasterxml.jackson.databind.DeserializationFeature;
-//import com.fasterxml.jackson.databind.ObjectMapper;
-//import com.fasterxml.jackson.databind.module.SimpleModule;
-//import com.google.gson.*;
-//import org.apache.commons.codec.binary.Base64;
-//import org.apache.log4j.Logger;
-//import org.codehaus.jackson.JsonNode;
-//
-//import org.json.JSONArray;
-//import org.json.JSONException;
-//import org.json.simple.JSONObject;
-//import org.json.simple.JSONValue;
-//import org.openecomp.sdc.be.model.*;
-//import org.openecomp.sdc.be.model.category.CategoryDefinition;
-//import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintJacksonDeserializer;;
-//import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
-//import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure;
-//import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject;
-//import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus;
-//import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
-//import org.openecomp.sdc.ci.tests.tosca.datatypes.VfModuleDefinition;
-//import org.openecomp.sdc.ci.tests.utils.Utils;
-//import org.yaml.snakeyaml.Yaml;
-//
-//import java.io.ByteArrayInputStream;
-//import java.io.IOException;
-//import java.io.InputStream;
-//import java.text.ParseException;
-//import java.util.*;
-
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.google.common.hash.Hashing;
import com.google.gson.*;
-import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONException;
}
public static String calculateMD5(String data) {
- String calculatedMd5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(data);
+ String calculatedMd5 = Hashing.md5().hashBytes(data.getBytes()).toString();
// encode base-64 result
- byte[] encodeBase64 = Base64.encodeBase64(calculatedMd5.getBytes());
+ byte[] encodeBase64 = Base64.getEncoder().encode(calculatedMd5.getBytes());
String encodeBase64Str = new String(encodeBase64);
return encodeBase64Str;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
-import org.apache.commons.codec.binary.Base64;
+import java.util.Base64;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
res = new byte[len];
inputStream.read(res, 0, len);
fromUiDownload = artifactUiDownloadData.getBase64Contents().getBytes();
- assertEquals(Base64.encodeBase64(res), fromUiDownload);
+ assertEquals(Base64.getEncoder().encode(res), fromUiDownload);
fileName = assetResponse.getFirstHeader(Constants.CONTENT_DISPOSITION_HEADER).getValue();
assertEquals(fileName, new StringBuilder().append("attachment; filename=\"")
.append(artifactUiDownloadData.getArtifactName()).append("\"").toString());
import org.mockserver.integration.ClientAndServer;
import org.mockserver.model.Header;
import org.mockserver.model.HttpRequest;
-import org.openecomp.sdc.api.IDistributionClient;
-import org.openecomp.sdc.api.consumer.IConfiguration;
-import org.openecomp.sdc.api.consumer.IFinalDistrStatusMessage;
-import org.openecomp.sdc.api.consumer.INotificationCallback;
-import org.openecomp.sdc.api.notification.IArtifactInfo;
-import org.openecomp.sdc.api.notification.INotificationData;
-import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
-import org.openecomp.sdc.api.results.IDistributionClientResult;
+import org.onap.sdc.api.IDistributionClient;
+import org.onap.sdc.api.consumer.IConfiguration;
+import org.onap.sdc.api.consumer.IFinalDistrStatusMessage;
+import org.onap.sdc.api.consumer.INotificationCallback;
+import org.onap.sdc.api.notification.IArtifactInfo;
+import org.onap.sdc.api.notification.INotificationData;
+import org.onap.sdc.api.results.IDistributionClientDownloadResult;
+import org.onap.sdc.api.results.IDistributionClientResult;
+import org.onap.sdc.http.HttpAsdcClient;
+import org.onap.sdc.http.HttpAsdcResponse;
+import org.onap.sdc.http.IHttpAsdcClient;
+import org.onap.sdc.impl.DistributionClientFactory;
+import org.onap.sdc.utils.ArtifactTypeEnum;
+import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.onap.sdc.utils.DistributionStatusEnum;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
import org.openecomp.sdc.be.dao.cassandra.OperationalEnvironmentDao;
import org.openecomp.sdc.be.datatypes.enums.EnvironmentStatusEnum;
import org.openecomp.sdc.common.datastructure.FunctionalInterfaces;
import org.openecomp.sdc.common.datastructure.Wrapper;
import org.openecomp.sdc.cucumber.spring.ImportTableConfig;
-import org.openecomp.sdc.http.HttpAsdcClient;
-import org.openecomp.sdc.http.HttpAsdcResponse;
-import org.openecomp.sdc.http.IHttpAsdcClient;
-import org.openecomp.sdc.impl.DistributionClientFactory;
-import org.openecomp.sdc.utils.ArtifactTypeEnum;
-import org.openecomp.sdc.utils.DistributionActionResultEnum;
-import org.openecomp.sdc.utils.DistributionStatusEnum;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import java.util.*;
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<artifactId>selenium-server</artifactId>
<version>2.53.1</version>
<scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
<scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
</dependency>
<dependency>
- <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
+ <groupId>org.onap.sdc.sdc-distribution-client</groupId>
<artifactId>sdc-distribution-client</artifactId>
- <version>1.2.3</version>
+ <version>1.4.1</version>
<scope>compile</scope>
</dependency>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>${commons-codec}</version>
- <scope>compile</scope>
- </dependency>
-
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<version>2.4</version>
</dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.9</version>
- <scope>compile</scope>
- </dependency>
-
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-proxy</artifactId>