From 5cae113297b748838111706f4b15573b38f0ea05 Mon Sep 17 00:00:00 2001 From: Tomasz Golabek Date: Wed, 28 Aug 2019 11:57:45 +0200 Subject: [PATCH] commons-codec removed - 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 --- asdctool/pom.xml | 23 +- .../cassandra-actions/attributes/version.rb | 2 +- .../sdc/asdctool/main/SdcSchemaFileImport.java | 4 +- catalog-be/pom.xml | 22 +- .../csar/CsarArtifactsAndGroupsBusinessLogic.java | 3 +- .../be/components/impl/ArtifactsBusinessLogic.java | 14 +- .../be/components/impl/ResourceBusinessLogic.java | 4 +- .../sdc/be/datamodel/utils/ArtifactUtils.java | 6 +- .../sdc/be/filters/BasicAuthenticationFilter.java | 4 +- .../be/servlets/AbstractValidationsServlet.java | 8 +- .../openecomp/sdc/be/servlets/ArtifactServlet.java | 4 +- .../be/switchover/detector/SwitchoverDetector.java | 4 +- .../java/org/openecomp/sdc/be/tosca/CsarUtils.java | 5 +- .../src/test/java/org/openecomp/sdc/ZipUtil.java | 7 +- .../components/impl/ArtifactBusinessLogicTest.java | 3 +- .../impl/ArtifactsBusinessLogicTest.java | 7 +- .../servlets/AbstractValidationsServletTest.java | 4 +- .../sdc/be/servlets/ResourceServletTest.java | 4 +- catalog-dao/pom.xml | 16 + catalog-fe/pom.xml | 16 +- catalog-model/pom.xml | 6 + common-app-api/pom.xml | 13 +- .../sdc/common/http/client/api/RestUtils.java | 4 +- .../impl/validator/RequestHeadersValidator.java | 7 +- .../openecomp/sdc/common/util/GeneralUtility.java | 28 +- .../sdc/common/util/YamlToObjectConverter.java | 46 ++- .../org/openecomp/sdc/common/test/YamlTest.java | 6 +- .../sdc/common/util/GeneralUtilityTest.java | 271 +++++++------- .../sdc/common/util/YamlToObjectConverterTest.java | 8 +- onboarding/pom.xml | 5 - .../action-library-rest-services/pom.xml | 6 + .../sdcrests/action/rest/services/ActionsImpl.java | 6 +- .../externaltesting-rest-services/pom.xml | 6 + .../item-rest/item-rest-services/pom.xml | 6 + .../notifications-fe/pom.xml | 6 + .../validation-rest-services/pom.xml | 6 + .../vendor-license-rest-services/pom.xml | 6 + .../vendor-software-products-rest-services/pom.xml | 6 + .../backend/openecomp-sdc-security-util/pom.xml | 6 - .../org/openecomp/sdc/securityutil/CipherUtil.java | 8 +- .../src/test/java/CipherUtilTest.java | 4 +- .../openecomp-utilities-lib/pom.xml | 5 - .../openecomp-sdc-notification-worker/pom.xml | 8 +- openecomp-ui/yarn.lock | 86 +---- pom.xml | 3 +- test-apis-ci/pom.xml | 23 +- .../tests/execute/artifacts/HeatEnvArtifact.java | 4 +- .../ci/tests/execute/devCI/ArtifactFromCsar.java | 4 +- .../DistributionDownloadArtifactTest.java | 6 +- .../execute/externalapi/DownloadArtifactsTest.java | 4 +- .../general/BasicHttpAuthenticationTest.java | 4 +- .../ci/tests/execute/imports/CsarUtilsTest.java | 4 +- .../ci/tests/execute/imports/ExportToscaTest.java | 5 +- .../execute/imports/ImportCsarResourceTest.java | 31 +- .../execute/imports/ImportNewResourceCITest.java | 3 +- .../ImportToscaCapabilitiesWithProperties.java | 12 +- .../imports/ImportUpdateResourseCsarTest.java | 8 +- .../sdc/ci/tests/utils/CsarParserUtils.java | 4 +- .../org/openecomp/sdc/ci/tests/utils/Decoder.java | 7 +- .../org/openecomp/sdc/ci/tests/utils/Utils.java | 415 --------------------- .../tests/utils/general/AtomicOperationUtils.java | 6 +- .../utils/general/OnboardingUtillViaApis.java | 4 +- .../sdc/ci/tests/utils/rest/ArtifactRestUtils.java | 7 +- .../sdc/ci/tests/utils/rest/BaseRestUtils.java | 6 +- .../sdc/ci/tests/utils/rest/ResponseParser.java | 36 +- .../sdc/externalApis/GetAssetServlet.java | 4 +- .../sdc/cucumber/steps/StepsTenantIsolationCI.java | 30 +- ui-ci/pom.xml | 27 +- utils/webseal-simulator/pom.xml | 13 +- 69 files changed, 481 insertions(+), 908 deletions(-) diff --git a/asdctool/pom.xml b/asdctool/pom.xml index ced840d173..ef766d7000 100644 --- a/asdctool/pom.xml +++ b/asdctool/pom.xml @@ -104,6 +104,10 @@ slf4j-log4j12 org.slf4j + + commons-codec + commons-codec + @@ -271,13 +275,6 @@ compile - - commons-codec - commons-codec - ${commons-codec} - compile - - com.fasterxml.jackson.core jackson-databind @@ -303,6 +300,12 @@ org.apache.httpcomponents httpclient ${httpclient.version} + + + commons-codec + commons-codec + + compile @@ -420,6 +423,12 @@ org.apache.poi poi ${apache-poi.version} + + + commons-codec + commons-codec + + diff --git a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/attributes/version.rb b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/attributes/version.rb index cb2dcd9ef9..ae4d15ac22 100644 --- a/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/attributes/version.rb +++ b/asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/attributes/version.rb @@ -1 +1 @@ -normal['version'] ="1.5.0" +normal['version'] ="1.5.1" diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java index eb1d487cdd..d8b7a0779d 100644 --- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java +++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/main/SdcSchemaFileImport.java @@ -20,6 +20,7 @@ package org.openecomp.sdc.asdctool.main; +import com.google.common.hash.Hashing; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; @@ -36,7 +37,6 @@ import java.util.Map; 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; @@ -142,7 +142,7 @@ public class SdcSchemaFileImport { 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); diff --git a/catalog-be/pom.xml b/catalog-be/pom.xml index eb6f0c617c..efd692557c 100644 --- a/catalog-be/pom.xml +++ b/catalog-be/pom.xml @@ -182,12 +182,18 @@ jersey-bean-validation - + org.apache.httpcomponents httpclient ${httpclient.version} compile + + + commons-codec + commons-codec + + @@ -204,12 +210,6 @@ compile - - commons-codec - commons-codec - ${commons-codec} - compile - @@ -335,6 +335,10 @@ io.netty netty-all + + commons-codec + commons-codec + @@ -440,6 +444,10 @@ slf4j-log4j12 org.slf4j + + commons-codec + commons-codec + diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java index f94cd38670..5f36d16933 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java @@ -24,7 +24,6 @@ import com.google.gson.Gson; 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; @@ -856,7 +855,7 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { private Either, 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, ResultStatusEnum> heatParameters = ImportUtils .getHeatParamsWithoutImplicitTypes(heatDecodedPayload, artifactType); if (heatParameters.isRight()) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index 3d149f79e6..bfa9973f24 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java @@ -25,7 +25,7 @@ package org.openecomp.sdc.be.components.impl; 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; @@ -2248,7 +2248,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { private Either 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, ResultStatusEnum> heatParameters = ImportUtils.getHeatParamsWithoutImplicitTypes(heatDecodedPayload, artifactInfo .getArtifactType()); if (heatParameters.isRight() && (!heatParameters.right() @@ -2356,7 +2356,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { .getEsId()); if (eitherArtifactData.isLeft()) { byte[] data = eitherArtifactData.left().value().getDataAsArray(); - data = Base64.encodeBase64(data); + data = Base64.getEncoder().encode(data); payloadWrapper.setInnerElement(data); } else { @@ -2372,9 +2372,9 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { @SuppressWarnings("unchecked") private void validateEnvVsHeat(Wrapper 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 heatEnvToscaJson = (Map) new Yaml().load(envPayload); - String heatDecodedPayload = new String(Base64.decodeBase64(heatPayloadData)); + String heatDecodedPayload = new String(Base64.getDecoder().decode(heatPayloadData)); Map heatToscaJson = (Map) new Yaml().load(heatDecodedPayload); Either, ResultStatusEnum> eitherHeatEnvProperties = ImportUtils.findFirstToscaMapElement(heatEnvToscaJson, TypeUtils.ToscaTagNamesEnum.PARAMETERS); @@ -3155,7 +3155,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { 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); @@ -4142,7 +4142,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { 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); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java index c40c845718..9289a5dd15 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java @@ -34,6 +34,7 @@ import static org.openecomp.sdc.be.components.impl.ImportUtils.getPropertyJsonSt 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; @@ -49,7 +50,6 @@ import java.util.function.Function; 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; @@ -766,7 +766,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { 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); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtils.java index 9479c80246..fcefb9ec8e 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtils.java @@ -20,7 +20,7 @@ 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; @@ -78,7 +78,7 @@ public class ArtifactUtils { 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); @@ -104,7 +104,7 @@ public class ArtifactUtils { 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; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/filters/BasicAuthenticationFilter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/filters/BasicAuthenticationFilter.java index 5166ef94d7..164243c6f1 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/filters/BasicAuthenticationFilter.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/filters/BasicAuthenticationFilter.java @@ -23,7 +23,7 @@ package org.openecomp.sdc.be.filters; 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; @@ -81,7 +81,7 @@ public class BasicAuthenticationFilter implements ContainerRequestFilter { 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) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java index e00889646a..abce2d8913 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java @@ -34,6 +34,7 @@ import java.io.InputStream; 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; @@ -41,7 +42,6 @@ import java.util.function.Supplier; 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; @@ -216,7 +216,7 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet { Response errorResp = buildErrorResponse(responseFormat); responseWrapper.setInnerElement(errorResp); } - String payloadData = Base64.encodeBase64String(data); + String payloadData = Base64.getEncoder().encodeToString(data); uploadResourceInfoWrapper.setPayloadData(payloadData); @@ -474,7 +474,7 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet { 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); } @@ -742,7 +742,7 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet { 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)); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ArtifactServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ArtifactServlet.java index 2b55ffa2c8..9355e8424f 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ArtifactServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ArtifactServlet.java @@ -36,7 +36,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.apache.commons.codec.binary.Base64; +import java.util.Base64; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum; @@ -712,7 +712,7 @@ public class ArtifactServlet extends BeGenericServlet { response = buildErrorResponse(actionResult.right().value()); } else { byte[] file = actionResult.left().value().getRight(); - String base64Contents = new String(Base64.encodeBase64(file)); + String base64Contents = new String(Base64.getEncoder().encode(file)); String artifactName = actionResult.left().value().getLeft(); ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK); ArtifactUiDownloadData artifactUiDownloadData = new ArtifactUiDownloadData(); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/switchover/detector/SwitchoverDetector.java b/catalog-be/src/main/java/org/openecomp/sdc/be/switchover/detector/SwitchoverDetector.java index 9e0c130b21..f7f7414924 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/switchover/detector/SwitchoverDetector.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/switchover/detector/SwitchoverDetector.java @@ -21,7 +21,7 @@ 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; @@ -119,7 +119,7 @@ public class SwitchoverDetector { 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); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java index 2f1357ea13..ce2ca21785 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java @@ -22,7 +22,6 @@ package org.openecomp.sdc.be.tosca; 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; @@ -635,7 +634,7 @@ public class CsarUtils { 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()); @@ -675,7 +674,7 @@ public class CsarUtils { } 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; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java b/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java index 87e351be8a..125e2a6a5a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/ZipUtil.java @@ -22,7 +22,7 @@ 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; @@ -42,7 +42,6 @@ public class ZipUtil { 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); @@ -51,10 +50,10 @@ public class ZipUtil { 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); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java index a86ed18827..d043ee2d33 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java @@ -28,7 +28,6 @@ import com.google.gson.Gson; 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; @@ -1031,7 +1030,7 @@ public class ArtifactBusinessLogicTest extends BaseBusinessLogicMock{ when(artifactInfo.getEsId()).thenReturn(esId); final Wrapper 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); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java index 553877773f..a21d22da3a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java @@ -30,8 +30,9 @@ import com.google.gson.Gson; 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; @@ -529,7 +530,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ 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); @@ -1239,7 +1240,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ artifactInfo.setArtifactName(artifactName); artifactInfo.setArtifactType(artifactType.getType()); artifactInfo.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); - artifactInfo.setPayload(Base64.encodeBase64(payload)); + artifactInfo.setPayload(Base64.getEncoder().encode(payload)); return artifactInfo; } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java index 5158c438df..faddd9270c 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/AbstractValidationsServletTest.java @@ -21,7 +21,7 @@ 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; @@ -76,7 +76,7 @@ public class AbstractValidationsServletTest { 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); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java index 6344e6f72f..0ca62ad80d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceServletTest.java @@ -25,7 +25,7 @@ package org.openecomp.sdc.be.servlets; 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; @@ -973,7 +973,7 @@ public class ResourceServletTest extends JerseyTest { } 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)); } diff --git a/catalog-dao/pom.xml b/catalog-dao/pom.xml index ebf97f9166..9c84fd321f 100644 --- a/catalog-dao/pom.xml +++ b/catalog-dao/pom.xml @@ -186,6 +186,12 @@ Modifications copyright (c) 2018 Nokia httpclient ${httpclient.version} provided + + + commons-codec + commons-codec + + @@ -315,12 +321,22 @@ Modifications copyright (c) 2018 Nokia org.apache.thrift libthrift + + commons-codec + commons-codec + org.apache.cassandra cassandra-all 3.11.3 + + + commons-codec + commons-codec + + test diff --git a/catalog-fe/pom.xml b/catalog-fe/pom.xml index 2f95a0b6e2..c541b06a9f 100644 --- a/catalog-fe/pom.xml +++ b/catalog-fe/pom.xml @@ -143,6 +143,12 @@ httpclient ${httpclient.version} compile + + + commons-codec + commons-codec + + @@ -166,12 +172,6 @@ compile - - commons-codec - commons-codec - ${commons-codec} - compile - @@ -248,6 +248,10 @@ slf4j-log4j12 org.slf4j + + commons-codec + commons-codec + diff --git a/catalog-model/pom.xml b/catalog-model/pom.xml index e456134d88..3e07e3102b 100644 --- a/catalog-model/pom.xml +++ b/catalog-model/pom.xml @@ -167,6 +167,12 @@ org.apache.httpcomponents httpclient ${httpclient.version} + + + commons-codec + commons-codec + + provided diff --git a/common-app-api/pom.xml b/common-app-api/pom.xml index e186465031..8678e9fd8e 100644 --- a/common-app-api/pom.xml +++ b/common-app-api/pom.xml @@ -69,6 +69,12 @@ org.apache.httpcomponents httpclient ${httpclient.version} + + + commons-codec + commons-codec + + provided @@ -86,13 +92,6 @@ provided - - commons-codec - commons-codec - ${commons-codec} - provided - - org.glassfish.jersey.media jersey-media-json-jackson diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RestUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RestUtils.java index efac5c18ef..ae270c8e16 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RestUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/RestUtils.java @@ -20,7 +20,7 @@ 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; @@ -29,7 +29,7 @@ import java.util.Properties; 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)); } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java index 5c389fcd3f..c6ff990aa1 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/rest/impl/validator/RequestHeadersValidator.java @@ -20,7 +20,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; @@ -75,8 +76,8 @@ public class RequestHeadersValidator { } // 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); diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java index 7ff19ace72..34faffca9c 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/GeneralUtility.java @@ -20,7 +20,8 @@ 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; @@ -49,7 +50,12 @@ public class GeneralUtility { * 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; } /** @@ -65,7 +71,7 @@ public class GeneralUtility { 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) { @@ -136,29 +142,21 @@ public class GeneralUtility { } 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(); } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java index 801b6c1aaa..a5fd9dc67b 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java @@ -20,7 +20,7 @@ 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; @@ -65,8 +65,8 @@ public class YamlToObjectConverter { 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); @@ -78,16 +78,16 @@ public class YamlToObjectConverter { 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); @@ -101,10 +101,8 @@ public class YamlToObjectConverter { 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); @@ -126,8 +124,8 @@ public class YamlToObjectConverter { 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); @@ -158,13 +156,15 @@ public class YamlToObjectConverter { 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> classMap = new HashMap<>(); public MyYamlConstructor(Class theRoot) { @@ -206,7 +206,8 @@ public class YamlToObjectConverter { 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)); @@ -215,7 +216,8 @@ public class YamlToObjectConverter { // 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 { @@ -259,9 +261,12 @@ public class YamlToObjectConverter { 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") @@ -276,7 +281,8 @@ public class YamlToObjectConverter { } } 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; diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java index 78465fbac4..707e8e1ddd 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/YamlTest.java @@ -20,7 +20,7 @@ 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; @@ -52,11 +52,11 @@ public class YamlTest { @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()))); } } diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/GeneralUtilityTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/GeneralUtilityTest.java index b5036060eb..4586b42eb7 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/GeneralUtilityTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/util/GeneralUtilityTest.java @@ -7,9 +7,9 @@ * 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. @@ -22,6 +22,7 @@ package org.openecomp.sdc.common.util; import com.google.common.collect.Lists; +import com.google.common.hash.Hashing; import org.apache.commons.io.FileUtils; import org.junit.Test; @@ -37,214 +38,212 @@ import static org.junit.Assert.assertTrue; 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 testString = Lists.newArrayList("testing","list"); - final int limit = 15; - final int delimiterLength = 2; + final List 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 testString = null; - final int limit = 15; - final int delimiterLength = 2; + final List 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 testString = Lists.newArrayList("testing","list","equal"); - final int limit = 18; - final int delimiterLength = 1; + final List 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 testString = Lists.newArrayList("long","testing","list","of","strings"); - final int limit = 20; - final int delimiterLength = 2; + final List 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); + } } diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/util/YamlToObjectConverterTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/util/YamlToObjectConverterTest.java index 49fc553302..55827bbd66 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/util/YamlToObjectConverterTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/util/YamlToObjectConverterTest.java @@ -19,7 +19,7 @@ */ 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; @@ -40,9 +40,7 @@ public class YamlToObjectConverterTest { 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; @@ -68,7 +66,7 @@ public class YamlToObjectConverterTest { @Test public void validateIsValidYamlEncoded64ReturnsTrueIfGivenYamlIsEncoded64() { - boolean result = yamlToObjectConverter.isValidYamlEncoded64(Base64.encodeBase64(testYaml.getBytes())); + boolean result = yamlToObjectConverter.isValidYamlEncoded64(Base64.getEncoder().encode(testYaml.getBytes())); assertTrue(result); } diff --git a/onboarding/pom.xml b/onboarding/pom.xml index 139db36c4d..cde206ceea 100644 --- a/onboarding/pom.xml +++ b/onboarding/pom.xml @@ -252,11 +252,6 @@ jackson-dataformat-yaml ${jackson.version} - - commons-codec - commons-codec - ${commons.codec.version} - com.datastax.cassandra cassandra-driver-core diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml index aaf19e6810..0b9520bc13 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml @@ -60,6 +60,12 @@ org.apache.httpcomponents httpclient ${http.client.version} + + + commons-codec + commons-codec + + org.apache.httpcomponents diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java index 7154d997c7..6b8a0c7358 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java @@ -94,6 +94,7 @@ import static org.openecomp.sdc.action.util.ActionUtil.actionErrorLogProcessor; 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; @@ -103,7 +104,6 @@ import java.util.LinkedHashMap; 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; @@ -197,7 +197,7 @@ public class ActionsImpl implements Actions { 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; } @@ -1208,7 +1208,7 @@ public class ActionsImpl implements Actions { 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; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/pom.xml index f97fe1d290..3fe91a0829 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/externaltesting-rest/externaltesting-rest-services/pom.xml @@ -64,6 +64,12 @@ org.apache.httpcomponents httpclient ${http.client.version} + + + commons-codec + commons-codec + + javax.inject diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml index 18710315ea..af0598c823 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/pom.xml @@ -31,6 +31,12 @@ org.apache.httpcomponents httpclient + + + commons-codec + commons-codec + + ${http.client.version} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml index 146c3116ed..31e57fc319 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/pom.xml @@ -138,6 +138,12 @@ org.apache.httpcomponents httpclient ${http.client.version} + + + commons-codec + commons-codec + + org.apache.cxf diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml index 6e112b8775..c6bddb99c4 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml @@ -64,6 +64,12 @@ org.apache.httpcomponents httpclient ${http.client.version} + + + commons-codec + commons-codec + + javax.inject diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml index 48125c0200..73a9491325 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml @@ -59,6 +59,12 @@ org.apache.httpcomponents httpclient ${http.client.version} + + + commons-codec + commons-codec + + org.apache.httpcomponents diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml index 1e7b7e6ce0..a475b936ab 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml @@ -59,6 +59,12 @@ org.apache.httpcomponents httpclient ${http.client.version} + + + commons-codec + commons-codec + + diff --git a/openecomp-be/backend/openecomp-sdc-security-util/pom.xml b/openecomp-be/backend/openecomp-sdc-security-util/pom.xml index c65549025b..7897604b35 100644 --- a/openecomp-be/backend/openecomp-sdc-security-util/pom.xml +++ b/openecomp-be/backend/openecomp-sdc-security-util/pom.xml @@ -50,12 +50,6 @@ 2.9.9 - - commons-codec - commons-codec - 1.11 - - javax.servlet javax.servlet-api diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtil.java b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtil.java index 4f4c18c282..4e41d16d02 100644 --- a/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtil.java +++ b/openecomp-be/backend/openecomp-sdc-security-util/src/main/java/org/openecomp/sdc/securityutil/CipherUtil.java @@ -21,13 +21,13 @@ 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()); @@ -64,7 +64,7 @@ public class CipherUtil { log.error("encrypt failed", ex); throw new CipherUtilException(ex); } - return Base64.encodeBase64String(addAll(iv, finalByte)); + return Base64.getEncoder().encodeToString(addAll(iv, finalByte)); } /** @@ -79,7 +79,7 @@ public class CipherUtil { */ 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 { @@ -97,7 +97,7 @@ public class CipherUtil { } private static SecretKeySpec getSecretKeySpec(String keyString) { - byte[] key = Base64.decodeBase64(keyString); + byte[] key = Base64.getDecoder().decode(keyString); return new SecretKeySpec(key, ALGORITHM); } diff --git a/openecomp-be/backend/openecomp-sdc-security-util/src/test/java/CipherUtilTest.java b/openecomp-be/backend/openecomp-sdc-security-util/src/test/java/CipherUtilTest.java index 888c888d42..ce8865ff1d 100644 --- a/openecomp-be/backend/openecomp-sdc-security-util/src/test/java/CipherUtilTest.java +++ b/openecomp-be/backend/openecomp-sdc-security-util/src/test/java/CipherUtilTest.java @@ -18,7 +18,7 @@ * ============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; @@ -34,7 +34,7 @@ public class CipherUtilTest { @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); diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/pom.xml index 5896889033..991a1a5ed8 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/pom.xml +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/pom.xml @@ -60,11 +60,6 @@ gson ${gson.version} - - commons-codec - commons-codec - ${commons.codec.version} - junit junit diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/pom.xml b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/pom.xml index 22a0e0a718..dba57612e1 100644 --- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/pom.xml +++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/pom.xml @@ -46,8 +46,14 @@ org.apache.httpcomponents httpclient - ${http.client.version} + ${http.client.version} provided + + + commons-codec + commons-codec + + org.apache.httpcomponents diff --git a/openecomp-ui/yarn.lock b/openecomp-ui/yarn.lock index b936780821..229effa97c 100644 --- a/openecomp-ui/yarn.lock +++ b/openecomp-ui/yarn.lock @@ -2,38 +2,6 @@ # 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" @@ -7591,19 +7559,21 @@ on-headers@~1.0.1: 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" @@ -9437,12 +9407,6 @@ rx@4.1.0: 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" @@ -9535,28 +9499,6 @@ scss-tokenizer@^0.2.3: 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" @@ -10261,7 +10203,7 @@ symbol-observable@1.0.1: 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" @@ -11391,7 +11333,3 @@ yeoman-generator@^2.0.5: 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" diff --git a/pom.xml b/pom.xml index 409eb41a02..76c4395776 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,6 @@ Modifications copyright (c) 2018-2019 Nokia 1.2.3 1.7.25 - 1.10 1.2 3.0.6 @@ -124,7 +123,7 @@ Modifications copyright (c) 2018-2019 Nokia 2.22.0 - 1.3.5 + 1.6.2 java diff --git a/test-apis-ci/pom.xml b/test-apis-ci/pom.xml index a2800f1969..d0e0f50462 100644 --- a/test-apis-ci/pom.xml +++ b/test-apis-ci/pom.xml @@ -165,13 +165,6 @@ compile - - commons-codec - commons-codec - ${commons-codec} - compile - - com.google.code.gson @@ -193,6 +186,12 @@ org.apache.httpcomponents httpclient ${httpclient.version} + + + commons-codec + commons-codec + + compile @@ -294,6 +293,10 @@ slf4j-log4j12 org.slf4j + + commons-codec + commons-codec + @@ -306,7 +309,7 @@ org.onap.sdc.sdc-tosca sdc-tosca - 1.4.6 + 1.6.2 compile @@ -356,9 +359,9 @@ - org.openecomp.sdc.sdc-distribution-client + org.onap.sdc.sdc-distribution-client sdc-distribution-client - 1.2.2 + 1.4.1 test diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java index 80e0a54ee4..7646567d48 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/artifacts/HeatEnvArtifact.java @@ -20,7 +20,7 @@ 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; @@ -173,7 +173,7 @@ public class HeatEnvArtifact extends ComponentBaseTest { 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); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java index 7a69d374eb..7dcf659650 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/devCI/ArtifactFromCsar.java @@ -20,7 +20,7 @@ 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; @@ -205,7 +205,7 @@ public class ArtifactFromCsar { // 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 { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java index 94715b2495..b340a4c673 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/distribution/DistributionDownloadArtifactTest.java @@ -20,7 +20,7 @@ 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; @@ -201,7 +201,7 @@ public class DistributionDownloadArtifactTest extends ComponentBaseTest { 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()); @@ -368,7 +368,7 @@ public class DistributionDownloadArtifactTest extends ComponentBaseTest { 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(); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java index e49c912ef4..f0e5b6032d 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/externalapi/DownloadArtifactsTest.java @@ -21,7 +21,7 @@ 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; @@ -348,7 +348,7 @@ public class DownloadArtifactsTest extends ComponentBaseTest { 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); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java index 404ed04766..bd1714f8ee 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/general/BasicHttpAuthenticationTest.java @@ -21,7 +21,7 @@ //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; @@ -295,7 +295,7 @@ public class BasicHttpAuthenticationTest extends ComponentBaseTest { @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 authorizationHeader = new HashMap(); authorizationHeader.put(HttpHeaderEnum.AUTHORIZATION.getValue(), encodedUserCredentials); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java index 56502757de..908eac857e 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/CsarUtilsTest.java @@ -20,7 +20,7 @@ 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; @@ -444,7 +444,7 @@ public class CsarUtilsTest extends ComponentBaseTest { assertNotNull(artifactUiDownloadData); byte[] fromUiDownload = artifactUiDownloadData.getBase64Contents().getBytes(); - byte[] decodeBase64 = Base64.decodeBase64(fromUiDownload); + byte[] decodeBase64 = Base64.getDecoder().decode(fromUiDownload); return decodeBase64; } diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java index 3f017f448c..c84b2a56ca 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ExportToscaTest.java @@ -23,7 +23,6 @@ package org.openecomp.sdc.ci.tests.execute.imports; 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; @@ -213,7 +212,7 @@ public class ExportToscaTest extends ComponentBaseTest { 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); @@ -383,7 +382,7 @@ public class ExportToscaTest extends ComponentBaseTest { 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); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java index eed10581e2..1ce10e3a1b 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportCsarResourceTest.java @@ -21,7 +21,6 @@ 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; @@ -737,7 +736,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { 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 @@ -755,7 +754,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { // 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"); @@ -782,7 +781,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { // 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"); @@ -797,7 +796,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { 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"); @@ -813,7 +812,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { 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"); @@ -834,7 +833,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { 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 @@ -851,7 +850,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { // 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 @@ -879,7 +878,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { // 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"); @@ -1059,7 +1058,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { 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 @@ -1077,7 +1076,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { // 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"); @@ -1092,7 +1091,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { // 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"); @@ -1445,7 +1444,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { 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 @@ -1471,7 +1470,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { 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 @@ -1644,7 +1643,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { 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()); @@ -1663,7 +1662,7 @@ public class ImportCsarResourceTest extends ComponentBaseTest { 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); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java index f529f00cf9..9c24bd0049 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportNewResourceCITest.java @@ -21,7 +21,6 @@ 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; @@ -161,7 +160,7 @@ public class ImportNewResourceCITest extends ComponentBaseTest { + " 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" diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java index 4338a1b151..339eb16ead 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportToscaCapabilitiesWithProperties.java @@ -21,7 +21,7 @@ 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; @@ -196,7 +196,7 @@ public class ImportToscaCapabilitiesWithProperties extends ComponentBaseTest { 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); @@ -231,7 +231,7 @@ public class ImportToscaCapabilitiesWithProperties extends ComponentBaseTest { 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); @@ -274,7 +274,7 @@ public class ImportToscaCapabilitiesWithProperties extends ComponentBaseTest { 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); @@ -322,7 +322,7 @@ public class ImportToscaCapabilitiesWithProperties extends ComponentBaseTest { 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); @@ -344,7 +344,7 @@ public class ImportToscaCapabilitiesWithProperties extends ComponentBaseTest { 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); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java index 473e4f2e36..ecc1858309 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/imports/ImportUpdateResourseCsarTest.java @@ -21,7 +21,7 @@ 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; @@ -73,7 +73,7 @@ public class ImportUpdateResourseCsarTest extends ComponentBaseTest { 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"); @@ -87,7 +87,7 @@ public class ImportUpdateResourseCsarTest extends ComponentBaseTest { // 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, @@ -270,7 +270,7 @@ public class ImportUpdateResourseCsarTest extends ComponentBaseTest { 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); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java index fc717ca79d..2006a56354 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarParserUtils.java @@ -20,7 +20,7 @@ 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; @@ -62,7 +62,7 @@ public class CsarParserUtils { 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 getListTypeHeatMetaDefinition(File csarFileLocation) throws Exception { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Decoder.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Decoder.java index 3b11388505..7640c35555 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Decoder.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Decoder.java @@ -20,24 +20,23 @@ 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; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java index ea6ef62618..035a0baae2 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/Utils.java @@ -60,91 +60,8 @@ public final class Utils { 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 getScriptList (List - // artifactsList){ - // - // ArrayList 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) { @@ -186,31 +103,6 @@ public final class Utils { 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); @@ -239,314 +131,7 @@ public final class Utils { } 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 artifactsList = new - // ArrayList(); - // - //// 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 createArtifactsList(String srcDir) { - // - // List artifactsList = new - // ArrayList(); - // File srcFile = new File(srcDir); - // addFileToList(srcFile, artifactsList); - // - // return artifactsList; - // } - // - // public void addFileToList(File srcFile, List - // 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 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 idArray = new ArrayList(); - // - // 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 buildCategoriesTagsListFromJson(String - // categoriesTagsJson){ - // - // ArrayList 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 getCategoriesFromDb() throws Exception{ - // - // ArrayList categoriesFromDbArrayList = new ArrayList<>(); - // RestResponse restResponse = new RestResponse(); - // String contentTypeHeaderData = "application/json"; - // String acceptHeaderDate = "application/json"; - // - // Map headersMap = new HashMap(); - // 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 actualArraylList, List expectedArrayList, String message) { diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java index 8e5079db92..8505bf0500 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/AtomicOperationUtils.java @@ -23,7 +23,7 @@ package org.openecomp.sdc.ci.tests.utils.general; 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; @@ -821,7 +821,7 @@ public final class AtomicOperationUtils { 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); @@ -836,7 +836,7 @@ public final class AtomicOperationUtils { 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); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java index f9ce645fc7..48a2fd0858 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtillViaApis.java @@ -22,7 +22,7 @@ package org.openecomp.sdc.ci.tests.utils.general; 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; @@ -86,7 +86,7 @@ public class OnboardingUtillViaApis { @SuppressWarnings("unchecked") Map 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); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java index 7daf1bd414..6d4c903cef 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java @@ -20,8 +20,9 @@ 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; @@ -892,9 +893,9 @@ public class ArtifactRestUtils extends BaseRestUtils { } 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; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java index 56859ff56a..4a3cb8c6be 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java @@ -20,7 +20,7 @@ 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; @@ -46,7 +46,7 @@ public class BaseRestUtils extends BaseValidationUtils { 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 "; @@ -258,7 +258,7 @@ public class BaseRestUtils extends BaseValidationUtils { public static Map 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 authorizationHeader = new HashMap<>(); authorizationHeader.put(HttpHeaderEnum.AUTHORIZATION.getValue(), encodedUserCredentials); diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java index 30e54d3914..3288aa9011 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java @@ -20,42 +20,12 @@ 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; @@ -398,9 +368,9 @@ public class ResponseParser { } 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; diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java index 917d980184..a7e9919950 100644 --- a/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java +++ b/test-apis-ci/src/main/java/org/openecomp/sdc/externalApis/GetAssetServlet.java @@ -22,7 +22,7 @@ package org.openecomp.sdc.externalApis; 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; @@ -263,7 +263,7 @@ public class GetAssetServlet extends ComponentBaseTest { 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()); diff --git a/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/StepsTenantIsolationCI.java b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/StepsTenantIsolationCI.java index 9f5e201fed..99c19b0668 100644 --- a/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/StepsTenantIsolationCI.java +++ b/test-apis-ci/src/test/java/org/openecomp/sdc/cucumber/steps/StepsTenantIsolationCI.java @@ -38,14 +38,21 @@ import org.apache.http.entity.StringEntity; 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; @@ -53,13 +60,6 @@ import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry; 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.*; diff --git a/ui-ci/pom.xml b/ui-ci/pom.xml index 22ffc2548c..e54e7d8f93 100644 --- a/ui-ci/pom.xml +++ b/ui-ci/pom.xml @@ -40,6 +40,10 @@ io.netty netty + + commons-codec + commons-codec + @@ -54,6 +58,12 @@ selenium-server 2.53.1 runtime + + + commons-codec + commons-codec + + @@ -103,6 +113,12 @@ httpclient ${httpclient.version} compile + + + commons-codec + commons-codec + + @@ -163,9 +179,9 @@ - org.openecomp.sdc.sdc-distribution-client + org.onap.sdc.sdc-distribution-client sdc-distribution-client - 1.2.3 + 1.4.1 compile @@ -204,13 +220,6 @@ compile - - commons-codec - commons-codec - ${commons-codec} - compile - - com.aventstack extentreports diff --git a/utils/webseal-simulator/pom.xml b/utils/webseal-simulator/pom.xml index 6f405cbda2..5861a6f12c 100644 --- a/utils/webseal-simulator/pom.xml +++ b/utils/webseal-simulator/pom.xml @@ -46,6 +46,12 @@ org.apache.httpcomponents httpclient 4.5.3 + + + commons-codec + commons-codec + + @@ -61,13 +67,6 @@ 2.4 - - commons-codec - commons-codec - 1.9 - compile - - org.eclipse.jetty jetty-proxy -- 2.16.6