import javax.servlet.http.HttpServletResponse;
import org.onap.portalapp.controller.EPRestrictedRESTfulBaseController;
+import org.onap.portalapp.music.conf.MusicSession;
+import org.onap.portalapp.music.util.MusicUtil;
import org.onap.portalapp.portal.domain.EPApp;
import org.onap.portalapp.portal.domain.EPRole;
+import org.onap.portalapp.portal.domain.EPServiceCookie;
import org.onap.portalapp.portal.domain.EPUser;
import org.onap.portalapp.portal.logging.aop.EPAuditLog;
import org.onap.portalapp.portal.service.AdminRolesService;
import org.onap.portalapp.portal.utils.EPCommonSystemProperties;
import org.onap.portalapp.portal.utils.EcompPortalUtils;
import org.onap.portalapp.portal.utils.PortalConstants;
+import org.onap.portalapp.validation.DataValidator;
+import org.onap.portalapp.validation.SecureString;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.onboarding.crossapi.PortalAPIResponse;
+import org.onap.portalsdk.core.onboarding.util.CipherUtil;
+import org.onap.portalsdk.core.util.SystemProperties;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
public class ExternalAppsRestfulController extends EPRestrictedRESTfulBaseController {
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExternalAppsRestfulController.class);
+ private final DataValidator DATA_VALIDATOR = new DataValidator();
@Autowired
private FunctionalMenuService functionalMenuService;
@ResponseBody
public PortalAPIResponse publishNotification(HttpServletRequest request,
@RequestBody EpNotificationItem notificationItem) throws Exception {
+
+ if(!DATA_VALIDATOR.isValid(notificationItem)){
+ PortalAPIResponse response = new PortalAPIResponse(false, "failed");
+ return response;
+ }
String appKey = request.getHeader("uebkey");
EPApp app = findEpApp(appKey);
List<Long> postRoleIds = new ArrayList<Long>();
EPRole role = epRoleService.getRole(app.getId(), roleId);
if (role != null)
postRoleIds.add(role.getId());
- }
- }
+ }
+ }
// --- recreate the user notification object with the POrtal Role Ids
EpNotificationItem postItem = new EpNotificationItem();
logger.warn(EELFLoggerDelegate.errorLogger, "Handling bad request", e);
response.sendError(HttpStatus.BAD_REQUEST.value(), e.getMessage());
}
+
+ @EPAuditLog
+ @RequestMapping(value = { "/validateCookie" }, method = RequestMethod.POST)
+ public boolean validateCookie(@RequestBody EPServiceCookie epServiceCookie, HttpServletRequest request) throws Exception {
+ Map<String,String> epServiceCookieValueMap = epServiceCookie.getValue();
+ if(epServiceCookieValueMap!=null) {
+ String multifactorauthfrontendurl = SystemProperties.getProperty("frontend_url");
+ String encryptedJSessionId = epServiceCookieValueMap.get(multifactorauthfrontendurl);
+ if(encryptedJSessionId != null) {
+ String jSessionId = CipherUtil.decryptPKC(encryptedJSessionId);
+ if(jSessionId != null) {
+ if(jSessionId.equals(request.getSession().getId())) {
+ if(MusicUtil.isMusicEnable()) {
+ MusicSession musicSession = new MusicSession();
+ String sessionId = musicSession.getAttribute(encryptedJSessionId);
+ logger.info(EELFLoggerDelegate.errorLogger, "Music sessionid : "+sessionId);
+ return (sessionId != null);
+ } else {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
}