List of usage examples for org.springframework.security.crypto.bcrypt BCrypt hashpw
public static String hashpw(byte passwordb[], String salt)
From source file:com.tsg.techsupportmvc.dao.UserCreate.java
public static void main(String[] args) { String password = "1234"; String salt = BCrypt.gensalt(); String hash = BCrypt.hashpw(password, salt); System.out.println(salt);/*ww w. j a v a 2s .c om*/ System.out.println(hash); }
From source file:de.ingrid.iplug.PlugServer.java
/** * To start the plug server from the commandline. * @param args Arguments for the plug server e.g. --descriptor . * @throws Exception If something goes wrong. *//* w w w . j a v a2s .c om*/ public static void main(String[] args) throws Exception { Map arguments = readParameters(args); PlugDescription plugDescription = null; File plugDescriptionFile = new File(PLUG_DESCRIPTION); if (arguments.containsKey("--plugdescription")) { plugDescriptionFile = new File((String) arguments.get("--plugdescription")); } plugDescription = loadPlugDescriptionFromFile(plugDescriptionFile); PlugServer server = null; if (arguments.containsKey("--resetPassword")) { String pw = (String) arguments.get("--resetPassword"); fLogger.info("Resetting password to '" + pw + "' ..."); plugDescription.setIplugAdminPassword(BCrypt.hashpw(pw, BCrypt.gensalt())); XMLSerializer serializer = new XMLSerializer(); serializer.serialize(plugDescription, plugDescriptionFile); fLogger.info("Done ... please restart iPlug."); return; } else if (arguments.containsKey("--migratePassword")) { fLogger.info("Migrating plain text password from PlugDescription to encrypted one ..."); plugDescription.setIplugAdminPassword( BCrypt.hashpw(plugDescription.getIplugAdminPassword(), BCrypt.gensalt())); XMLSerializer serializer = new XMLSerializer(); serializer.serialize(plugDescription, plugDescriptionFile); fLogger.info("Done ... please restart iPlug."); return; } else if (arguments.containsKey("--descriptor")) { File commConf = new File((String) arguments.get("--descriptor")); server = new PlugServer(plugDescription, commConf, plugDescriptionFile, 60 * 1000); } if (server != null) { server.initPlugServer(); } }
From source file:cz.lbenda.coursing.service.AbstractPasswordGenerator.java
public final static String generatePassword(final String pass) { return BCrypt.hashpw(pass, BCrypt.gensalt(12)); }
From source file:de.ingrid.interfaces.csw.admin.command.AdminManager.java
/** * Read the override configuration and convert the clear text password to a bcrypt-hash, * which is used and needed by the base-webapp v3.6.1 *//* w w w. ja va 2s. com*/ private static void migratePassword() { try { InputStream is = new FileInputStream("conf/config.properties"); Properties props = new Properties(); props.load(is); String oldPassword = props.getProperty("ingrid.admin.password"); is.close(); props.setProperty("ingrid.admin.password", BCrypt.hashpw(oldPassword, BCrypt.gensalt())); OutputStream os = new FileOutputStream("conf/config.override.properties"); props.store(os, "Override configuration written by the application"); os.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.radixware.manager.hibernateDAO.Config.UserEntity.java
public void setPwd(String pwd) { this.pwd = BCrypt.hashpw(pwd, BCrypt.gensalt()); }
From source file:com.tsg.techsupportmvc.dao.UserDaoDbImpl.java
@Override public String getHash(String password, String salt) { return BCrypt.hashpw(password, salt); }
From source file:hr.diskobolos.core.crypt.PasswordHashCalc.java
/** * This method can be used to generate a string representing an account * password suitable for storing in a database. It will be an OpenBSD-style * crypt(3) formatted hash string of length=60 The bcrypt workload is * specified in the above static variable, a value from 10 to 31. A workload * of 12 is a very reasonable safe default as of 2013. This automatically * handles secure 128-bit salt generation and storage within the hash. * * @param password_plaintext The account's plaintext password as provided * during account creation, or when changing an account's password. * @return String - a string of length 60 that is the bcrypt hashed password * in crypt(3) format./*from w w w . j a v a2 s . c om*/ */ public String hashPassword(String password_plaintext) { String salt = BCrypt.gensalt(workload); String hashed_password = BCrypt.hashpw(password_plaintext, salt); return (hashed_password); }
From source file:de.appsolve.padelcampus.utils.LoginUtil.java
public void updateLoginCookie(HttpServletRequest request, HttpServletResponse response) { Player player = sessionUtil.getUser(request); if (player != null) { UUID cookieUUID = UUID.randomUUID(); UUID cookieValue = UUID.randomUUID(); String cookieValueHash = BCrypt.hashpw(cookieValue.toString(), BCrypt.gensalt()); LoginCookie loginCookie = new LoginCookie(); loginCookie.setUUID(cookieUUID.toString()); loginCookie.setPlayerUUID(player.getUUID()); loginCookie.setLoginCookieHash(cookieValueHash); loginCookie.setValidUntil(new LocalDate().plusYears(1)); loginCookieDAO.saveOrUpdate(loginCookie); Cookie cookie = new Cookie(COOKIE_LOGIN_TOKEN, cookieUUID.toString() + ":" + cookieValue.toString()); cookie.setDomain(request.getServerName()); cookie.setMaxAge(ONE_YEAR_SECONDS); cookie.setPath("/"); response.addCookie(cookie);//from ww w. ja v a2 s . c om } }
From source file:de.ingrid.interfaces.csw.admin.command.AdminManager.java
/** * Read the override configuration and write a new bcrypt-hash password. *//*from w w w .ja v a 2 s.c om*/ private static void resetPassword(String newPassword) { try { InputStream is = new FileInputStream("conf/config.override.properties"); Properties props = new Properties(); props.load(is); props.setProperty("ingrid.admin.password", BCrypt.hashpw(newPassword, BCrypt.gensalt())); OutputStream os = new FileOutputStream("conf/config.override.properties"); props.store(os, "Override configuration written by the application"); os.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.unitedid.auth.client.factors.PasswordFactor.java
public PasswordFactor(String password, String credentialId, String salt) throws UnsupportedEncodingException, NoSuchAlgorithmException { this.type = "password"; this.credentialId = credentialId; this.salt = salt; String bcryptHash = BCrypt.hashpw(sha256PreHash(password), salt); passwordHash = bcryptHash.substring(salt.length()); }