List of usage examples for org.apache.commons.codec.digest DigestUtils md5Hex
public static String md5Hex(String data)
From source file:be.solidx.hot.Script.java
public void setCode(byte[] code) { this.code = code; md5 = DigestUtils.md5Hex(code); }
From source file:com.napkindrawing.dbversion.Revision.java
public void assignUpgradeScriptTemplateChecksum() { upgradeScriptTemplateChecksum = DigestUtils.md5Hex(upgradeScriptTemplate); }
From source file:fll.web.DoLogin.java
/** * Does the work of login. Exists as a separate method so that it can be * called from {@link fll.web.admin.CreateUser} *//*from www . j a va 2s.c o m*/ public static void doLogin(final HttpServletRequest request, final HttpServletResponse response, final ServletContext application, final HttpSession session) throws IOException, ServletException { final DataSource datasource = ApplicationAttributes.getDataSource(application); Connection connection = null; try { connection = datasource.getConnection(); // check for authentication table if (Queries.isAuthenticationEmpty(connection)) { LOGGER.warn("No authentication information in the database"); session.setAttribute(SessionAttributes.MESSAGE, "<p class='error'>No authentication information in the database - see administrator</p>"); response.sendRedirect(response.encodeRedirectURL("login.jsp")); return; } // compute hash final String user = request.getParameter("user"); final String pass = request.getParameter("pass"); if (null == user || user.isEmpty() || null == pass || pass.isEmpty()) { LOGGER.warn("Form fields missing"); session.setAttribute(SessionAttributes.MESSAGE, "<p class='error'>You must fill out all fields in the form.</p>"); response.sendRedirect(response.encodeRedirectURL("login.jsp")); return; } final String hashedPass = DigestUtils.md5Hex(pass); // compare login information if (LOGGER.isTraceEnabled()) { LOGGER.trace("Checking user: " + user + " hashedPass: " + hashedPass); } final Map<String, String> authInfo = Queries.getAuthInfo(connection); for (final Map.Entry<String, String> entry : authInfo.entrySet()) { if (user.equals(entry.getKey()) && hashedPass.equals(entry.getValue())) { // clear out old login cookies first CookieUtils.clearLoginCookies(application, request, response); final String magicKey = String.valueOf(System.currentTimeMillis()); Queries.addValidLogin(connection, user, magicKey); CookieUtils.setLoginCookie(response, magicKey); String redirect = SessionAttributes.getRedirectURL(session); if (null == redirect) { redirect = "index.jsp"; } response.sendRedirect(response.encodeRedirectURL(redirect)); return; } else { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Didn't match user: " + entry.getKey() + " pass: " + entry.getValue()); } } } LOGGER.warn("Incorrect login credentials user: " + user); session.setAttribute(SessionAttributes.MESSAGE, "<p class='error'>Incorrect login information provided</p>"); response.sendRedirect(response.encodeRedirectURL("login.jsp")); return; } catch (final SQLException e) { throw new RuntimeException(e); } finally { SQLFunctions.close(connection); } }
From source file:com.openlattice.mail.gravatar.Gravatar.java
public URL getUrl(String email) { String emailHash = DigestUtils.md5Hex(email.toLowerCase().trim()); String params = formatUrlParameters(); try {/* w ww . j a v a 2s.c o m*/ URL url = new URL(GRAVATAR_URL + emailHash + params); return url; } catch (MalformedURLException e) { logErrorAndSendEmailReport(e); } return null; }
From source file:duoc.cl.dej4501.DejMobile.Presentacion.RegistrarClienteServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession sesion = request.getSession(); String rut = request.getParameter("txtRut"); if (objClienteSessionBeans.validarRut(rut) == false) { sesion.setAttribute("rutInvalidoMsg", "Rut ingresado no es valido"); request.getRequestDispatcher("./RegistroCliente.jsp").forward(request, response); }/*w w w.ja v a 2 s .c o m*/ if (objClienteSessionBeans.buscaUsuarioXRut(rut) != null) { sesion.setAttribute("rutInvalidoMsg", "Rut ingresado ya se encuentra en el sistema"); request.getRequestDispatcher("./RegistroCliente.jsp").forward(request, response); } String clave = DigestUtils.md5Hex(request.getParameter("txtClave")); String confirmarClave = DigestUtils.md5Hex(request.getParameter("txtConfirmarClave")); if (clave.equals(confirmarClave) == false) { sesion.setAttribute("claveInvalidaMsg", "Password invalida"); response.sendRedirect("RegistroCliente.jsp"); } String nombre = request.getParameter("txtNombre"); String apellidoPaterno = request.getParameter("txtApellidoPaterno"); String apellidoMaterno = request.getParameter("txtApellidoMaterno"); String direccion = request.getParameter("txtDireccion"); int numeracion = Integer.parseInt(request.getParameter("txtNumeracion")); int comuna = Integer.parseInt(request.getParameter("ddlComuna")); int telefono = Integer.parseInt(request.getParameter("txtTelefono")); ClienteDTO infoClienteDTO = new ClienteDTO(rut, clave, nombre, apellidoPaterno, apellidoMaterno, direccion, numeracion, comuna, telefono); try { objClienteSessionBeans.addCliente(infoClienteDTO); sesion.setAttribute("msgCorrecto", "Cliente Ingresado de forma correcta"); response.sendRedirect("Login.jsp"); } catch (Exception ex) { sesion.setAttribute("msgError", "Cliente no pudo ingresar a la base de datos"); response.sendRedirect("RegistroCliente.jsp"); } }
From source file:com.easarrive.aws.plugins.common.service.impl.SQSNotificationService.java
/** * {@inheritDoc}// w ww . j a va2 s . com */ @Override public boolean isSignatureMessageValid(Message message) { if (message == null) { return false; } String md5MessageBody = message.getMD5OfBody(); if (StringUtil.isEmpty(md5MessageBody)) { return false; } String messageBody = message.getBody(); try { return md5MessageBody.equals(DigestUtils.md5Hex(messageBody)); } catch (Exception e) { return false; } }
From source file:io.seldon.memcache.SecurityHashPeer.java
/** * Uses {@link DigestUtils}.// ww w.jav a2 s . com * @param input - string to hash * @return a hex encoded string */ public static String md5digest(String input) { return DigestUtils.md5Hex(input); }
From source file:com.espe.distribuidas.protocolocajero.pc.Cabecera.java
public void setVerificacion(String verificacion) { //System.out.println(verificacion); String rs1 = DigestUtils.md5Hex(verificacion); this.verificacion = rs1; }
From source file:com.granule.CompressorHandler.java
public void handle(HttpServletRequest request, HttpServletResponse response, String id) throws IOException, ServletException { if (id != null) { CompressorSettings settings = TagCacheFactory .getCompressorSettings(request.getSession().getServletContext().getRealPath("/")); CachedBundle bundle;// ww w . j a v a2 s . c o m try { bundle = TagCacheFactory.getInstance().getCompiledBundle(new RealRequestProxy(request), settings, id); } catch (JSCompileException e) { throw new ServletException(e); } if (bundle == null) { response.setStatus(404); return; } response.setHeader("Content-Type", bundle.getMimeType() + "; charset=utf-8"); response.setHeader("ETag", DigestUtils.md5Hex(bundle.getBundleValue())); HttpHeaders.setCacheExpireDate(response, 6048000); OutputStream os = response.getOutputStream(); try { if (settings.isGzipOutput() && gzipSupported(request)) { response.setHeader("Content-Encoding", "gzip"); os.write(bundle.getBundleValue()); } else { bundle.getUncompressedScript(os); } os.flush(); } finally { os.close(); } } }
From source file:me.adaptive.che.infrastructure.vfs.WorkspaceIdLocalFSMountStrategy.java
public static String getWorkspaceFolderName(Long workspaceId) { return DigestUtils.md5Hex(workspaceId.toString()); }