List of usage examples for org.apache.commons.codec.digest DigestUtils md5Hex
public static String md5Hex(String data)
From source file:es.uvigo.ei.sing.gc.view.models.PasswordRecoveryViewModel.java
@Command public void changePassword() { if (this.isPasswordOk()) { final Session session = HibernateUtil.currentSession(); final User user = ZKUtils.hLoad(User.class, this.email, session); user.setPassword(DigestUtils.md5Hex(this.newPassword)); session.persist(user);//from www .ja va2s . co m session.flush(); Messagebox.show("Password successfully changed. Press 'Ok' to go to the login page.", "Password Changed", Messagebox.OK, Messagebox.INFORMATION, new EventListener<Event>() { @Override public void onEvent(Event event) throws Exception { Executions.sendRedirect("index.zul"); } }); } }
From source file:de.uzk.hki.da.cb.CheckFormatsAction.java
/** * Scans every file in files with jhove and sets the pathToJhoveOutput * property accordingly/*w w w . j a v a2 s .co m*/ * * @param files * @throws IOException * @throws SubsystemNotAvailableException */ private void attachJhoveInfoToAllFiles(List<DAFile> files) throws IOException, SubsystemNotAvailableException { for (DAFile f : files) { // dir String dir = Path.make(wa.dataPath(), WorkArea.TMP_JHOVE, f.getRep_name()).toString(); String fileName = DigestUtils.md5Hex(f.getRelative_path()); if (!new File(dir).exists()) new File(dir).mkdirs(); if (f.getRelative_path().toLowerCase().equals("premis.xml") || !f.getRelative_path().toLowerCase().endsWith(".xml")) { File target = Path.makeFile(dir, fileName); logger.debug("will write jhove output to: " + target); try { if (!fileFormatFacade.extract(wa.toFile(f), target, f.getFormatPUID())) throw new RuntimeException("Unknown error during metadata file extraction."); } catch (ConnectionException e) { throw new SubsystemNotAvailableException("fileFormatFacade.extract() could not connect.", e); } } else logger.debug("Skipping jhove validation for xml file " + f.getRelative_path()); } }
From source file:mashup.fm.oauth.provider.MashupOAuthProvider.java
/** * Generate access token./*w ww . j a va 2 s .c om*/ * * @param accessor * the accessor * @throws OAuthException * the o auth exception */ public static synchronized OAuthAccessor generateAccessToken(OAuthAccessor accessor) throws OAuthException { Logger.info("Generate Access Token: %s", accessor); // generate oauth_token and oauth_secret String consumer_key = accessor.consumer.consumerKey; // generate token and secret based on consumer_key // for now use md5 of name + current time as token String token_data = consumer_key + System.nanoTime(); String token = DigestUtils.md5Hex(token_data); // first remove the accessor from cache // ALL_TOKENS.remove(accessor); accessor.requestToken = null; accessor.accessToken = token; // update token in local cache // ALL_TOKENS.add(accessor); return accessor.save(); }
From source file:com.easarrive.image.thumbor.executer.controller.ThumborConfigureController.java
/** * ??/* w ww.j ava2s . c o m*/ * * @param request * @param response ? * @return ?? */ @RequestMapping(value = "/reload", method = { RequestMethod.POST }) @ResponseBody public DataDeliveryWrapper<Boolean> reloadConfig(HttpServletRequest request, HttpServletResponse response) { //?? String acceptEncoding = this.getAcceptEncoding(request); try { String version = request.getHeader("VERSION"); String sign = request.getHeader("DATA_SIGN"); String charset = request.getHeader("CHARSET"); //?? String dataJson = this.getRequestBody(request); //? if (StringUtil.isEmpty(charset)) { charset = request.getCharacterEncoding(); } if (StringUtil.isEmpty(charset)) { charset = Constant.Charset.UTF8; } // if (StringUtil.isEmpty(version)) { return new DataDeliveryWrapper<Boolean>(HttpStatus.SC_NOT_FOUND, this.encode("", acceptEncoding), false); } else if (!"1.0.0.0.1".equals(version)) { return new DataDeliveryWrapper<Boolean>(HttpStatus.SC_NOT_FOUND, this.encode("??", acceptEncoding), false); } else if (StringUtil.isEmpty(sign)) { return new DataDeliveryWrapper<Boolean>(HttpStatus.SC_NOT_FOUND, this.encode("??", acceptEncoding), false); } else if (StringUtil.isEmpty(dataJson)) { return new DataDeliveryWrapper<Boolean>(HttpStatus.SC_NOT_FOUND, this.encode("?", acceptEncoding), false); } String signTemp = DigestUtils.md5Hex(dataJson); if (!sign.equals(signTemp)) { return new DataDeliveryWrapper<Boolean>(HttpStatus.SC_FORBIDDEN, this.encode("??", acceptEncoding), false); } ConfigureFactory.clear(); // ThumborConfigure configure = ConfigureFactory.getConfigure(); // if (logger.isInfoEnabled()) { // logger.info("?? {}", configure); // } ThumborConfigureMap configureMap = ConfigureFactory.getConfigureMap(); if (logger.isInfoEnabled()) { logger.info("?? {}", configureMap); } return new DataDeliveryWrapper<Boolean>(HttpStatus.SC_OK, this.encode("Thumbor ???", acceptEncoding), true); } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error("Thumbor ?", e); } return new DataDeliveryWrapper<Boolean>(HttpStatus.SC_INTERNAL_SERVER_ERROR, this.encode("Thumbor ??", acceptEncoding), false); } }
From source file:de.logicline.splash.service.UserServiceImpl.java
@Transactional public UserEntity createWebAccount(String userId) { ContactEntity ce = contactDao.getContactByUserId(userId); String clearTextPassword = new PasswordGenerator().generatePswd(10, 10, 2, 2, 2); String password = BCrypt.hashpw(clearTextPassword, BCrypt.gensalt(12)); UserEntity ue = userDao.find(userId); if (ue == null) { ue = new UserEntity(); ue.setUserId(ce.getUserIdFk());//from w w w. ja v a 2s . c o m ue.setUsername(ce.getLastName()); ue.setPassword(password); ue.setClearTextPasswd(clearTextPassword); String token = DigestUtils.md5Hex(password + ce.getLastName()); ue.setToken(token); ue.setRole(Enums.UserRole.ROLE_CUSTOMER.name()); userDao.create(ue); } ue.setPassword(password); ue.setClearTextPasswd(clearTextPassword); userDao.edit(ue); return ue; }
From source file:com.glaf.core.web.rest.MxFileSystemResource.java
@GET @POST//w w w .j a v a 2 s . c om @Path("/dir") @ResponseBody @Produces({ MediaType.APPLICATION_OCTET_STREAM }) public byte[] dir(@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; LogUtils.debug("root:" + root); 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.isDirectory()) { 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", "folder"); json.put("leaf", false); json.put("isParent", true); array.add(json); } } } } LogUtils.debug(array.toJSONString()); return array.toJSONString().getBytes("UTF-8"); }
From source file:de.bps.onyx.util.SummaryCheckSumValidator.java
private static SummaryChecksumValidatorResult internalValidate(final String html) { final SummaryChecksumValidatorResult result = new SummaryChecksumValidatorResult(); // determine hashed HTML content final int start = html.indexOf(" <div class=\"test\">"); if (start > 0) { final int end = html.indexOf(" <div class=\"hash\">", start); if (end > 0) { final String toHash = html.substring(start, end); // if (log.isDebugEnabled()) { // log.debug("HTML to validate: " + toHash); // } // determine hash int startHash = html.indexOf(STRONG, end); if (startHash > 0) { startHash += STRONG.length(); final int endHash = html.indexOf("</strong>", startHash); if (endHash > 0) { final String hash = html.substring(startHash, endHash); // compare final String toCompare = DigestUtils.md5Hex(toHash); final boolean equal = hash.equals(toCompare); // if (log.isDebugEnabled()) { // log.debug("Hash to validate: " + hash); // log.debug("Hash to compare : " + toCompare); // log.debug("Equal: " + equal); // } if (equal) { result.result = "OK"; result.validated = true; return result; }/*ww w . j av a2s .co m*/ } else { result.result = "onyx.summary.validation.result.hash.end.not.found"; } } else { result.result = "onyx.summary.validation.result.hash.start.not.found"; } } else { result.result = "onyx.summary.validation.result.content.end.not.found"; } } else { result.result = "onyx.summary.validation.result.content.start.not.found"; } return result; }
From source file:com.k42b3.kadabra.FileMap.java
private static void build(HandlerAbstract handler, StringBuilder resp, String path) throws Exception { Item[] files = handler.getFiles(path); for (int i = 0; i < files.length; i++) { Item item = files[i];/* w w w . j ava2 s . c o m*/ // check whether not current or up dir if (item.getName().equals(".") || item.getName().equals("..") || item.getName().equals(FileMap.getFileName())) { continue; } if (item.isDirectory()) { resp.append("<dir name=\"" + item.getName() + "\">\n"); build(handler, resp, path + "/" + item.getName()); resp.append("</dir>\n"); } if (item.isFile()) { byte[] content = handler.getContent(path + "/" + item.getName()); String md5 = DigestUtils.md5Hex(Kadabra.normalizeContent(content)); resp.append("<file name=\"" + item.getName() + "\" md5=\"" + md5 + "\" />\n"); } } }
From source file:com.enderville.enderinstaller.util.InstallScript.java
/** * Checks the md5 of the minecraft.jar and whether the mods folder exists in * order to warn the user./*from w w w . j a v a 2s .co m*/ * * @return A string containing warnings for the user, or null if there were * none. */ public static String preInstallCheck() { //TODO check the number in .minecraft/bin/version file? try { InputStream mcJarIn = new FileInputStream(InstallerConfig.getMinecraftJar()); String digest = DigestUtils.md5Hex(mcJarIn); mcJarIn.close(); boolean jarValid = InstallerConfig.getMinecraftJarMD5().equalsIgnoreCase(digest); File modsDir = new File(InstallerConfig.getMinecraftModsFolder()); boolean noMods = !modsDir.exists() || modsDir.listFiles().length == 0; String msg = null; if (!jarValid) { msg = String.format("Your minecraft.jar has been modified or is not the correct version (%s).", InstallerConfig.getMinecraftVersion()); } if (!noMods) { msg = (msg == null ? "" : msg + "\n") + "You already have mods installed to the minecraft mods folder."; } return msg; } catch (Exception e) { LOGGER.error("Pre-installation check error", e); return "There was an error verifying your minecraft installation. " + e.getMessage(); } }
From source file:com.abiquo.server.core.enterprise.UserGenerator.java
@Deprecated public User createInstance(final Enterprise enterprise, final Role role, final String password, final String name, final String surname, final String email, final String nick) { String locale = newString(nextSeed(), 0, 255); User user = new User(enterprise, role, name, surname, email, nick, DigestUtils.md5Hex(password), locale, User.AuthType.ABIQUO);/*from w w w.j a va2 s. c o m*/ user.setActive(1); return user; }