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

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

Introduction

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

Prototype

public static String sha512Hex(String data) 

Source Link

Usage

From source file:etc.uma.utils.StringUtils.java

public static String toSha512(String theString) {
    return DigestUtils.sha512Hex(theString);
}

From source file:DAO.ValidatorDAO.java

public String validate(String user, String pass) {
    pass = DigestUtils.sha512Hex(pass);
    SessionFactory sf = HibernateUtil.getSessionFactory();
    Session session = sf.openSession();//  w w w .jav a 2 s.com
    SQLQuery sQLQuery = session.createSQLQuery(sqlGeneratorLogin());
    sQLQuery.addEntity(Usuarios.class);
    sQLQuery.setString("user_id", user);
    sQLQuery.setString("pass", pass);
    Usuarios u = (Usuarios) sQLQuery.uniqueResult();
    if (u != null) {
        return u.getUsrToken();
    }
    return "Error";
}

From source file:fr.cnrs.sharp.reasoning.Interlinking.java

/**
 * Generates a Jena Model with an SHA-512 fingerprint of a file content.
 * @param inputRawFile the file to be fingerprinted
 * @return a Jena Model with an SHA-512, based on PROV and tavernaprov vocabularies.
 * @throws IOException/*from w w w .  j a  va2  s.  c o m*/
 */
public static Model fingerprint(Path inputRawFile) throws IOException {
    StopWatch sw = new StopWatch();
    sw.start();

    Model data = ModelFactory.createDefaultModel();

    Path p = inputRawFile;
    String label = p.getFileName().toString();
    System.out.println();

    FileInputStream fis = new FileInputStream(p.toFile());
    String sha512 = DigestUtils.sha512Hex(fis);

    StringBuffer sb = new StringBuffer();
    sb.append("@base         <http://fr.symetric> .\n" + "@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .\n"
            + "@prefix prov: <http://www.w3.org/ns/prov#> .\n"
            + "@prefix tavernaprov:  <http://ns.taverna.org.uk/2012/tavernaprov/> .\n"
            + "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n");

    sb.append("<#" + UUID.randomUUID().toString() + ">\n" + "\t a prov:Entity ;\n");
    sb.append("\t rdfs:label \"" + label + "\"^^xsd:String ;\n");
    sb.append("\t tavernaprov:sha512 \"" + sha512 + "\"^^xsd:String .");

    RDFDataMgr.read(data, new StringReader(sb.toString()), null, Lang.TTL);

    fis.close();
    return data;
}

From source file:com.bloatit.framework.utils.Hash.java

public static String shortHash(final String value) {
    return DigestUtils.sha512Hex(value).substring(10, 20);
}

From source file:edu.isi.misd.tagfiler.util.LocalFileChecksum.java

/**
 * Computes a checksum on a file, given the proper message digest
 * implementation//from w w w.j  ava 2 s  .com
 * 
 * @param file
 *            file to read
 * @param messageDigest
 *            MessageDigest to use
 * @return the checksum bytes of the file
 * @thows FatalException if the checksum cannot be constructed.
 */
public static String computeFileChecksum(File file) throws FatalException {
    if (file == null)
        throw new IllegalArgumentException("file");

    String checksum = null;

    FileInputStream stream = null;
    try {
        stream = new FileInputStream(file);
        if (DigestMethod.SHA512.equals(digestType)) {
            checksum = DigestUtils.sha512Hex(stream);
        } else if (DigestMethod.SHA256.equals(digestType)) {
            checksum = DigestUtils.sha256Hex(stream);
        } else if (DigestMethod.SHA1.equals(digestType)) {
            checksum = DigestUtils.shaHex(stream);
        } else {
            checksum = DigestUtils.md5Hex(stream);
        }
    } catch (IOException e) {
        e.printStackTrace();
        throw new FatalException(e);
    } finally {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
            }
        }
    }
    return checksum;
}

From source file:com.bloatit.framework.utils.Hash.java

public static String generateUniqueToken() {
    UUID.randomUUID().toString();
    try {/*w w w  .  j a v  a2  s. co m*/
        final byte[] bytes = new byte[RANDOM_SIZE];
        SecureRandom.getInstance(SHA1_PRNG).nextBytes(bytes);
        return DigestUtils.sha512Hex(DigestUtils.sha512Hex(bytes) + UUID.randomUUID().toString());
    } catch (final NoSuchAlgorithmException e) {
        throw new BadProgrammerException(e);
    }
}

From source file:de.appsolve.padelcampus.utils.PlayerUtil.java

public boolean isPasswordValid(Player player, String password) {
    if (player == null || StringUtils.isEmpty(player.getPasswordHash())) {
        return false;
    }//from   w w  w .  j  a v  a2 s. c om
    if (!player.getSalted()) {
        String hash = DigestUtils.sha512Hex(password);
        return hash.equals(player.getPasswordHash());
    } else {
        return BCrypt.checkpw(password, player.getPasswordHash());
    }
}

From source file:com.lhy.commons.encrypt.service.EncryptService.java

@Override
public License getLicense(File licenseFile, String ipAddress) {
    License licFile = null;//from  w  ww  .j a va  2  s  .c o m
    try {
        ObjectInput in = new ObjectInputStream(new FileInputStream(licenseFile));
        licFile = (License) in.readObject();
        if (licFile.getIpAddress().equals(DigestUtils.sha512Hex(ipAddress))
                && licFile.getLicenseType().equals(LicenseType.user)) {
            licFile.setLicenseType(LicenseType.user);
        } else {
            licFile.setLicenseType(LicenseType.developer);
        }
        in.close();
    } catch (FileNotFoundException e) {
        log.error(e.getMessage());
    } catch (IOException e) {
        log.error(e.getMessage());
    } catch (ClassNotFoundException e) {
        log.error(e.getMessage());
    }
    return licFile;
}

From source file:de.phoenix.security.LoginFilter.java

/**
 * A single use filter to authentifacte the user by its username and
 * password for once. Use this to get a token from the server and delete the
 * LoginFilter!//w w w .j a  v  a2s  .  co  m
 * 
 * @param user
 *            The username
 * @param password
 *            The password in plain text. It will be pre hashed in the class
 */
public LoginFilter(String user, String password) {
    this.username = user;
    this.password = DigestUtils.sha512Hex(password);
}

From source file:com.twosigma.beaker.core.rest.LoginRest.java

private String hash(String password) {
    return DigestUtils.sha512Hex(password + config.getPasswordSalt());
}