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


Java StrongPasswordEncryptor类代码示例

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


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

示例1: testCheck

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
/**
 * Test method for {@link net.webpasswordsafe.server.plugin.encryption.JasyptDigester#check(java.lang.String, java.lang.String)}.
 */
@Test
public void testCheck()
{
    JasyptDigester digester = new JasyptDigester();
    digester.setPasswordEncryptor(new StrongPasswordEncryptor());
    String clearText = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
    System.out.println("clearText="+clearText);
    System.out.println("clearText.length="+clearText.length());
    String password1 = digester.digest(clearText);
    System.out.println("password1="+password1);
    System.out.println("password1.length="+password1.length());
    String password2 = digester.digest(clearText);
    System.out.println("password2="+password2);
    System.out.println("password2.length="+password2.length());
    assertTrue(digester.check(clearText, password1));
    assertTrue(digester.check(clearText, password2));
    assertFalse(password1.equals(password2));
}
 
开发者ID:alfameCom,项目名称:salasanasiilo,代码行数:22,代码来源:JasyptDigesterTest.java

示例2: doExecute

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
public String doExecute() {
	getSessionManager().beginTransaction();
	Anvandare anvandare = getDAOFactory().getAnvandareDAO().findByLogin(login);
	if(anvandare != null) {
		if(anvandare.getPassword().equals("")) {
		    getDromelvaSession().setAnvandare(anvandare);
			// Nyskapad användare har tomt password, bör ändra det direkt då de loggat in
			return SUCCESS;
		}
           StrongPasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
           if(passwordEncryptor.checkPassword(password,anvandare.getPassword())) {
               getDromelvaSession().setAnvandare(anvandare);
               return SUCCESS;
           }
	}
	addFieldError("login","Felaktig användare/lösenord");
	return ERROR;
}
 
开发者ID:dromelvan,项目名称:dromelvan-webapp-struts2,代码行数:19,代码来源:Login.java

