summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/utils
diff options
context:
space:
mode:
authorst782s <statta@research.att.com>2018-01-30 17:29:36 -0500
committerst782s <statta@research.att.com>2018-02-01 15:10:02 -0500
commit21a8761f684745bb300e075c7e98ad897ace9eed (patch)
tree6d585c3fe39fbb42a314941dbc8646e6ccf188cf /ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/utils
parent3af8af1310d5a27cb58be29505573f0bbdc1717c (diff)
Security/ Package Name changes
Issue-ID: PORTAL-174, PORTAL-157, PORTAL-156, PORTAL-148, PORTAL-145, PORTAL-140, PORTAL-133, PORTAL-121, PORTAL-111, PORTAL-88 Includes security fixes, Role Centralization, replace certain ECOMP occurrences etc Change-Id: I3c8b706709c6b92e646e3cbe50c2d660e8a46ef4 Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/utils')
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/AuthorizationUtil.java56
-rw-r--r--ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/UnzipUtil.java147
2 files changed, 0 insertions, 203 deletions
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/AuthorizationUtil.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/AuthorizationUtil.java
deleted file mode 100644
index 2711c3da..00000000
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/AuthorizationUtil.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal
- * ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ===================================================================
- *
- * Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
- * you may not use this software 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ============LICENSE_END============================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.openecomp.portalapp.widget.utils;
-
-import java.nio.charset.Charset;
-import java.util.Base64;
-
-public class AuthorizationUtil {
-
- public boolean authorization(String auth, String security_user, String security_pass){
- if (auth != null && auth.startsWith("Basic")) {
- String base64Credentials = auth.substring("Basic".length()).trim();
- String credentials = new String(Base64.getDecoder().decode(base64Credentials),
- Charset.forName("UTF-8"));
- final String[] values = credentials.split(":",2);
- if(security_user.equals(values[0]) && security_pass.equals(values[1]))
- return true;
- }
- return false;
- }
-}
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/UnzipUtil.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/UnzipUtil.java
deleted file mode 100644
index edf35d53..00000000
--- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/utils/UnzipUtil.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*-
- * ============LICENSE_START==========================================
- * ONAP Portal
- * ===================================================================
- * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * ===================================================================
- *
- * Unless otherwise specified, all software contained herein is licensed
- * under the Apache License, Version 2.0 (the “License”);
- * you may not use this software 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ============LICENSE_END============================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- */
-package org.openecomp.portalapp.widget.utils;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-import org.openecomp.portalapp.widget.constant.WidgetConstant;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class UnzipUtil {
-
- /**
- * Size of the buffer to read/write data
- */
- private static final int BUFFER_SIZE = 4096;
- private static final Logger logger = LoggerFactory.getLogger(UnzipUtil.class);
-
- /**
- * Extracts a zip file specified by the zipFilePath to a directory specified by
- * destDirectory (will be created if does not exists)
- *
- * @param zipFilePath
- * path
- * @param destDirectory
- * directory
- * @param widgetName
- * name
- * @return Map of contents
- * @throws IOException
- * On error
- */
- public Map<String, byte[]> unzip_db(String zipFilePath, String destDirectory, String widgetName)
- throws IOException {
-
- logger.debug("UnzipUtil.unzip_db: unzip widget file {}", widgetName);
- File destDir = new File(destDirectory);
- if (!destDir.exists())
- destDir.mkdir();
- ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));
- ZipEntry entry = zipIn.getNextEntry();
- Map<String, byte[]> map = new HashMap<>();
-
- String[] requiredKeys = { WidgetConstant.WIDGET_CONTROLLER_LOCATION, WidgetConstant.WIDGET_MARKUP_LOCATION,
- WidgetConstant.WIDGET_STYLE_LOCATION };
- for (String k : requiredKeys)
- map.put(k, null);
-
- // iterates over entries in the zip file
- Stack<File> stack = new Stack<>();
- while (entry != null) {
- String filePath = destDirectory + File.separator + widgetName + File.separator
- + entry.getName().substring(entry.getName().indexOf("/") + 1);
- final String entryShortName = entry.getName().substring(entry.getName().indexOf("/") + 1);
- logger.debug("UnzipUtil.unzip_db: file path {}, short name {}", filePath, entryShortName);
- if (!entry.isDirectory()) {
- // if the entry is a file, extracts it
- logger.debug("UnzipUtil.unzip_db: unzip and save widget file {}", filePath);
- stack.push(new File(filePath));
- extractFile(zipIn, filePath);
- } else {
- // if the entry is a directory, make the directory
- logger.debug("UnzipUtil.unzip_db: unzip and create widget folder {}", filePath);
- File dir = new File(filePath);
- stack.push(new File(filePath));
- dir.mkdir();
- }
- // Is this one we need?
- if (map.containsKey(entryShortName))
- map.put(entryShortName, Files.readAllBytes(Paths.get(filePath)));
- zipIn.closeEntry();
- entry = zipIn.getNextEntry();
- }
- zipIn.close();
- while (!stack.isEmpty())
- stack.pop().delete();
-
- for (String k : requiredKeys)
- if (!map.containsKey(k))
- logger.warn("UnzipUtil.unzip_db: no zip archive entry found for required key {}", k);
-
- return map;
- }
-
- /**
- * Extracts a zip entry (file entry)
- *
- * @param zipIn
- * @param filePath
- * @throws IOException
- */
- private void extractFile(ZipInputStream zipIn, String filePath) throws IOException {
- BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
- byte[] bytesIn = new byte[BUFFER_SIZE];
- int read = 0;
- while ((read = zipIn.read(bytesIn)) != -1) {
- bos.write(bytesIn, 0, read);
- }
- bos.close();
- }
-} \ No newline at end of file