List of usage examples for org.apache.commons.codec.digest DigestUtils md5Hex
public static String md5Hex(String data)
From source file:com.amazonaws.kinesis.agg.AggRecordTest.java
@Test public void shouldGenerateValidHashKeys() { final String expectedHashKeyHex = DigestUtils.md5Hex(partitionKey); final String expectedHashKeyDecimal = new BigInteger(expectedHashKeyHex, 16).toString(10); final AggRecord record = new AggRecord(); record.addUserRecord(partitionKey, null, "dummy data".getBytes()); Assert.assertThat(new BigInteger(expectedHashKeyDecimal).compareTo(MIN_VALID_HASHKEY) >= 0, is(true)); Assert.assertThat(new BigInteger(expectedHashKeyDecimal).compareTo(MAX_VALID_HASHKEY) <= 0, is(true)); Assert.assertThat(record.getExplicitHashKey(), equalTo(expectedHashKeyDecimal)); }
From source file:lt.emasina.resthub.server.query.QueryId.java
@Inject public QueryId(@Assisted String sql, CCJSqlParserManager pm) throws QueryException { try {//from w w w.j a v a2s . c om Statement stmt = pm.parse(new StringReader(sql)); if (stmt instanceof Select) { this.select = (Select) stmt; this.sql = SQL_FORMATTER.format(this.select.toString()); this.md5 = DigestUtils.md5Hex(this.sql); this.id = QueryFactory.nextUID(); } else { throw new QueryException("Only SELECT statements allowed!"); } } catch (JSQLParserException ex) { throw new QueryException(ex.getCause().getMessage()); } }
From source file:it.isislab.dmason.util.SystemManagement.Worker.Digester.java
public String getDigest(String data) { if (digestAlg.equals(DigestAlgorithm.MD2)) digest = DigestUtils.md5Hex(data); if (digestAlg.equals(DigestAlgorithm.MD5)) digest = DigestUtils.md5Hex(data); if (digestAlg.equals(DigestAlgorithm.SHA1)) digest = DigestUtils.sha256Hex(data); return digest; }
From source file:com.sonicle.webtop.mail.bol.js.JsTag.java
public JsTag(String tagId, String description, String color) { this.hashId = "tid" + DigestUtils.md5Hex(tagId); this.tagId = tagId; this.description = description; this.color = color; }
From source file:net.osxx.controller.admin.StatisticsController.java
/** * /*from w ww .j a v a 2s. c o m*/ */ @RequestMapping(value = "/setting", method = RequestMethod.POST) public String setting(@RequestParam(defaultValue = "false") Boolean isEnabled, RedirectAttributes redirectAttributes) { Setting setting = SettingUtils.get(); if (isEnabled) { if (StringUtils.isEmpty(setting.getCnzzSiteId()) || StringUtils.isEmpty(setting.getCnzzPassword())) { try { String createAccountUrl = "http://intf.cnzz.com/user/companion/osxx.php?domain=" + setting.getSiteUrl() + "&key=" + DigestUtils.md5Hex(setting.getSiteUrl() + "Lfg4uP0H"); URLConnection urlConnection = new URL(createAccountUrl).openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); String line = null; while ((line = in.readLine()) != null) { if (line.contains("@")) { break; } } if (line != null) { setting.setCnzzSiteId(StringUtils.substringBefore(line, "@")); setting.setCnzzPassword(StringUtils.substringAfter(line, "@")); } } catch (IOException e) { e.printStackTrace(); } } } setting.setIsCnzzEnabled(isEnabled); SettingUtils.set(setting); cacheService.clear(); addFlashMessage(redirectAttributes, SUCCESS_MESSAGE); return "redirect:setting.jhtml"; }
From source file:net.shopxx.controller.admin.StatisticsController.java
/** * // w w w .j a v a 2s. co m */ @RequestMapping(value = "/setting", method = RequestMethod.POST) public String setting(@RequestParam(defaultValue = "false") Boolean isEnabled, RedirectAttributes redirectAttributes) { Setting setting = SettingUtils.get(); if (isEnabled) { if (StringUtils.isEmpty(setting.getCnzzSiteId()) || StringUtils.isEmpty(setting.getCnzzPassword())) { try { String createAccountUrl = "http://intf.cnzz.com/user/companion/shopxx.php?domain=" + setting.getSiteUrl() + "&key=" + DigestUtils.md5Hex(setting.getSiteUrl() + "Lfg4uP0H"); URLConnection urlConnection = new URL(createAccountUrl).openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); String line = null; while ((line = in.readLine()) != null) { if (line.contains("@")) { break; } } if (line != null) { setting.setCnzzSiteId(StringUtils.substringBefore(line, "@")); setting.setCnzzPassword(StringUtils.substringAfter(line, "@")); } } catch (IOException e) { e.printStackTrace(); } } } setting.setIsCnzzEnabled(isEnabled); SettingUtils.set(setting); cacheService.clear(); addFlashMessage(redirectAttributes, SUCCESS_MESSAGE); return "redirect:setting.jhtml"; }
From source file:net.groupbuy.controller.admin.StatisticsController.java
/** * //ww w.ja v a 2s .co m */ @RequestMapping(value = "/setting", method = RequestMethod.POST) public String setting(@RequestParam(defaultValue = "false") Boolean isEnabled, RedirectAttributes redirectAttributes) { Setting setting = SettingUtils.get(); if (isEnabled) { if (StringUtils.isEmpty(setting.getCnzzSiteId()) || StringUtils.isEmpty(setting.getCnzzPassword())) { try { String createAccountUrl = "http://intf.cnzz.com/user/companion/groupbuy.php?domain=" + setting.getSiteUrl() + "&key=" + DigestUtils.md5Hex(setting.getSiteUrl() + "Lfg4uP0H"); URLConnection urlConnection = new URL(createAccountUrl).openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); String line = null; while ((line = in.readLine()) != null) { if (line.contains("@")) { break; } } if (line != null) { setting.setCnzzSiteId(StringUtils.substringBefore(line, "@")); setting.setCnzzPassword(StringUtils.substringAfter(line, "@")); } } catch (IOException e) { e.printStackTrace(); } } } setting.setIsCnzzEnabled(isEnabled); SettingUtils.set(setting); cacheService.clear(); addFlashMessage(redirectAttributes, SUCCESS_MESSAGE); return "redirect:setting.jhtml"; }
From source file:com.dp2345.controller.admin.StatisticsController.java
/** * // w w w . j a v a 2s . c o m */ @RequestMapping(value = "/setting", method = RequestMethod.POST) public String setting(@RequestParam(defaultValue = "false") Boolean isEnabled, RedirectAttributes redirectAttributes) { Setting setting = SettingUtils.get(); if (isEnabled) { if (StringUtils.isEmpty(setting.getCnzzSiteId()) || StringUtils.isEmpty(setting.getCnzzPassword())) { try { String createAccountUrl = "http://intf.cnzz.com/user/companion/dp2345.php?domain=" + setting.getSiteUrl() + "&key=" + DigestUtils.md5Hex(setting.getSiteUrl() + "Lfg4uP0H"); URLConnection urlConnection = new URL(createAccountUrl).openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); String line = null; while ((line = in.readLine()) != null) { if (line.contains("@")) { break; } } if (line != null) { setting.setCnzzSiteId(StringUtils.substringBefore(line, "@")); setting.setCnzzPassword(StringUtils.substringAfter(line, "@")); } } catch (IOException e) { e.printStackTrace(); } } } setting.setIsCnzzEnabled(isEnabled); SettingUtils.set(setting); cacheService.clear(); addFlashMessage(redirectAttributes, SUCCESS_MESSAGE); return "redirect:setting.jhtml"; }
From source file:com.msds.km.service.AbstractDrivingLicenseRecognitionServcie.java
/** * MD5??//w w w . ja v a 2 s .c o m * @return */ protected String getFileSignature(File file) { if (file == null || !file.exists()) { return null; } try { byte[] bytes = IOUtils.toByteArray(new FileInputStream(file)); return DigestUtils.md5Hex(bytes); } catch (FileNotFoundException e) { logger.error("file not founded", e); throw new RecognitionException(e); } catch (IOException e) { logger.error("io excepton", e); throw new RecognitionException(e); } }
From source file:com.odap.server.audit.ConfigHandler.java
public ConfigMessage registerNewServer(ConfigMessage config) throws TException { logger.info("Enter registerNewServer()"); ConfigMessage msg = new ConfigMessage(); QueryRunner qRunner = new QueryRunner(); Integer account_id = null;/*from w ww. j av a 2 s. c o m*/ Integer server_id = null; //Authenticate the user and get the account_id; String query = "SELECT * FROM joomla.cloud_users WHERE username = ? AND password = ?"; { String parameters[] = { config.getUsername().replaceAll("[^A-Za-z0-9 ]", ""), DigestUtils.md5Hex(config.getPassword().replaceAll("[^A-Za-z0-9 ]", "")) }; try { List<Map<String, Object>> mapList = (List<Map<String, Object>>) qRunner .query(AuditServer.connectionPool.getConnection(), query, new MapListHandler(), parameters); if (mapList.size() < 1) { logger.warn("Username " + config.getUsername() + " not authenticated"); return msg; } account_id = (Integer) mapList.get(0).get("account_id"); } catch (SQLException e) { logger.error("Issue finding user account", e); return msg; } } String session_id = nextSessionId(); { try { { query = "INSERT INTO servers (account_id,server_name,server_software,server_port,server_authentication_token,server_timezone,strip_predicates) VALUES (?,?,?,?,?,?,?)"; Object parameters[] = { account_id.toString(), config.getServer_name().replaceAll("[^A-Za-z0-9 ]", ""), config.getServer_software(), new Short(config.getPort()), session_id, new Double(config.getTimezone_offset()), config.strip_predicates }; qRunner.update(AuditServer.connectionPool.getConnection(), query, parameters); } { String parameters[] = { account_id.toString(), config.getServer_name(), session_id }; query = "SELECT * FROM servers WHERE account_id = ? AND server_name = ? and server_authentication_token = ?"; List<Map<String, Object>> mapList = (List<Map<String, Object>>) qRunner.query( AuditServer.connectionPool.getConnection(), query, new MapListHandler(), parameters); if (mapList.size() < 1) { logger.error("Unable to find server after after registering it"); return msg; } server_id = (Integer) mapList.get(0).get("id"); } } catch (SQLException e) { logger.error("Issue registering server", e); } } msg.token = session_id; msg.server_id = server_id.shortValue(); msg.server = "dbauditcloud.com"; logger.info("Exiting registerNewServer()"); return msg; }