当前位置: 首页>>代码示例>>Java>>正文


Java ShaPasswordEncoder类代码示例

本文整理汇总了Java中org.springframework.security.authentication.encoding.ShaPasswordEncoder的典型用法代码示例。如果您正苦于以下问题:Java ShaPasswordEncoder类的具体用法?Java ShaPasswordEncoder怎么用?Java ShaPasswordEncoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ShaPasswordEncoder类属于org.springframework.security.authentication.encoding包,在下文中一共展示了ShaPasswordEncoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
static public void main(String[] args ) {
	if (args == null || args.length != 2) {
		System.out.println("Please use: EssencePasswordEncoderSHA username password");
		System.exit(1);
	}
	ShaPasswordEncoder encoder = new ShaPasswordEncoder(256);
	String hash = encoder.encodePassword(args[1], args[0]); // pwd, salt
	System.out.println("Encoded password for " + args[0] + "/" + args[1] + " is: " + hash);
}
 
开发者ID:dpinney,项目名称:essence,代码行数:10,代码来源:EssencePasswordEncoderSHA.java

示例2: init

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
    ShaPasswordEncoder encoder = new ShaPasswordEncoder();
    encoder.setEncodeHashAsBase64(true);

    auth
        .inMemoryAuthentication()
            .passwordEncoder(encoder)
            .withUser("admin").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("ADMIN").and()
            .withUser("coordinator").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("COORDINATOR");

    User coordinator = new Coordinator();
    coordinator.setUsername("coordinator");
    userRepository.save(coordinator);

    auth
        .ldapAuthentication()
            .userSearchFilter("uid={0}")
            .contextSource().url("ldap://dir3.udl.net:389/dc=UdL,dc=es")
            .and()
        .userDetailsContextMapper(userDetailsContextMapper);
}
 
开发者ID:UdL-EPS-SoftArch,项目名称:entsoftarch-1516-server,代码行数:23,代码来源:AuthenticationUdLConfig.java

示例3: save

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public User save(User user) {

    logger.debug("UserServiceImpl - save: plainPassword: " + user.getPlainPassword());

    // get existing user for salt string
    if (user.getId() == 0L && user.getPlainPassword() != null) {
        // create salt and password for inserted or updated user
        ShaPasswordEncoder pwdEnc = new ShaPasswordEncoder();
        user.setSalt(user.getUsername() + "-" + user.getEmail());
        user.setPassword(pwdEnc.encodePassword(user.getPlainPassword(), user.getSalt()));
    }

    // save new or updated user
    return userDao.save(user);
}
 
开发者ID:bernfried,项目名称:SimplePRP,代码行数:18,代码来源:UserServiceImpl.java

示例4: main

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
public static void main(String[] args) {
	ShaPasswordEncoder enc = new ShaPasswordEncoder(512);
	enc.setIterations(1000);
	enc.setEncodeHashAsBase64(true);
	String encodedPass = enc.encodePassword("nesa", "nesa");
	System.out.println(encodedPass);
	System.out.println(enc.isPasswordValid(encodedPass, "nesa", "nesa"));
}
 
开发者ID:PacktPublishing,项目名称:Spring-MVC-Blueprints,代码行数:9,代码来源:CartPasswordEncoder.java

示例5: testSha

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
@SuppressWarnings("unused")
static private void testSha() {
	ShaPasswordEncoder encoder = new ShaPasswordEncoder();
	String hash = encoder.encodePassword("test1", "test1"); // pwd, salt
	System.out.println("test1:" + hash);
	System.out.println("test2:" + encoder.encodePassword("test2", "test2"));
	
	ShaPasswordEncoder encoder1 = new ShaPasswordEncoder(256);
	String hash1 = encoder1.encodePassword("test1", "test1"); // pwd, salt
	System.out.println("test1-256:" + hash1);
}
 
开发者ID:dpinney,项目名称:essence,代码行数:12,代码来源:PasswordEncoderTest.java

示例6: init

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
    ShaPasswordEncoder encoder = new ShaPasswordEncoder();
    encoder.setEncodeHashAsBase64(true);

    auth
        .inMemoryAuthentication()
            .passwordEncoder(encoder)
            .withUser("admin").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("ADMIN").and()
            .withUser("coordinator1").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("COORDINATOR").and()
            .withUser("professor1").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("PROFESSOR", "PROPONENT").and()
            .withUser("student1").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("STUDENT", "PROFESSOR");
}
 
开发者ID:UdL-EPS-SoftArch,项目名称:entsoftarch-1516-server,代码行数:14,代码来源:AuthenticationHerokuConfig.java

示例7: InternalAuthenticationProvider

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
@Autowired
public InternalAuthenticationProvider(SCIMUserProvisioning userProvisioning,
                                      ShaPasswordEncoder shaPasswordEncoder,
                                      BCryptPasswordEncoder bCryptPasswordEncoder,
                                      @Value("${osiam.tempLock.count:0}") Integer maxLoginFailures,
                                      @Value("${osiam.tempLock.timeout:0}") Integer lockTimeout) {
    this.userProvisioning = userProvisioning;
    this.shaPasswordEncoder = shaPasswordEncoder;
    this.bCryptPasswordEncoder = bCryptPasswordEncoder;
    this.maxLoginFailures = maxLoginFailures;
    this.lockTimeout = lockTimeout;
}
 
