List of usage examples for com.google.common.hash Hashing sha256
public static HashFunction sha256()
From source file:com.godaddy.logging.Sha256HashProcessor.java
@Override public String process(final Object object) { ByteArrayOutputStream binaryStream = new ByteArrayOutputStream(); try {//from w w w . ja va 2 s. c om ObjectOutputStream outputStream = new ObjectOutputStream(binaryStream); outputStream.writeObject(object); } catch (IOException e) { return "<Error Hashing>"; } return Hashing.sha256().hashBytes(binaryStream.toByteArray()).toString(); }
From source file:pt.uc.dei.aor.projecto8.whiteboard.facades.UsersFacade.java
public void newUser(String nameUser, String passwordUser) { Groups groups = new Groups("user", nameUser); groupsFacade.create(groups);// w w w . ja v a2s .co m String encrypt = Hashing.sha256().hashString(passwordUser, Charsets.UTF_8).toString(); Users users = new Users(nameUser, encrypt); users.setGroupsGroupid(groups); super.create(users); groups.getUsersList().add(users); groupsFacade.edit(groups); // users.setUsername(nameUser); // users.setPassword(encrypt); // edit(users); }
From source file:com.android.tools.idea.LogAnonymizerUtil.java
/** * Returns a hash for the given module. The hash value will be consistent only for the current session. Once the IDE is shutdown, * the hash for the module will change.//ww w . j av a2 s . c o m */ @NotNull public static String anonymize(@Nullable Module module) { if (module == null) { return "null"; } if (module.isDisposed()) { return "<disposed>"; } return "module:" + Hashing.sha256().hashString(SALT + module.getName(), StandardCharsets.UTF_8).toString(); }
From source file:ddf.security.http.impl.HttpSessionFactory.java
/** * Synchronized method because of jettys getSession method is not thread safe. Additionally, * assures a SAML {@link SecurityTokenHolder} has been set on the {@link * SecurityConstants#SAML_ASSERTION} attribute * * @param httpRequest//from www .ja v a 2 s . co m * @return */ @Override public synchronized HttpSession getOrCreateSession(HttpServletRequest httpRequest) { HttpSession session = httpRequest.getSession(true); if (session.getAttribute(SecurityConstants.SAML_ASSERTION) == null) { session.setAttribute(SecurityConstants.SAML_ASSERTION, new SecurityTokenHolder()); SecurityLogger.audit("Creating a new session with id {} for client {}.", Hashing.sha256().hashString(session.getId(), StandardCharsets.UTF_8).toString(), httpRequest.getRemoteAddr()); } return session; }
From source file:io.gravitee.gateway.policy.impl.CachedPolicyConfigurationFactory.java
private String hash(Class<?> policyConfigurationClass, String policyConfiguration) { return Hashing.sha256() .hashString((policyConfiguration == null) ? policyConfigurationClass.getName() : policyConfigurationClass.getName() + policyConfiguration, StandardCharsets.UTF_8) .toString();//from w w w .j a va 2 s . c om }
From source file:edu.iit.sat.itmd4515.agoyal18.domain.security.User.java
@PrePersist @PreUpdate//from ww w . ja v a 2 s .c o m private void hashPassword() { String sha256hex = Hashing.sha256().hashString(this.password, StandardCharsets.UTF_8).toString(); this.password = sha256hex; }
From source file:org.apache.servicecomb.demo.signature.SignatureUtils.java
public static String genSignature(HttpServletResponseEx responseEx) { Hasher hasher = Hashing.sha256().newHasher(); byte[] bytes = responseEx.getBodyBytes(); if (bytes != null) { hasher.putBytes(bytes, 0, responseEx.getBodyBytesLength()); }/*from w w w . j av a2s .c o m*/ return hasher.hash().toString(); }
From source file:com.streamsets.datacollector.usagestats.StatsInfo.java
@VisibleForTesting static String computeHash(String value) { return Hashing.sha256().newHasher().putString(value, Charset.forName("UTF-8")).hash().toString(); }
From source file:com.ea.promed.beans.ClientBean.java
public String createClientByAdmin() throws MessagingException, UnsupportedEncodingException { if (client.getId() != null) { Client eClient = (Client) sessionMap.get("eClient"); client.setUser(eClient.getUser()); clientFacade.edit(client);//w w w . j a v a 2 s.c o m sessionMap.put("message", "Client Info updated Successfully."); } else { String code = UUID.randomUUID().toString(); String hash = Hashing.sha256().hashString(code, Charsets.UTF_8).toString(); client.getUser().setVerification(hash); client.getUser().setPassword(hash); clientFacade.create(client); userFacade.activateUser(client.getUser(), 4); emailBean.setToemail(client.getUser().getEmail()); emailBean.setSubject("Login Credentials : Pro Medical Services"); emailBean.setMessagetext(client.getFirstName(), "Your user name is " + client.getUser().getUsername() + ". You can create new password by clicking below link.", hash); emailBean.sendEMail(); sessionMap.put("message", "Client Info added Successfully."); } return "clients?faces-redirect=true"; }
From source file:com.ea.promed.beans.NurseBean.java
public String createNurse() throws MessagingException, UnsupportedEncodingException { if (nurse.getId() != null) { Nurse eNurse = (Nurse) sessionMap.get("eNurse"); nurse.setUser(eNurse.getUser()); nurseFacade.edit(nurse);// w w w. j a va2s .c o m sessionMap.put("message", "Nurse Info updated Successfully."); } else { String code = UUID.randomUUID().toString(); String hash = Hashing.sha256().hashString(code, Charsets.UTF_8).toString(); nurse.getUser().setVerification(hash); nurse.getUser().setPassword(hash); nurseFacade.create(nurse); userFacade.activateUser(nurse.getUser(), 3); emailBean.setToemail(nurse.getUser().getEmail()); emailBean.setSubject("Login Credentials : Pro Medical Services"); emailBean.setMessagetext(nurse.getFirstName(), "Your user name is " + nurse.getUser().getUsername() + ". You can create new password by clicking below link.", hash); emailBean.sendEMail(); sessionMap.put("message", "Nurse Info added Successfully."); } return "nurses?faces-redirect=true"; }