change method

This commit is contained in:
MaxKey
2022-01-03 20:30:39 +08:00
parent a7b8489496
commit 840105f482
22 changed files with 234 additions and 250 deletions

View File

@@ -86,7 +86,7 @@ public abstract class AbstractAuthenticationRealm {
}
public UserInfo loadUserInfo(String username, String password) {
return loginService.loadUserInfo(username, password);
return loginService.find(username, password);
}
public abstract boolean passwordMatches(UserInfo userInfo, String password);
@@ -163,7 +163,7 @@ public abstract class AbstractAuthenticationRealm {
loginHistoryService.login(historyLogin);
loginService.setLastLoginInfo(userInfo);
loginService.updateLastLogin(userInfo);
return true;
}
@@ -185,7 +185,7 @@ public abstract class AbstractAuthenticationRealm {
loginHistoryService.logoff(userInfo.getLastLogoffTime(), sessionIdAttribute.toString());
}
loginService.setLastLogoffInfo(userInfo);
loginService.updateLastLogoff(userInfo);
_logger.debug("Session " + WebContext.getAttribute(WebConstants.CURRENT_USER_SESSION_ID) + ", user "
+ userInfo.getUsername() + " Logout, datetime " + userInfo.getLastLogoffTime() + " .");

View File

@@ -54,11 +54,11 @@ public class LoginService {
private static final String GROUPS_SELECT_STATEMENT = "select distinct g.id,g.name from mxk_userinfo u,mxk_groups g,mxk_group_member gm where u.id = ? and u.id=gm.memberid and gm.groupid=g.id ";
private static final String DEFAULT_USERINFO_SELECT_STATEMENT = "select * from mxk_userinfo where username = ?";
private static final String DEFAULT_USERINFO_SELECT_STATEMENT = "select * from mxk_userinfo where username = ? ";
private static final String DEFAULT_USERINFO_SELECT_STATEMENT_USERNAME_MOBILE = "select * from mxk_userinfo where username = ? or mobile = ? ";
private static final String DEFAULT_USERINFO_SELECT_STATEMENT_USERNAME_MOBILE = "select * from mxk_userinfo where (username = ? or mobile = ?)";
private static final String DEFAULT_USERINFO_SELECT_STATEMENT_USERNAME_MOBILE_EMAIL = "select * from mxk_userinfo where username = ? or mobile = ? or email = ? ";
private static final String DEFAULT_USERINFO_SELECT_STATEMENT_USERNAME_MOBILE_EMAIL = "select * from mxk_userinfo where (username = ? or mobile = ? or email = ?) ";
private static final String DEFAULT_MYAPPS_SELECT_STATEMENT = "select distinct app.id,app.name from mxk_apps app,mxk_group_privileges gp,mxk_groups g where app.id=gp.appid and gp.groupid=g.id and g.id in(%s)";
@@ -77,27 +77,14 @@ public class LoginService {
this.jdbcTemplate=jdbcTemplate;
}
public UserInfo loadUserInfo(String username, String password) {
public UserInfo find(String username, String password) {
List<UserInfo> listUserInfo = null ;
if( LOGIN_ATTRIBUTE_TYPE == 1) {
listUserInfo = jdbcTemplate.query(
DEFAULT_USERINFO_SELECT_STATEMENT,
new UserInfoRowMapper(),
username
);
listUserInfo = findByUsername(username,password);
}else if( LOGIN_ATTRIBUTE_TYPE == 2) {
listUserInfo = jdbcTemplate.query(
DEFAULT_USERINFO_SELECT_STATEMENT_USERNAME_MOBILE,
new UserInfoRowMapper(),
username,username
);
listUserInfo = findByUsernameOrMobile(username,password);
}else if( LOGIN_ATTRIBUTE_TYPE == 3) {
listUserInfo = jdbcTemplate.query(
DEFAULT_USERINFO_SELECT_STATEMENT_USERNAME_MOBILE_EMAIL,
new UserInfoRowMapper(),
username,username,username
);
listUserInfo = findByUsernameOrMobileOrEmail(username,password);
}
UserInfo userInfo = null;
@@ -108,6 +95,29 @@ public class LoginService {
return userInfo;
}
public List<UserInfo> findByUsername(String username, String password) {
return jdbcTemplate.query(
DEFAULT_USERINFO_SELECT_STATEMENT,
new UserInfoRowMapper(),
username
);
}
public List<UserInfo> findByUsernameOrMobile(String username, String password) {
return jdbcTemplate.query(
DEFAULT_USERINFO_SELECT_STATEMENT_USERNAME_MOBILE,
new UserInfoRowMapper(),
username,username
);
}
public List<UserInfo> findByUsernameOrMobileOrEmail(String username, String password) {
return jdbcTemplate.query(
DEFAULT_USERINFO_SELECT_STATEMENT_USERNAME_MOBILE_EMAIL,
new UserInfoRowMapper(),
username,username,username
);
}
/**
@@ -115,7 +125,7 @@ public class LoginService {
*
* @param userInfo
*/
public void lockUser(UserInfo userInfo) {
public void updateLock(UserInfo userInfo) {
try {
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
jdbcTemplate.update(LOCK_USER_UPDATE_STATEMENT,
@@ -133,7 +143,7 @@ public class LoginService {
*
* @param userInfo
*/
public void unlockUser(UserInfo userInfo) {
public void updateUnlock(UserInfo userInfo) {
try {
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
jdbcTemplate.update(UNLOCK_USER_UPDATE_STATEMENT,
@@ -151,7 +161,7 @@ public class LoginService {
*
* @param userInfo
*/
public void resetBadPasswordCountAndLockout(UserInfo userInfo) {
public void updateLockout(UserInfo userInfo) {
try {
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
jdbcTemplate.update(BADPASSWORDCOUNT_RESET_UPDATE_STATEMENT,
@@ -169,7 +179,7 @@ public class LoginService {
*
* @param userInfo
*/
public void setBadPasswordCount(UserInfo userInfo) {
public void updateBadPasswordCount(UserInfo userInfo) {
try {
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
int badPasswordCount = userInfo.getBadPasswordCount() + 1;
@@ -194,7 +204,7 @@ public class LoginService {
String.format(DEFAULT_MYAPPS_SELECT_STATEMENT, grantedAuthorityString),
new RowMapper<GrantedAuthority>() {
public GrantedAuthority mapRow(ResultSet rs, int rowNum) throws SQLException {
return new SimpleGrantedAuthority(rs.getString("ID"));
return new SimpleGrantedAuthority(rs.getString("id"));
}
});
@@ -205,7 +215,7 @@ public class LoginService {
public List<Groups> queryGroups(UserInfo userInfo) {
List<Groups> listGroups = jdbcTemplate.query(GROUPS_SELECT_STATEMENT, new RowMapper<Groups>() {
public Groups mapRow(ResultSet rs, int rowNum) throws SQLException {
Groups group = new Groups(rs.getString("ID"), rs.getString("NAME"), 0);
Groups group = new Groups(rs.getString("id"), rs.getString("name"), 0);
return group;
}
@@ -239,128 +249,131 @@ public class LoginService {
}
public void setLastLoginInfo(UserInfo userInfo) {
public void updateLastLogin(UserInfo userInfo) {
jdbcTemplate.update(LOGIN_USERINFO_UPDATE_STATEMENT,
new Object[] { userInfo.getLastLoginTime(), userInfo.getLastLoginIp(), userInfo.getLoginCount() + 1, userInfo.getId() },
new Object[] {
userInfo.getLastLoginTime(),
userInfo.getLastLoginIp(),
userInfo.getLoginCount() + 1,
userInfo.getId()
},
new int[] { Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.VARCHAR });
}
public void setLastLogoffInfo(UserInfo userInfo) {
jdbcTemplate.update(LOGOUT_USERINFO_UPDATE_STATEMENT, new Object[] { userInfo.getLastLogoffTime(), userInfo.getId() },
new int[] { Types.VARCHAR, Types.VARCHAR });
public void updateLastLogoff(UserInfo userInfo) {
jdbcTemplate.update( LOGOUT_USERINFO_UPDATE_STATEMENT,
new Object[] { userInfo.getLastLogoffTime(), userInfo.getId() },
new int[] { Types.VARCHAR, Types.VARCHAR });
}
public class UserInfoRowMapper implements RowMapper<UserInfo> {
@Override
public UserInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
UserInfo userInfo = new UserInfo();
userInfo.setId(rs.getString("ID"));
userInfo.setUsername(rs.getString("USERNAME"));
userInfo.setPassword(rs.getString("PASSWORD"));
userInfo.setSharedSecret(rs.getString("SHAREDSECRET"));
userInfo.setSharedCounter(rs.getString("SHAREDCOUNTER"));
userInfo.setDecipherable(rs.getString("DECIPHERABLE"));
userInfo.setWindowsAccount(rs.getString("WINDOWSACCOUNT"));
userInfo.setUserType(rs.getString("USERTYPE"));
userInfo.setId(rs.getString("id"));
userInfo.setUsername(rs.getString("username"));
userInfo.setPassword(rs.getString("password"));
userInfo.setSharedSecret(rs.getString("sharedsecret"));
userInfo.setSharedCounter(rs.getString("sharedcounter"));
userInfo.setDecipherable(rs.getString("decipherable"));
userInfo.setWindowsAccount(rs.getString("windowsaccount"));
userInfo.setUserType(rs.getString("usertype"));
userInfo.setDisplayName(rs.getString("DISPLAYNAME"));
userInfo.setNickName(rs.getString("NICKNAME"));
userInfo.setNameZhSpell(rs.getString("NAMEZHSPELL"));// nameZHSpell
userInfo.setNameZhShortSpell(rs.getString("NAMEZHSHORTSPELL"));// nameZHSpell
userInfo.setGivenName(rs.getString("GIVENNAME"));
userInfo.setMiddleName(rs.getString("MIDDLENAME"));
userInfo.setFamilyName(rs.getString("FAMILYNAME"));
userInfo.setHonorificPrefix(rs.getString("HONORIFICPREFIX"));
userInfo.setHonorificSuffix(rs.getString("HONORIFICSUFFIX"));
userInfo.setFormattedName(rs.getString("FORMATTEDNAME"));
userInfo.setDisplayName(rs.getString("displayname"));
userInfo.setNickName(rs.getString("nickname"));
userInfo.setNameZhSpell(rs.getString("namezhspell"));// nameZHSpell
userInfo.setNameZhShortSpell(rs.getString("namezhshortspell"));// nameZHSpell
userInfo.setGivenName(rs.getString("givenname"));
userInfo.setMiddleName(rs.getString("middlename"));
userInfo.setFamilyName(rs.getString("familyname"));
userInfo.setHonorificPrefix(rs.getString("honorificprefix"));
userInfo.setHonorificSuffix(rs.getString("honorificsuffix"));
userInfo.setFormattedName(rs.getString("formattedname"));
userInfo.setGender(rs.getInt("GENDER"));
userInfo.setBirthDate(rs.getString("BIRTHDATE"));
userInfo.setPicture(rs.getBytes("PICTURE"));
userInfo.setMarried(rs.getInt("MARRIED"));
userInfo.setIdType(rs.getInt("IDTYPE"));
userInfo.setIdCardNo(rs.getString("IDCARDNO"));
userInfo.setWebSite(rs.getString("WEBSITE"));
userInfo.setGender(rs.getInt("gender"));
userInfo.setBirthDate(rs.getString("birthdate"));
userInfo.setPicture(rs.getBytes("picture"));
userInfo.setMarried(rs.getInt("married"));
userInfo.setIdType(rs.getInt("idtype"));
userInfo.setIdCardNo(rs.getString("idcardno"));
userInfo.setWebSite(rs.getString("website"));
userInfo.setAuthnType(rs.getInt("AUTHNTYPE"));
userInfo.setMobile(rs.getString("MOBILE"));
userInfo.setMobileVerified(rs.getInt("MOBILEVERIFIED"));
userInfo.setEmail(rs.getString("EMAIL"));
userInfo.setEmailVerified(rs.getInt("EMAILVERIFIED"));
userInfo.setPasswordQuestion(rs.getString("PASSWORDQUESTION"));
userInfo.setPasswordAnswer(rs.getString("PASSWORDANSWER"));
userInfo.setAuthnType(rs.getInt("authntype"));
userInfo.setMobile(rs.getString("mobile"));
userInfo.setMobileVerified(rs.getInt("mobileverified"));
userInfo.setEmail(rs.getString("email"));
userInfo.setEmailVerified(rs.getInt("emailverified"));
userInfo.setPasswordQuestion(rs.getString("passwordquestion"));
userInfo.setPasswordAnswer(rs.getString("passwordanswer"));
userInfo.setAppLoginAuthnType(rs.getInt("APPLOGINAUTHNTYPE"));
userInfo.setAppLoginPassword(rs.getString("APPLOGINPASSWORD"));
userInfo.setProtectedApps(rs.getString("PROTECTEDAPPS"));
userInfo.setAppLoginAuthnType(rs.getInt("apploginauthntype"));
userInfo.setAppLoginPassword(rs.getString("apploginpassword"));
userInfo.setProtectedApps(rs.getString("protectedapps"));
userInfo.setPasswordLastSetTime(rs.getString("PASSWORDLASTSETTIME"));
userInfo.setPasswordSetType(rs.getInt("PASSWORDSETTYPE"));
userInfo.setBadPasswordCount(rs.getInt("BADPASSWORDCOUNT"));
userInfo.setBadPasswordTime(rs.getString("BADPASSWORDTIME"));
userInfo.setUnLockTime(rs.getString("UNLOCKTIME"));
userInfo.setIsLocked(rs.getInt("ISLOCKED"));
userInfo.setLastLoginTime(rs.getString("LASTLOGINTIME"));
userInfo.setLastLoginIp(rs.getString("LASTLOGINIP"));
userInfo.setLastLogoffTime(rs.getString("LASTLOGOFFTIME"));
userInfo.setLoginCount(rs.getInt("LOGINCOUNT"));
userInfo.setPasswordLastSetTime(rs.getString("passwordlastsettime"));
userInfo.setPasswordSetType(rs.getInt("passwordsettype"));
userInfo.setBadPasswordCount(rs.getInt("badpasswordcount"));
userInfo.setBadPasswordTime(rs.getString("badpasswordtime"));
userInfo.setUnLockTime(rs.getString("unlocktime"));
userInfo.setIsLocked(rs.getInt("islocked"));
userInfo.setLastLoginTime(rs.getString("lastlogintime"));
userInfo.setLastLoginIp(rs.getString("lastloginip"));
userInfo.setLastLogoffTime(rs.getString("lastlogofftime"));
userInfo.setLoginCount(rs.getInt("logincount"));
userInfo.setTimeZone(rs.getString("TIMEZONE"));
userInfo.setLocale(rs.getString("LOCALE"));
userInfo.setPreferredLanguage(rs.getString("PREFERREDLANGUAGE"));
userInfo.setTimeZone(rs.getString("timezone"));
userInfo.setLocale(rs.getString("locale"));
userInfo.setPreferredLanguage(rs.getString("preferredlanguage"));
userInfo.setWorkEmail(rs.getString("WORKEMAIL"));
userInfo.setWorkPhoneNumber(rs.getString("WORKPHONENUMBER"));
userInfo.setWorkCountry(rs.getString("WORKCOUNTRY"));
userInfo.setWorkRegion(rs.getString("WORKREGION"));
userInfo.setWorkLocality(rs.getString("WORKLOCALITY"));
userInfo.setWorkStreetAddress(rs.getString("WORKSTREETADDRESS"));
userInfo.setWorkAddressFormatted(rs.getString("WORKADDRESSFORMATTED"));
userInfo.setWorkPostalCode(rs.getString("WORKPOSTALCODE"));
userInfo.setWorkFax(rs.getString("WORKFAX"));
userInfo.setWorkEmail(rs.getString("workemail"));
userInfo.setWorkPhoneNumber(rs.getString("workphonenumber"));
userInfo.setWorkCountry(rs.getString("workcountry"));
userInfo.setWorkRegion(rs.getString("workregion"));
userInfo.setWorkLocality(rs.getString("worklocality"));
userInfo.setWorkStreetAddress(rs.getString("workstreetaddress"));
userInfo.setWorkAddressFormatted(rs.getString("workaddressformatted"));
userInfo.setWorkPostalCode(rs.getString("workpostalcode"));
userInfo.setWorkFax(rs.getString("workfax"));
userInfo.setHomeEmail(rs.getString("HOMEEMAIL"));
userInfo.setHomePhoneNumber(rs.getString("HOMEPHONENUMBER"));
userInfo.setHomeCountry(rs.getString("HOMECOUNTRY"));
userInfo.setHomeRegion(rs.getString("HOMEREGION"));
userInfo.setHomeLocality(rs.getString("HOMELOCALITY"));
userInfo.setHomeStreetAddress(rs.getString("HOMESTREETADDRESS"));
userInfo.setHomeAddressFormatted(rs.getString("HOMEADDRESSFORMATTED"));
userInfo.setHomePostalCode(rs.getString("HOMEPOSTALCODE"));
userInfo.setHomeFax(rs.getString("HOMEFAX"));
userInfo.setHomeEmail(rs.getString("homeemail"));
userInfo.setHomePhoneNumber(rs.getString("homephonenumber"));
userInfo.setHomeCountry(rs.getString("homecountry"));
userInfo.setHomeRegion(rs.getString("homeregion"));
userInfo.setHomeLocality(rs.getString("homelocality"));
userInfo.setHomeStreetAddress(rs.getString("homestreetaddress"));
userInfo.setHomeAddressFormatted(rs.getString("homeaddressformatted"));
userInfo.setHomePostalCode(rs.getString("homepostalcode"));
userInfo.setHomeFax(rs.getString("homefax"));
userInfo.setEmployeeNumber(rs.getString("EMPLOYEENUMBER"));
userInfo.setDivision(rs.getString("DIVISION"));
userInfo.setCostCenter(rs.getString("COSTCENTER"));
userInfo.setOrganization(rs.getString("ORGANIZATION"));
userInfo.setDepartmentId(rs.getString("DEPARTMENTID"));
userInfo.setDepartment(rs.getString("DEPARTMENT"));
userInfo.setJobTitle(rs.getString("JOBTITLE"));
userInfo.setJobLevel(rs.getString("JOBLEVEL"));
userInfo.setManagerId(rs.getString("MANAGERID"));
userInfo.setManager(rs.getString("MANAGER"));
userInfo.setAssistantId(rs.getString("ASSISTANTID"));
userInfo.setAssistant(rs.getString("ASSISTANT"));
userInfo.setEntryDate(rs.getString("ENTRYDATE"));//
userInfo.setQuitDate(rs.getString("QUITDATE"));
userInfo.setStartWorkDate(rs.getString("STARTWORKDATE"));// STARTWORKDATE
userInfo.setEmployeeNumber(rs.getString("employeenumber"));
userInfo.setDivision(rs.getString("division"));
userInfo.setCostCenter(rs.getString("costcenter"));
userInfo.setOrganization(rs.getString("organization"));
userInfo.setDepartmentId(rs.getString("departmentid"));
userInfo.setDepartment(rs.getString("department"));
userInfo.setJobTitle(rs.getString("jobtitle"));
userInfo.setJobLevel(rs.getString("joblevel"));
userInfo.setManagerId(rs.getString("managerid"));
userInfo.setManager(rs.getString("manager"));
userInfo.setAssistantId(rs.getString("assistantid"));
userInfo.setAssistant(rs.getString("assistant"));
userInfo.setEntryDate(rs.getString("entrydate"));//
userInfo.setQuitDate(rs.getString("quitdate"));
userInfo.setStartWorkDate(rs.getString("startworkdate"));// STARTWORKDATE
userInfo.setExtraAttribute(rs.getString("EXTRAATTRIBUTE"));
userInfo.setExtraAttribute(rs.getString("extraattribute"));
userInfo.setCreatedBy(rs.getString("CREATEDBY"));
userInfo.setCreatedDate(rs.getString("CREATEDDATE"));
userInfo.setModifiedBy(rs.getString("MODIFIEDBY"));
userInfo.setModifiedDate(rs.getString("MODIFIEDDATE"));
userInfo.setCreatedBy(rs.getString("createdby"));
userInfo.setCreatedDate(rs.getString("createddate"));
userInfo.setModifiedBy(rs.getString("modifiedby"));
userInfo.setModifiedDate(rs.getString("modifieddate"));
userInfo.setStatus(rs.getInt("STATUS"));
userInfo.setGridList(rs.getInt("GRIDLIST"));
userInfo.setDescription(rs.getString("DESCRIPTION"));
userInfo.setTheme(rs.getString("THEME"));
userInfo.setInstId(rs.getString("INSTID"));
userInfo.setStatus(rs.getInt("status"));
userInfo.setGridList(rs.getInt("gridlist"));
userInfo.setDescription(rs.getString("description"));
userInfo.setTheme(rs.getString("theme"));
userInfo.setInstId(rs.getString("instid"));
if (userInfo.getTheme() == null || userInfo.getTheme().equalsIgnoreCase("")) {
userInfo.setTheme("default");
}

View File

@@ -78,7 +78,7 @@ public class SessionListenerAdapter implements HttpSessionListener {
init();
UserInfo userInfo = (UserInfo)session.getAttribute(WebConstants.CURRENT_USER);
userInfo.setLastLogoffTime(DateUtils.formatDateTime(new Date()));
loginService.setLastLogoffInfo(userInfo);
loginService.updateLastLogoff(userInfo);
loginHistoryService.logoff(userInfo.getLastLogoffTime(), sessionIdAttribute.toString());
_logger.debug(

View File

@@ -58,7 +58,7 @@ public class RestUserInfoController {
public UserInfo create(@RequestBody UserInfo userInfo,
@RequestParam(required = false) String attributes,
UriComponentsBuilder builder) throws IOException {
UserInfo loadUserInfo = userInfoService.loadByUsername(userInfo.getUsername());
UserInfo loadUserInfo = userInfoService.findByUsername(userInfo.getUsername());
if(loadUserInfo != null) {
userInfoService.update(userInfo);
}else {
@@ -73,7 +73,7 @@ public class RestUserInfoController {
@RequestParam(required = true) String username,
@RequestParam(required = true) String password,
UriComponentsBuilder builder) throws IOException {
UserInfo loadUserInfo = userInfoService.loadByUsername(username);
UserInfo loadUserInfo = userInfoService.findByUsername(username);
if(loadUserInfo != null) {
UserInfo changePassword = new UserInfo();
changePassword.setId(loadUserInfo.getId());
@@ -91,7 +91,7 @@ public class RestUserInfoController {
@RequestBody UserInfo userInfo,
@RequestParam(required = false) String attributes)
throws IOException {
UserInfo loadUserInfo = userInfoService.loadByUsername(userInfo.getUsername());
UserInfo loadUserInfo = userInfoService.findByUsername(userInfo.getUsername());
if(loadUserInfo != null) {
userInfoService.update(userInfo);
}else {
@@ -103,7 +103,6 @@ public class RestUserInfoController {
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.OK)
public void delete(@PathVariable final String id) {
userInfoService.logisticDeleteAllByCid(id);
userInfoService.logicDelete(id);
}
}

View File

@@ -22,6 +22,7 @@ import java.util.List;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
import org.maxkey.constants.ConstantsStatus;
import org.maxkey.entity.Organizations;
import org.maxkey.entity.UserInfo;
import org.maxkey.entity.UserInfoAdjoint;
@@ -34,44 +35,42 @@ import org.maxkey.entity.UserInfoAdjoint;
public interface UserInfoMapper extends IJpaBaseMapper<UserInfo>{
//login query
public UserInfo findByAppIdAndUsername(UserInfo userInfo);
public UserInfo loadByAppIdAndUsername(UserInfo userInfo);
@Select("select * from mxk_userinfo where username = #{value} and status = " + ConstantsStatus.ACTIVE)
public UserInfo findByUsername(String username);
public int logisticDeleteAllByCid(String cid);
@Select("select * from mxk_userinfo where ( email = #{value} or mobile= #{value} ) and status = " + ConstantsStatus.ACTIVE)
public UserInfo findByEmailMobile(String emailMobile);
public List<Organizations> findDeptsByUserId(String userId);
public UserInfo loadByUsername(String username);
public List<UserInfoAdjoint> findAdjointsByUserId(String userId);
public void locked(UserInfo userInfo);
public void updateLocked(UserInfo userInfo);
public void unlock(UserInfo userInfo);
public void updateLockout(UserInfo userInfo);
public void updateBadPWDCount(UserInfo userInfo);
public int changePassword(UserInfo userInfo);
public int updatePassword(UserInfo userInfo);
public int changeAppLoginPassword(UserInfo userInfo);
public int updateAppLoginPassword(UserInfo userInfo);
public int updateProtectedApps(UserInfo userInfo);
public int updateProtectedApps(UserInfo userInfo);
public int changeSharedSecret(UserInfo userInfo);
public int updateSharedSecret(UserInfo userInfo);
public int changePasswordQuestion(UserInfo userInfo);
public int updatePasswordQuestion(UserInfo userInfo);
public int changeAuthnType(UserInfo userInfo);
public int updateAuthnType(UserInfo userInfo);
public int changeEmail(UserInfo userInfo);
public int updateEmail(UserInfo userInfo);
public int changeMobile(UserInfo userInfo);
public int updateMobile(UserInfo userInfo);
public int updateProfile(UserInfo userInfo);
public int updateProfile(UserInfo userInfo);
public List<Organizations> loadDeptsByUserId(String userId);
public List<UserInfoAdjoint> loadAdjointsByUserId(String userId);
@Select("select * from mxk_userinfo where email = #{value} or mobile= #{value}")
public UserInfo queryUserInfoByEmailMobile(String emailMobile);
@Update("update mxk_userinfo set gridlist = #{gridList} where id = #{id}")
public int updateGridList(UserInfo userInfo) ;
public int updateGridList(UserInfo userInfo) ;
}

View File

@@ -72,7 +72,7 @@ public class AccountsService extends JpaBaseService<Accounts>{
public boolean insert(Accounts account) {
if (super.insert(account)) {
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
UserInfo loadUserInfo = userInfoService.loadUserRelated(account.getUserId());
UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
account.setUserInfo(loadUserInfo);
OrganizationsCast cast = new OrganizationsCast();
cast.setProvider(account.getAppId());
@@ -92,7 +92,7 @@ public class AccountsService extends JpaBaseService<Accounts>{
public boolean update(Accounts account) {
if (super.update(account)) {
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
UserInfo loadUserInfo = userInfoService.loadUserRelated(account.getUserId());
UserInfo loadUserInfo = userInfoService.findUserRelated(account.getUserId());
account.setUserInfo(loadUserInfo);
OrganizationsCast cast = new OrganizationsCast();
cast.setProvider(account.getAppId());
@@ -114,7 +114,7 @@ public class AccountsService extends JpaBaseService<Accounts>{
if (super.remove(id)) {
UserInfo loadUserInfo = null;
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
loadUserInfo = userInfoService.loadUserRelated(account.getUserId());
loadUserInfo = userInfoService.findUserRelated(account.getUserId());
account.setUserInfo(loadUserInfo);
kafkaPersistService.send(
KafkaIdentityTopic.ACCOUNT_TOPIC,

View File

@@ -78,7 +78,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
userInfo = passwordEncoder(userInfo);
if (super.insert(userInfo)) {
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
UserInfo loadUserInfo = loadUserRelated(userInfo.getId());
UserInfo loadUserInfo = findUserRelated(userInfo.getId());
kafkaPersistService.send(
KafkaIdentityTopic.USERINFO_TOPIC,
loadUserInfo,
@@ -95,7 +95,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
userInfo = passwordEncoder(userInfo);
if (super.update(userInfo)) {
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
UserInfo loadUserInfo = loadUserRelated(userInfo.getId());
UserInfo loadUserInfo = findUserRelated(userInfo.getId());
accountUpdate(loadUserInfo);
kafkaPersistService.send(
KafkaIdentityTopic.USERINFO_TOPIC,
@@ -112,7 +112,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
public boolean delete(UserInfo userInfo) {
UserInfo loadUserInfo = null;
if(kafkaPersistService.getApplicationConfig().isKafkaSupport()) {
loadUserInfo = loadUserRelated(userInfo.getId());
loadUserInfo = findUserRelated(userInfo.getId());
}
if( super.delete(userInfo)){
@@ -142,10 +142,10 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
}
}
public UserInfo loadUserRelated(String userId) {
public UserInfo findUserRelated(String userId) {
UserInfo loadUserInfo =this.get(userId);
loadUserInfo.setDepts(getMapper().loadDeptsByUserId(userId));
loadUserInfo.setAdjoints(getMapper().loadAdjointsByUserId(userId));
loadUserInfo.setDepts(getMapper().findDeptsByUserId(userId));
loadUserInfo.setAdjoints(getMapper().findAdjointsByUserId(userId));
return loadUserInfo;
}
@@ -176,30 +176,25 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
return false;
}
public UserInfo loadByUsername(String username) {
return getMapper().loadByUsername(username);
public UserInfo findByUsername(String username) {
return getMapper().findByUsername(username);
}
public UserInfo loadByAppIdAndUsername(String appId,String username){
public UserInfo findByEmailMobile(String emailMobile) {
return getMapper().findByEmailMobile(emailMobile);
}
public UserInfo findByAppIdAndUsername(String appId,String username){
try {
UserInfo userinfo = new UserInfo();
userinfo.setUsername(username);
return getMapper().loadByAppIdAndUsername(userinfo) ;
return getMapper().findByAppIdAndUsername(userinfo) ;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public void logisticDeleteAllByCid(String cid){
try {
getMapper().logisticDeleteAllByCid(cid);
} catch(Exception e) {
e.printStackTrace();
}
}
public UserInfo passwordEncoder(UserInfo userInfo) {
//密码不为空,则需要进行加密处理
if(userInfo.getPassword()!=null && !userInfo.getPassword().equals("")) {
@@ -274,7 +269,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
changeUserInfo = passwordEncoder(changeUserInfo);
if (getMapper().changePassword(changeUserInfo) > 0) {
if (getMapper().updatePassword(changeUserInfo) > 0) {
changePasswordProvisioning(changeUserInfo);
return true;
}
@@ -306,13 +301,13 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
}
}
public boolean changeAppLoginPassword(UserInfo userinfo) {
public boolean updateAppLoginPassword(UserInfo userinfo) {
try {
if(WebContext.getUserInfo() != null) {
userinfo.setModifiedBy(WebContext.getUserInfo().getId());
}
userinfo.setModifiedDate(DateUtils.getCurrentDateTimeAsString());
return getMapper().changeAppLoginPassword(userinfo) > 0;
return getMapper().updateAppLoginPassword(userinfo) > 0;
} catch (Exception e) {
e.printStackTrace();
}
@@ -324,11 +319,11 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
* 锁定用户islock1 用户解锁 2 用户锁定
* @param userInfo
*/
public void locked(UserInfo userInfo) {
public void updateLocked(UserInfo userInfo) {
try {
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
userInfo.setIsLocked(ConstantsStatus.STOP);
getMapper().locked(userInfo);
getMapper().updateLocked(userInfo);
}
} catch(Exception e) {
e.printStackTrace();
@@ -339,12 +334,12 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
* 用户登录成功后,重置错误密码次数和解锁用户
* @param userInfo
*/
public void unlock(UserInfo userInfo) {
public void updateLockout(UserInfo userInfo) {
try {
if(userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
userInfo.setIsLocked(ConstantsStatus.START);
userInfo.setBadPasswordCount(0);
getMapper().unlock(userInfo);
getMapper().updateLockout(userInfo);
}
} catch(Exception e) {
e.printStackTrace();
@@ -367,34 +362,27 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
}
}
public boolean changeSharedSecret(UserInfo userInfo){
return getMapper().changeSharedSecret(userInfo)>0;
public boolean updateSharedSecret(UserInfo userInfo){
return getMapper().updateSharedSecret(userInfo)>0;
}
public boolean changePasswordQuestion(UserInfo userInfo){
return getMapper().changePasswordQuestion(userInfo)>0;
public boolean updatePasswordQuestion(UserInfo userInfo){
return getMapper().updatePasswordQuestion(userInfo)>0;
}
public boolean changeAuthnType(UserInfo userInfo){
return getMapper().changeAuthnType(userInfo)>0;
public boolean updateAuthnType(UserInfo userInfo){
return getMapper().updateAuthnType(userInfo)>0;
}
public boolean changeEmail(UserInfo userInfo){
return getMapper().changeEmail(userInfo)>0;
public boolean updateEmail(UserInfo userInfo){
return getMapper().updateEmail(userInfo)>0;
}
public boolean changeMobile(UserInfo userInfo){
return getMapper().changeMobile(userInfo)>0;
public boolean updateMobile(UserInfo userInfo){
return getMapper().updateMobile(userInfo)>0;
}
public UserInfo queryUserInfoByEmailMobile(String emailMobile) {
return getMapper().queryUserInfoByEmailMobile(emailMobile);
}
public int updateProfile(UserInfo userInfo){
return getMapper().updateProfile(userInfo);
}

View File

@@ -1,14 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.maxkey.persistence.mapper.UserInfoMapper">
<select id="loadByUsername" parameterType="string" resultType="UserInfo">
select
*
from
mxk_userinfo
where username = #{value}
</select>
<select id="queryPageResults" parameterType="UserInfo" resultType="UserInfo">
select
@@ -70,7 +62,7 @@
order by sortorder,id
</select>
<update id="locked" parameterType="UserInfo" >
<update id="updateLocked" parameterType="UserInfo" >
update mxk_userinfo set
<if test="isLocked != null">
islocked = #{isLocked},
@@ -80,7 +72,7 @@
id = #{id}
</update>
<update id="lockout" parameterType="UserInfo" >
<update id="updateLockout" parameterType="UserInfo" >
update mxk_userinfo set
<if test="isLocked != null">
islocked = #{isLocked},
@@ -92,7 +84,7 @@
id = #{id}
</update>
<update id="changePassword" parameterType="UserInfo" >
<update id="updatePassword" parameterType="UserInfo" >
update mxk_userinfo set
<if test="password != null">
password = #{password},
@@ -104,7 +96,7 @@
id = #{id}
</update>
<update id="changeSharedSecret" parameterType="UserInfo" >
<update id="updateSharedSecret" parameterType="UserInfo" >
update mxk_userinfo set
<if test="sharedSecret != null">
sharedsecret = #{sharedSecret},
@@ -115,7 +107,7 @@
id = #{id}
</update>
<update id="changeAppLoginPassword" parameterType="UserInfo" >
<update id="updateAppLoginPassword" parameterType="UserInfo" >
update mxk_userinfo set
<if test="appLoginPassword != null">
apploginpassword = #{appLoginPassword},
@@ -135,7 +127,7 @@
id = #{id}
</update>
<update id="changePasswordQuestion" parameterType="UserInfo" >
<update id="updatePasswordQuestion" parameterType="UserInfo" >
update mxk_userinfo set
<if test="passwordAnswer != null">
passwordquestion = #{passwordQuestion},
@@ -146,7 +138,7 @@
id = #{id}
</update>
<update id="changeAuthnType" parameterType="UserInfo" >
<update id="updateAuthnType" parameterType="UserInfo" >
update mxk_userinfo set
<if test="authnType != null">
authntype = #{authnType},
@@ -156,7 +148,7 @@
id = #{id}
</update>
<update id="changeEmail" parameterType="UserInfo" >
<update id="updateEmail" parameterType="UserInfo" >
update mxk_userinfo set
<if test="email != null">
email = #{email},
@@ -172,7 +164,7 @@
id = #{id}
</update>
<update id="changeMobile" parameterType="UserInfo" >
<update id="updateMobile" parameterType="UserInfo" >
update mxk_userinfo set
<if test="mobile != null">
mobile = #{mobile},
@@ -184,13 +176,6 @@
where
id = #{id}
</update>
<update id="logisticBatchDelete" parameterType="java.util.List">
update mxk_userinfo set status='2' where id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<update id="updateProfile" parameterType="UserInfo" >
update mxk_userinfo set
@@ -248,7 +233,7 @@
id = #{id}
</update>
<select id="loadDeptsByUserId" parameterType="string" resultType="Organizations">
<select id="findDeptsByUserId" parameterType="string" resultType="Organizations">
select o.* , 1 isPrimary from mxk_organizations o,mxk_userinfo u
where o.instid = #{instId}
and u.instid = #{instId}
@@ -264,7 +249,7 @@
and ua.userid=#{value}
</select>
<select id="loadAdjointsByUserId" parameterType="string" resultType="UserInfoAdjoint">
<select id="findAdjointsByUserId" parameterType="string" resultType="UserInfoAdjoint">
select
*
from mxk_userinfo_adjunct

View File

@@ -220,7 +220,7 @@ For all error codes, it is RECOMMENDED that CAS provide a more detailed message
if(Boolean.isTrue(storedTicket.getCasDetails().getIsAdapter())){
AbstractAuthorizeAdapter adapter =(AbstractAuthorizeAdapter)Instance.newInstance(storedTicket.getCasDetails().getAdapter());
UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(principal);
UserInfo userInfo = (UserInfo) userInfoService.findByUsername(principal);
adapter.generateInfo(authentication,userInfo, serviceResponseBuilder);
}
}else{
@@ -330,7 +330,7 @@ Response on ticket validation failure:
if(Boolean.isTrue(storedTicket.getCasDetails().getIsAdapter())){
AbstractAuthorizeAdapter adapter =(AbstractAuthorizeAdapter)Instance.newInstance(storedTicket.getCasDetails().getAdapter());
UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(principal);
UserInfo userInfo = (UserInfo) userInfoService.findByUsername(principal);
adapter.generateInfo(authentication,userInfo, serviceResponseBuilder);
}
}else{

View File

@@ -103,7 +103,7 @@ public class Cas30AuthorizeEndpoint extends CasBaseAuthorizeEndpoint{
if(Boolean.isTrue(storedTicket.getCasDetails().getIsAdapter())){
AbstractAuthorizeAdapter adapter =(AbstractAuthorizeAdapter)Instance.newInstance(storedTicket.getCasDetails().getAdapter());
UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(principal);
UserInfo userInfo = (UserInfo) userInfoService.findByUsername(principal);
adapter.generateInfo(authentication,userInfo, serviceResponseBuilder);
}
}else{
@@ -177,7 +177,7 @@ public class Cas30AuthorizeEndpoint extends CasBaseAuthorizeEndpoint{
if(Boolean.isTrue(storedTicket.getCasDetails().getIsAdapter())){
AbstractAuthorizeAdapter adapter =(AbstractAuthorizeAdapter)Instance.newInstance(storedTicket.getCasDetails().getAdapter());
UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(principal);
UserInfo userInfo = (UserInfo) userInfoService.findByUsername(principal);
adapter.generateInfo(authentication,userInfo, serviceResponseBuilder);
}
}else{

View File

@@ -46,7 +46,7 @@ public class OAuth2UserDetailsService implements UserDetailsService {
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UserInfo userInfo;
try {
userInfo = loginService.loadUserInfo(username, "");
userInfo = loginService.find(username, "");
} catch (NoSuchClientException e) {
throw new UsernameNotFoundException(e.getMessage(), e);
}

View File

@@ -280,7 +280,7 @@ public class OpenIdConnectUserInfoEndpoint {
public UserInfo queryUserInfo(String userId){
_logger.debug("userId : "+userId);
UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(userId);
UserInfo userInfo = (UserInfo) userInfoService.findByUsername(userId);
return userInfo;
}

View File

@@ -160,7 +160,7 @@ public class UserInfoEndpoint {
public UserInfo queryUserInfo(String userId){
_logger.debug("userId : "+userId);
UserInfo userInfo = (UserInfo) userInfoService.loadByUsername(userId);
UserInfo userInfo = (UserInfo) userInfoService.findByUsername(userId);
return userInfo;
}

View File

@@ -98,7 +98,7 @@ public class ForgotPasswordContorller {
emailMobile =emailMobile + "@" + emailConfig.getSmtpHost().substring(emailConfig.getSmtpHost().indexOf(".")+1);
}
userInfo = userInfoService.queryUserInfoByEmailMobile(emailMobile);
userInfo = userInfoService.findByEmailMobile(emailMobile);
if(null != userInfo) {
if (forgotType == ForgotType.EMAIL ) {

View File

@@ -90,7 +90,7 @@ public class OneTimePasswordController {
String sharedSecret = Base32Utils.encode(byteSharedSecret);
sharedSecret = passwordReciprocal.encode(sharedSecret);
userInfo.setSharedSecret(sharedSecret);
userInfoService.changeSharedSecret(userInfo);
userInfoService.updateSharedSecret(userInfo);
WebContext.setUserInfo(userInfo);
return WebContext.redirect("/safe/otp/timebased");
}
@@ -124,7 +124,7 @@ public class OneTimePasswordController {
sharedSecret = passwordReciprocal.encode(sharedSecret);
userInfo.setSharedSecret(sharedSecret);
userInfo.setSharedCounter("0");
userInfoService.changeSharedSecret(userInfo);
userInfoService.updateSharedSecret(userInfo);
WebContext.setUserInfo(userInfo);
return WebContext.redirect("/safe/otp/counterbased");
}
@@ -156,7 +156,7 @@ public class OneTimePasswordController {
sharedSecret = passwordReciprocal.encode(sharedSecret);
userInfo.setSharedSecret(sharedSecret);
userInfo.setSharedCounter("0");
userInfoService.changeSharedSecret(userInfo);
userInfoService.updateSharedSecret(userInfo);
WebContext.setUserInfo(userInfo);
return WebContext.redirect("/safe/otp/hotp");
}

View File

@@ -46,7 +46,7 @@ public class ProfileController {
@RequestMapping(value = { "/myProfile" })
public ModelAndView forwardBasic() {
ModelAndView modelAndView = new ModelAndView("profile/myProfile");
UserInfo userInfo = userInfoService.loadByUsername(WebContext.getUserInfo().getUsername());
UserInfo userInfo = userInfoService.findByUsername(WebContext.getUserInfo().getUsername());
WebContext.getSession().setAttribute(userInfo.getId(), userInfo.getPicture());
// HashMap<String,Object>extraAttributeMap=new HashMap<String,Object>();

View File

@@ -201,12 +201,12 @@ public class RegistrationController {
if(!(StringUtils.isValidEmail(emailMobile)||StringUtils.isValidMobileNo(emailMobile))) {
return new Message(WebContext.getI18nValue("register.emailMobile.error"),"1");
}
UserInfo temp=userInfoService.queryUserInfoByEmailMobile(emailMobile);
UserInfo temp=userInfoService.findByEmailMobile(emailMobile);
if(temp!=null) {
return new Message(WebContext.getI18nValue("register.emailMobile.exist"),"1");
}
temp=userInfoService.loadByUsername(userInfo.getUsername());
temp=userInfoService.findByUsername(userInfo.getUsername());
if(temp!=null) {
return new Message(WebContext.getI18nValue("register.user.error"),"1");
}

View File

@@ -137,7 +137,7 @@ public class SafeController {
if(newPassword.equals(confirmPassword)){
if(StringUtils.isEmpty(userInfo.getAppLoginPassword())||userInfo.getAppLoginPassword().equals(PasswordReciprocal.getInstance().encode(oldPassword))){
userInfo.setAppLoginPassword(PasswordReciprocal.getInstance().encode(newPassword));
boolean change= userInfoService.changeAppLoginPassword(userInfo);
boolean change= userInfoService.updateAppLoginPassword(userInfo);
_logger.debug(""+change);
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.prompt);
}
@@ -168,17 +168,17 @@ public class SafeController {
@RequestParam("theme") String theme) {
UserInfo userInfo =WebContext.getUserInfo();
userInfo.setAuthnType(Integer.parseInt(authnType));
userInfoService.changeAuthnType(userInfo);
userInfoService.updateAuthnType(userInfo);
userInfo.setMobile(mobile);
userInfoService.changeMobile(userInfo);
userInfoService.updateMobile(userInfo);
userInfo.setEmail(email);
userInfo.setTheme(theme);
WebContext.setCookie(response,null, WebConstants.THEME_COOKIE_NAME, theme, ConstantsTimeInterval.ONE_WEEK);
userInfoService.changeEmail(userInfo);
userInfoService.updateEmail(userInfo);
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);

View File

@@ -166,7 +166,7 @@ public class LoginEndpoint {
@RequestMapping("/login/sendsms/{mobile}")
@ResponseBody
public String produceOtp(@PathVariable("mobile") String mobile) {
UserInfo queryUserInfo=userInfoService.queryUserInfoByEmailMobile(mobile);
UserInfo queryUserInfo=userInfoService.findByEmailMobile(mobile);
if(queryUserInfo!=null) {
smsOtpAuthn.produce(queryUserInfo);
return "ok";

View File

@@ -108,7 +108,7 @@ public class LoginSessionController {
}
UserInfo userInfo = WebContext.getUserInfo();
String lastLogoffTime = DateUtils.formatDateTime(new Date());
loginService.setLastLogoffInfo(userInfo);
loginService.updateLastLogoff(userInfo);
loginHistoryService.logoff(lastLogoffTime, sessionId);
onlineTicketServices.remove("OT-" + sessionId);
}

View File

@@ -49,7 +49,7 @@ public class RestTimeBasedOtpController {
public boolean getUser(@RequestParam String username,
@RequestParam String token) {
UserInfo validUserInfo = userInfoService.loadByUsername(username);
UserInfo validUserInfo = userInfoService.findByUsername(username);
if(validUserInfo != null) {
if(timeBasedOtpAuthn.validate(validUserInfo, token)) {
return true;

View File

@@ -106,7 +106,7 @@ public class LoginSessionController {
}
UserInfo userInfo = WebContext.getUserInfo();
String lastLogoffTime = DateUtils.formatDateTime(new Date());
loginService.setLastLogoffInfo(userInfo);
loginService.updateLastLogoff(userInfo);
loginHistoryService.logoff(lastLogoffTime, sessionId);
onlineTicketServices.remove("OT-" + sessionId);
}