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.thoughtworks.go.util.CachedDigestUtilsTest.java

@Test
public void shouldComputeForAnEmptyStringUsingMD5() {
    String fingerprint = "";
    String computeMD5 = CachedDigestUtils.md5Hex(fingerprint);
    assertThat(computeMD5, is(DigestUtils.md5Hex(fingerprint)));
}

From source file:br.com.railsos.os.bean.LoginBean.java

public void salvar() {
    try {//from w w w.  j a v  a 2  s  . c om
        LoginDAO loginDAO = new LoginDAO();
        login.setPassword(DigestUtils.md5Hex(login.getPassword()));
        loginDAO.merge(login);

        login = new Login();

        logins = loginDAO.listar();

        Messages.addGlobalInfo("Usurio salvo com sucesso");
    } catch (RuntimeException erro) {
        Messages.addFlashGlobalError("Ocorreu um erro ao tentar salvar um novo usurio");
        erro.printStackTrace();
    }
}

From source file:com.haulmont.cuba.core.sys.remoting.discovery.StaticServerSelector.java

protected void initSelectorId() {
    id = DigestUtils.md5Hex(baseUrl);
    log.trace("Selector id for '" + baseUrl + "' is '" + id + "'");
}

From source file:com.payu.sdk.helper.SignatureHelper.java

/**
 * builds the signature for the transaction
 *
 * @param order The order that will have the signature
 * @param merchantId The merchantId into the signature
 * @param key The apiKey of the merchant
 * @param valueFormat The format to use for decimal values
 * @param algorithm The algorithm to use
 * @return the full signature to use// www  . ja  va 2 s  .c o m
 */
public static String buildSignature(Order order, Integer merchantId, String key, String valueFormat,
        String algorithm) {

    String message = buildMessage(order, merchantId, key, valueFormat);

    if (MD5_ALGORITHM.equalsIgnoreCase(algorithm)) {
        return DigestUtils.md5Hex(message);
    } else if (SHA_ALGORITHM.equalsIgnoreCase(algorithm)) {
        return DigestUtils.shaHex(message);
    } else {
        throw new IllegalArgumentException("Could not create signature. Invalid algoritm");
    }
}

From source file:com.pzy.jcook.project.web.FrontController.java

@RequestMapping(value = "login", method = RequestMethod.POST)
public String login(Model model, String username, String password, HttpServletRequest req) {
    User user = userService.findByUsername(username);
    if (user != null && user.getPassword().equals(DigestUtils.md5Hex(password))) {
        req.getSession().setAttribute("webuser", user);
        return "web/car";
    } else/*from w  ww .j a v a 2  s  .com*/

        return "web/login";
}

From source file:br.com.parceriasistemas.jsf.cd.bean.UsuarioCon.java

public String logarUsuarioBean() throws Exception {
    UsuarioDao usuDao = new UsuarioDao();
    Usuario us;//  w  w w . j a va  2s . c  om
    String resultado;
    try {
        String encript = DigestUtils.md5Hex(this.obj.getSenhaUsuario());
        this.obj.setSenhaUsuario(encript);

        us = usuDao.verificarDadosLoginBanco(this.obj);
        if (us != null) {
            this.nomeUsuarioLogado = us.getNomeUsuario();
            this.idUsuarioLogado = us.getIdUsuario();
            FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("usuario", us);

            resultado = "/pages/pageWelcome.xhtml?faces-redirect=true";
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_INFO, "Sucesso!", "Usurio Logado"));
        } else {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
                    "Erro de Login!", "Usurio ou Senha Invlida"));
            resultado = "/login.xhtml?faces-redirect=false";
        }
    } catch (Exception e) {
        throw e;
    }
    System.out.println("resultado: " + resultado);
    return resultado;
}

From source file:corner.encrypt.services.impl.MD5EncryptServiceImpl.java

/**
 * @see corner.encrypt.EncryptService#encrypt(java.lang.String)
 */
@Override
public String encrypt(String src) {
    return DigestUtils.md5Hex(src);
}

From source file:com.fatwire.dta.sscrawler.reporting.reporters.SameContentPageletReporter.java

public synchronized void addToReport(final ResultPage page) {
    if (page.getResponseCode() == 200 && CacheHelper.shouldCache(page.getResponseHeaders())) {
        final String hex = DigestUtils.md5Hex(page.getBody());
        List<QueryString> x = map.get(hex);
        if (x == null) {
            x = new ArrayList<QueryString>();
            map.put(hex, x);//from  ww  w.  j a  va 2  s . c o m
        }
        x.add(page.getUri());
    }
}

From source file:com.zb.app.biz.service.WeixinTest.java

public void login() {
    httpClient = new HttpClient();
    PostMethod post = new PostMethod(loginUrl);
    post.addParameter(new NameValuePair("username", account));
    post.addParameter(new NameValuePair("pwd", DigestUtils.md5Hex(password)));
    post.addParameter(new NameValuePair("imgcode", ""));
    post.addParameter(new NameValuePair("f", "json"));
    post.setRequestHeader("Host", "mp.weixin.qq.com");
    post.setRequestHeader("Referer", "https://mp.weixin.qq.com/cgi-bin/loginpage?t=wxm2-login&lang=zh_CN");

    try {//  ww w  . ja v  a 2 s. c o  m
        int code = httpClient.executeMethod(post);
        if (HttpStatus.SC_OK == code) {
            String res = post.getResponseBodyAsString();
            JSONParser parser = new JSONParser();
            JSONObject obj = (JSONObject) parser.parse(res);
            JSONObject _obj = (JSONObject) obj.get("base_resp");
            @SuppressWarnings("unused")
            String msg = (String) _obj.get("err_msg");
            String redirect_url = (String) obj.get("redirect_url");
            Long errCode = (Long) _obj.get("ret");
            if (0 == errCode) {
                isLogin = true;
                token = StringUtils.substringAfter(redirect_url, "token=");
                if (null == token) {
                    token = StringUtils.substringBetween(redirect_url, "token=", "&");
                }
                StringBuffer cookie = new StringBuffer();
                for (Cookie c : httpClient.getState().getCookies()) {
                    cookie.append(c.getName()).append("=").append(c.getValue()).append(";");
                }
                this.cookiestr = cookie.toString();
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.nec.harvest.provider.PageProvider.java

/**
 * Get relative URL for every resources with product version
 * /* w  ww .  ja v a 2  s.  co  m*/
 * @param relativeUrl
 * @return
 * @throws IOException
 */
protected String addVersionOnUrl(String relativeUrl) throws IOException {
    String version;

    try {
        version = ProductHelper.getProductInfor().getVersion();
    } catch (Exception ex) {
        version = ProductHelper.getProductInfor().getProjectVersion();
    }

    relativeUrl += QUESTION_CHARACTER;
    relativeUrl += REVISION_PARAMS;
    relativeUrl += EQUALS_CHARACTER;
    relativeUrl += DigestUtils.md5Hex(version);
    return relativeUrl;
}