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:be.solidx.hot.Script.java

@Override
public boolean outdated(String value) {
    String md5 = DigestUtils.md5Hex(value.getBytes());
    return !md5.equals(this.md5);
}

From source file:io.cloudslang.lang.compiler.caching.CachedPrecompileServiceImpl.java

boolean hasChangedSinceCached(SlangSource source1, SlangSource source2) {
    String source1AsStr = source1.toString();
    String source2AsStr = source2.toString();
    return (source1AsStr.length() != source2AsStr.length())
            || (!DigestUtils.md5Hex(source1AsStr).equals(DigestUtils.md5Hex(source2AsStr)))
            || (!DigestUtils.sha256Hex(source1AsStr).equals(DigestUtils.sha256Hex(source2AsStr)));
}

From source file:edu.iit.sat.itmd4515.ajain62.fp.domain.security.User.java

@PrePersist
@PreUpdate
private void hashpassword() {
    String digestPassword = DigestUtils.md5Hex(this.password);
    this.password = digestPassword;
}

From source file:de.ingrid.interfaces.csw.harvest.impl.RecordCache.java

@Override
protected String getRelativePath(Serializable id) {
    return DigestUtils.md5Hex(id.toString()).substring(0, 3);
}

From source file:eionet.meta.DDUser.java

/**
 *
 *///  w  ww.  j  av a 2  s.  c  om
public boolean authenticate(String userName, String userPwd) {

    invalidate();

    try {
        String masterPwdHash = Props.getProperty(PropsIF.DD_MASTER_PASSWORD_HASH);

        if (userPwd != null && masterPwdHash != null && masterPwdHash.equals(DigestUtils.md5Hex(userPwd))) {
            if (userName == null) {
                throw new SignOnException("username not given");
            }
            fullName = userName;
            LOGGER.info("User " + userName + " logged in with master password.");
        } else {
            AuthMechanism.sessionLogin(userName, userPwd);
            fullName = AuthMechanism.getFullName(userName);
            LOGGER.debug("User " + userName + " logged in through local login page.");
        }

        authented = true;
        username = userName;
        password = userPwd;
    } catch (Exception e) {
        LOGGER.error(e.toString(), e);
    }

    return authented;
}

From source file:com.thoughtworks.go.api.ControllerMethods.java

default String etagFor(String str) {
    return DigestUtils.md5Hex(str);
}

From source file:com.dp2345.controller.mall.PasswordController.java

/**
 * ???//from  w  w w.  j a  v a  2s .c o m
 */
@RequestMapping(value = "/find", method = RequestMethod.POST)
public @ResponseBody Message find(String captchaId, String captcha, String username, String email) {
    if (!captchaService.isValid(CaptchaType.findPassword, captchaId, captcha)) {
        return Message.error("shop.captcha.invalid");
    }
    if (StringUtils.isEmpty(username) || StringUtils.isEmpty(email)) {
        return Message.error("shop.common.invalid");
    }
    Member member = memberService.findByUsername(username);
    if (member == null) {
        return Message.error("shop.password.memberNotExist");
    }
    if (!member.getEmail().equalsIgnoreCase(email)) {
        return Message.error("shop.password.invalidEmail");
    }
    Setting setting = SettingUtils.get();
    SafeKey safeKey = new SafeKey();
    safeKey.setValue(UUID.randomUUID().toString() + DigestUtils.md5Hex(RandomStringUtils.randomAlphabetic(30)));
    safeKey.setExpire(setting.getSafeKeyExpiryTime() != 0
            ? DateUtils.addMinutes(new Date(), setting.getSafeKeyExpiryTime())
            : null);
    member.setSafeKey(safeKey);
    memberService.update(member);
    mailService.sendFindPasswordMail(member.getEmail(), member.getUsername(), safeKey);
    return Message.success("shop.password.mailSuccess");
}

From source file:es.uvigo.ei.sing.rubioseq.gui.util.DBInitializer.java

/**
 * This method is responsible for the initializacion of the BD, that is:
 * - Creating the default RUbioSeqConfiguration.
 * - Creating the default users.//from   www.  ja  v a 2  s  .co  m
 * - Creating a datastore pointing to "/" for the admin user.
 * 
 * This method also plays a key role in the deployment of the application 
 * since it prints the message "[DBInitializer] DB initialized." which is
 * triggered by the launch-rubioseq-gui.sh in order to know that the app. is
 * deployed and launch a browser.
 * 
 * @author hlfernandez
 */
