我想通過編寫代碼來消耗Liferay的用戶實體來添加用戶。密碼不加密,因此登錄失敗。代碼粘貼在下面。如何在Liferay 6.1中保存用戶時加密密碼?
int countOfUsr = UserLocalServiceUtil.getUsersCount();
User user = UserLocalServiceUtil.createUser(countOfUsr + 1);
Date date = new Date();
user.setCompanyId(countOfUsr + 1);
user.setCreateDate(date);
user.setModifiedDate(date);
user.setDefaultUser(false);
user.setContactId(countOfUsr + 1);
user.setPasswordEncrypted(true);
user.setAgreedToTermsOfUse(true);
user.setPassword("123");
user.setPasswordReset(false);
user.setPasswordModifiedDate(date);
user.setReminderQueryQuestion("what-is-your-father's-middle-name");
user.setReminderQueryAnswer("daddad");
user.setGraceLoginCount(0);
user.setScreenName("shibu");
user.setFirstName("SHIBU");
user.setEmailAddress("[email protected]");
user.setFacebookId(0);
user.setOpenId("");
user.setPortraitId(0);
user.setLanguageId("en_US");
user.setTimeZoneId("GMT");
UserLocalServiceUtil.addUser(user);
- 如何修改代碼以正確保存用戶?
- 如何做密碼加密?
- 如何給user.setDigest(arg)賦值?