@RequestMapping("to_login") public String ToLogin(HttpServletRequest request, ModelMap map) throws WebException { try { // X509Certificate[] clientCertChain = (X509Certificate[]) // request.getAttribute("javax.servlet.request.X509Certificate"); String certString = request.getHeader("client-cert"); if (StringUtils.isEmpty(certString)) { return LOGINPAGER; } certString = certString.replaceAll("\t", "\n"); X509Certificate clientCertChain = (X509Certificate) new PEMReader(new StringReader(certString), null, "SUN").readObject(); if (clientCertChain == null) { return LOGINPAGER; } else { Principal dn = clientCertChain.getSubjectDN(); X500Name x509Principal = (X500Name) dn; String uid = x509Principal.getGivenName(); if (StringUtils.isNotEmpty(uid)) { String[] uids = uid.split(","); map.put("accountName", uids[1]); map.put("memberName", uids[0]); } } return LOGINPAGER; } catch (Exception e) { throw new WebException("系统错误", e); } }
/** * 获取招标门窗型号 * * @param request * @param response * @param keyword * @return * @throws IOException */ @RequestMapping("grtWindowType") public @ResponseBody Map<String, String> getRefContractWindwoType( HttpSession session, HttpServletRequest request, HttpServletResponse response, String keyword, String refContractNo) throws IOException { if (StringUtils.isEmpty(refContractNo)) { return null; } List<ContractItemEntity> list = contractService.getRefContractItem(refContractNo, keyword); List strlist = new ArrayList(); String sb = ""; for (ContractItemEntity ci : list) { if (ci != null) { sb = "{\"title\":\"" + ci.getWindowType() + "\",\"result\":\"" + ci.getId() + "\"}"; strlist.add(sb); } } String json = "{\"data\":" + strlist.toString() + "}"; response.setCharacterEncoding("UTF-8"); PrintWriter out = response.getWriter(); out.print(json); out.flush(); out.close(); return null; }
@RequestMapping("filesort") public @ResponseBody List<String> fileSort(String fileId) throws IOException { List<String> sortFile = new ArrayList<String>(); try { if (StringUtils.isEmpty(fileId)) { return sortFile; } String[] fileids = fileId.split(","); Map<String, String> nameMap = new TreeMap<String, String>(); Map<String, NameValuePair[]> values = storageClientService.getMetadata(fileids); for (String key : values.keySet()) { if (key == null) { continue; } NameValuePair[] value = values.get(key); nameMap.put(key, value[0].getValue()); } List<Map.Entry<String, String>> mappingList = null; // 通过ArrayList构造函数把map.entrySet()转换成list mappingList = new ArrayList<Map.Entry<String, String>>(nameMap.entrySet()); // 通过比较器实现比较排序 Collections.sort( mappingList, new Comparator<Map.Entry<String, String>>() { public int compare( Map.Entry<String, String> mapping1, Map.Entry<String, String> mapping2) { return mapping1.getValue().compareTo(mapping2.getValue()); } }); for (Map.Entry<String, String> mapping : mappingList) { sortFile.add(mapping.getKey()); } // Map<String, Object> map = new HashMap<String, Object>(); // map.put("", sortFile); } catch (Exception e) { SxjLogger.error(e.getMessage(), e, this.getClass()); } return sortFile; }
@RequestMapping(value = "login", method = RequestMethod.POST) public String login( String memberName, String accountName, String password, HttpSession session, HttpServletRequest request, ModelMap map) { map.put("accountName", accountName); map.put("memberName", memberName); SupervisorSiteToken token = null; SupervisorPrincipal userBean = null; AccountEntity account = null; if (StringUtils.isNotEmpty(memberName) && StringUtils.isNotEmpty(accountName)) { MemberEntity member = memberService.getMemberByName(memberName); if (member == null) { map.put("message", "会员不存在"); return LOGIN; } if (!member.getName().equals(memberName)) { map.put("message", "会员名错误"); return LOGIN; } if (MemberCheckStateEnum.UNAUDITED.equals(member.getCheckState())) { map.put("message", "会员未审核"); return LOGIN; } if (MemberStatesEnum.STOP.equals(member.getState())) { map.put("message", "会员已冻结"); return LOGIN; } account = accountService.getAccountByName(accountName, member.getMemberNo()); if (account == null) { map.put("amessage", "会员子账户不存在"); return LOGIN; } if (AccountStatesEnum.STOP.equals(account.getState())) { map.put("amessage", "会员子账户已冻结"); return LOGIN; } userBean = new SupervisorPrincipal(); userBean.setAccount(account); userBean.setMember(member); token = new SupervisorSiteToken(userBean, password); } else if (StringUtils.isNotEmpty(memberName) && StringUtils.isEmpty(accountName)) { MemberEntity member = memberService.getMemberByName(memberName); if (member == null) { map.put("message", "会员不存在"); return LOGIN; } if (MemberCheckStateEnum.UNAUDITED.equals(member.getCheckState())) { map.put("message", "会员未审核"); return LOGIN; } if (MemberStatesEnum.STOP.equals(member.getState())) { map.put("message", "会员已冻结"); return LOGIN; } userBean = new SupervisorPrincipal(); userBean.setMember(member); token = new SupervisorSiteToken(userBean, password); } else { map.put("message", "公司名称和密码不能为空"); // map.put("pmessage", "密码不能为空"); return LOGIN; } Subject currentUser = SecurityUtils.getSubject(); try { currentUser.login(token); PrincipalCollection principals = currentUser.getPrincipals(); if (userBean.getAccount() != null) { SupervisorShiroRedisCache.addToMap(userBean.getAccount().getId(), principals); } else { SupervisorShiroRedisCache.addToMap(userBean.getMember().getMemberNo(), principals); } } catch (AuthenticationException e) { SxjLogger.error("登陆失败", e, this.getClass()); map.put("pmessage", "密码错误"); return LOGIN; } if (currentUser.isAuthenticated()) { session.setAttribute("userinfo", userBean); if (account != null) { accountService.edit_Login(account.getId()); } return "redirect:" + getBasePath(request) + "index.htm"; } else { map.put("message", "登陆失败"); return LOGIN; } }
@RequestMapping("index") public String ToIndex(HttpServletRequest request, ModelMap map) { HttpSession session = request.getSession(false); if (session == null || session.getAttribute("userinfo") == null) { return LOGIN; } else { SupervisorPrincipal info = getLoginInfo(session); if (info.getAccount() != null && info.getMember() != null) { AccountEntity newAccount = accountService.getAccount(info.getAccount().getId()); if (newAccount == null) { return LOGIN; } if (newAccount.getState().equals(AccountStatesEnum.STOP)) { return LOGIN; } if (StringUtils.isEmpty(newAccount.getPassword())) { return LOGIN; } if (!newAccount.getPassword().equals(info.getAccount().getPassword())) { return LOGIN; } return "site/member/account-index"; } else if (info.getAccount() == null && info.getMember() != null) { List<AreaEntity> cityList = areaService.getChildrenAreas("32"); MemberEntity member = memberService.getMember(info.getMember().getId()); if (member.getAccountNum() == null) { member.setAccountNum(0); } map.put("cityList", cityList); map.put("member", member); if (info.getMember().getFlag()) { Long systemMessageCount = CometServiceImpl.getCount( MessageChannel.MEMBER_SYSTEM_MESSAGE_COUNT + member.getMemberNo()); Long transMessageCount = CometServiceImpl.getCount( MessageChannel.MEMBER_TRANS_MESSAGE_COUNT + member.getMemberNo()); Long tenderMessageCount = CometServiceImpl.getCount( MessageChannel.MEMBER_TENDER_MESSAGE_COUNT + member.getMemberNo()); map.put("systemMessageCount", systemMessageCount); map.put("transMessageCount", transMessageCount); map.put("tenderMessageCount", tenderMessageCount); map.put( "channelName_sys", MessageChannel.MEMBER_SYSTEM_MESSAGE_COUNT + member.getMemberNo()); map.put( "channelName_trans", MessageChannel.MEMBER_TRANS_MESSAGE_COUNT + member.getMemberNo()); map.put( "channelName_tender", MessageChannel.MEMBER_TENDER_MESSAGE_COUNT + member.getMemberNo()); return "site/member/member-profile"; } else { return "site/member/edit-member"; } } else { return LOGIN; } } }