static void initDatabase() {
    System.out.println("[DBInitializer] Initializing DB ...");

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("rubioseq-database");
    EntityManager em = emf.createEntityManager();
    EntityTransaction tx = null;
    try {
        /*
         * Store Global Configuration
         */
        if (em.createQuery("SELECT u FROM RUbioSeqConfiguration u").getResultList().size() == 0) {
            RUbioSeqConfiguration config = new RUbioSeqConfiguration();
            config.setRubioseqCommand("/opt/RUbioSeq3.7/RUbioSeq.pl");
            config.setPrivateDatastoresRootDirectory("/path/to/private/datastores/root");
            config.setCreatePrivateDatastoresOnUserRegistration(false);

            tx = em.getTransaction();
            try {
                tx.begin();
                em.persist(config);
                tx.commit();
            } finally {
                if (tx != null && tx.isActive()) {
                    tx.rollback();
                }
            }
        }
        /*
         * Create Default Users
         */
        if (em.createQuery("SELECT u FROM User u").getResultList().size() == 0) {
            User user = new User();
            user.setUsername("rubiosequser");
            user.setPassword(DigestUtils.md5Hex("rubioseqpass"));
            user.setAdmin(false);
            user.setEmail("rubiosequser@rubioseg.org");

            tx = em.getTransaction();
            try {
                tx.begin();
                em.persist(user);
                tx.commit();
            } finally {
                if (tx != null && tx.isActive()) {
                    tx.rollback();
                }
            }

            user = new User();
            user.setUsername("admin");
            user.setPassword(DigestUtils.md5Hex("admin"));
            user.setAdmin(true);
            user.setEmail("rubiosequser@rubioseg.org");

            tx = em.getTransaction();
            try {
                tx.begin();
                em.persist(user);
                tx.commit();
            } finally {
                if (tx != null && tx.isActive()) {
                    tx.rollback();
                }
            }
        }
        /*
         * Create Default Datastores
         */
        boolean createDefaultAdminDatastore = true;
        List<User> adminUsers = getAdminUsers(em);
        @SuppressWarnings("unchecked")
        List<DataStore> datastores = (List<DataStore>) em.createQuery("SELECT d FROM DataStore d")
                .getResultList();
        for (User adminUser : adminUsers) {
            if (datastores.size() == 0) {
                createDefaultAdminDatastore = true;
            } else {
                for (DataStore d : datastores) {
                    if (d.getUser() != null && d.getUser().equals(adminUser) && d.getPath().equals("/")) {
                        createDefaultAdminDatastore = false;
                    }
                }
            }
            if (createDefaultAdminDatastore) {
                DataStore adminDS = new DataStore();
                adminDS.setUser(adminUser);
                adminDS.setPath("/");
                adminDS.setMode(DataStoreMode.Private);
                adminDS.setType(DataStoreType.Input_Output);
                adminDS.setName(adminUser.getUsername() + "_default");

                tx = em.getTransaction();
                try {
                    tx.begin();
                    em.persist(adminDS);
                    tx.commit();
                } finally {
                    if (tx != null && tx.isActive()) {
                        tx.rollback();
                    }
                }
            }
        }
    } finally {
        em.close();
    }

    System.out.println("[DBInitializer] DB initialized.");
}

From source file:jenkins.plugins.publish_over.helper.InputStreamMatcher.java

public void appendTo(final StringBuffer stringBuffer) {
    stringBuffer.append("Expected InputStream with contents (md5) = ")
            .append(DigestUtils.md5Hex(expectedContents));
}

From source file:alluxio.cli.fs.command.ChecksumCommand.java

/**
 * Calculates the md5 checksum for a file.
 *
 * @param filePath The {@link AlluxioURI} path of the file calculate MD5 checksum on
 * @return A string representation of the file's MD5 checksum
 *///from ww w  .j a  v a 2 s  .  c  o m
private String calculateChecksum(AlluxioURI filePath) throws AlluxioException, IOException {
    OpenFileOptions options = OpenFileOptions.defaults().setReadType(ReadType.NO_CACHE);
    try (FileInStream fis = mFileSystem.openFile(filePath, options)) {
        return DigestUtils.md5Hex(fis);
    }
}