List of usage examples for org.apache.commons.codec.digest DigestUtils md5Hex
public static String md5Hex(String data)
From source file:com.gson.oauth.Pay.java
/** * package, ??/*from ww w . jav a 2s . c om*/ * @param params * @param paternerKey * @return * @throws UnsupportedEncodingException */ private static String packageSign(Map<String, String> params, String paternerKey) throws UnsupportedEncodingException { String string1 = createSign(params, false); String stringSignTemp = string1 + "&key=" + paternerKey; String signValue = DigestUtils.md5Hex(stringSignTemp).toUpperCase(); String string2 = createSign(params, true); return string2 + "&sign=" + signValue; }
From source file:com.sammyun.controller.console.ProfileController.java
/** * /*from w w w . j a v a 2s .c o m*/ */ @RequestMapping(value = "/update", method = RequestMethod.POST) public String update(String currentPassword, String iconPhoto, String password, String email, RedirectAttributes redirectAttributes) { if (!isValid(Admin.class, "email", email)) { return ERROR_VIEW; } Admin pAdmin = adminService.getCurrent(); if (StringUtils.isNotEmpty(currentPassword) && StringUtils.isNotEmpty(password)) { if (!isValid(Admin.class, "password", password)) { return ERROR_VIEW; } if (!StringUtils.equals(DigestUtils.md5Hex(currentPassword), pAdmin.getPassword())) { return ERROR_VIEW; } pAdmin.setPassword(DigestUtils.md5Hex(password)); } pAdmin.setEmail(email); pAdmin.setIconPhoto(iconPhoto); adminService.update(pAdmin); addFlashMessage(redirectAttributes, SUCCESS_MESSAGE); return "redirect:edit.ct"; }
From source file:com.buaa.cfs.security.token.TokenIdentifier.java
/** * Returns a tracking identifier that can be used to associate usages of a token across multiple client sessions. * <p>//from ww w . j a v a 2 s .co m * Currently, this function just returns an MD5 of {{@link #getBytes()}. * * @return tracking identifier */ public String getTrackingId() { if (trackingId == null) { trackingId = DigestUtils.md5Hex(getBytes()); } return trackingId; }
From source file:com.espe.distribuidas.foodbet.servicios.UsuarioServicio.java
public Usuario obtenerUsuario(String usuario, String clave) { boolean correcto = false; Usuario user = this.usuarioDAO.findById(usuario, false); if (user != null) { String claveMd5 = DigestUtils.md5Hex(clave); if (user.getClave().equals(claveMd5)) correcto = true;//w ww . j av a2s. co m } else { throw new ValidacionException("No se encontro el usuario"); } if (correcto) { return user; } else { return null; } }
From source file:com.hyeb.back.sysuser.SysUserController.java
/** * ?//w w w . ja v a 2 s. c o m */ @RequestMapping(value = "/save", method = RequestMethod.POST) public String save(SysUser sysUser, Long[] roleIds, RedirectAttributes redirectAttributes) { if (!isValid(sysUser, Save.class)) { return ERROR_VIEW; } if (sysUserService.usernameExists(sysUser.getUsername())) { return ERROR_VIEW; } sysUser.setPassword(DigestUtils.md5Hex(sysUser.getPassword())); sysUser.setIsLocked(false); sysUser.setLoginFailureCount(0); sysUser.setLockedDate(null); sysUser.setLoginDate(null); sysUser.setLoginIp(null); sysUserService.save(sysUser); addFlashMessage(redirectAttributes, SUCCESS_MESSAGE); return "redirect:list.jhtml"; }
From source file:internal.diff.aws.service.AmazonS3ETagFileChecksumServiceImpl.java
@Override public String calculateChecksum(Path file) throws IOException { long fileSize = Files.size(file); int parts = (int) (fileSize / S3_MULTIPART_SIZE_LIMIT_IN_BYTES); parts += fileSize % S3_MULTIPART_SIZE_LIMIT_IN_BYTES > 0 ? 1 : 0; ByteBuffer checksumBuffer = ByteBuffer.allocate(parts * 16); SeekableByteChannel byteChannel = Files.newByteChannel(file); for (int part = 0; part < parts; part++) { int partSizeInBytes; if (part < parts - 1 || fileSize % S3_MULTIPART_SIZE_LIMIT_IN_BYTES == 0) { partSizeInBytes = S3_MULTIPART_SIZE_LIMIT_IN_BYTES; } else {//from w w w .j a v a 2 s.com partSizeInBytes = (int) (fileSize % S3_MULTIPART_SIZE_LIMIT_IN_BYTES); } ByteBuffer partBuffer = ByteBuffer.allocate(partSizeInBytes); boolean endOfFile; do { endOfFile = byteChannel.read(partBuffer) == -1; } while (!endOfFile && partBuffer.hasRemaining()); checksumBuffer.put(DigestUtils.md5(partBuffer.array())); } if (parts > 1) { return DigestUtils.md5Hex(checksumBuffer.array()) + "-" + parts; } else { return Hex.encodeHexString(checksumBuffer.array()); } }
From source file:com.hdos.platform.core.shiro.UserRealm.java
/** * ?// ww w .j a v a 2 s .c o m */ @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException { UsernamePasswordToken token = (UsernamePasswordToken) authcToken; String username = token.getUsername(); String password = DigestUtils.md5Hex(String.valueOf(token.getPassword())); AccountVO accountVO = accountService.queryAccountByAccountAndPwd(username, password); if (null != accountVO) { // TODO: ? UserProfile UserProfile profile = new UserProfile(accountVO.getUserId(), accountVO.getUserAccount(), accountVO.getUserAccount()); return new SimpleAuthenticationInfo(profile, password, getName()); } return null; }
From source file:com.dp2345.controller.admin.AdminController.java
/** * ?/*from www. j a va 2 s . c o m*/ */ @RequestMapping(value = "/save", method = RequestMethod.POST) public String save(Admin admin, Long[] roleIds, RedirectAttributes redirectAttributes) { admin.setRoles(new HashSet<Role>(roleService.findList(roleIds))); if (!isValid(admin, Save.class)) { return ERROR_VIEW; } if (adminService.usernameExists(admin.getUsername())) { return ERROR_VIEW; } admin.setPassword(DigestUtils.md5Hex(admin.getPassword())); admin.setIsLocked(false); admin.setLoginFailureCount(0); admin.setLockedDate(null); admin.setLoginDate(null); admin.setLoginIp(null); admin.setOrders(null); adminService.save(admin); addFlashMessage(redirectAttributes, SUCCESS_MESSAGE); return "redirect:list.jhtml"; }
From source file:com.noelios.restlet.ext.oauth.MemoryOAuthProvider.java
@Override public void generateAccessToken(OAuthAccessor accessor) { // generate oauth_token and oauth_secret final String consumer_key = (String) accessor.consumer.getProperty("name"); // generate token and secret based on consumer_key // for now use md5 of name + current time as token final String token_data = consumer_key + System.nanoTime(); final String token = DigestUtils.md5Hex(token_data); // first remove the accessor from cache this.tokens.remove(accessor); accessor.requestToken = null;/*from w w w .j ava 2 s .c o m*/ accessor.accessToken = token; Context.getCurrentLogger().fine("Adding access token " + accessor); // update token in local cache this.tokens.add(accessor); }
From source file:com.floragunn.searchguard.authentication.backend.simple.SettingsBasedAuthenticationBackend.java
@Override public User authenticate(final com.floragunn.searchguard.authentication.AuthCredentials authCreds) throws AuthException { final String user = authCreds.getUsername(); final char[] password = authCreds.getPassword(); authCreds.clear();//from w ww . j av a 2 s. com String pass = settings.get(ConfigConstants.SEARCHGUARD_AUTHENTICATION_SETTINGSDB_USER + user, null); String digest = settings.get(ConfigConstants.SEARCHGUARD_AUTHENTICATION_SETTINGSDB_DIGEST, null); if (digest != null) { digest = digest.toLowerCase(); switch (digest) { case "sha": case "sha1": pass = DigestUtils.sha1Hex(pass); break; case "sha256": pass = DigestUtils.sha256Hex(pass); break; case "sha384": pass = DigestUtils.sha384Hex(pass); break; case "sha512": pass = DigestUtils.sha512Hex(pass); break; default: pass = DigestUtils.md5Hex(pass); break; } } if (pass != null && Arrays.equals(pass.toCharArray(), password)) { return new User(user); } throw new AuthException("No user " + user + " or wrong password (digest: " + (digest == null ? "plain/none" : digest) + ")"); }