Package org.springframework.security.authentication.encoding

Examples of org.springframework.security.authentication.encoding.Md5PasswordEncoder


        }
    }

    private String getHash() throws NoSuchAlgorithmException, UnsupportedEncodingException
    {
        PasswordEncoder encoder = new Md5PasswordEncoder();
        String hashedPass = encoder.encodePassword(password, null);

        password = password.replaceAll(".*", "0");
        passwordConf = passwordConf.replaceAll(".*", "0");
        return hashedPass;
    }
View Full Code Here


    }
  }
 
  private UserDetails makeRootUser(InternalUser user) {
    Object salt = null;
    Md5PasswordEncoder encoder = new Md5PasswordEncoder();
    return new User(user.getEmail(), encoder.encodePassword(user.getPassword(), salt),
        true, true, true, true, makeRootGrantedAuthorities());
  }
View Full Code Here

    return authorities;
  }
 
  private UserDetails makeUser(InternalUser user) throws Exception {
    Object salt = null;
    Md5PasswordEncoder encoder = new Md5PasswordEncoder();
   
    if(user.getAdmin() != null && user.getAdmin()) {
      return new User(user.getEmail(), encoder.encodePassword(user.getPassword(), salt),
          true, true, true, true, makeAdminGrantedAuthorities());
    }
   
    // TODO change it! By default it's a provider user
    return new User(user.getEmail(), encoder.encodePassword(user.getPassword(), salt),
        true, true, true, true, makeProviderGrantedAuthorities(user));
  }
View Full Code Here

  public static void main(String[] args) {
    if (args.length != 3) {
      System.out.println("Usage : [md5|sha|plaintext] username password");
    } else if (args[0].equals("md5")) {
      PasswordEncoder encoder = new Md5PasswordEncoder();
      System.out.println(encoder.encodePassword(args[2], args[1]));
    } else if (args[0].equals("sha")) {
      PasswordEncoder encoder = new ShaPasswordEncoder();
      System.out.println(encoder.encodePassword(args[2], args[1]));
    } else if (args[0].equals("plaintext")) {
      PasswordEncoder encoder = new PlaintextPasswordEncoder();
      System.out.println(encoder.encodePassword(args[2], args[1]));
    } else {
      System.out.println("Algorithm must be md5, sha or plaintext");
    }
  }
View Full Code Here

  @RequestMapping(value = { "/generatePassword" }, method = RequestMethod.GET)
  public ResponseEntity<String> generatePassword(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) throws Exception {
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.add("Content-Type", MediaType.TEXT_PLAIN.toString());
    return new ResponseEntity<String>(new Md5PasswordEncoder().encodePassword(request.getParameter("passwordField"), null), responseHeaders, HttpStatus.CREATED);
  }
View Full Code Here

    @Test
    public void userShouldBeRegisteredUsingEncryptedPassword() throws Exception{
        String password = "password";
        RegisterUserDto registerUserDto = createRegisterUserDto("username", password, "email@email.em", null);
        EncryptionService realEncryptionService = new EncryptionService(new Md5PasswordEncoder());
        TransactionalAuthenticator authenticatorSpy = spy(new TransactionalAuthenticator(pluginLoader, userDao, groupDao,
                realEncryptionService, mailService, avatarService, pluginService,
                securityFacade, rememberMeServices, sessionStrategy, validator, authenticationManager));

        authenticatorSpy.register(registerUserDto);
View Full Code Here

        existingProfile.setGeoLocation(profile.getGeoLocation());
        existingProfile.setVideoEmbeds(profile.getVideoEmbeds());
        existingProfile.setGravatarEmail(profile.getGravatarEmail());

        if (!StringUtils.isEmpty(profile.getGravatarEmail())) {
            Md5PasswordEncoder encoder = new Md5PasswordEncoder();
            String hashedEmail = encoder.encodePassword(profile.getGravatarEmail(), null);
            existingProfile.setAvatarUrl(String.format("http://gravatar.com/avatar/%s", hashedEmail));
        }

        teamRepository.save(existingProfile);
        try {
View Full Code Here

    @RequestMapping(value = "/register.do", method = RequestMethod.POST)
    public String addItemTemplate(@ModelAttribute("newUser") UserAuth userAuth,
                                  BindingResult result) {

        userAuth.setActive(true);
        Md5PasswordEncoder enc = new Md5PasswordEncoder();
        userAuth.setPasswordHash(enc.encodePassword(userAuth.getPasswordHash(), null));
        userService.createUser(userAuth);
        User user = new User();
        user.setId(userAuth.getUserId());
        service.addUser(user);
View Full Code Here

        this.password = encode(password);
        this.roles = roles;
    }

    private String encode(String password) {
        return new Md5PasswordEncoder().encodePassword(password, SALT);
    }
View Full Code Here

   * @param password
   *            - decoded password string
   */
  public void setAndEncodePassword(String password) {
    // create the encoder object
    Md5PasswordEncoder encoder = new Md5PasswordEncoder();
    encoder.setEncodeHashAsBase64(true);

    // encode the password using the unique user ID as the salt
    String encodedPassword = encoder.encodePassword(password, new Long(this.getId()));

    // set the password
    setPassword(encodedPassword);
  }
View Full Code Here

TOP

Related Classes of org.springframework.security.authentication.encoding.Md5PasswordEncoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.