List of usage examples for org.springframework.security.crypto.bcrypt BCryptPasswordEncoder BCryptPasswordEncoder
public BCryptPasswordEncoder()
From source file:cz.lbenda.coursing.client.ClientAppConfig.java
public @Bean PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); }
From source file:cz.zcu.kiv.eegdatabase.wui.core.person.PersonServiceImpl.java
private String encodePassword(String plaintextPassword) { if (plaintextPassword == null) return encodeRandomPassword(); return new BCryptPasswordEncoder().encode(plaintextPassword); }
From source file:cz.zcu.kiv.eegdatabase.wui.core.person.PersonServiceImpl.java
private boolean matchPasswords(String plaintextPassword, String encodedPassword) { return new BCryptPasswordEncoder().matches(plaintextPassword, encodedPassword); }
From source file:ch.wisv.areafiftylan.users.service.UserServiceImpl.java
@Override public void resetPassword(Long userId, String password) { User user = userRepository.findOne(userId); // The token is being checked in the authentication, so just set the password here user.setPasswordHash(new BCryptPasswordEncoder().encode(password)); userRepository.saveAndFlush(user);/* www .j ava 2 s . c om*/ }
From source file:com.abixen.platform.core.domain.model.User.java
public void changePassword(String currentPassword, String newPassword) { final PasswordEncoder encoder = new BCryptPasswordEncoder(); if (!encoder.matches(currentPassword, getPassword())) { throw new UsernameNotFoundException("Wrong username and / or password."); }// w w w . j a va 2 s . c o m setPassword(encoder.encode(newPassword)); }
From source file:ch.wisv.areafiftylan.users.service.UserServiceImpl.java
@Override public void changePassword(Long userId, String oldPassword, String newPassword) { User user = userRepository.findOne(userId); if (new BCryptPasswordEncoder().matches(oldPassword, user.getPassword())) { user.setPasswordHash(getPasswordHash(newPassword)); userRepository.save(user);/*from w w w .j a v a 2 s .c o m*/ } else { throw new AccessDeniedException("Wrong password"); } }
From source file:com.abixen.platform.core.domain.model.User.java
public void changeAvatar(String imageLibraryDirectory, MultipartFile avatarFile) throws IOException { final File currentAvatarFile = new File(imageLibraryDirectory + "/user-avatar/" + getAvatarFileName()); if (currentAvatarFile.exists()) { if (!currentAvatarFile.delete()) { throw new FileExistsException(); }/*from ww w. j a v a2 s . co m*/ } final PasswordEncoder encoder = new BCryptPasswordEncoder(); final String newAvatarFileName = encoder.encode(avatarFile.getName() + new Date().getTime()) .replaceAll("\"", "s").replaceAll("/", "a").replace(".", "sde"); final File newAvatarFile = new File(imageLibraryDirectory + "/user-avatar/" + newAvatarFileName); final FileOutputStream out = new FileOutputStream(newAvatarFile); out.write(avatarFile.getBytes()); out.close(); setAvatarFileName(newAvatarFileName); }
From source file:io.dacopancm.jfee.managedController.SociosBean.java
public String editSocioRequestPageAction() { try {// w w w. ja v a2 s. com return "/views/s/adminSocios/editarSocio.xhtml?faces-redirect=true&socCi=" + selectedSocio.getUsuario().getUsrCi() + "&h=" + UriUtils.encode(new BCryptPasswordEncoder().encode(selectedSocio.getUsuario().getUsrCi()), "UTF-8") + "&r=adminSocios"; } catch (UnsupportedEncodingException ex) { log.error("jfee: " + ex, ex); } return null; }
From source file:cz.zcu.kiv.eegdatabase.data.service.HibernatePersonService.java
/** * @return password encoded by whatever mechanism is currently used to store passwords *//*from w w w. ja va 2 s . co m*/ private String encodePassword(String plaintextPassword) { String result = new BCryptPasswordEncoder().encode(plaintextPassword); //log.debug("Encoded password = " + result);//uncomment if needed return result; }
From source file:ch.wisv.areafiftylan.users.service.UserServiceImpl.java
/** * Encrypt the password using the BCryptPasswordEncoder with default settings * * @param plainTextPassword The password to be encoded * * @return The hashed password/*w w w.j a v a 2 s. co m*/ */ private String getPasswordHash(String plainTextPassword) { return new BCryptPasswordEncoder().encode(plainTextPassword); }