List of usage examples for org.apache.commons.codec.digest DigestUtils sha256Hex
public static String sha256Hex(String data)
From source file:de.appsolve.padelcampus.utils.FileUtil.java
public Image save(String contentType, byte[] byteArray, ImageCategory category, Integer width, Integer height) throws IOException, ImageProcessingException { //generate file path based on checksum of byte array String checksum = DigestUtils.sha256Hex(byteArray); Image existingImage = imageDAO.findBySha256(checksum); if (existingImage != null) { return existingImage; }/*from w w w. j ava 2s. co m*/ //create Image Image image = new Image(); image.setSha256(checksum); image.setWidth(width); image.setHeight(height); image.setContentType(contentType); image.setContentLength(0L + byteArray.length); image.setContent(byteArray); image.setCategory(category); imageDAO.saveOrUpdate(image); return image; }
From source file:at.fhjoanneum.swenga.project.audiocracyweb.facades.CustomerFacade.java
@Override public void create(Customer entity) { entity.setPassword(DigestUtils.sha256Hex(entity.getPassword())); super.create(entity); }
From source file:com.monitor.baseservice.utils.XCodeUtil.java
public static String getSHA256(byte[] data) throws Exception { return DigestUtils.sha256Hex(data); }
From source file:edu.iit.sat.itmd4515.cdara.fp.security.User.java
/** * Hash code algorithm for password/*w w w. j av a 2 s. c o m*/ */ @PrePersist @PreUpdate private void hashPassword() { String digestPassword = DigestUtils.sha256Hex(this.password); this.password = digestPassword; }
From source file:com.lioland.harmony.services.Login.java
@GET @Produces("application/json") @Path("/authenticate") public User authenticateUser(@QueryParam("email") String email, @QueryParam("password") String password) { User user = new User(); user.setEmail(email);//from w ww .j a va 2s.c o m user.loadObject(); if (user.getPassword().equals(password)) { user.setPassword(DigestUtils.sha256Hex(user.getEmail().toLowerCase())); return user; } else { return null; } }
From source file:com.streamsets.lib.security.http.TestDisconnectedSecurityInfo.java
@Test public void testInfoMethodsForJson() { DisconnectedSecurityInfo info = new DisconnectedSecurityInfo(); Assert.assertTrue(info.getEntries().isEmpty()); DisconnectedSecurityInfo.Entry entry = new DisconnectedSecurityInfo.Entry(); entry.setUserNameSha(DigestUtils.sha256Hex("us")); entry.setPasswordHash("ph"); entry.getRoles().add("r"); info.setEntries(ImmutableList.of(entry)); Assert.assertEquals(entry, info.getEntry("us")); Assert.assertEquals(ImmutableList.of(entry), info.getEntries()); entry = new DisconnectedSecurityInfo.Entry(); entry.setUserNameSha(DigestUtils.sha256Hex("us1")); entry.setPasswordHash("ph1"); entry.getRoles().add("r1"); info.setEntries(ImmutableList.of(entry)); Assert.assertEquals(ImmutableList.of(entry), info.getEntries()); }
From source file:com.github.aynu.yukar.baseline.provider.domain.auth.CertificationDomain.java
/** * // w w w . java2 s. c o m * <dl> * <dt>? * <dd>SHA-256(HEX)??????????? * </dl> * @param password (?????,???????) * @return ? */ public Certification changePassword(final String password) { Validate.notBlank(password); final String newPassword = DigestUtils.sha256Hex(password); Validate.isTrue(!newPassword.equals(certification.getPassword()), "The validated password is same"); return new Certification(certification.getAccount(), newPassword); }
From source file:it.isislab.dmason.util.SystemManagement.Worker.Digester.java
public String getDigest(byte data[]) { if (digestAlg.equals(DigestAlgorithm.MD2)) digest = DigestUtils.md5Hex(data); if (digestAlg.equals(DigestAlgorithm.MD5)) digest = DigestUtils.md5Hex(data); if (digestAlg.equals(DigestAlgorithm.SHA1)) digest = DigestUtils.sha256Hex(data); return digest; }
From source file:com.marcosanta.controllers.RecuperarController.java
public void recuperaContrasena() { usuario = consultasBDservice.findUsuarioByUsername(user); if (usuario != null) { if (usuario.getCorreo().equalsIgnoreCase(correo)) { if (recuperaService.enviaCorreo(correo)) { String pw = recuperaService.generaContrasena(); System.out.println(pw); String crypt = DigestUtils.sha256Hex(pw); System.out.println(""); usuario.setPw(crypt);// www. j a v a 2 s . co m consultasBDservice.saveUser(usuario); FacesUtils.addInfoMessage("info", "El correo fue enviado de manera correcta"); } else { FacesUtils.addWarningMessage("error", "El correo no pudo llegar al destinatario"); } } else { FacesUtils.addWarningMessage("error", "El correo ingresado, no coincide con el que se tiene registrado"); } } else { FacesUtils.addWarningMessage("error", "El usuario ingresado no existe"); } }
From source file:com.supinfo.supfriends.web.api.servlet.WebServicesServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String action = req.getParameter("action"); String username = req.getParameter("username"); String password = req.getParameter("password"); String encodedPassword = DigestUtils.sha256Hex(password); String responseJson = ""; UserEntity user = userFacade.findByUsername(username); if (user == null) { resp.setStatus(403);//from ww w. j a v a2s .c o m resp.getWriter().println(String.format("User %s doesn't exists", username)); return; } if (!user.getPassword().equals(encodedPassword)) { resp.setStatus(401); resp.getWriter().println("Wrong password"); return; } switch (action) { case "update": String latitude, longitude; latitude = req.getParameter("latitude"); longitude = req.getParameter("longitude"); responseJson = update(username, latitude, longitude); break; case "listGroups": responseJson = listGroups(); break; case "getPosition": String groupId = req.getParameter("groupID"); responseJson = getPosition(groupId); break; } resp.getWriter().println(responseJson); }