List of usage examples for org.apache.commons.codec.digest DigestUtils md5Hex
public static String md5Hex(String data)
From source file:com.webarch.common.shiro.authentication.CredentialsMatcher.java
@Override public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) { if (token.getCredentials() != null || info.getCredentials() != null) { String submitPWD = new String((char[]) token.getCredentials()); String storePWD = (String) info.getCredentials(); String md5PWD = DigestUtils.md5Hex(submitPWD); if (md5PWD.equals(storePWD)) { return true; }// w w w. j av a 2 s.c o m } return false; }
From source file:eu.scape_project.pw.idp.model.PasswordHashingEntityListener.java
/** * Hashes the plainPassword of the user if set and stores it in password. * /* w ww . jav a 2 s.co m*/ * @param user * the to update */ @SuppressWarnings("unused") @PrePersist @PreUpdate private void hashPassword(IdpUser user) { final String password = user.getPlainPassword(); if (password != null) { user.setPassword(DigestUtils.md5Hex(password)); } }
From source file:dk.deck.resolver.AbstractArtifactResolver.java
protected String getMd5(File file) throws IOException { String md5Hex = DigestUtils.md5Hex(new FileInputStream(file)); return md5Hex; }
From source file:com.talis.storage.memory.MemoryStoreTest.java
@Test public void storedItemEtagIsMd5OfEntity() throws Exception { SubmittedItem submitted = new SubmittedItem(MediaType.TEXT_PLAIN_TYPE, new ByteArrayInputStream(data)); StoredItem stored = store.write(itemURI, submitted); String expectedEtag = DigestUtils.md5Hex(data); assertEquals(expectedEtag, stored.getEtag()); }
From source file:com.gnizr.db.dao.Link.java
/** * Computes the MD5 hash of an input URL string. * /*from www. j a v a2s. c o m*/ * @param url a valid URL string * @return MD5 of the input URL */ public static final String computeUrlHash(String url) { return DigestUtils.md5Hex(url); }
From source file:com.haulmont.cuba.client.testsupport.TestUserSessionSource.java
@Override public synchronized UserSession getUserSession() { if (session == null) { User user = new User(); user.setId(UUID.fromString(USER_ID)); user.setLogin("test_admin"); user.setName("Test Administrator"); user.setPassword(DigestUtils.md5Hex("test_admin")); session = new UserSession(UUID.randomUUID(), user, Collections.<Role>emptyList(), Locale.ENGLISH, false);/*w w w. jav a 2s . com*/ } return session; }
From source file:ch.cyberduck.core.local.AbstractTemporaryFileService.java
protected String shorten(final String path, int limit) { if (path.length() > limit) { return DigestUtils.md5Hex(path); }//from ww w .ja v a 2 s .co m return path; }
From source file:com.dp2345.controller.mall.member.PasswordController.java
/** * ???/*from w w w . j a va 2 s. c o m*/ */ @RequestMapping(value = "/check_current_password", method = RequestMethod.GET) public @ResponseBody boolean checkCurrentPassword(String currentPassword) { if (StringUtils.isEmpty(currentPassword)) { return false; } Member member = memberService.getCurrent(); if (StringUtils.equals(DigestUtils.md5Hex(currentPassword), member.getPassword())) { return true; } else { return false; } }
From source file:jodtemplate.pptx.io.PPTXImageReader.java
public void read(final Resources resources, final Presentation presentation) throws IOException { final String imagesPath = Utils.removePrefixSeparator(presentation.getFullPath() + "media/"); for (Resource resource : resources.getResources()) { if (resource.getName().startsWith(imagesPath)) { final String fileName = FilenameUtils.getName(resource.getName()); if (fileName.matches("^imageJodT.+?$")) { try (final InputStream imageStream = resource.getInputStream()) { final String md5 = DigestUtils.md5Hex(imageStream); final Image image = new Image(); image.setFullPath("/" + resource.getName()); image.setMd5(md5);// w w w.j a v a 2s . c o m presentation.addImage(image); } } } } }
From source file:mx.edu.ittepic.proyectofinal.ejbs.ejbUsers.java
public String getUser(String username, String password) { Message m = new Message(); GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create();/*from w w w .j ava 2 s .com*/ String md5 = DigestUtils.md5Hex(password); try { Users users; Query q = entity.createNamedQuery("Users.getUser").setParameter("username", username) .setParameter("password", md5); users = (Users) q.getSingleResult(); Role role = users.getRoleid(); m.setCode(200); m.setMsg("Tiene acceso al sistema"); m.setDetail(users.getUsername() + ":" + users.getApikey() + ":" + role.getRoleid()); } catch (NoResultException e) { m.setCode(401); m.setMsg("No tiene acceso al sistema"); m.setDetail(e.toString()); } return gson.toJson(m); }