List of usage examples for org.apache.commons.codec.digest DigestUtils md5Hex
public static String md5Hex(String data)
From source file:mx.edu.ittepic.proyectofinal.ejbs.ejbUsers.java
public String newUser(String username, String password, String phone, String neigborhood, String zipcode, String city, String country, String state, String region, String street, String email, String streetnumber, String photo, String cellphone, String companyid, String roleid, String gender) { Message m = new Message(); Users u = new Users(); GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create();/* w w w . j av a 2 s.c o m*/ Company com = entity.find(Company.class, Integer.parseInt(companyid)); Role rol = entity.find(Role.class, Integer.parseInt(roleid)); try { String cadenaoriginal = password; String md5 = DigestUtils.md5Hex(cadenaoriginal); u.setUsername(username); u.setPassword(md5); u.setPhone(phone); u.setNeigborhood(neigborhood); u.setZipcode(zipcode); u.setCity(city); u.setCountry(country); u.setState(state); u.setRegion(region); u.setStreet(street); u.setEmail(email); u.setStreetnumber(streetnumber); u.setPhoto(photo); u.setCellphone(cellphone); u.setCompanyid(com); u.setRoleid(rol); u.setGender(gender.charAt(0)); u.setApikey("off"); entity.persist(u); entity.flush(); updateUser(u.getUserid().toString(), u.getApikey()); m.setCode(200); m.setMsg("El usuario se ha registro correctamente"); m.setDetail(u.getUserid().toString()); } catch (IllegalArgumentException e) { m.setCode(503); m.setMsg("Error en la base de datos"); m.setDetail(e.toString()); } catch (TransactionRequiredException e) { m.setCode(503); m.setMsg("Error en la transaccion con la base de datos"); m.setDetail(e.toString()); } catch (EntityExistsException e) { m.setCode(400); m.setMsg("Hubo problemas con la base de datos"); m.setDetail(e.toString()); } catch (ConstraintViolationException e) { m.setCode(400); m.setMsg("Hubo problemas con la base de datos"); m.setDetail(e.getConstraintViolations().toString()); } return gson.toJson(m); }
From source file:com.magnet.mmx.server.plugin.mmxmgmt.message.MessageIdGeneratorImpl.java
@Override public String generateTopicMessageId(String appId, String topicId) { StringBuilder builder = new StringBuilder(); builder.append(Long.toString(getCurrentTimeMillis())); builder.append(appId);// w w w. j av a2 s . com builder.append(topicId); builder.append(randomGenerator.nextLong()); String generated; try { byte[] bytes = builder.toString().getBytes(MMXServerConstants.UTF8_ENCODING); generated = DigestUtils.md5Hex(bytes); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(e); } return generated; }
From source file:com.glaf.core.web.rest.MxFileSystemResource.java
@GET @POST// w w w . ja va 2 s .co m @Path("/json") @ResponseBody @Produces({ MediaType.APPLICATION_OCTET_STREAM }) public byte[] json(@Context HttpServletRequest request) throws IOException { Map<String, Object> params = RequestUtils.getParameterMap(request); LogUtils.debug(params); JSONArray array = new JSONArray(); String path = request.getParameter("path"); if (StringUtils.isEmpty(path)) { path = "/WEB-INF"; } String root = SystemProperties.getAppPath() + "/" + path; File dir = new File(root); if (dir.exists() && dir.isDirectory()) { File[] contents = dir.listFiles(); if (contents != null) { for (int i = 0; i < contents.length; i++) { File file = contents[i]; if (file.exists() && file.isFile()) { if (StringUtils.contains(file.getName(), "jdbc.properties")) { continue; } if (StringUtils.contains(file.getName(), "hibernate.cfg.xml")) { continue; } JSONObject json = new JSONObject(); json.put("id", DigestUtils.md5Hex(path + "/" + file.getName())); json.put("parentId", DigestUtils.md5Hex(path + "/")); json.put("startIndex", i + 1); json.put("date", DateUtils.getDateTime(new Date(file.lastModified()))); json.put("name", file.getName()); json.put("path", path + "/" + file.getName()); json.put("class", "file"); json.put("size", file.length()); json.put("leaf", true); array.add(json); } } } } return array.toJSONString().getBytes("UTF-8"); }
From source file:com.chiorichan.account.Account.java
public final boolean validatePassword(String pass) { String password = getPassword(); return (password.equals(pass) || password.equals(DigestUtils.md5Hex(pass)) || DigestUtils.md5Hex(password).equals(pass)); }
From source file:com.sammyun.controller.console.AdminController.java
/** * ?/* ww w.j av a 2s . co m*/ */ @RequestMapping(value = "/save", method = RequestMethod.POST) public String save(Admin admin, Long dictSchoolId, Long[] roleIds, RedirectAttributes redirectAttributes, ModelMap model) { DictSchool dictSchool = dictSchoolService.find(dictSchoolId); admin.setDictSchool(dictSchool); admin.setRoles(new HashSet<Role>(roleService.findList(roleIds))); if (!isValid(admin, Save.class)) { return ERROR_VIEW; } if (adminService.usernameExists(admin.getUsername())) { return ERROR_VIEW; } admin.setPassword(DigestUtils.md5Hex(admin.getPassword())); admin.setIsLocked(false); admin.setLoginFailureCount(0); admin.setLockedDate(null); admin.setLoginDate(null); admin.setLoginIp(null); adminService.save(admin); model.addAttribute("menuId", Admin.class.getSimpleName()); addFlashMessage(redirectAttributes, SUCCESS_MESSAGE); //?? ImUserUtil imUserUtil = new ImUserUtil(); imUserUtil.getDefalutWorkSetting(dictSchool); //?? imUserUtil.getSystemMember(dictSchool); return "redirect:list.ct"; }
From source file:com.dianping.lion.service.impl.UserServiceImplTest.java
@Test public void testLoginSucceedAt1stTime() { try {/* w w w . java2 s . co m*/ //if auth succeed 1st time, writing it to mysql User user = userService.login(rightUserNameForTest, rightPwdForTest); User userDB = userService.findById(user.getId()); assertNotNull(userDB); assertNotNull(DigestUtils.md5Hex(rightPwdForTest).toUpperCase().equals(userDB.getPassword())); } catch (Exception e) { } }
From source file:com.st.qunar.order.service.StatusChangeLogServiceTest.java
@Test public void updateHttp() throws Exception { // data=com.st.qunar.order.pojo.Data@110bcb82[changeCode=0101,orderDesc=????????,orderNo=ygz140509165402046,time=1399625811166,transactionId=ygz1405091654020460101], // notifyType=ORDER,sign=212EB3E9EE0F8EF9B6D054EF3BDAD2E1,version=1.0] JsonMapper mapper = JsonMapper.nonDefaultMapper(); OrderStatusUpdateInfo bean = new OrderStatusUpdateInfo(); Data data = new Data(); data.setChangeCode("0101"); data.setOrderDesc("????????"); data.setOrderNo("ygz140509174917705"); data.setTime("1399629303361"); data.setTransactionId("ygz1405091749177050101"); bean.setData(data);//w w w . ja v a 2s . c o m String dataJsonStr = mapper.toJson(data); dataJsonStr = dataJsonStr.replaceAll("time\":\"", "time\":"); dataJsonStr = dataJsonStr.replaceAll("\",\"transactionId", ",\"transactionId"); String md5Str = dataJsonStr + "secCode=" + AccountConfig.QUNAR_ORDER_STATUS_UPDATE_SEC_CODE; String locSign = DigestUtils.md5Hex(md5Str).toUpperCase(); // AccountConfig.QUNAR_ORDER_STATUS_UPDATE_SEC_CODE) System.out.println("orgStr:" + md5Str); System.out.println("locSign:" + locSign); System.out.println("qnSign::B3971EE64D7F4F289F2992FFCE43FC85"); bean.setSign(locSign); bean.setVersion("1.0"); bean.setNotifyType("ORDER"); // String beanString = mapper.toJson(bean); // // System.out.println("Bean:" + beanString);// 42.121.4.104 // String exportContent = Request.Post("http://localhost:9000/qunar/order/status/update") // .bodyString(beanString, ContentType.APPLICATION_JSON).execute().returnContent().asString(); // System.out.println("exportContent:" + exportContent); }
From source file:com.wipro.ats.bdre.tdimport.FileMonitor.java
private static void putEligibleFileInfoInMap(String fileName, FileContent fc) { // *Start* Eligible files moved to data structure for ingestion to HDFS FileCopyInfo fileCopyInfo = new FileCopyInfo(); try {// w ww .jav a 2 s. c o m fileCopyInfo.setFileName(fileName); fileCopyInfo.setSubProcessId(TDImportRunnableMain.getSubProcessId()); fileCopyInfo.setServerId(Integer.toString(123461)); fileCopyInfo.setSrcLocation(fc.getFile().getName().getPath()); fileCopyInfo.setTdTable(TDImportRunnableMain.getTdTable()); fileCopyInfo.setFileHash(DigestUtils.md5Hex(fc.getInputStream())); fileCopyInfo.setFileSize(fc.getSize()); fileCopyInfo.setTimeStamp(fc.getLastModifiedTime()); fileCopyInfo.setTdDB(TDImportRunnableMain.getTdDB()); fileCopyInfo.setTdUserName(TDImportRunnableMain.getTdUserName()); fileCopyInfo.setTdPassword(TDImportRunnableMain.getTdPassword()); fileCopyInfo.setTdDelimiter(TDImportRunnableMain.getTdDelimiter()); fileCopyInfo.setTdTpdid(TDImportRunnableMain.getTdTpdid()); // putting element to structure addToQueue(fileName, fileCopyInfo); } catch (Exception err) { LOGGER.error("Error adding file to queue ", err); throw new BDREException(err); } // *End* Eligible files moved to data structure for ingestion to HDFS }
From source file:com.cloud.agent.api.SecurityIngressRulesCmd.java
public SecurityIngressRulesCmd(String guestIp, String guestMac, String vmName, Long vmId, String signature, Long seqNum, IpPortAndProto[] ruleSet) { super();/*from w w w.j a va 2 s . c o m*/ this.guestIp = guestIp; this.vmName = vmName; this.ruleSet = ruleSet; this.guestMac = guestMac; this.signature = signature; this.seqNum = seqNum; this.vmId = vmId; if (signature == null) { String stringified = stringifyRules(); this.signature = DigestUtils.md5Hex(stringified); } }
From source file:corner.payment.services.impl.view.AlipayViewHelper.java
/** * @see corner.payment.services.ViewHelper#sign() *//*from w ww .j a v a 2s . c o m*/ @Override public void sign() { String[] signParameter = new String[] { "charset", "description", "defaultbank", "notify_url", "order", "account", "payment_type", "paymethod", "return_url", "seller", "service", "show_url", "subject", "total_fee" }; StringBuffer sb = new StringBuffer(); for (String p : signParameter) { String v = this.getOptionValue(p); if (v == null) { continue; } sb.append(this.getFieldNameMapped(p)); sb.append("="); sb.append(v); sb.append("&"); } sb.setLength(sb.length() - 1); sb.append(this.key); System.out.println("from corner:"); System.out.println(sb.toString()); this.addField("sign", DigestUtils.md5Hex(sb.toString())); this.addField("sign_type", "MD5"); }