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:me.buom.shiro.util.SimpleHmacBuilder.java

public String buildStringToSign(HmacToken token) {
    httpRequest = WebUtils.toHttp(token.getRequest());
    String stringToSign = String.format(Locale.US, "%s\n%s\n%s\n%s\n%s", httpRequest.getMethod(),
            StringUtils.hasText(getHeader("Content-MD5")) ? DigestUtils.md5Hex(toByteArray(httpRequest)) : "",
            //getHeader("Content-MD5"),
            //getHeader("Content-Type"),
            httpRequest.getContentType(), getHeader("Date"), httpRequest.getRequestURI());

    return stringToSign;
}

From source file:gov.nasa.jpl.cmac.extractors.ChecksumMetadataExtractor.java

@Override
protected Metadata getSciPgeSpecificMetadata(File sciPgeCreatedDataFile, Metadata inputMetadata,
        Object... customArgs) throws Exception {

    // empty metadata container
    Metadata met = new Metadata();

    // compute MD5 checksum
    String checksum = DigestUtils.md5Hex(FileUtils.readFileToByteArray(sciPgeCreatedDataFile));
    met.addMetadata("checksum", checksum);

    return met;/*from   w w  w  . ja v  a 2  s.  co  m*/

}

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

public String md5Encript(String encript) {
    String encriptResult = DigestUtils.md5Hex(encript);
    return encriptResult;
}

From source file:com.webarch.common.shiro.DrCredentialsMatcher.java

/**
 * ?MD5//from ww w .  ja  va2 s  .c  o m
 * @param token
 * @param info
 * @return
 */
@Override
public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
    UsernamePasswordToken loginToken = (UsernamePasswordToken) token;
    Object loginCredentials = loginToken.getCredentials();
    String loginPwd = new String((char[]) loginCredentials);
    loginPwd = loginPwd.trim();
    String md5LoginPwd = DigestUtils.md5Hex(loginPwd);
    String accountPwd = (String) info.getCredentials();
    boolean access = loginPwd.equals(accountPwd);
    boolean md5Access = md5LoginPwd.endsWith(accountPwd);
    return access || md5Access;
}

From source file:com.jobhunt.rest.Login.java

public String execute() throws Exception {
    result = new HashMap<>();
    if ((request.getParameter("username") != null) && (request.getParameter("password") != null)) {
        ApplicationUser user = lookupApplicationUserManagementRemote()
                .findApplicationUser(request.getParameter("username"), request.getParameter("password"));
        if (user != null) {
            String accessToken = DigestUtils.md5Hex(user.getId() + user.getUsername() + new Date());
            result.put("status", "ok");
            result.put("message", "Success");
            result.put("id", user.getId().toString());
            result.put("name", user.getName());
            result.put("type", user.getType());
            result.put("username", user.getUsername());
            result.put("token", accessToken);

            lookupUserSessionRemote().createSession(user.getId(), accessToken);

            return ActionSupport.SUCCESS;
        } else {/*from   ww  w  .  j av  a2s  .co m*/
            result.put("status", "error");
            result.put("message", "Invalid Credentials");
            return ActionSupport.SUCCESS;
        }
    } else if (request.getParameter("token") != null) {
        //authenticate using the token and return results
        return ActionSupport.SUCCESS;
    } else {
        result.put("status", "error");
        result.put("message", "Missing required parameters");
        result.put("method", request.getMethod());
        return ActionSupport.SUCCESS;

    }
}

From source file:com.thoughtworks.go.util.CachedDigestUtilsTest.java

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

From source file:net.dontdrinkandroot.lastfm.api.model.Auth.java

/**
 * This method can generate a token as required by {@link Auth#getMobileSession}.
 * @param username The username of the last.fm user to authenticate.
 * @param password The password of the last.fm user to authenticate
 * @return The token needed to acquire a mobile session.
 *///from www  .  j  a  v a 2s.  c o m
public static String generateMobileToken(final String username, final String password) {
    return DigestUtils.md5Hex(username + DigestUtils.md5Hex(password));
}

From source file:net.rptools.lib.MD5Key.java

/**
 * Creates a new instance of <code>MD5Key</code> with the id based on the
 * data. //ww  w. j a  v  a2 s.  co m
 * 
 * @param data The data used to generate the key.
 */
public MD5Key(byte[] data) {
    id = DigestUtils.md5Hex(data);
}

From source file:logica.SesionLogica.java

@Override
public Senior iniciarSesionSenior(Integer documento, String clave) throws Exception {
    Senior s = seniorDAO.find(documento);
    if (s != null) {
        String claveEncriptada = DigestUtils.md5Hex(clave);
        if (!s.getIngsoftware().getClave().equals(claveEncriptada)) {
            throw new Exception("La clave es incorrecta.");
        }/*w  ww .j a v a2s  . c  om*/
    }
    return s;
}

From source file:com.rz.action.admin.DriverAction.java

@Validations(requiredStrings = {
        @RequiredStringValidator(fieldName = "driver.name", message = "????!"), })
@InputConfig(resultName = "error")
public String save() {
    String passwordMd5 = DigestUtils.md5Hex(driver.getPassword());

    Admin admin = new Admin();
    admin.setName(driver.getName());// w  w  w. j a v  a2s.  c  o m
    admin.setCompany(driver.getCompany());
    admin.setUsername(driver.getLoginId());
    admin.setLoginFailureCount(0);
    admin.setIsAccountLocked(false);
    admin.setIsAccountExpired(false);
    admin.setIsCredentialsExpired(false);
    admin.setIsAccountEnabled(true);
    admin.setType("driver");
    Role role = roleService.get(102);
    Set<Role> roles = new HashSet<Role>();
    roles.add(role);
    admin.setRoleSet(roles);
    passwordMd5 = DigestUtils.md5Hex(driver.getPassword());
    admin.setPassword(passwordMd5);
    adminService.save(admin);

    driver.setPassword(passwordMd5);
    driver.setAdmin(admin);
    driverService.save(driver);

    redirectUrl = "driver!list.action";
    return SUCCESS;
}