Example usage for org.apache.commons.codec.digest DigestUtils md5Hex

List of usage examples for org.apache.commons.codec.digest DigestUtils md5Hex

Introduction

In this page you can find the example usage for org.apache.commons.codec.digest DigestUtils md5Hex.

Prototype

public static String md5Hex(String data) 

Source Link

Usage

From source file:com.betel.flowers.service.UsuarioService.java

public Boolean insert(Usuario usuario) {
    Boolean exito = Boolean.FALSE;
    Usuario axu = this.findByCodigo(usuario);
    if (axu.getId() == null) {
        usuario.setUsername(usuario.getUsername().trim());
        usuario.setCodigo(this.obtenerCodigo());
        usuario.setPassword(DigestUtils.md5Hex(usuario.getPassword()));
        usuario.setFlag(1);/*from w  ww. j  ava2 s .c  o  m*/
        this.ds.save(usuario);
        exito = Boolean.TRUE;
    }
    return exito;
}

From source file:duoc.cl.dej4501.DejMobile.Presentacion.ValidaUsuarioServlet.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession sesion = request.getSession();
    String rut = request.getParameter("txtRut");
    String clave = DigestUtils.md5Hex(request.getParameter("txtClave"));
    ClienteComunasDTO infoClienteComunasDTO = this.objClienteSessionBeans.ClienteValidaLogin(rut, clave);
    if (infoClienteComunasDTO != null) {
        sesion.setAttribute("usuarioConectado", infoClienteComunasDTO);
        response.sendRedirect("Menu.jsp");
    } else {/*from   w  w  w  .j  a  v  a  2 s.c o m*/
        sesion.setAttribute("msgError", "Usuario y/o Clave incorrecta");
        response.sendRedirect("Login.jsp");
    }
}

From source file:com.opengamma.web.bundle.WebProdBundleResource.java

@GET
public Response get(@PathParam("bundleId") String idStr, @Context Request request) {
    Bundle bundle = data().getBundleManager().getBundle(idStr);
    if (bundle == null) {
        return null;
    }/*from   w  w w .ja va 2s.  c o  m*/
    String compressedContent = data().getCompressor().compressBundle(bundle);
    EntityTag etag = new EntityTag(DigestUtils.md5Hex(compressedContent));
    ResponseBuilder builder = request.evaluatePreconditions(etag);
    if (builder == null) {
        BundleType type = BundleType.getType(idStr);
        String mimeType = null;
        switch (type) {
        case JS:
            mimeType = "text/javascript";
            break;
        case CSS:
            mimeType = "text/css";
            break;
        default:
            mimeType = MediaType.TEXT_HTML;
            break;
        }
        builder = Response.ok(compressedContent).header("Content-type", mimeType);
    }
    return builder.tag(etag).build();
}

From source file:br.com.mandado.bean.AutenticacaoBean.java

/**
 * @return/*  w  ww .  j  a v a  2  s.co m*/
 */
public String autenticar() {
    try {
        UsuarioDAO usuarioDAO = new UsuarioDAO();
        usuarioLogado = usuarioDAO.autenticar(usuarioLogado.getCpf(),
                DigestUtils.md5Hex(usuarioLogado.getSenha()));

        if (usuarioLogado == null) {
            FacesUtil.adicionarMsgErro("CPF e/ou senha invlidos");
            return null;
        } else {
            FacesUtil.adicionarMsgInfo("Usurio autenticado com sucesso!");
            return "/pages/principal.xhtml?faces-redirect=true";
        }
    } catch (RuntimeException ex) {
        FacesUtil.adicionarMsgErro("Erro ao tentar autenticar no sistema: " + ex.getMessage());
        return null;
    }
}

From source file:it.isislab.dmason.util.SystemManagement.Worker.Digester.java

public String getDigest(byte 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.haulmont.cuba.core.sys.encryption.Md5EncryptionModule.java

@Override
public String getPlainHash(String content) {
    return DigestUtils.md5Hex(content);
}

From source file:amfservices.navigate.Authenticate.java

public static Map<String, Object> authenticateSystem(SessionCache sessions, Map<String, Object> params) {
    String sid = null;/*from w ww. ja  va2 s .c o m*/
    try {
        Map<String, Object> data = (Map) params.get("data");

        String uid = (String) data.get(PGMacro.UID);
        String adminPass = (String) data.get(PGMacro.SIGNED_REQUEST);

        PGException.Assert(
                PGConfig.inst().temp().AdminTool_UID().equals(uid)
                        || UserList.getList(UserList.ListType.SYSTEM_ACCOUNT).contains(uid),
                PGError.INVALID_USER, "User " + uid + " not be system account");

        String md5Pass = DigestUtils.md5Hex(adminPass);
        PGException.Assert(PGConfig.inst().temp().SystemPasswordMD5().equals(md5Pass),
                PGError.INVALID_SIGNED_REQUEST, "User password are wrong!");

        sid = PGHelper.randomGUID();
        sessions.putSession(sid, uid);
    } finally {
        EntityPool.inst().releaseAllThreadResources();
        PGLog.info("authenticateSystem release resources");
    }

    Map<String, Object> resp = new HashMap(1);
    Map<String, Object> data = new HashMap(1);
    data.put(PGMacro.SID, sid);
    resp.put("data", data);
    return resp;
}

From source file:com.dp2345.controller.admin.ProfileController.java

/**
 * ???// ww w  .ja v  a 2 s . co  m
 */
@RequestMapping(value = "/check_current_password", method = RequestMethod.GET)
public @ResponseBody boolean checkCurrentPassword(String currentPassword) {
    if (StringUtils.isEmpty(currentPassword)) {
        return false;
    }
    Admin admin = adminService.getCurrent();
    if (StringUtils.equals(DigestUtils.md5Hex(currentPassword), admin.getPassword())) {
        return true;
    } else {
        return false;
    }
}

From source file:alluxio.shell.command.ChecksumCommandTest.java

/**
 * Tests md5 checksum calculation.//  ww  w.j  a v  a 2 s  . co m
 */
@Test
public void checksum() throws IOException {
    FileSystemTestUtils.createByteFile(mFileSystem, "/testFile", WriteType.MUST_CACHE, 10);
    mFsShell.run("checksum", "/testFile");
    String str = mOutput.toString();
    String[] splitString = str.split("\\s+");

    byte[] data = BufferUtils.getIncreasingByteArray(10);
    try {
        String expectedMd5 = DigestUtils.md5Hex(data);
        Assert.assertEquals(splitString[1], expectedMd5);
    } catch (Exception e) {
        Assert.fail("md5cksum failure not expected: " + e.getMessage());
    }
}

From source file:br.com.sigcopex.bean.AutenticacaoBean.java

public String autenticar() {
    try {/*  w ww  . j a  v a  2  s .  c  om*/
        UsuarioDAO usuarioDAO = new UsuarioDAO();
        usuarioLogado = usuarioDAO.autenticar(usuarioLogado.getCpf(),
                DigestUtils.md5Hex(usuarioLogado.getSenha()));
        usuarioAtivo = usuarioLogado;
        if (usuarioLogado == null) {
            FacesUtil.adicionarMsgError("CPF e/ou senha invlido(s)");
            return null;
        } else {
            FacesUtil.adicionarMsgInfo("Usurio autenticado com sucesso: " + usuarioLogado.getNome());
            return "/pages/principal.xhtml?faces-redirect=true";
        }

    } catch (RuntimeException ex) {
        FacesUtil.adicionarMsgError("Erro ao tentar autenticar no sistema: " + ex.getMessage());
        return null;
    }

}