List of usage examples for org.apache.commons.codec.digest DigestUtils sha256Hex
public static String sha256Hex(String data)
From source file:co.com.mobick.operaciones.UsuarioLoginFacade.java
public void ultimaActualizacion(UsuarioLogin us, String pw) { try {/*w ww . j a va 2 s . c o m*/ UsuarioLogin actualizado = new UsuarioLogin(); actualizado.setUsuarioLogin(us.getUsuarioLogin()); actualizado.setUsuario(us.getUsuario()); actualizado.setRolIdrol(us.getRolIdrol()); actualizado.setContrasena(DigestUtils.sha256Hex(pw)); actualizado.setEstadoContrasena(true); int query = em.createQuery( "UPDATE UsuarioLogin u SET u.contrasena=:contrasena, u.estadoContrasena=FALSE WHERE u.usuarioLogin=:id") .setParameter("contrasena", actualizado.getContrasena()) .setParameter("id", actualizado.getUsuarioLogin()).executeUpdate(); } catch (Exception e) { System.out.println("error en actulizar"); e.printStackTrace(); } }
From source file:edu.iit.sat.itmd4515.sdupoy.fp.domain.security.User.java
@PrePersist @PreUpdate private void hashPassword() { String digestPassword = DigestUtils.sha256Hex(this.password); this.password = digestPassword; }
From source file:it.marcoberri.mbfasturl.model.User.java
/** * * @param password */ public void setPasswordPlain(String password) { this.password = DigestUtils.sha256Hex(password); }
From source file:io.lavagna.model.ProjectMetadata.java
private static String hash(SortedMap<Integer, CardLabel> labels, SortedMap<Integer, LabelListValueWithMetadata> labelListValues, Map<ColumnDefinition, BoardColumnDefinition> columnsDefinition) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream daos = new DataOutputStream(baos); try {/* w w w .j a va2s . c o m*/ for (CardLabel cl : labels.values()) { hash(daos, cl); } for (LabelListValueWithMetadata l : labelListValues.values()) { hash(daos, l); } for (BoardColumnDefinition b : columnsDefinition.values()) { hash(daos, b); } daos.flush(); return DigestUtils.sha256Hex(new ByteArrayInputStream(baos.toByteArray())); } catch (IOException e) { throw new IllegalStateException(e); } }
From source file:com.screenslicer.common.Crypto.java
public static String fastHash(String str) { try {/*from w ww . j a va2 s . c om*/ return new String(DigestUtils.sha256Hex(str)); } catch (Exception e) { Log.exception(e); throw new RuntimeException(e); } }
From source file:ece356.LoginServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from ww w. jav a 2 s . c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String query = ""; String name = request.getParameter("name"); String password = request.getParameter("password"); String url; try { DatabaseConnection dbcon = new DatabaseConnection(); Login credentials = dbcon.selectLogin( "name = '" + name + "' AND " + "password = '" + DigestUtils.sha256Hex(password) + "'"); url = "index.jsp"; switch (credentials.getUserType()) { case 0: url = "PatientServlet"; break; case 1: url = "StaffServlet"; break; case 2: url = "DoctorServlet"; break; case 3: url = "LegalServlet"; break; case 4: url = "FinancialServlet"; break; default: //throw error break; } getServletContext().setAttribute("dbcon", dbcon); getServletContext().setAttribute("credentials", credentials); response.sendRedirect(url); // need to remove these 3 lines //request.setAttribute("dbcon", dbcon); //request.setAttribute("credentials", credentials); //request.setAttribute("requestType", 0); // above this //getServletContext().getRequestDispatcher(url).forward(request, response); } catch (ClassNotFoundException ex) { Logger.getLogger(LoginServlet.class.getName()).log(Level.SEVERE, null, ex); url = "/error.jsp"; request.setAttribute("exception", ex); getServletContext().getRequestDispatcher(url).forward(request, response); } catch (SQLException ex) { url = "/error.jsp"; request.setAttribute("exception", ex); Logger.getLogger(LoginServlet.class.getName()).log(Level.SEVERE, null, ex); getServletContext().getRequestDispatcher(url).forward(request, response); } }
From source file:me.adaptive.core.data.api.UserTokenEntityService.java
private String getToken(UserEntity user) { StringBuilder builder = new StringBuilder(user.getUserId()); builder.append(user.getUserId()).append(user.getPasswordHash()).append(System.nanoTime()).append(SALT); return String.valueOf(DigestUtils.sha256Hex(builder.toString())); }
From source file:com.remediatetheflag.global.actions.auth.user.DoLogoutAction.java
@Override public void doAction(HttpServletRequest request, HttpServletResponse response) throws Exception { User user = (User) request.getSession().getAttribute(Constants.ATTRIBUTE_SECURITY_CONTEXT); if (null != user) { UserAuthenticationEvent attempt = new UserAuthenticationEvent(); attempt.setLogoutDate(new Date()); attempt.setUsername(user.getUsername()); attempt.setSessionIdHash(DigestUtils.sha256Hex(request.getSession().getId())); hpc.addLogoutEvent(attempt);//from w ww . j ava 2 s .c o m logger.debug("Logout successful for : " + user.getIdUser()); } request.getSession().removeAttribute(Constants.ATTRIBUTE_SECURITY_CONTEXT); request.getSession().removeAttribute(Constants.ATTRIBUTE_SECURITY_ROLE); request.getSession().invalidate(); request.getSession(true); try { response.sendRedirect(Constants.INDEX_PAGE); } catch (IOException e) { logger.error("Failed Logout Redirect: " + e.getMessage()); } }
From source file:com.migo.service.impl.UserServiceImpl.java
@Override public void save(UserEntity user) { user.setPassword(DigestUtils.sha256Hex(user.getPassword())); userDao.save(user); }
From source file:com.thoughtworks.go.plugin.access.common.models.Image.java
public String getHash() { if (hash == null) { hash = DigestUtils.sha256Hex(toDataURI()); } return hash; }