示例3: testJasptEncoderInstance

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
public void testJasptEncoderInstance() {
    PasswordEncoder passwordEncoder = idmEngineConfiguration.getPasswordEncoder();
    idmEngineConfiguration.setPasswordEncoder(new JasyptPasswordEncryptor(new StrongPasswordEncryptor()));
    validatePassword();

    idmEngineConfiguration.setPasswordEncoder(passwordEncoder);
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:8,代码来源:PasswordEncoderTest.java

示例4: main

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
public static void main(String[] args) {
  String password = args.length >= 1 ? args[0] : "strong";
  String text = args.length >= 2 ? args[1] : "i am hero";

  PasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
  String encryptedPassword = passwordEncryptor.encryptPassword(password);

  BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
  textEncryptor.setPassword(encryptedPassword);
  String myEncryptedText = textEncryptor.encrypt(text);

  System.out.println(myEncryptedText);
}
 
开发者ID:jandy-team,项目名称:jandy,代码行数:14,代码来源:Main.java

示例5: getPasswordEncryptor

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
public PasswordEncryptor getPasswordEncryptor() {
    switch (this) {
        case NONE : return null;
        case BASIC : return new BasicPasswordEncryptor();
        case STRONG : return new StrongPasswordEncryptor();
        default : throw new IllegalStateException("No support for encryptor type " + this);
    }
}
 
开发者ID:washingtonpost,项目名称:dropwizard-peer-authenticator,代码行数:9,代码来源:AllowedPeerConfiguration.java

示例6: init

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
@PostConstruct
void init() {
    passwordEncryptor = new StrongPasswordEncryptor();
    textEncryptor = new StrongTextEncryptor();
    textEncryptor.setPassword(encryptorKey);

}
 
开发者ID:chonglou,项目名称:itpkg,代码行数:8,代码来源:EncryptHelper.java

示例7: checkPassword

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
/**
 * Checks a plain Text Password against a Encrypted String
 *
 * @param password
 * @param encryptedPassword
 * @return boolean indicating if credentials are equal or not.
 */
public static boolean checkPassword(final String password, final String encryptedPassword) {
    if ((password == null) || (password.isEmpty())) {
        return false;
    }
    if ((encryptedPassword == null) || (encryptedPassword.isEmpty())) {
        return false;
    }
    initializeDefaultCryptographyProvider();
    String cs_encryptedPassword = SecurityServiceProviderUtility.decryptFromHexadecimalString(encryptedPassword);
    StrongPasswordEncryptor strongPasswordEncryptor = new StrongPasswordEncryptor();
    return strongPasswordEncryptor.checkPassword(password, cs_encryptedPassword);
}
 
开发者ID:jaschenk,项目名称:jeffaschenk-commons,代码行数:20,代码来源:SecurityServiceProviderUtility.java

示例8: setup

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
@Before
public void setup() {

    fixture = Fixtures.newGivenWhenThenFixture(UserAggregate.class);

    UserCommandHandler commandHandler = new UserCommandHandler(fixture.getRepository(), userQueryRepository, new StrongPasswordEncryptor());
    fixture.registerAnnotatedCommandHandler(commandHandler);

    this.mockMvc = MockMvcBuilders
            .webAppContextSetup(this.wac)
            .addFilters(springSessionRepositoryFilter, springSecurityFilterChain)
            .build();
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:14,代码来源:FacebookControllerTest.java

示例9: doExecute

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
public String doExecute() {
	if(!getPassword().equals(getPassword2())) {
           addFieldError("password","Lösenorden matchar inte");
           return ERROR;
       }
	getSessionManager().beginTransaction();
	Anvandare anvandare = getDromelvaSession().getAnvandare();
	anvandare.setPassword(new StrongPasswordEncryptor().encryptPassword(getPassword()));
	anvandare = getDAOFactory().getAnvandareDAO().save(anvandare);
	getSessionManager().commitTransaction();

	getDromelvaSession().setAnvandare(anvandare);
	return SUCCESS;
}
 
开发者ID:dromelvan,项目名称:dromelvan-webapp-struts2,代码行数:15,代码来源:EditPassword.java

示例10: EncryptPassword

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
private String EncryptPassword(String password){
	StrongPasswordEncryptor encryptor=new StrongPasswordEncryptor();
	String encryptedPassword=encryptor.encryptPassword(password);
	return encryptedPassword;
}
 
开发者ID:jtatia,项目名称:Course-Management-System,代码行数:6,代码来源:AdminDAO.java

示例11: passwordEncryptor

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
@Bean
public PasswordEncryptor passwordEncryptor() {
    return new StrongPasswordEncryptor();
}
 
开发者ID:bartgerard,项目名称:ubrew_v0.1,代码行数:5,代码来源:CoreServiceConfig.java

示例12: addUser

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
/** Add an user to the DB.
 * @return String */
public String addUser() {
	HttpSession session = ServletActionContext.getRequest().getSession();
	User us = new User();
	
	// Save fields
	us.setUsername(this.usernameForm);
	us.setPassword(this.passwordForm);
	us.setRepeatPassword(this.repeatPasswordForm);
	us.setEmail(this.emailForm);
	us.setRole(String.valueOf(this.roleForm));
	us.setType(String.valueOf(this.typeForm));
	us.setOrganisation(String.valueOf(this.organisationForm));
	
	session.setAttribute("newUser", us);
	
    Connection connection = null;
    try {
        connection = new DBConnectionManager().getConnection();
        Statement statement = connection.createStatement();
        ResultSet rs = statement.executeQuery("SELECT * FROM aliada.user WHERE user_name='" + getUsernameForm() + "'");
        if (!rs.next()) {
            statement = connection.createStatement();
            
            if (this.passwordForm.equals(this.repeatPasswordForm)) {
            	// Encrypt password
             StrongPasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
             String encryptedPassword = passwordEncryptor.encryptPassword(this.passwordForm);
             
             statement.executeUpdate("INSERT INTO aliada.user VALUES ('" + this.usernameForm + "', '"
               + encryptedPassword + "', '" + this.emailForm + "', '" + this.typeForm + "', '" + this.roleForm + "', '" + this.organisationForm + "')");
             addActionMessage(getText("user.save.ok"));
             rs.close();
             statement.close();
             connection.close(); 
             getUsersDb();
             session.setAttribute("newUser", null);
            } else {
            	rs.close();
             statement.close();
             connection.close();
            	addFieldError("passwordForm", getText("userPassword.not.equals"));
            	addFieldError("repeatPasswordForm", getText("userPassword.not.equals"));
            	return ERROR;
            }
        } else {
            rs.close();
            statement.close();
            connection.close();
            addFieldError("usernameForm", getText("err.duplicate.user"));
            return ERROR;
        }         	
    } catch (SQLException e) {
        logger.error(MessageCatalog._00011_SQL_EXCEPTION, e);
        return ERROR;
    }
    return SUCCESS;        
}
 
开发者ID:ALIADA,项目名称:aliada-tool,代码行数:60,代码来源:UsersAction.java

示例13: execute

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
/**
 * @return Returns the result of the execution.
 */

public String execute() {
	
	ServletActionContext.getRequest().getSession().setAttribute("action", ActionContext.getContext().getName());
	ServletActionContext.getRequest().getSession().setAttribute("loggedInUser", getInputUser());
	
	Connection conn = null;
	Statement st = null;
	ResultSet rs = null;
	try {
		conn = new DBConnectionManager().getConnection();
		if (conn == null) {
			logger.debug(MessageCatalog._00006_BBDD_CONFIGURATION_INVALID);
			addActionError(getText("error.databaseConfiguration"));
			return ERROR;
		}
		st = conn.createStatement();
		StrongPasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
		
		rs = st.executeQuery("select user_name,user_password,org_name, u.user_type_code from aliada.user u "
				+ "INNER JOIN aliada.organisation o ON u.organisationId = o.organisationId "
				+ "INNER JOIN aliada.t_user_type t ON t.user_type_code = u.user_type_code "
				+ "where user_name = '" + getInputUser() + "' "
				+ "AND language = '" + getLocale().getISO3Language() + "'");
		
		if (rs.next()) {
		    if (passwordEncryptor.checkPassword(getInputPassword(), rs.getString("user_password"))) {
                   ServletActionContext.getRequest().getSession().setAttribute("logedUser", rs.getString("user_name"));
                   ServletActionContext.getRequest().getSession().setAttribute("inst", rs.getString("org_name"));
                   // User type
                   ServletActionContext.getRequest().getSession().setAttribute("type", rs.getInt("user_type_code"));
                   rs.close();
                st.close();
                conn.close();
                return SUCCESS;
              } else {
                logger.debug(MessageCatalog._00010_LOGON_FAILURE);
                addActionError(getText("error.login"));
                   rs.close();
                   st.close();
                   conn.close();
                   return ERROR;
              }			
		} else {
			logger.debug(MessageCatalog._00010_LOGON_FAILURE);
			addActionError(getText("error.login"));
			rs.close();
			st.close();
			conn.close();
			return ERROR;
		}
	} catch (SQLException e) {
		logger.error(MessageCatalog._00011_SQL_EXCEPTION, e);
	}

	return SUCCESS;
}
 
开发者ID:ALIADA,项目名称:aliada-tool,代码行数:61,代码来源:LogonAction.java

示例14: strongPasswordEncryptor

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
@Bean
public StrongPasswordEncryptor strongPasswordEncryptor() {
    return new StrongPasswordEncryptor();
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:5,代码来源:EncryptionConfig.java

示例15: encryptPassword

import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
public static String encryptPassword(String plainPassword) {
    StrongPasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
    return passwordEncryptor.encryptPassword(plainPassword);
}
 
开发者ID:josteitv,项目名称:authenticator-demo,代码行数:5,代码来源:PasswordUtils.java


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