开发者ID:osiam,项目名称:osiam,代码行数:13,代码来源:InternalAuthenticationProvider.java

示例8: user_prepareForgotPasswordMessage

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
public String user_prepareForgotPasswordMessage(Long id)  {
	try {
		
		User user = userDAO.findById(id);
		PasswordEncoder encoder = new ShaPasswordEncoder(256);
		String hash = encoder.encodePassword(user.getEmail() + new Date().getTime(), user.getSalt());
		PasswordResetRequest  passwordResetRequest = new PasswordResetRequest(user.getLogin() ,hash);
		passwordResetRequestDAO.merge(passwordResetRequest);
		return hash;
	} 
	catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
开发者ID:JD-Software,项目名称:JDeSurvey,代码行数:16,代码来源:UserService.java

示例9: user_updatePassword

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
@Transactional(readOnly = false)
public User user_updatePassword(User user) {
		User dbUser = userDAO.findById(user.getId());
		dbUser.setLastUpdateDate(new Date());
		PasswordEncoder encoder = new ShaPasswordEncoder(256);
		dbUser.setPassword(encoder.encodePassword(user.getPassword(), user.getSalt()));
		return userDAO.merge(dbUser);
}
 
开发者ID:JD-Software,项目名称:JDeSurvey,代码行数:9,代码来源:UserService.java

示例10: user_merge

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
@Transactional(readOnly = false)
public User user_merge(User user) {
	//create save the password
	if (user.getId() == null) {
		user.setCreationDate(new Date());
		user.setLastUpdateDate(new Date());
		PasswordEncoder encoder = new ShaPasswordEncoder(256);
		user.setPassword(encoder.encodePassword(user.getPassword(), user.getSalt()));
		return userDAO.merge(user);
	}
	
	else
		//update do not update the password
		{	
		User dbUser = userDAO.findById(user.getId());
		dbUser.setLastUpdateDate(new Date());			
		dbUser.setLogin(user.getLogin());
		dbUser.setFirstName(user.getFirstName());
		dbUser.setDateOfBirth(user.getDateOfBirth());
		dbUser.setMiddleName(user.getMiddleName());
		dbUser.setLastName(user.getLastName());
		dbUser.setEmail(user.getEmail());
		dbUser.setEnabled(user.getEnabled());
		dbUser.setGroups(user.getGroups());
		dbUser.setDepartments(user.getDepartments());
		dbUser.setSurveyDefinitions(user.getSurveyDefinitions());
		return userDAO.merge(dbUser);	
	}
}
 
开发者ID:JD-Software,项目名称:JDeSurvey,代码行数:30,代码来源:UserService.java

示例11: UserServiceImpl

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
@Autowired
public UserServiceImpl(@Qualifier("userRepository") UserRepository repository,
                       @Qualifier("dozerMapper") Mapper dozerMapper,
                       @Qualifier("userPasswordEncoder") ShaPasswordEncoder passwordEncoder) {
    super(repository, dozerMapper, UserInfo.class, User.class);
    this.userRepository = repository;
    this.passwordEncoder = passwordEncoder;
}
 
开发者ID:zutherb,项目名称:AppStash,代码行数:9,代码来源:UserServiceImpl.java

示例12: getUserByUsername

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
@Override
public User getUserByUsername(String username) {
    // Just a mock interface support only one single root
    // Here you can add DAO to load user from the database
    if (username.equals(USER_TEST)) {
        User user = new User();
        user.setLogin(USER_TEST);
        user.setPassword(new ShaPasswordEncoder().encodePassword("password", null));

        return user;
    } else {
        return null;
    }
}
 
开发者ID:imrabti,项目名称:gwtp-spring-security,代码行数:15,代码来源:UserServiceImpl.java

示例13: authenticate

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
@Override
public User authenticate(String username, String password) {
    // get user by username
    User user = userDao.getByUsername(username);
    if (user != null) {
        ShaPasswordEncoder pwdEnc = new ShaPasswordEncoder();
        String pwd = pwdEnc.encodePassword(password, user.getSalt());
        if (pwd.equals(user.getPassword())) {
            return user;
        }
    }
    return null;
}
 
开发者ID:bernfried,项目名称:SimplePRP,代码行数:14,代码来源:UserServiceImpl.java

示例14: encode

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
public static String encode(String password) {
    ShaPasswordEncoder encoder = new ShaPasswordEncoder(256);
    String encodedPassword = encoder.encodePassword(password, null);
    return encodedPassword;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:6,代码来源:Sha256PasswordEncoderMain.java

示例15: passwordEncoder

import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入依赖的package包/类
@Bean
public ShaPasswordEncoder passwordEncoder() {
    return new ShaPasswordEncoder();// argument can put 256 for SHA-256
}
 
开发者ID:tvajjala,项目名称:interview-preparation,代码行数:5,代码来源:WebSecurityConfig.java


注:本文中的org.springframework.security.authentication.encoding.ShaPasswordEncoder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。