List of usage examples for javax.servlet.http HttpSession getId
public String getId();
From source file:gov.nih.nci.security.upt.actions.CommonDoubleAssociationAction.java
public String setRoleAssociation(BaseDoubleAssociationForm baseDoubleAssociationForm) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) { if (logDoubleAssociation.isDebugEnabled()) logDoubleAssociation.debug("||" + baseDoubleAssociationForm.getFormName() + "|setRoleAssociation|Failure|No Session or User Object Forwarding to the Login Page||"); return ForwardConstants.LOGIN_PAGE; }//www . j ava 2s . co m UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(), session.getId()); try { UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession()) .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER); baseDoubleAssociationForm.setRequest(request); baseDoubleAssociationForm.buildDisplayForm(userProvisioningManager); baseDoubleAssociationForm.updateRoleAssociation(userProvisioningManager); addActionMessage("Association Update Successful"); } catch (CSException cse) { addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())); if (logDoubleAssociation.isDebugEnabled()) logDoubleAssociation.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDoubleAssociationForm.getFormName() + "|setRoleAssociation|Failure|Error Setting Role Association for the " + baseDoubleAssociationForm.getFormName() + " object|" + logDoubleAssociation.toString() + "|" + cse.getMessage()); } if (logDoubleAssociation.isDebugEnabled()) logDoubleAssociation.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDoubleAssociationForm.getFormName() + "|setRoleAssociation|Success|Success in Setting Role Association for " + baseDoubleAssociationForm.getFormName() + " object|" + logDoubleAssociation.toString() + "|"); return ForwardConstants.SET_ROLEASSOCIATION_SUCCESS; }
From source file:org.apache.tapestry.ApplicationServlet.java
/** * Retrieves the {@link IEngine engine} that will process this * request. This comes from one of the following places: * <ul>/*from www .ja v a 2s .co m*/ * <li>The {@link HttpSession}, if the there is one. * <li>From the pool of available engines * <li>Freshly created * </ul> * **/ protected IEngine getEngine(RequestContext context) throws ServletException { IEngine engine = null; HttpSession session = context.getSession(); // If there's a session, then find the engine within it. if (session != null) { engine = (IEngine) session.getAttribute(_attributeName); if (engine != null) { if (LOG.isDebugEnabled()) LOG.debug("Retrieved " + engine + " from session " + session.getId() + "."); return engine; } if (LOG.isDebugEnabled()) LOG.debug("Session exists, but doesn't contain an engine."); } Locale locale = getLocaleFromRequest(context); engine = (IEngine) _enginePool.retrieve(locale); if (engine == null) { engine = createEngine(context); engine.setLocale(locale); } else { if (LOG.isDebugEnabled()) LOG.debug("Using pooled engine " + engine + " (from locale " + locale + ")."); } return engine; }
From source file:pivotal.au.se.gemfirexdweb.controller.LoginController.java
@RequestMapping(value = "/login", method = RequestMethod.POST) public String login(@ModelAttribute("loginAttribute") Login loginAttribute, Model model, HttpSession session) throws Exception { logger.debug("Received request to login"); ConnectionManager cm = ConnectionManager.getInstance(); Connection conn;/*from www . j a v a 2 s .c om*/ try { if (loginAttribute.getUsername().trim().equals("")) { conn = AdminUtil.getNewConnection(loginAttribute.getUrl()); } else { conn = AdminUtil.getNewConnection(loginAttribute.getUrl(), loginAttribute.getUsername(), loginAttribute.getPassword()); } SQLFireJDBCConnection newConn = new SQLFireJDBCConnection(conn, loginAttribute.getUrl(), new java.util.Date().toString(), loginAttribute.getUsername().trim().equals("") ? "APP" : loginAttribute.getUsername().toUpperCase()); cm.addConnection(newConn, session.getId()); session.setAttribute("user_key", session.getId()); session.setAttribute("schema", loginAttribute.getUsername().trim().equals("") ? "APP" : loginAttribute.getUsername().toUpperCase()); session.setAttribute("url", loginAttribute.getUrl()); session.setAttribute("prefs", new UserPref()); session.setAttribute("history", new LinkedList()); session.setAttribute("connectedAt", new java.util.Date().toString()); Map<String, String> schemaMap = AdminUtil.getSchemaMap(); // get schema count now schemaMap = QueryUtil.populateSchemaMap(conn, schemaMap, loginAttribute.getUsername().trim().equals("") ? "APP" : loginAttribute.getUsername().toUpperCase()); session.setAttribute("schemaMap", schemaMap); logger.info(loginAttribute); // This will resolve to /WEB-INF/jsp/main.jsp return "main"; } catch (Exception ex) { model.addAttribute("error", ex.getMessage()); Login login = new Login(); login.setUsername(loginAttribute.getUsername()); login.setUrl(loginAttribute.getUrl()); model.addAttribute("loginAttribute", login); // This will resolve to /WEB-INF/jsp/loginpage.jsp return "loginpage"; } }
From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java
public String delete(BaseDBForm baseDBForm) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) { if (logDB.isDebugEnabled()) logDB.debug("||" + baseDBForm.getFormName() + "|delete|Failure|No Session or User Object Forwarding to the Login Page||"); return ForwardConstants.LOGIN_PAGE; }// w w w .j a v a 2 s . c o m UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(), session.getId()); try { UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession()) .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER); baseDBForm.setRequest(request); baseDBForm.buildDisplayForm(userProvisioningManager); baseDBForm.removeDBObject(userProvisioningManager); addActionMessage("Delete Successful"); } catch (CSException cse) { addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDBForm.getFormName() + "|delete|Failure|Error Deleting the " + baseDBForm.getFormName() + " object|" + "|" + cse.getMessage()); } session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDBForm.getFormName() + "|delete|Success|Success Deleting " + baseDBForm.getFormName() + " object|" + "|"); return ForwardConstants.DELETE_SUCCESS; }
From source file:com.cws.us.pws.controllers.CommonController.java
@RequestMapping(value = "/search", method = RequestMethod.GET) public final ModelAndView siteSearch() { final String methodName = CommonController.CNAME + "#siteSearch()"; if (DEBUG) {//from w w w .j a v a2 s . c om DEBUGGER.debug(methodName); } ModelAndView mView = new ModelAndView(); final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder .currentRequestAttributes(); final HttpServletRequest hRequest = requestAttributes.getRequest(); final HttpSession hSession = hRequest.getSession(); if (DEBUG) { DEBUGGER.debug("ServletRequestAttributes: {}", requestAttributes); DEBUGGER.debug("HttpServletRequest: {}", hRequest); DEBUGGER.debug("HttpSession: {}", hSession); DEBUGGER.debug("Session ID: {}", hSession.getId()); DEBUGGER.debug("Dumping session content:"); @SuppressWarnings("unchecked") Enumeration<String> sessionEnumeration = hSession.getAttributeNames(); while (sessionEnumeration.hasMoreElements()) { String sessionElement = sessionEnumeration.nextElement(); Object sessionValue = hSession.getAttribute(sessionElement); DEBUGGER.debug("Attribute: " + sessionElement + "; Value: " + sessionValue); } DEBUGGER.debug("Dumping request content:"); @SuppressWarnings("unchecked") Enumeration<String> requestEnumeration = hRequest.getAttributeNames(); while (requestEnumeration.hasMoreElements()) { String requestElement = requestEnumeration.nextElement(); Object requestValue = hRequest.getAttribute(requestElement); DEBUGGER.debug("Attribute: " + requestElement + "; Value: " + requestValue); } DEBUGGER.debug("Dumping request parameters:"); @SuppressWarnings("unchecked") Enumeration<String> paramsEnumeration = hRequest.getParameterNames(); while (paramsEnumeration.hasMoreElements()) { String requestElement = paramsEnumeration.nextElement(); Object requestValue = hRequest.getParameter(requestElement); DEBUGGER.debug("Parameter: " + requestElement + "; Value: " + requestValue); } } mView.addObject("command", new SearchRequest()); mView.setViewName(this.appConfig.getSearchRequestPage()); if (DEBUG) { DEBUGGER.debug("ModelAndView: {}", mView); } return mView; }
From source file:com.cws.us.pws.controllers.CommonController.java
@RequestMapping(value = "/contact", method = RequestMethod.GET) public final ModelAndView showMessagingPage() { final String methodName = CommonController.CNAME + "#showMessagingPage()"; if (DEBUG) {//from www . jav a2s .co m DEBUGGER.debug(methodName); } ModelAndView mView = new ModelAndView(); final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder .currentRequestAttributes(); final HttpServletRequest hRequest = requestAttributes.getRequest(); final HttpSession hSession = hRequest.getSession(); if (DEBUG) { DEBUGGER.debug("ServletRequestAttributes: {}", requestAttributes); DEBUGGER.debug("HttpServletRequest: {}", hRequest); DEBUGGER.debug("HttpSession: {}", hSession); DEBUGGER.debug("Session ID: {}", hSession.getId()); DEBUGGER.debug("Dumping session content:"); @SuppressWarnings("unchecked") Enumeration<String> sessionEnumeration = hSession.getAttributeNames(); while (sessionEnumeration.hasMoreElements()) { String sessionElement = sessionEnumeration.nextElement(); Object sessionValue = hSession.getAttribute(sessionElement); DEBUGGER.debug("Attribute: " + sessionElement + "; Value: " + sessionValue); } DEBUGGER.debug("Dumping request content:"); @SuppressWarnings("unchecked") Enumeration<String> requestEnumeration = hRequest.getAttributeNames(); while (requestEnumeration.hasMoreElements()) { String requestElement = requestEnumeration.nextElement(); Object requestValue = hRequest.getAttribute(requestElement); DEBUGGER.debug("Attribute: " + requestElement + "; Value: " + requestValue); } DEBUGGER.debug("Dumping request parameters:"); @SuppressWarnings("unchecked") Enumeration<String> paramsEnumeration = hRequest.getParameterNames(); while (paramsEnumeration.hasMoreElements()) { String requestElement = paramsEnumeration.nextElement(); Object requestValue = hRequest.getParameter(requestElement); DEBUGGER.debug("Parameter: " + requestElement + "; Value: " + requestValue); } } mView.addObject("svcAddress", this.appConfig.getServiceEmail()); mView.addObject("command", new EmailMessage()); mView.setViewName(this.appConfig.getContactPage()); if (DEBUG) { DEBUGGER.debug("ModelAndView: {}", mView); } return mView; }
From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java
public String create(BaseDBForm baseDBForm) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) { if (logDB.isDebugEnabled()) logDB.debug("||" + baseDBForm.getFormName() + "|create|Failure|No Session or User Object Forwarding to the Login Page||"); return ForwardConstants.LOGIN_PAGE; }//from w w w .j ava2 s .c o m UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(), session.getId()); try { List<String> errors = baseDBForm.validate(); if (errors != null && errors.size() > 0) { for (String error : errors) { addActionError(error); } session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDBForm.getFormName() + "|create|Failure|Error validating the " + baseDBForm.getFormName() + " object|" + baseDBForm.toString() + "|"); return "input"; } UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession()) .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER); baseDBForm.setRequest(request); baseDBForm.buildDBObject(userProvisioningManager); addActionMessage("Add Successful"); } catch (CSException cse) { addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDBForm.getFormName() + "|create|Failure|Error Adding the " + baseDBForm.getFormName() + " object|" + baseDBForm.toString() + "|" + cse.getMessage()); } session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDBForm.getFormName() + "|create|Success|Adding a new " + baseDBForm.getFormName() + " object|" + baseDBForm.toString() + "|"); return ForwardConstants.CREATE_SUCCESS; }
From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java
public String update(BaseDBForm baseDBForm) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) { if (logDB.isDebugEnabled()) logDB.debug("||" + baseDBForm.getFormName() + "|update|Failure|No Session or User Object Forwarding to the Login Page||"); return ForwardConstants.LOGIN_PAGE; }//from w w w . j a v a 2 s . c o m UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(), session.getId()); try { List<String> errors = baseDBForm.validate(); if (errors != null && errors.size() > 0) { for (String error : errors) addActionError(error); session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDBForm.getFormName() + "|update|Failure|Error validating the " + baseDBForm.getFormName() + " object|" + "|"); return "input"; } UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession()) .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER); baseDBForm.setRequest(request); baseDBForm.buildDBObject(userProvisioningManager); addActionMessage("Update Successful"); } catch (CSException cse) { addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDBForm.getFormName() + "|update|Failure|Error Updating the " + baseDBForm.getFormName() + " object|" + "|" + cse.getMessage()); } session.setAttribute(DisplayConstants.CURRENT_FORM, baseDBForm); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDBForm.getFormName() + "|update|Success|Updating existing " + baseDBForm.getFormName() + " object|" + "|"); return ForwardConstants.UPDATE_SUCCESS; }
From source file:gov.nih.nci.security.upt.actions.CommonDoubleAssociationAction.java
public String removeProtectionGroupAssociation(BaseDoubleAssociationForm baseDoubleAssociationForm) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) { if (logDoubleAssociation.isDebugEnabled()) logDoubleAssociation.debug("||" + baseDoubleAssociationForm.getFormName() + "|removeProtectionGroupAssociation|Failure|No Session or User Object Forwarding to the Login Page||"); return ForwardConstants.LOGIN_PAGE; }// ww w . j a va 2 s . c o m UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(), session.getId()); if (baseDoubleAssociationForm.getProtectionGroupAssociatedId() == null || baseDoubleAssociationForm.getProtectionGroupAssociatedId().equalsIgnoreCase("")) { addActionError("A record needs to be selected first"); if (logDoubleAssociation.isDebugEnabled()) logDoubleAssociation.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDoubleAssociationForm.getFormName() + "|removeProtectionGroupAssociation|Failure|No Protection Group Id selected for " + baseDoubleAssociationForm.getFormName() + " object||"); return ForwardConstants.LOAD_PROTECTIONGROUPASSOCIATION_SUCCESS; } try { UserProvisioningManager userProvisioningManager = (UserProvisioningManager) (request.getSession()) .getAttribute(DisplayConstants.USER_PROVISIONING_MANAGER); baseDoubleAssociationForm.setRequest(request); baseDoubleAssociationForm.buildDisplayForm(userProvisioningManager); baseDoubleAssociationForm.removeProtectionGroupAssociation(userProvisioningManager); addActionMessage("Protection Group Successfully removed"); } catch (CSException cse) { addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())); if (logDoubleAssociation.isDebugEnabled()) logDoubleAssociation.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDoubleAssociationForm.getFormName() + "|removeProtectionGroupAssociation|Failure|Error Removing Protection Group Association for the " + baseDoubleAssociationForm.getFormName() + " object|" + baseDoubleAssociationForm.toString() + "|" + cse.getMessage()); } if (logDoubleAssociation.isDebugEnabled()) logDoubleAssociation.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + baseDoubleAssociationForm.getFormName() + "|removeGroupAssociation|Success|Success in Removing Protection Group Association for " + baseDoubleAssociationForm.getFormName() + " object|" + baseDoubleAssociationForm.toString() + "|"); return ForwardConstants.REMOVE_PROTECTIONGROUPASSOCIATION_SUCCESS; }
From source file:gov.nih.nci.security.upt.actions.CommonDBAction.java
public String testConnection(BaseDBForm form) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); HttpSession session = request.getSession(); if (session.isNew() || (session.getAttribute(DisplayConstants.LOGIN_OBJECT) == null)) { if (logDB.isDebugEnabled()) logDB.debug("||" + form.getFormName() + "|Test Connection|Failure|No Session or User Object Forwarding to the Login Page||"); return ForwardConstants.LOGIN_PAGE; }/*from w ww .j av a 2s .c om*/ UserInfoHelper.setUserInfo(((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId(), session.getId()); try { List<String> errors = form.validate(); if (errors != null && errors.size() > 0) { for (String error : errors) addActionError(error); session.setAttribute(DisplayConstants.CURRENT_FORM, form); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + form.getFormName() + "|Test Connection|Failure|Error testing Aplication Database Connection" + "|"); return "input"; } // Test JDBC Database Connection Properties. //String message = JDBCHelper.testConnectionHibernate(baseDBForm); String message = JDBCHelper.testConnectionJDBC(form); // addActionMessage(message); } catch (CSException cse) { addActionError(org.apache.commons.lang.StringEscapeUtils.escapeHtml(cse.getMessage())); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + form.getFormName() + "|Test Connection|Failure|Error Testing Application Database Connection." + "|" + cse.getMessage()); } session.setAttribute(DisplayConstants.CURRENT_FORM, form); if (logDB.isDebugEnabled()) logDB.debug(session.getId() + "|" + ((LoginForm) session.getAttribute(DisplayConstants.LOGIN_OBJECT)).getLoginId() + "|" + form.getFormName() + "|Test Connection|Success|Testing Application Database connection." + "|"); return ForwardConstants.UPDATE_SUCCESS; }