List of usage examples for org.springframework.security.crypto.bcrypt BCrypt checkpw
public static boolean checkpw(String plaintext, String hashed)
From source file:cz.lbenda.coursing.service.AbstractPasswordGenerator.java
public final static boolean checkPassword(final String candidate, final String stored) { return BCrypt.checkpw(candidate, stored); }
From source file:org.radixware.manager.hibernateDAO.Config.UserEntity.java
public boolean isCorrectPassowrd(String password) { if (BCrypt.checkpw(password, this.pwd)) return true; else//from www. j av a 2 s . c o m return false; }
From source file:de.appsolve.padelcampus.utils.PlayerUtil.java
public boolean isPasswordValid(Player player, String password) { if (player == null || StringUtils.isEmpty(player.getPasswordHash())) { return false; }//from w w w. j a v a 2s .co m if (!player.getSalted()) { String hash = DigestUtils.sha512Hex(password); return hash.equals(player.getPasswordHash()); } else { return BCrypt.checkpw(password, player.getPasswordHash()); } }
From source file:com.cfs.backingbean.AlterarSenha.java
public void alterarSenha() { user = new Users(); UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication() .getPrincipal();/* ww w . j av a 2 s . c o m*/ user = usersDao.buscaUsuarioPorUSERNAME(userDetails.getUsername()); if (user == null) { System.out.println(Utilities.getInstance().getLineNumber() + "user null"); return; } if (!BCrypt.checkpw(senhaAtual, user.getPassword())) { JSFUtil.addErrorMessage("Senha atual incorreta."); return; } user.setPassword(HashSenha.hash(senhaNova)); try { usersDao.salvar(user); } catch (DAOException ex) { Logger.getLogger(AlterarSenha.class.getName()).log(Level.SEVERE, null, ex); JSFUtil.addErrorMessage("Erro senha no alterada."); } JSFUtil.addInfoMessage("Senha alterada com sucesso!"); limpar(); }
From source file:de.ingrid.iplug.BCryptUserRealm.java
@Override public Principal authenticate(String username, Object credentials, HttpRequest request) { String password;//w ww. jav a 2s .c o m synchronized (this) { password = (String) users.get(username); } if (password == null) return null; if (BCrypt.checkpw(credentials.toString(), password)) { return new User(username); } return null; }
From source file:de.ingrid.server.security.PlugdescriptionLoginModule.java
@Override protected IngridPrincipal authenticate(final String userName, final String password) { final String pd = System.getProperty("plugDescription"); final File file = new File(pd); IngridPrincipal ingridPrincipal = null; if (file.exists()) { PlugDescription plugDescription; try {/* ww w . ja v a 2s . c o m*/ plugDescription = new PlugdescriptionSerializer().deSerialize(file); final String pwd = plugDescription.getIplugAdminPassword(); if (userName.equals("admin") && BCrypt.checkpw(password, pwd)) { final Set<String> set = new HashSet<String>(); set.add("admin"); ingridPrincipal = new IngridPrincipal.KnownPrincipal("admin", pwd, set); } else { ingridPrincipal = new IngridPrincipal.UnknownPrincipal(); } } catch (final IOException e) { LOG.error("can not verify login datas", e); } } else { ingridPrincipal = new IngridPrincipal.SuperAdmin("superadmin"); } return ingridPrincipal; }
From source file:de.ingrid.interfaces.csw.admin.IngridHashUserRealm.java
@Override public Principal authenticate(String username, Object credentials, Request request) { synchronized (this) { Principal user = super.getPrincipal(username); if (user == null) { this.put("admin", new KnownPrincipal("admin", ApplicationProperties.get(ConfigurationKeys.INGRID_ADMIN_PASSWORD), null)); user = super.getPrincipal(username); }/* w w w . ja va 2 s . c o m*/ } KnownPrincipal principal = (KnownPrincipal) super.getPrincipal(username); String pw = principal.getPassword(); try { if (BCrypt.checkpw(credentials.toString(), pw)) { return principal; } } catch (Exception e) { log.error("Error during password check:", e); return null; } return null; }
From source file:de.ingrid.admin.security.PlugdescriptionLoginModule.java
@Override protected IngridPrincipal authenticate(String userName, String password) { String pd = System.getProperty(IKeys.PLUG_DESCRIPTION); File file = new File(pd); IngridPrincipal ingridPrincipal = null; String pwd = null;/*from w ww.ja va 2s . c om*/ if (file.exists()) { PlugDescription plugDescription; try { plugDescription = new PlugdescriptionSerializer().deSerialize(file); pwd = plugDescription.getIplugAdminPassword(); } catch (IOException e) { LOG.error("can not verify login datas", e); } } if (pwd != null) { try { if (userName.equals("admin") && BCrypt.checkpw(password, pwd)) { Set<String> set = new HashSet<String>(); set.add("admin"); ingridPrincipal = new IngridPrincipal.KnownPrincipal("admin", pwd, set); } else { ingridPrincipal = new IngridPrincipal.UnknownPrincipal(); } } catch (Exception e) { LOG.error("Error during password check:", e); ingridPrincipal = new IngridPrincipal.UnknownPrincipal(); } } else { ingridPrincipal = new IngridPrincipal.SuperAdmin("superadmin"); } return ingridPrincipal; }
From source file:io.dacopancm.jfee.managedController.FacturaAfiliacionBean.java
@PostConstruct public void postConstruct() { try {/*from w w w . j a va 2 s .co m*/ Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap(); if (params.containsKey("r")) { returnPage = params.get("r"); } if (params.containsKey("socCi") && params.containsKey("h")) { String hash = UriUtils.decode(params.get("h"), "UTF-8"); String ci = params.get("socCi"); if (BCrypt.checkpw(ci, hash)) { selectedSocio = socioService.getSocioByCi(ci); } } else { //redirect to index } } catch (UnsupportedEncodingException ex) { log.error(ex.getMessage()); //redirect to index } }
From source file:com.cfitzarl.cfjwed.service.impl.AccountServiceImpl.java
/** {@inheritDoc} **/ @Override public boolean hasValidCreds(Account account, String creds) { return BCrypt.checkpw(creds, account.getPassword()); }