本文整理汇总了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));
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例6: init
import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
@PostConstruct
void init() {
passwordEncryptor = new StrongPasswordEncryptor();
textEncryptor = new StrongTextEncryptor();
textEncryptor.setPassword(encryptorKey);
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例11: passwordEncryptor
import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
@Bean
public PasswordEncryptor passwordEncryptor() {
return new StrongPasswordEncryptor();
}
示例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;
}
示例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;
}
示例14: strongPasswordEncryptor
import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
@Bean
public StrongPasswordEncryptor strongPasswordEncryptor() {
return new StrongPasswordEncryptor();
}
示例15: encryptPassword
import org.jasypt.util.password.StrongPasswordEncryptor; //导入依赖的package包/类
public static String encryptPassword(String plainPassword) {
StrongPasswordEncryptor passwordEncryptor = new StrongPasswordEncryptor();
return passwordEncryptor.encryptPassword(plainPassword);
}