List of usage examples for javax.servlet.http HttpSession getId
public String getId();
From source file:org.kmnet.com.fw.web.token.transaction.TransactionTokenInterceptor.java
/** * Updates the value of existing token in <code>TransactionTokenStore</code> as well as in the request * <p>/*w w w.j ava 2 s .co m*/ * Updated <code>TransactionToken</code> instance is set to request attribute * <code>TransactionTokenInterceptor.NEXT_TOKEN</code>. * <p> * @param request * @param session * @param receivedToken * @param tokenInfo * @param generator * @param tokenStore */ void updateToken(HttpServletRequest request, HttpSession session, TransactionToken receivedToken, TransactionTokenInfo tokenInfo, TokenStringGenerator generator, TransactionTokenStore tokenStore) { TransactionToken nextToken = new TransactionToken(tokenInfo.getTokenName(), receivedToken.getTokenKey(), generator.generate(session.getId())); tokenStore.store(nextToken); request.setAttribute(NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME, nextToken); }
From source file:com.ggfix.gg.user.controller.UserAuthorityController.java
@RequestMapping("/login") public String login(String account, String password, HttpSession session) { if (this.userManager.login(account, password)) { List<User> users = this.userManager.getUsersByEmail(account); if (users != null) { session.setAttribute("User", users.get(0)); session.setAttribute("UserId", users.get(0).getId()); session.setAttribute("UserName", users.get(0).getFirstName()); session.removeAttribute("errorInfo"); }/* www. j av a2s. c om*/ } else { if (session.getAttribute("UserName") == null) session.setAttribute("UserName", session.getId()); session.setAttribute("errorInfo", "wrongUserOrPassword"); } return "index"; }
From source file:at.gv.egiz.pdfas.web.helper.PdfAsHelper.java
public static void injectSignature(HttpServletRequest request, HttpServletResponse response, CreateCMSSignatureResponseType createCMSSignatureResponseType, ServletContext context) throws Exception { logger.debug("Got CMS Signature Response"); HttpSession session = request.getSession(); StatusRequest statusRequest = (StatusRequest) session.getAttribute(PDF_STATUS); if (statusRequest == null) { throw new PdfAsWebException("No Signature running in session:" + session.getId()); }//from ww w . j a v a 2s. c om statusRequest.setSigature(createCMSSignatureResponseType.getCMSSignature()); statusRequest = pdfAs.process(statusRequest); session.setAttribute(PDF_STATUS, statusRequest); PdfAsHelper.process(request, response, context); }
From source file:gov.nih.nci.caintegrator.application.lists.UserListBeanHelper.java
/** * deprecated constructor -- used to support legacy code * @param userListBean/*w ww . j a v a 2s.c o m*/ * @deprecated */ public UserListBeanHelper(HttpSession session) { this.userListBean = (UserListBean) presentationTierCache .getNonPersistableObjectFromSessionCache(session.getId(), CacheConstants.USER_LISTS); }
From source file:com.huateng.ebank.framework.web.TransFilter.java
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpSession httpSession = request.getSession(false); if (null != httpSession) { Object o = httpSession.getAttribute(GlobalInfo.KEY_GLOBAL_INFO); if (null != o && o instanceof GlobalInfo) { GlobalInfo globalInfo = (GlobalInfo) o; /**/* w w w.ja v a2 s.c om*/ * ? */ GlobalInfo.setCurrentInstance(globalInfo); String sessionId = httpSession.getId(); globalInfo.setSessionId(sessionId); //set funcid globalInfo.setFuncId(request.getParameter("__FuncId")); /** add by zhaozhiguo 2011-6-20 BMS-3153 begin */ String path = request.getServletPath(); if (!path.endsWith("ChangePwd.ftl") && !path.endsWith("logout.do") && !path.endsWith("login.do")) { if (globalInfo.getLastpwdchgtm() == null) { globalInfo.setPswdForcedToChange(true);//? } else { long between = DateUtil.getDaysBetween(new Date(), globalInfo.getLastpwdchgtm()); if (between > globalInfo.getEffectiveDay() && globalInfo.getEffectiveDay() >= 0) { globalInfo.setPswdForcedToChange(true);//N?,? } } if (globalInfo.isPswdForcedToChange()) { ((HttpServletResponse) resp).getWriter().print("<script>top.location='" + request.getContextPath() + "/fpages/management/ftl/ChangePwd.ftl';</script>"); return; } /***add by ningpeng 2012-11-7 begin*/ String tlrNo = globalInfo.getTlrno(); String sta = userService.getUserLoginStatus(tlrNo); if (sta == null || SystemConstant.TLR_NO_STATE_LOGOUT.equals(sta)) { ((HttpServletResponse) resp) .sendRedirect(request.getContextPath() + "/common/success.jsp?type=signout"); return; } /***add by ningpeng 2012-11-7 end*/ } /** add by zhaozhiguo 2011-6-20 BMS-3153 end */ } else { if (expiredSystem((HttpServletRequest) req, (HttpServletResponse) resp)) { return; } } } else { if (expiredSystem((HttpServletRequest) req, (HttpServletResponse) resp)) { return; } } filterChain.doFilter(req, resp); }
From source file:gov.nih.nci.rembrandt.web.graphing.data.GeneExpressionPlot.java
public static HashMap generateBarChart(String gene, String reporter, HttpSession session, PrintWriter pw, GeneExpressionDataSetType geType) { String log2Filename = null;//from w ww . jav a 2 s . c om String rawFilename = null; String medianFilename = null; String bwFilename = ""; String legendHtml = null; HashMap charts = new HashMap(); PlotSize ps = PlotSize.MEDIUM; final String geneName = gene; final String alg = geType.equals(GeneExpressionDataSetType.GeneExpressionDataSet) ? RembrandtConstants.REPORTER_SELECTION_AFFY : RembrandtConstants.REPORTER_SELECTION_UNI; try { InstitutionCriteria institutionCriteria = InsitutionAccessHelper.getInsititutionCriteria(session); final GenePlotDataSet gpds = new GenePlotDataSet(gene, reporter, institutionCriteria, geType, session.getId()); //final GenePlotDataSet gpds = new GenePlotDataSet(gene, institutionCriteria,GeneExpressionDataSetType.GeneExpressionDataSet ); //LOG2 Dataset DefaultStatisticalCategoryDataset dataset = (DefaultStatisticalCategoryDataset) gpds.getLog2Dataset(); //RAW Dataset CategoryDataset meanDataset = (CategoryDataset) gpds.getRawDataset(); //B&W dataset DefaultBoxAndWhiskerCategoryDataset bwdataset = (DefaultBoxAndWhiskerCategoryDataset) gpds .getBwdataset(); //Median dataset CategoryDataset medianDataset = (CategoryDataset) gpds.getMedianDataset(); charts.put("diseaseSampleCountMap", gpds.getDiseaseSampleCountMap()); //IMAGE Size Control if (bwdataset != null && bwdataset.getRowCount() > 5) { ps = PlotSize.LARGE; } else { ps = PlotSize.MEDIUM; } //SMALL/MEDIUM == 650 x 400 //LARGE == 1000 x 400 //put as external Props? int imgW = 650; if (ps == PlotSize.LARGE) { imgW = new BigDecimal(bwdataset.getRowCount()).multiply(new BigDecimal(75)).intValue() > 1000 ? new BigDecimal(bwdataset.getRowCount()).multiply(new BigDecimal(75)).intValue() : 1000; } JFreeChart bwChart = null; //B&W plot CategoryAxis xAxis = new CategoryAxis("Disease Type"); NumberAxis yAxis = new NumberAxis("Log2 Expression Intensity"); yAxis.setAutoRangeIncludesZero(true); BoxAndWhiskerCoinPlotRenderer bwRenderer = null; // BoxAndWhiskerRenderer bwRenderer = new BoxAndWhiskerRenderer(); if (reporter != null) { //single reporter, show the coins bwRenderer = new BoxAndWhiskerCoinPlotRenderer(gpds.getCoinHash()); bwRenderer.setDisplayCoinCloud(true); bwRenderer.setDisplayMean(false); bwRenderer.setDisplayAllOutliers(true); bwRenderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { String tt = ""; NumberFormat formatter = new DecimalFormat(".####"); String key = ""; //String s = formatter.format(-1234.567); // -001235 if (dataset instanceof DefaultBoxAndWhiskerCategoryDataset) { DefaultBoxAndWhiskerCategoryDataset ds = (DefaultBoxAndWhiskerCategoryDataset) dataset; try { String med = formatter.format(ds.getMedianValue(series, item)); tt += "Median: " + med + "<br/>"; tt += "Mean: " + formatter.format(ds.getMeanValue(series, item)) + "<br/>"; tt += "Q1: " + formatter.format(ds.getQ1Value(series, item)) + "<br/>"; tt += "Q3: " + formatter.format(ds.getQ3Value(series, item)) + "<br/>"; tt += "Max: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMaxFaroutOutlier(ds, series, item)) + "<br/>"; tt += "Min: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMinFaroutOutlier(ds, series, item)) + "<br/>"; //tt += "<br/><br/>Please click on the box and whisker to view a plot for this reporter.<br/>"; //tt += "X: " + ds.getValue(series, item).toString()+"<br/>"; //tt += "<br/><a href=\\\'#\\\' id=\\\'"+ds.getRowKeys().get(series)+"\\\' onclick=\\\'alert(this.id);return false;\\\'>"+ds.getRowKeys().get(series)+" plot</a><br/><br/>"; key = ds.getRowKeys().get(series).toString(); } catch (Exception e) { } } return tt; } }); } else { //groups, dont show coins bwRenderer = new BoxAndWhiskerCoinPlotRenderer(); bwRenderer.setDisplayAllOutliers(true); bwRenderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { String tt = ""; NumberFormat formatter = new DecimalFormat(".####"); String key = ""; //String s = formatter.format(-1234.567); // -001235 if (dataset instanceof DefaultBoxAndWhiskerCategoryDataset) { DefaultBoxAndWhiskerCategoryDataset ds = (DefaultBoxAndWhiskerCategoryDataset) dataset; try { String med = formatter.format(ds.getMedianValue(series, item)); tt += "Median: " + med + "<br/>"; tt += "Mean: " + formatter.format(ds.getMeanValue(series, item)) + "<br/>"; tt += "Q1: " + formatter.format(ds.getQ1Value(series, item)) + "<br/>"; tt += "Q3: " + formatter.format(ds.getQ3Value(series, item)) + "<br/>"; tt += "Max: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMaxFaroutOutlier(ds, series, item)) + "<br/>"; tt += "Min: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMinFaroutOutlier(ds, series, item)) + "<br/>"; tt += "<br/><br/>Please click on the box and whisker to view a plot for this reporter.<br/>"; //tt += "X: " + ds.getValue(series, item).toString()+"<br/>"; //tt += "<br/><a href=\\\'#\\\' id=\\\'"+ds.getRowKeys().get(series)+"\\\' onclick=\\\'alert(this.id);return false;\\\'>"+ds.getRowKeys().get(series)+" plot</a><br/><br/>"; key = ds.getRowKeys().get(series).toString(); } catch (Exception e) { } } return "onclick=\"popCoin('" + geneName + "','" + key + "', '" + alg + "');\" | " + tt; } }); } bwRenderer.setFillBox(false); CategoryPlot bwPlot = new CategoryPlot(bwdataset, xAxis, yAxis, bwRenderer); bwChart = new JFreeChart(bwPlot); // JFreeChart bwChart = new JFreeChart( // null /*"Gene Expression Plot (" + gene.toUpperCase() + ")"*/, // new Font("SansSerif", Font.BOLD, 14), // bwPlot, // true // ); bwChart.setBackgroundPaint(java.awt.Color.white); //bwChart.getTitle().setHorizontalAlignment(TextTitle.DEFAULT_HORIZONTAL_ALIGNMENT.LEFT); bwChart.removeLegend(); //END BW plot // create the chart...for LOG2 dataset JFreeChart log2Chart = ChartFactory.createBarChart( null /*"Gene Expression Plot (" + gene.toUpperCase() + ")"*/, // chart // title "Groups", // domain axis label "Log2 Expression Intensity", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); //create the chart .... for RAW dataset JFreeChart meanChart = ChartFactory.createBarChart( null /*"Gene Expression Plot (" + gene.toUpperCase() + ")"*/, // chart // title "Groups", // domain axis label "Mean Expression Intensity", // range axis label meanDataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // create the chart .... for Median dataset JFreeChart medianChart = ChartFactory.createBarChart( null /*"Gene Expression Plot (" + gene.toUpperCase() + ")"*/, // chart // title "Groups", // domain axis label "Median Expression Intensity", // range axis label medianDataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); log2Chart.setBackgroundPaint(java.awt.Color.white); // lets start some customization to retro fit w/jcharts lookand feel CategoryPlot log2Plot = log2Chart.getCategoryPlot(); CategoryAxis log2Axis = log2Plot.getDomainAxis(); log2Axis.setLowerMargin(0.02); // two percent log2Axis.setCategoryMargin(0.20); // 20 percent log2Axis.setUpperMargin(0.02); // two percent // same for our fake chart - just to get the tooltips meanChart.setBackgroundPaint(java.awt.Color.white); CategoryPlot meanPlot = meanChart.getCategoryPlot(); CategoryAxis meanAxis = meanPlot.getDomainAxis(); meanAxis.setLowerMargin(0.02); // two percent meanAxis.setCategoryMargin(0.20); // 20 percent meanAxis.setUpperMargin(0.02); // two percent // median plot medianChart.setBackgroundPaint(java.awt.Color.white); CategoryPlot medianPlot = medianChart.getCategoryPlot(); CategoryAxis medianAxis = medianPlot.getDomainAxis(); medianAxis.setLowerMargin(0.02); // two percent medianAxis.setCategoryMargin(0.20); // 20 percent medianAxis.setUpperMargin(0.02); // two percent // customise the renderer... StatisticalBarRenderer log2Renderer = new StatisticalBarRenderer(); // BarRenderer renderer = (BarRenderer) plot.getRenderer(); log2Renderer.setItemMargin(0.01); // one percent log2Renderer.setDrawBarOutline(true); log2Renderer.setOutlinePaint(Color.BLACK); log2Renderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { HashMap pv = gpds.getPValuesHashMap(); HashMap std_d = gpds.getStdDevMap(); String currentPV = (String) pv .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); String stdDev = (String) std_d .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); return "Probeset : " + dataset.getRowKey(series) + "<br/>Intensity : " + new DecimalFormat("0.0000").format(dataset.getValue(series, item)) + "<br/>" + RembrandtConstants.PVALUE + " : " + currentPV + "<br/>Std. Dev.: " + stdDev + "<br/>"; } }); log2Plot.setRenderer(log2Renderer); // customize the renderer BarRenderer meanRenderer = (BarRenderer) meanPlot.getRenderer(); meanRenderer.setItemMargin(0.01); // one percent meanRenderer.setDrawBarOutline(true); meanRenderer.setOutlinePaint(Color.BLACK); meanRenderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { HashMap pv = gpds.getPValuesHashMap(); HashMap std_d = gpds.getStdDevMap(); String currentPV = (String) pv .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); String stdDev = (String) std_d .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); return "Probeset : " + dataset.getRowKey(series) + "<br/>Intensity : " + new DecimalFormat("0.0000").format(dataset.getValue(series, item)) + "<br/>" + RembrandtConstants.PVALUE + ": " + currentPV + "<br/>"; //"<br/>Std. Dev.: " + stdDev + "<br/>"; } }); meanPlot.setRenderer(meanRenderer); // customize the renderer BarRenderer medianRenderer = (BarRenderer) medianPlot.getRenderer(); medianRenderer.setItemMargin(0.01); // one percent medianRenderer.setDrawBarOutline(true); medianRenderer.setOutlinePaint(Color.BLACK); medianRenderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { HashMap pv = gpds.getPValuesHashMap(); HashMap std_d = gpds.getStdDevMap(); String currentPV = (String) pv .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); String stdDev = (String) std_d .get(dataset.getRowKey(series) + "::" + dataset.getColumnKey(item)); return "Probeset : " + dataset.getRowKey(series) + "<br/>Intensity : " + new DecimalFormat("0.0000").format(dataset.getValue(series, item)) + "<br/>" + RembrandtConstants.PVALUE + ": " + currentPV + "<br/>"; //"<br/>Std. Dev.: " + stdDev + "<br/>"; } }); // LegendTitle lg = chart.getLegend(); medianPlot.setRenderer(medianRenderer); // lets generate a custom legend - assumes theres only one source? LegendItemCollection lic = log2Chart.getLegend().getSources()[0].getLegendItems(); legendHtml = LegendCreator.buildLegend(lic, "Probesets"); log2Chart.removeLegend(); meanChart.removeLegend(); medianChart.removeLegend(); //bwChart.removeLegend(); // <-- do this above // Write the chart image to the temporary directory ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); // BW if (bwChart != null) { int bwwidth = new BigDecimal(1.5).multiply(new BigDecimal(imgW)).intValue(); bwFilename = ServletUtilities.saveChartAsPNG(bwChart, bwwidth, 400, info, session); CustomOverlibToolTipTagFragmentGenerator ttip = new CustomOverlibToolTipTagFragmentGenerator(); String toolTip = " href='javascript:void(0);' alt='GeneChart JFreechart Plot' "; ttip.setExtra(toolTip); //must have href for area tags to have cursor:pointer ChartUtilities.writeImageMap(pw, bwFilename, info, ttip, new StandardURLTagFragmentGenerator()); info.clear(); // lose the first one info = new ChartRenderingInfo(new StandardEntityCollection()); } //END BW log2Filename = ServletUtilities.saveChartAsPNG(log2Chart, imgW, 400, info, session); CustomOverlibToolTipTagFragmentGenerator ttip = new CustomOverlibToolTipTagFragmentGenerator(); String toolTip = " alt='GeneChart JFreechart Plot' "; ttip.setExtra(toolTip); //must have href for area tags to have cursor:pointer ChartUtilities.writeImageMap(pw, log2Filename, info, ttip, new StandardURLTagFragmentGenerator()); // clear the first one and overwrite info with our second one - no // error bars info.clear(); // lose the first one info = new ChartRenderingInfo(new StandardEntityCollection()); rawFilename = ServletUtilities.saveChartAsPNG(meanChart, imgW, 400, info, session); // Write the image map to the PrintWriter // can use a different writeImageMap to pass tooltip and URL custom ttip = new CustomOverlibToolTipTagFragmentGenerator(); toolTip = " alt='GeneChart JFreechart Plot' "; ttip.setExtra(toolTip); //must have href for area tags to have cursor:pointer ChartUtilities.writeImageMap(pw, rawFilename, info, ttip, new StandardURLTagFragmentGenerator()); info.clear(); // lose the first one info = new ChartRenderingInfo(new StandardEntityCollection()); medianFilename = ServletUtilities.saveChartAsPNG(medianChart, imgW, 400, info, session); // Write the image map to the PrintWriter // can use a different writeImageMap to pass tooltip and URL custom ttip = new CustomOverlibToolTipTagFragmentGenerator(); toolTip = " alt='GeneChart JFreechart Plot' "; ttip.setExtra(toolTip); //must have href for area tags to have cursor:pointer ChartUtilities.writeImageMap(pw, medianFilename, info, ttip, new StandardURLTagFragmentGenerator()); // ChartUtilities.writeImageMap(pw, filename, info, true); pw.flush(); } catch (Exception e) { System.out.println("Exception - " + e.toString()); e.printStackTrace(System.out); log2Filename = "public_error_500x300.png"; } // return filename; charts.put("errorBars", log2Filename); charts.put("noErrorBars", rawFilename); charts.put("medianBars", medianFilename); charts.put("bwFilename", bwFilename); charts.put("legend", legendHtml); charts.put("size", ps.toString()); return charts; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.mtprofile.MTProfileImportHandler.java
public void invokePageHandler(WebPageDescriptor p_pageDescriptor, HttpServletRequest p_request, HttpServletResponse p_response, ServletContext p_context) throws ServletException, IOException, EnvoyServletException { HttpSession session = p_request.getSession(false); String sessionId = session.getId(); SessionManager sessionMgr = (SessionManager) session.getAttribute(WebAppConstants.SESSION_MANAGER); String currentCompanyId = CompanyThreadLocal.getInstance().getValue(); boolean isSuperAdmin = ((Boolean) session.getAttribute(WebAppConstants.IS_SUPER_ADMIN)).booleanValue(); String action = p_request.getParameter(MTProfileConstants.ACTION); try {/*www . ja v a 2 s . c o m*/ if (MTProfileConstants.IMPORT_ACTION.equals(action)) { if (isSuperAdmin) { importMTProfile(p_request); p_request.setAttribute("currentId", currentCompanyId); } } else if ("startUpload".equals(action)) { File uploadedFile = this.uploadFile(p_request); if (isSuperAdmin) { String importToCompId = p_request.getParameter("companyId"); session.setAttribute("importToCompId", importToCompId); } session.setAttribute("uploading_filter", uploadedFile); } else if ("doImport".equals(action)) { int count = 0; if (sessionMgr.getAttribute("count") != null) { count = (Integer) sessionMgr.getAttribute("count"); if (count == 1) { count++; sessionMgr.setAttribute("count", count); } } else { count++; sessionMgr.setAttribute("count", count); } if (session.getAttribute("uploading_filter") != null) { filter_percentage_map.clear();// .remove(sessionId); filter_error_map.clear();// .remove(sessionId); File uploadedFile = (File) session.getAttribute("uploading_filter"); String importToCompId = (String) session.getAttribute("importToCompId"); session.removeAttribute("importToCompId"); session.removeAttribute("uploading_filter"); DoImport imp = new DoImport(sessionId, uploadedFile, currentCompanyId, importToCompId); imp.start(); } else { logger.error("No uploaded user info file."); } } else if ("refreshProgress".equals(action)) { this.refreshProgress(p_request, p_response, sessionId); return; } } catch (RemoteException re) { throw new EnvoyServletException(EnvoyServletException.EX_GENERAL, re); } catch (GeneralException ge) { throw new EnvoyServletException(EnvoyServletException.EX_GENERAL, ge); } super.invokePageHandler(p_pageDescriptor, p_request, p_response, p_context); }
From source file:com.hillert.botanic.controller.AuthenticationController.java
@RequestMapping(value = "/authenticate", method = { RequestMethod.POST }) public AuthenticationToken authorize(@RequestBody AuthenticationRequest authenticationRequest, HttpServletRequest request) {/*from ww w. ja va 2s .c o m*/ UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken( authenticationRequest.getUsername(), authenticationRequest.getPassword()); Authentication authentication = this.authenticationManager.authenticate(token); SecurityContextHolder.getContext().setAuthentication(authentication); HttpSession session = request.getSession(true); session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext()); UserDetails details = this.userDetailsService.loadUserByUsername(authenticationRequest.getUsername()); final Map<String, Boolean> roles = new HashMap<String, Boolean>(); for (GrantedAuthority authority : details.getAuthorities()) { roles.put(authority.toString(), Boolean.TRUE); } return new AuthenticationToken(details.getUsername(), roles, session.getId()); }
From source file:com.onehippo.gogreen.login.HstConcurrentLoginFilter.java
private void registerUserSession(HttpServletRequest request, String username) { log.debug("HstConcurrentLoginFilter will register session for {}", username); HttpSession session = request.getSession(); session.setAttribute(USERNAME_ATTR, username); ServletContext servletContext = session.getServletContext(); @SuppressWarnings("unchecked") Map<String, HttpSessionWrapper> map = (Map<String, HttpSessionWrapper>) servletContext .getAttribute(USERNAME_SESSIONID_MAP_ATTR); if (map != null) { String newSessionId = session.getId(); HttpSessionWrapper oldHttpSessionWrapper = map.put(username, new HttpSessionWrapper(session, earlySessionInvalidation)); log.debug("HstConcurrentLoginFilter registered session ({}) for {}.", newSessionId, username); if (oldHttpSessionWrapper != null) { oldHttpSessionWrapper.invalidate(); log.debug("HstConcurrentLoginFilter kicked out session ({}) for {}.", oldHttpSessionWrapper.getId(), username);//from ww w.j av a2 s . c om } } else { log.error("HstConcurrentLoginFilter is in invalid state. The session ids map is not found."); } }
From source file:org.opencron.server.service.HomeService.java
public int checkLogin(HttpServletRequest request, String username, String password) throws IOException { //session/*from w w w . ja v a 2s. c o m*/ /* if (!httpSession.isNew()) { httpSession.invalidate(); httpSession.removeAttribute(Globals.LOGIN_USER); }*/ HttpSession httpSession = request.getSession(); User user = queryDao.hqlUniqueQuery("FROM User WHERE userName = ?", username); if (user == null) return 500; //??? byte[] salt = Encodes.decodeHex(user.getSalt()); String saltPassword = Encodes.encodeHex(Digests.sha1(password.getBytes(), salt, 1024)); if (saltPassword.equals(user.getPassword())) { if (user.getRoleId() == 999L) { httpSession.setAttribute(OpencronTools.PERMISSION, true); } else { httpSession.setAttribute(OpencronTools.PERMISSION, false); } if (!PropertyPlaceholder.getBoolean("opencron.multilogin")) { Boolean logined = SingleLoginListener.logined(user); if (logined) { HttpSession session = SingleLoginListener.getLoginedSession(user.getUserId()); if (session != null) { session.setAttribute("loginMsg", "?,?"); } //?session, SingleLoginListener.removeUserSession(user.getUserId()); //??... TerminalService.TerminalSession.exit(session.getId()); } SingleLoginListener.addUserSession(httpSession); } OpencronTools.logined(request, user); return 200; } else { return 500; } }