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:io.muic.ooc.webapp.servlet.AddServlet.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    System.out.println("Add " + username);
    System.out.println("Add " + password);
    if (StringUtils.isBlank(username) && StringUtils.isBlank(password)) {
        String error = "Username or password is missing.";
        request.setAttribute("error", error);
        RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/add.jsp");
        rd.include(request, response);//  w w  w  .j a  va  2 s  .c om
    } else {
        try {
            if (mySQLService.findOne(username)) {
                String error = "This Username is already exist.";
                request.setAttribute("error", error);
                RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/add.jsp");
                rd.include(request, response);
            } else {
                String digest = DigestUtils.md5Hex(password);
                mySQLService.addDataBase(username, digest);
                response.sendRedirect("/");
            }
        } catch (Exception e) {

        }

    }
}

From source file:com.dlshouwen.core.api.controller.ApiController.java

/**
 * ??//from  w  w w .j  a v  a  2  s.  c o  m
 *
 * @param request
 * @param response
 * @throws Exception
 */
@RequestMapping(value = "/login")
public void login(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String loginName = request.getParameter("username");
    String password = request.getParameter("plainPassword");
    JSONObject obj = new JSONObject();
    Boolean flag = false;
    String msg = "";
    try {
        if (loginName != null && loginName.trim().length() > 0 && password != null
                && password.trim().length() > 0) {
            password = DigestUtils.md5Hex(password + "{loginname}");
            flag = secUserDao.queryUserByLoginNameAndPass(loginName, password);
            if (!flag) {
                msg = "????";
            }
        } else {
            msg = "????";
        }
    } catch (Exception ex) {
        msg = ",?";
        ex.printStackTrace();
    }
    obj.put("result", flag);
    obj.put("msg", msg);
    response.setContentType("text/html;charset=utf-8");
    response.getWriter().write(obj.toString());
}

From source file:com.funtl.framework.smoke.core.commons.persistence.redis.RedisCache.java

/**
 * key//from  w  ww. ja  va2s .c om
 */
private String getKey(Object key) {
    StringBuilder accum = new StringBuilder();
    accum.append(KEY_PREFIX);
    accum.append(this.id).append(":");
    accum.append(DigestUtils.md5Hex(String.valueOf(key)));
    return accum.toString();
}

From source file:com.eviware.loadui.impl.statistics.AbstractStatisticsWriter.java

public AbstractStatisticsWriter(StatisticsManager manager, StatisticVariable variable,
        Map<String, Class<? extends Number>> values, Map<String, Object> config,
        EntryAggregator entryAggregator) {
    this.config = config;
    this.variable = variable;
    id = DigestUtils.md5Hex(variable.getStatisticHolder().getId() + variable.getLabel() + getType());
    descriptor = new TrackDescriptorImpl(id, values, entryAggregator);
    delay = config.containsKey(DELAY) ? ((Number) config.get(DELAY)).longValue()
            : manager.getMinimumWriteDelay();

    // TODO//from w w  w . j  a va2s  .  c o  m
    if (LoadUI.isController())
        manager.getExecutionManager().registerTrackDescriptor(descriptor);

    aggregator = BeanInjector.getBean(StatisticsAggregator.class);
}

From source file:com.at.lic.LicenseControl.java

private void generateLicense(String licenseCheckCode) throws Exception {

    String lcc = licenseCheckCode;
    String lic_code = DigestUtils.md5Hex(lcc);
    String date = License.getSimpleDateFormat().format(new Date());

    StringBuilder sb = new StringBuilder();
    sb.append(lcc);//  w  w  w .j av a  2 s  . c om
    sb.append(lic_code);
    sb.append(date);

    byte[] signature = RSAKeyManager.sign(sb.toString());
    String sign_code = Base64.encodeBase64String(signature);

    License lic = new License();
    lic.setCheckCode(lcc);
    lic.setLicenseCode(lic_code);
    lic.setSignCode(sign_code);
    lic.setSignDate(date);

    File f = new File("cfg/grgbanking.lic");
    if (!f.exists()) {
        File pf = f.getParentFile();
        if (!pf.exists()) {
            pf.mkdirs();
        }
    } else {
        f.renameTo(new File(f.getAbsolutePath() + ".bak"));
    }
    Serializer serializer = new Persister();
    serializer.write(lic, f);

    log.info("Generating License Successful.");
}

From source file:alfio.manager.PaypalManager.java

private static String toWebProfileName(Event event, Locale locale, APIContext apiContext) {
    return "ALFIO-"
            + DigestUtils.md5Hex(apiContext.getClientID() + "-" + event.getId() + "-" + event.getShortName())
            + "-" + locale.toString();
}

From source file:eu.uqasar.web.upload.Gravatar.java

/**
 * Returns the Gravatar URL for the given email address.
 *//*  w w  w .  j av  a2  s.  c  o m*/
private String getUrl(String email) {
    Validate.notNull(email, "email");

    // hexadecimal MD5 hash of the requested user's lowercased email address
    // with all whitespace trimmed
    String emailHash = DigestUtils.md5Hex(email.toLowerCase().trim());
    String params = formatUrlParameters();
    return GRAVATAR_URL + emailHash + ".png" + params;
}

From source file:fr.ortolang.discovery.entity.EntityDescriptor.java

public void setEntityId(String entityId) {
    this.entityId = entityId;
    this.alias = DigestUtils.md5Hex(entityId);
}

From source file:com.endgame.binarypig.util.BuildSequenceFileFromDir.java

@Override
public int run(String[] args) throws Exception {

    File inDir = new File(args[0]);
    Path name = new Path(args[1]);

    Text key = new Text();
    BytesWritable val = new BytesWritable();

    Configuration conf = getConf();
    FileSystem fs = FileSystem.get(conf);
    SequenceFile.Writer writer = SequenceFile.createWriter(fs, conf, name, Text.class, BytesWritable.class,
            CompressionType.RECORD);/* ww  w.  j a v a2  s  .co  m*/

    for (File file : inDir.listFiles()) {
        if (!file.isFile()) {
            System.out.println("Skipping " + file + " (not a file) ...");
            continue;
        }

        byte[] bytes = FileUtils.readFileToByteArray(file);
        val.set(bytes, 0, bytes.length);
        key.set(DigestUtils.md5Hex(bytes));
        writer.append(key, val);
    }
    writer.close();

    return 0;
}

From source file:com.shenit.commons.codec.CodecUtils.java

/**
 * ?MD5/*from   www . j a v  a  2s. c  om*/
 * 
 * @param source
 * @param salt
 * @return
 */
public static String md5Hex(String source, String salt) {
    return DigestUtils
            .md5Hex(source + (salt == null ? StringUtils.EMPTY : (ShenStrings.DELIMITER_UNDERSCORE + salt)));
}