diff options
author | 2018-01-30 17:29:36 -0500 | |
---|---|---|
committer | 2018-02-01 15:10:02 -0500 | |
commit | 21a8761f684745bb300e075c7e98ad897ace9eed (patch) | |
tree | 6d585c3fe39fbb42a314941dbc8646e6ccf188cf /ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/controller | |
parent | 3af8af1310d5a27cb58be29505573f0bbdc1717c (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/controller')
3 files changed, 0 insertions, 486 deletions
diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/controller/DatabaseFileUploadController.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/controller/DatabaseFileUploadController.java deleted file mode 100644 index 02cc9415..00000000 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/controller/DatabaseFileUploadController.java +++ /dev/null @@ -1,116 +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.controller; - -import java.io.UnsupportedEncodingException; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalapp.widget.service.StorageService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class DatabaseFileUploadController { - - @Autowired - private StorageService storageService; - - private static final Logger logger = LoggerFactory.getLogger(DatabaseFileUploadController.class); - - @ResponseBody - @RequestMapping(value = "/microservices/markup/{widgetId}", method = RequestMethod.GET) - public String getWidgetMarkup(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId){ - String markup = null; - try{ - logger.debug("DatabaseFileUploadController.getWidgetMarkup: getting markup.html for widget with widgetId = {}" , widgetId); - markup = storageService.getWidgetMarkup(widgetId); - }catch(Exception e){ - logger.error("Exception occurred while performing DatabaseFileUploadController.getWidgetMarkup in widget microservices. Details:" + e.getMessage()); - } - return markup; - } - - @ResponseBody - @RequestMapping(value = "/microservices/{widgetId}/controller.js", method = RequestMethod.GET) - public String getWidgetController(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId){ - String controller = null; - try{ - logger.debug("DatabaseFileUploadController.getWidgetController: getting controller.js for widget with widgetId = {}" , widgetId); - controller = storageService.getWidgetController(widgetId); - }catch(Exception e){ - logger.error("Exception occurred while performing DatabaseFileUploadController.getWidgetController in widget microservices. Details:" + e.getMessage()); - } - return controller; - } - - @ResponseBody - @RequestMapping(value = "/microservices/{widgetId}/framework.js", method = RequestMethod.GET) - public String getWidgetFramework(HttpServletRequest request, HttpServletResponse response, - @PathVariable("widgetId") long widgetId){ - String framework = null; - try{ - logger.debug("DatabaseFileUploadController.getWidgetFramework: getting framework.js for widget with widgetId = {}" , widgetId); - framework = storageService.getWidgetFramework(widgetId); - }catch(Exception e){ - logger.error("Exception occurred while performing DatabaseFileUploadController.getWidgetFramework in widget microservices. Details:" + e.getMessage()); - } - return framework; - } - - @ResponseBody - @RequestMapping(value = "/microservices/{widgetId}/styles.css", method = RequestMethod.GET) - public String getWidgetCSS(HttpServletRequest request, HttpServletResponse response, - @PathVariable("widgetId") long widgetId){ - String css = null; - try { - logger.debug("DatabaseFileUploadController.getWidgetCSS: getting styles.css for widget with widgetId = {}" , widgetId); - css = storageService.getWidgetCSS(widgetId); - } catch (UnsupportedEncodingException e) { - logger.error("Exception occurred while performing DatabaseFileUploadController.getWidgetCSS in widget microservices. Details:" + e.getMessage()); - } - return css; - } -} diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/controller/HealthController.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/controller/HealthController.java deleted file mode 100644 index dfe5c2d6..00000000 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/controller/HealthController.java +++ /dev/null @@ -1,72 +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.controller; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HealthController { - - @RequestMapping(value = { "/health" }, method = RequestMethod.GET, produces = "application/json") - public HealthStatus getWidgetCatalog(HttpServletRequest request, HttpServletResponse response) { - return new HealthStatus("ok"); - } - - class HealthStatus { - private String status; - - public HealthStatus(String status){ - this.status = status; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - - } -}
\ No newline at end of file diff --git a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/controller/WidgetsCatalogController.java b/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/controller/WidgetsCatalogController.java deleted file mode 100644 index 60d92772..00000000 --- a/ecomp-portal-widget-ms/widget-ms/src/main/java/org/openecomp/portalapp/widget/controller/WidgetsCatalogController.java +++ /dev/null @@ -1,298 +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.controller; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.openecomp.portalapp.widget.domain.ValidationRespond; -import org.openecomp.portalapp.widget.domain.WidgetCatalog; -import org.openecomp.portalapp.widget.service.StorageService; -import org.openecomp.portalapp.widget.service.WidgetCatalogService; -import org.openecomp.portalapp.widget.utils.AuthorizationUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.EnableAspectJAutoProxy; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.multipart.MultipartFile; - -import com.fasterxml.jackson.databind.ObjectMapper; - -@Controller -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy -public class WidgetsCatalogController { - - @Value("${server.port}") - String port; - @Value("${server.contextPath}") - String context; - - @Value("${security.user.name}") - String security_user; - @Value("${security.user.password}") - String security_pass; - - @Autowired - WidgetCatalogService widgetCatalogService; - - @Autowired - StorageService storageService; - - @Autowired - RestTemplate restTemplate; - - AuthorizationUtil util = new AuthorizationUtil(); - - private static final Logger logger = LoggerFactory.getLogger(WidgetsCatalogController.class); - - @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog" }, method = RequestMethod.GET, produces = "application/json") - public List<WidgetCatalog> getWidgetCatalog(HttpServletRequest request, HttpServletResponse response - ,@RequestHeader(value="Authorization") String auth) throws IOException{ - - List<WidgetCatalog> widgetCatalog = null; - if(!util.authorization(auth, security_user, security_pass)){ - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - logger.error("Basic Authentication Error while performing WidgetsCatalogController.getWidgetCatalog in widget microserivce. Please check your username and password."); - return widgetCatalog; - } - try { - widgetCatalog = widgetCatalogService.getWidgetCatalog(); - logger.debug("WidgetsCatalogController.getWidgetCatalog: getting widget list {}", widgetCatalog); - } catch (Exception e) { - logger.error("Exception occurred while performing WidgetsCatalogController.getWidgetCatalog in widget microservices. Details:" + e.getMessage()); - } - return widgetCatalog; - } - - @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/{loginName}" }, method = RequestMethod.GET, produces = "application/json") - public List<WidgetCatalog> getUserWidgetCatalog(HttpServletRequest request, HttpServletResponse response, - @PathVariable("loginName") String loginName, @RequestHeader(value="Authorization") String auth) throws IOException { - List<WidgetCatalog> widgetCatalog = null; - if(!util.authorization(auth, security_user, security_pass)){ - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - logger.error("Basic Authentication Error while performing WidgetsCatalogController.getUserWidgetCatalog in widget microserivce. Please check your username and password."); - return widgetCatalog; - } - try { - widgetCatalog = widgetCatalogService.getUserWidgetCatalog(loginName); - logger.debug("WidgetsCatalogController.getUserWidgetCatalog: getting widget list {}", widgetCatalog); - } catch (Exception e) { - logger.error("Exception occurred while performing WidgetsCatalogController.getUserWidgetCatalog in widget microservices. Details:" + e.getMessage()); - } - return widgetCatalog; - } - - @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/{widgetId}" }, method = RequestMethod.PUT, produces = "application/json") - public void updateWidgetCatalog(HttpServletRequest request, HttpServletResponse response, - @RequestBody WidgetCatalog newWidgetCatalog, @PathVariable("widgetId") long widgetId, - @RequestHeader(value="Authorization") String auth) throws IOException { - - if(!util.authorization(auth, security_user, security_pass)){ - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - logger.error("Basic Authentication Error while performing WidgetsCatalogController.updateWidgetCatalog in widget microserivce. Please check your username and password."); - return; - } - try { - widgetCatalogService.updateWidgetCatalog(widgetId, newWidgetCatalog); - logger.debug("WidgetsCatalogController.updateWidgetCatalog: updating widget {}", newWidgetCatalog); - } catch (Exception e) { - logger.error("Exception occurred while performing WidgetsCatalogController.updateWidgetCatalog in widget microservices. Details:" + e.getMessage()); - e.printStackTrace(); - } - } - - @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog" }, method = RequestMethod.POST, produces = "application/json") - public ValidationRespond saveWidgetCatalog(HttpServletRequest request, HttpServletResponse response, @RequestHeader(value="Authorization") String auth, - @RequestParam("file") MultipartFile file, @RequestParam("widget") String widget) throws IOException { - - ValidationRespond respond = null; - if(!util.authorization(auth, security_user, security_pass)){ - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - logger.error("Basic Authentication Error while performing WidgetsCatalogController.saveWidgetCatalog in widget microserivce. Please check your username and password."); - return new ValidationRespond(false, "Basic Authentication Error, please check your username and password."); - } - try { - //check the zip file structure first - respond = storageService.checkZipFile(file); - - if(respond.isValid()){ - //save the widget catalog - WidgetCatalog newWidget = new ObjectMapper().readValue(widget, WidgetCatalog.class); - - long widgetId = widgetCatalogService.saveWidgetCatalog(newWidget); - logger.debug("WidgetsCatalogController.saveWidgetCatalog: saving widget={}", newWidget); - //save the widget zip file ; - storageService.save(file, newWidget, widgetId); - } - - } catch (Exception e) { - logger.error("Exception occurred while performing WidgetsCatalogController.saveWidgetCatalog in widget microservices. Details:", e); - } - return respond; - } - - @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/{widgetId}" }, method = RequestMethod.POST, produces = "application/json") - public ValidationRespond updateWidgetCatalogwithFiles(HttpServletRequest request, HttpServletResponse response, @RequestHeader(value="Authorization") String auth, - @RequestParam("file") MultipartFile file, @RequestParam("widget") String widget, @PathVariable("widgetId") long widgetId) throws IOException { - System.out.println("microserivces updating with files" + widgetId); - ValidationRespond respond = null; - if(!util.authorization(auth, security_user, security_pass)){ - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - logger.error("Basic Authentication Error while performing WidgetsCatalogController.saveWidgetCatalog in widget microserivce. Please check your username and password."); - return new ValidationRespond(false, "Basic Authentication Error, please check your username and password."); - } - try { - //check the zip file structure first - respond = storageService.checkZipFile(file); - if(respond.isValid()){ - //update the widget catalog - WidgetCatalog newWidget = new ObjectMapper().readValue(widget, WidgetCatalog.class); - widgetCatalogService.updateWidgetCatalog(widgetId, newWidget); - logger.debug("WidgetsCatalogController.saveWidgetCatalog: updating widget with widgetId={}", widgetId); - //update the widget zip file - storageService.update(file, newWidget, widgetId); - } - } catch (Exception e) { - logger.error("Exception occurred while performing WidgetsCatalogController.saveWidgetCatalog in widget microservices. Details:" + e.getMessage()); - e.printStackTrace(); - } - return respond; - } - - @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/{widgetId}" }, method = { - RequestMethod.DELETE }, produces = "application/json") - public void deleteOnboardingWidget(HttpServletRequest request, HttpServletResponse response, - @PathVariable("widgetId") long widgetId, @RequestHeader(value="Authorization") String auth) throws IOException{ - if(!util.authorization(auth, security_user, security_pass)){ - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - logger.error("Basic Authentication Error while performing WidgetsCatalogController.deleteOnboardingWidget in widget microserivce. Please check your username and password."); - return; - } - try { - logger.debug("WidgetsCatalogController.deleteOnboardingWidget: deleting widget {}", widgetId); - //WidgetCatalog widget = widgetCatalogService.getWidgetCatalog(widgetId); - widgetCatalogService.deleteWidgetCatalog(widgetId); - storageService.deleteWidgetFile(widgetId); - } catch (Exception e) { - logger.error("Exception occurred while performing WidgetsCatalogController.deleteOnboardingWidget in widget microservices. Details:" + e.getMessage()); - } - } - - @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/parameters/{widgetId}" }, method = RequestMethod.GET, produces = "application/json") - public Long getServiceIdByWidget(HttpServletRequest request, HttpServletResponse response, - @PathVariable("widgetId") Long widgetId, @RequestHeader(value="Authorization") String auth) throws IOException { - - Long serviceId = null; - if(!util.authorization(auth, security_user, security_pass)){ - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - logger.error("Basic Authentication Error while performing WidgetsCatalogController.getServiceIdByWidget in widget microserivce. Please check your username and password."); - return serviceId; - } - try{ - logger.debug("WidgetsCatalogController.getServiceIdByWidget: getting service Id for widget {}", widgetId); - serviceId = widgetCatalogService.getServiceIdByWidget(widgetId); - }catch(Exception e){ - logger.error("Exception occurred while performing WidgetsCatalogController.getServiceIdByWidget in widget microservices. Details:" + e.getMessage()); - } - return serviceId; - } - - - @ResponseBody - @RequestMapping(value = { "/microservices/widgetCatalog/service/{serviceId}" }, method = RequestMethod.GET, produces = "application/json") - public List<WidgetCatalog> getWidgetByServiceId(HttpServletRequest request, HttpServletResponse response, - @PathVariable("serviceId") Long serviceId, @RequestHeader(value="Authorization") String auth) throws IOException { - List<WidgetCatalog> list = new ArrayList<WidgetCatalog>(); - if(!util.authorization(auth, security_user, security_pass)){ - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - logger.error("Basic Authentication Error while performing WidgetsCatalogController.getWidgetByServiceId in widget microserivce. Please check your username and password."); - return null; - } - try{ - logger.debug("WidgetsCatalogController.getWidgetByServiceId: getting service Id for widget {}", serviceId); - list = widgetCatalogService.getWidgetsByServiceId(serviceId); - }catch(Exception e){ - logger.error("Exception occurred while performing WidgetsCatalogController.getWidgetByServiceId in widget microservices. Details:" + e.getMessage()); - } - return list; - } - - - @ResponseBody - @RequestMapping(value = { "/microservices/download/{widgetId}" }, method = RequestMethod.GET, produces = "application/json") - public byte[] getWidgetZipFile(HttpServletRequest request, HttpServletResponse response, - @PathVariable("widgetId") long widgetId, @RequestHeader(value="Authorization") String auth) throws Exception { - byte[] byteFile = null; - if(!util.authorization(auth, security_user, security_pass)){ - response.sendError(HttpServletResponse.SC_UNAUTHORIZED); - logger.error("Basic Authentication Error while performing WidgetsCatalogController.getWidgetZipFile in widget microserivce. Please check your username and password."); - return byteFile; - } - try { - byteFile = storageService.getWidgetCatalogContent(widgetId); - logger.debug("WidgetsCatalogController.getWidgetZipFile: getting widget zip file for widget with id {}", widgetId); - } catch (Exception e) { - logger.error("Exception occurred while performing WidgetsCatalogController.getWidgetZipFile in widget microservices. Details:" + e.getMessage()); - } - return byteFile; - } - - -}
\ No newline at end of file |