mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 01:18:27 +08:00
mv to repository
This commit is contained in:
parent
bd04a24bd8
commit
e0a274fada
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package com.google.code.kaptcha.impl;
|
package com.google.code.kaptcha.impl;
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
@ -91,4 +108,4 @@ public class LightNoise extends Configurable implements NoiseProducer
|
|||||||
|
|
||||||
graph.dispose();
|
graph.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package com.google.code.kaptcha.impl;
|
package com.google.code.kaptcha.impl;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package com.google.code.kaptcha.text.impl;
|
package com.google.code.kaptcha.text.impl;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|||||||
@ -26,10 +26,10 @@ import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
|
|||||||
import org.maxkey.entity.Groups;
|
import org.maxkey.entity.Groups;
|
||||||
import org.maxkey.entity.HistoryLogin;
|
import org.maxkey.entity.HistoryLogin;
|
||||||
import org.maxkey.entity.UserInfo;
|
import org.maxkey.entity.UserInfo;
|
||||||
import org.maxkey.persistence.db.LoginHistoryService;
|
import org.maxkey.persistence.repository.LoginHistoryRepository;
|
||||||
import org.maxkey.persistence.db.PasswordPolicyValidator;
|
import org.maxkey.persistence.repository.LoginRepository;
|
||||||
|
import org.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||||
import org.maxkey.persistence.service.UserInfoService;
|
import org.maxkey.persistence.service.UserInfoService;
|
||||||
import org.maxkey.persistence.db.LoginService;
|
|
||||||
import org.maxkey.util.DateUtils;
|
import org.maxkey.util.DateUtils;
|
||||||
import org.maxkey.web.WebConstants;
|
import org.maxkey.web.WebConstants;
|
||||||
import org.maxkey.web.WebContext;
|
import org.maxkey.web.WebContext;
|
||||||
@ -52,9 +52,9 @@ public abstract class AbstractAuthenticationRealm {
|
|||||||
|
|
||||||
protected PasswordPolicyValidator passwordPolicyValidator;
|
protected PasswordPolicyValidator passwordPolicyValidator;
|
||||||
|
|
||||||
protected LoginService loginService;
|
protected LoginRepository loginRepository;
|
||||||
|
|
||||||
protected LoginHistoryService loginHistoryService;
|
protected LoginHistoryRepository loginHistoryRepository;
|
||||||
|
|
||||||
protected AbstractRemeberMeService remeberMeService;
|
protected AbstractRemeberMeService remeberMeService;
|
||||||
|
|
||||||
@ -81,12 +81,12 @@ public abstract class AbstractAuthenticationRealm {
|
|||||||
return passwordPolicyValidator;
|
return passwordPolicyValidator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginService getUserInfoLoginService() {
|
public LoginRepository getLoginRepository() {
|
||||||
return loginService;
|
return loginRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserInfo loadUserInfo(String username, String password) {
|
public UserInfo loadUserInfo(String username, String password) {
|
||||||
return loginService.find(username, password);
|
return loginRepository.find(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean passwordMatches(UserInfo userInfo, String password);
|
public abstract boolean passwordMatches(UserInfo userInfo, String password);
|
||||||
@ -102,7 +102,7 @@ public abstract class AbstractAuthenticationRealm {
|
|||||||
|
|
||||||
|
|
||||||
public List<Groups> queryGroups(UserInfo userInfo) {
|
public List<Groups> queryGroups(UserInfo userInfo) {
|
||||||
return loginService.queryGroups(userInfo);
|
return loginRepository.queryGroups(userInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,7 +112,7 @@ public abstract class AbstractAuthenticationRealm {
|
|||||||
* @return ArrayList<GrantedAuthority>
|
* @return ArrayList<GrantedAuthority>
|
||||||
*/
|
*/
|
||||||
public ArrayList<GrantedAuthority> grantAuthority(UserInfo userInfo) {
|
public ArrayList<GrantedAuthority> grantAuthority(UserInfo userInfo) {
|
||||||
return loginService.grantAuthority(userInfo);
|
return loginRepository.grantAuthority(userInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,7 +122,7 @@ public abstract class AbstractAuthenticationRealm {
|
|||||||
* @return ArrayList<GrantedAuthority Apps>
|
* @return ArrayList<GrantedAuthority Apps>
|
||||||
*/
|
*/
|
||||||
public ArrayList<GrantedAuthority> queryAuthorizedApps(ArrayList<GrantedAuthority> grantedAuthoritys) {
|
public ArrayList<GrantedAuthority> queryAuthorizedApps(ArrayList<GrantedAuthority> grantedAuthoritys) {
|
||||||
return loginService.queryAuthorizedApps(grantedAuthoritys);
|
return loginRepository.queryAuthorizedApps(grantedAuthoritys);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,9 +161,9 @@ public abstract class AbstractAuthenticationRealm {
|
|||||||
historyLogin.setDisplayName(userInfo.getDisplayName());
|
historyLogin.setDisplayName(userInfo.getDisplayName());
|
||||||
historyLogin.setInstId(userInfo.getInstId());
|
historyLogin.setInstId(userInfo.getInstId());
|
||||||
|
|
||||||
loginHistoryService.login(historyLogin);
|
loginHistoryRepository.login(historyLogin);
|
||||||
|
|
||||||
loginService.updateLastLogin(userInfo);
|
loginRepository.updateLastLogin(userInfo);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -182,10 +182,10 @@ public abstract class AbstractAuthenticationRealm {
|
|||||||
if (sessionIdAttribute != null) {
|
if (sessionIdAttribute != null) {
|
||||||
remeberMeService.removeRemeberMe(response);
|
remeberMeService.removeRemeberMe(response);
|
||||||
|
|
||||||
loginHistoryService.logoff(userInfo.getLastLogoffTime(), sessionIdAttribute.toString());
|
loginHistoryRepository.logoff(userInfo.getLastLogoffTime(), sessionIdAttribute.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
loginService.updateLastLogoff(userInfo);
|
loginRepository.updateLastLogoff(userInfo);
|
||||||
|
|
||||||
_logger.debug("Session " + WebContext.getAttribute(WebConstants.CURRENT_USER_SESSION_ID) + ", user "
|
_logger.debug("Session " + WebContext.getAttribute(WebConstants.CURRENT_USER_SESSION_ID) + ", user "
|
||||||
+ userInfo.getUsername() + " Logout, datetime " + userInfo.getLastLogoffTime() + " .");
|
+ userInfo.getUsername() + " Logout, datetime " + userInfo.getLastLogoffTime() + " .");
|
||||||
|
|||||||
@ -20,10 +20,11 @@ package org.maxkey.authn.realm.jdbc;
|
|||||||
import org.maxkey.authn.realm.AbstractAuthenticationRealm;
|
import org.maxkey.authn.realm.AbstractAuthenticationRealm;
|
||||||
import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
|
import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
|
||||||
import org.maxkey.constants.ConstantsLoginType;
|
import org.maxkey.constants.ConstantsLoginType;
|
||||||
|
import org.maxkey.entity.PasswordPolicy;
|
||||||
import org.maxkey.entity.UserInfo;
|
import org.maxkey.entity.UserInfo;
|
||||||
import org.maxkey.persistence.db.LoginHistoryService;
|
import org.maxkey.persistence.repository.LoginHistoryRepository;
|
||||||
import org.maxkey.persistence.db.LoginService;
|
import org.maxkey.persistence.repository.LoginRepository;
|
||||||
import org.maxkey.persistence.db.PasswordPolicyValidator;
|
import org.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||||
import org.maxkey.persistence.service.UserInfoService;
|
import org.maxkey.persistence.service.UserInfoService;
|
||||||
import org.maxkey.web.WebConstants;
|
import org.maxkey.web.WebConstants;
|
||||||
import org.maxkey.web.WebContext;
|
import org.maxkey.web.WebContext;
|
||||||
@ -54,16 +55,16 @@ public class JdbcAuthenticationRealm extends AbstractAuthenticationRealm {
|
|||||||
public JdbcAuthenticationRealm(
|
public JdbcAuthenticationRealm(
|
||||||
PasswordEncoder passwordEncoder,
|
PasswordEncoder passwordEncoder,
|
||||||
PasswordPolicyValidator passwordPolicyValidator,
|
PasswordPolicyValidator passwordPolicyValidator,
|
||||||
LoginService loginService,
|
LoginRepository loginRepository,
|
||||||
LoginHistoryService loginHistoryService,
|
LoginHistoryRepository loginHistoryRepository,
|
||||||
AbstractRemeberMeService remeberMeService,
|
AbstractRemeberMeService remeberMeService,
|
||||||
UserInfoService userInfoService,
|
UserInfoService userInfoService,
|
||||||
JdbcTemplate jdbcTemplate) {
|
JdbcTemplate jdbcTemplate) {
|
||||||
|
|
||||||
this.passwordEncoder =passwordEncoder;
|
this.passwordEncoder =passwordEncoder;
|
||||||
this.passwordPolicyValidator=passwordPolicyValidator;
|
this.passwordPolicyValidator=passwordPolicyValidator;
|
||||||
this.loginService = loginService;
|
this.loginRepository = loginRepository;
|
||||||
this.loginHistoryService = loginHistoryService;
|
this.loginHistoryRepository = loginHistoryRepository;
|
||||||
this.remeberMeService = remeberMeService;
|
this.remeberMeService = remeberMeService;
|
||||||
this.userInfoService = userInfoService;
|
this.userInfoService = userInfoService;
|
||||||
this.jdbcTemplate = jdbcTemplate;
|
this.jdbcTemplate = jdbcTemplate;
|
||||||
@ -73,8 +74,8 @@ public class JdbcAuthenticationRealm extends AbstractAuthenticationRealm {
|
|||||||
public JdbcAuthenticationRealm(
|
public JdbcAuthenticationRealm(
|
||||||
PasswordEncoder passwordEncoder,
|
PasswordEncoder passwordEncoder,
|
||||||
PasswordPolicyValidator passwordPolicyValidator,
|
PasswordPolicyValidator passwordPolicyValidator,
|
||||||
LoginService loginService,
|
LoginRepository loginRepository,
|
||||||
LoginHistoryService loginHistoryService,
|
LoginHistoryRepository loginHistoryRepository,
|
||||||
AbstractRemeberMeService remeberMeService,
|
AbstractRemeberMeService remeberMeService,
|
||||||
UserInfoService userInfoService,
|
UserInfoService userInfoService,
|
||||||
JdbcTemplate jdbcTemplate,
|
JdbcTemplate jdbcTemplate,
|
||||||
@ -84,8 +85,8 @@ public class JdbcAuthenticationRealm extends AbstractAuthenticationRealm {
|
|||||||
|
|
||||||
this.passwordEncoder =passwordEncoder;
|
this.passwordEncoder =passwordEncoder;
|
||||||
this.passwordPolicyValidator=passwordPolicyValidator;
|
this.passwordPolicyValidator=passwordPolicyValidator;
|
||||||
this.loginService = loginService;
|
this.loginRepository = loginRepository;
|
||||||
this.loginHistoryService = loginHistoryService;
|
this.loginHistoryRepository = loginHistoryRepository;
|
||||||
this.remeberMeService = remeberMeService;
|
this.remeberMeService = remeberMeService;
|
||||||
this.jdbcTemplate = jdbcTemplate;
|
this.jdbcTemplate = jdbcTemplate;
|
||||||
this.ldapAuthenticationRealm = ldapAuthenticationRealm;
|
this.ldapAuthenticationRealm = ldapAuthenticationRealm;
|
||||||
@ -121,14 +122,14 @@ public class JdbcAuthenticationRealm extends AbstractAuthenticationRealm {
|
|||||||
if (!passwordMatches) {
|
if (!passwordMatches) {
|
||||||
passwordPolicyValidator.plusBadPasswordCount(userInfo);
|
passwordPolicyValidator.plusBadPasswordCount(userInfo);
|
||||||
insertLoginHistory(userInfo, ConstantsLoginType.LOCAL, "", "xe00000004", WebConstants.LOGIN_RESULT.PASSWORD_ERROE);
|
insertLoginHistory(userInfo, ConstantsLoginType.LOCAL, "", "xe00000004", WebConstants.LOGIN_RESULT.PASSWORD_ERROE);
|
||||||
|
PasswordPolicy passwordPolicy = passwordPolicyValidator.getPasswordPolicyRepository().getPasswordPolicy();
|
||||||
if(userInfo.getBadPasswordCount()>=(passwordPolicyValidator.getPasswordPolicy().getAttempts()/2)) {
|
if(userInfo.getBadPasswordCount()>=(passwordPolicy.getAttempts()/2)) {
|
||||||
throw new BadCredentialsException(
|
throw new BadCredentialsException(
|
||||||
WebContext.getI18nValue("login.error.password.attempts",
|
WebContext.getI18nValue("login.error.password.attempts",
|
||||||
new Object[]{
|
new Object[]{
|
||||||
userInfo.getBadPasswordCount() + 1,
|
userInfo.getBadPasswordCount() + 1,
|
||||||
passwordPolicyValidator.getPasswordPolicy().getAttempts(),
|
passwordPolicy.getAttempts(),
|
||||||
passwordPolicyValidator.getPasswordPolicy().getDuration()}));
|
passwordPolicy.getDuration()}));
|
||||||
}else {
|
}else {
|
||||||
throw new BadCredentialsException(WebContext.getI18nValue("login.error.password"));
|
throw new BadCredentialsException(WebContext.getI18nValue("login.error.password"));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,8 +27,10 @@ import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
|
|||||||
import org.maxkey.authn.support.rememberme.RemeberMeServiceFactory;
|
import org.maxkey.authn.support.rememberme.RemeberMeServiceFactory;
|
||||||
import org.maxkey.configuration.ApplicationConfig;
|
import org.maxkey.configuration.ApplicationConfig;
|
||||||
import org.maxkey.password.onetimepwd.AbstractOtpAuthn;
|
import org.maxkey.password.onetimepwd.AbstractOtpAuthn;
|
||||||
import org.maxkey.persistence.db.PasswordPolicyValidator;
|
|
||||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||||
|
import org.maxkey.persistence.repository.LoginHistoryRepository;
|
||||||
|
import org.maxkey.persistence.repository.LoginRepository;
|
||||||
|
import org.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
@ -37,8 +39,6 @@ import org.springframework.context.MessageSource;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.maxkey.persistence.db.LoginService;
|
|
||||||
import org.maxkey.persistence.db.LoginHistoryService;
|
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ -80,13 +80,13 @@ public class AuthenticationAutoConfiguration implements InitializingBean {
|
|||||||
return new PasswordPolicyValidator(jdbcTemplate,messageSource);
|
return new PasswordPolicyValidator(jdbcTemplate,messageSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "loginService")
|
@Bean(name = "loginRepository")
|
||||||
public LoginService LoginService(JdbcTemplate jdbcTemplate) {
|
public LoginRepository loginRepository(JdbcTemplate jdbcTemplate) {
|
||||||
return new LoginService(jdbcTemplate);
|
return new LoginRepository(jdbcTemplate);
|
||||||
}
|
}
|
||||||
@Bean(name = "loginHistoryService")
|
@Bean(name = "loginHistoryRepository")
|
||||||
public LoginHistoryService loginHistoryService(JdbcTemplate jdbcTemplate) {
|
public LoginHistoryRepository LoginHistoryRepository(JdbcTemplate jdbcTemplate) {
|
||||||
return new LoginHistoryService(jdbcTemplate);
|
return new LoginHistoryRepository(jdbcTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.util;
|
package org.maxkey.util;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import java.io.OutputStreamWriter;
|
|||||||
*/
|
*/
|
||||||
public class Copyright {
|
public class Copyright {
|
||||||
// 存放java文件的文件夹,必须是文件夹
|
// 存放java文件的文件夹,必须是文件夹
|
||||||
private static String srcFolder = "C:\\IDES\\shimi\\eclipse-workspace\\MaxKey";
|
private static String srcFolder = "D:\\MaxKey\\workspace\\workspace-maxkey\\MaxKey";
|
||||||
//已添加标识
|
//已添加标识
|
||||||
private static String copyRightText = "http://www.apache.org/licenses/LICENSE-2.0";
|
private static String copyRightText = "http://www.apache.org/licenses/LICENSE-2.0";
|
||||||
//扫描目录
|
//扫描目录
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey;
|
package org.maxkey;
|
||||||
|
|
||||||
public class Integer2LongTest {
|
public class Integer2LongTest {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.util;
|
package org.maxkey.util;
|
||||||
|
|
||||||
import java.security.Provider;
|
import java.security.Provider;
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.word;
|
package org.maxkey.word;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|||||||
@ -29,8 +29,8 @@ import org.maxkey.crypto.password.MessageDigestPasswordEncoder;
|
|||||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||||
import org.maxkey.crypto.password.SM3PasswordEncoder;
|
import org.maxkey.crypto.password.SM3PasswordEncoder;
|
||||||
import org.maxkey.crypto.password.StandardPasswordEncoder;
|
import org.maxkey.crypto.password.StandardPasswordEncoder;
|
||||||
import org.maxkey.persistence.db.InstitutionService;
|
import org.maxkey.persistence.repository.InstitutionsRepository;
|
||||||
import org.maxkey.persistence.db.LocalizationService;
|
import org.maxkey.persistence.repository.LocalizationRepository;
|
||||||
import org.maxkey.util.IdGenerator;
|
import org.maxkey.util.IdGenerator;
|
||||||
import org.maxkey.util.SnowFlakeId;
|
import org.maxkey.util.SnowFlakeId;
|
||||||
import org.maxkey.web.WebContext;
|
import org.maxkey.web.WebContext;
|
||||||
@ -65,14 +65,15 @@ public class ApplicationAutoConfiguration implements InitializingBean {
|
|||||||
return new DataSourceTransactionManager(dataSource);
|
return new DataSourceTransactionManager(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "institutionService")
|
@Bean(name = "institutionsRepository")
|
||||||
public InstitutionService institutionService(JdbcTemplate jdbcTemplate) {
|
public InstitutionsRepository InstitutionsRepository(JdbcTemplate jdbcTemplate) {
|
||||||
return new InstitutionService(jdbcTemplate);
|
return new InstitutionsRepository(jdbcTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "localizationService")
|
@Bean(name = "localizationRepository")
|
||||||
public LocalizationService localizationService(JdbcTemplate jdbcTemplate,InstitutionService institutionService) {
|
public LocalizationRepository localizationRepository(JdbcTemplate jdbcTemplate,
|
||||||
return new LocalizationService(jdbcTemplate,institutionService);
|
InstitutionsRepository institutionsRepository) {
|
||||||
|
return new LocalizationRepository(jdbcTemplate,institutionsRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -24,9 +24,9 @@ import javax.servlet.Filter;
|
|||||||
|
|
||||||
import org.maxkey.configuration.ApplicationConfig;
|
import org.maxkey.configuration.ApplicationConfig;
|
||||||
import org.maxkey.constants.ConstantsTimeInterval;
|
import org.maxkey.constants.ConstantsTimeInterval;
|
||||||
import org.maxkey.persistence.db.InstitutionService;
|
import org.maxkey.persistence.repository.InstitutionsRepository;
|
||||||
import org.maxkey.persistence.db.LoginHistoryService;
|
import org.maxkey.persistence.repository.LoginHistoryRepository;
|
||||||
import org.maxkey.persistence.db.LoginService;
|
import org.maxkey.persistence.repository.LoginRepository;
|
||||||
import org.maxkey.web.SessionListenerAdapter;
|
import org.maxkey.web.SessionListenerAdapter;
|
||||||
import org.maxkey.web.WebXssRequestFilter;
|
import org.maxkey.web.WebXssRequestFilter;
|
||||||
import org.maxkey.web.WebInstRequestFilter;
|
import org.maxkey.web.WebInstRequestFilter;
|
||||||
@ -284,11 +284,11 @@ public class MvcAutoConfiguration implements InitializingBean , WebMvcConfigurer
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public FilterRegistrationBean<Filter> WebInstRequestFilter(
|
public FilterRegistrationBean<Filter> WebInstRequestFilter(
|
||||||
InstitutionService institutionService,
|
InstitutionsRepository institutionsRepository,
|
||||||
ApplicationConfig applicationConfig) {
|
ApplicationConfig applicationConfig) {
|
||||||
_logger.debug("WebInstRequestFilter init for /* ");
|
_logger.debug("WebInstRequestFilter init for /* ");
|
||||||
FilterRegistrationBean<Filter> registrationBean =
|
FilterRegistrationBean<Filter> registrationBean =
|
||||||
new FilterRegistrationBean<Filter>(new WebInstRequestFilter(institutionService,applicationConfig));
|
new FilterRegistrationBean<Filter>(new WebInstRequestFilter(institutionsRepository,applicationConfig));
|
||||||
registrationBean.addUrlPatterns("/*");
|
registrationBean.addUrlPatterns("/*");
|
||||||
registrationBean.setName("webInstRequestFilter");
|
registrationBean.setName("webInstRequestFilter");
|
||||||
registrationBean.setOrder(3);
|
registrationBean.setOrder(3);
|
||||||
@ -297,11 +297,11 @@ public class MvcAutoConfiguration implements InitializingBean , WebMvcConfigurer
|
|||||||
|
|
||||||
@Bean(name = "sessionListenerAdapter")
|
@Bean(name = "sessionListenerAdapter")
|
||||||
public SessionListenerAdapter sessionListenerAdapter(
|
public SessionListenerAdapter sessionListenerAdapter(
|
||||||
LoginService loginService,
|
LoginRepository loginRepository,
|
||||||
LoginHistoryService loginHistoryService
|
LoginHistoryRepository loginHistoryRepository
|
||||||
) {
|
) {
|
||||||
SessionListenerAdapter sessionListenerAdapter =
|
SessionListenerAdapter sessionListenerAdapter =
|
||||||
new SessionListenerAdapter(loginService,loginHistoryService);
|
new SessionListenerAdapter(loginRepository,loginHistoryRepository);
|
||||||
return sessionListenerAdapter;
|
return sessionListenerAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
280
maxkey-core/src/main/java/org/maxkey/entity/LdapContext.java
Normal file
280
maxkey-core/src/main/java/org/maxkey/entity/LdapContext.java
Normal file
@ -0,0 +1,280 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import org.apache.mybatis.jpa.persistence.JpaBaseEntity;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "MXK_LDAP_CONTEXT")
|
||||||
|
public class LdapContext extends JpaBaseEntity implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -4595539647817265938L;
|
||||||
|
@Id
|
||||||
|
@Column
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO, generator = "snowflakeid")
|
||||||
|
String id;
|
||||||
|
@Column
|
||||||
|
String product;
|
||||||
|
@Column
|
||||||
|
String providerUrl;
|
||||||
|
@Column
|
||||||
|
String principal;
|
||||||
|
@Column
|
||||||
|
String credentials;
|
||||||
|
@Column
|
||||||
|
String filters;
|
||||||
|
@Column
|
||||||
|
String basedn;
|
||||||
|
@Column
|
||||||
|
String msadDomain;
|
||||||
|
@Column
|
||||||
|
String sslSwitch;
|
||||||
|
@Column
|
||||||
|
String trustStore;
|
||||||
|
@Column
|
||||||
|
String trustStorePassword;
|
||||||
|
@Column
|
||||||
|
String description;
|
||||||
|
@Column
|
||||||
|
String createdBy;
|
||||||
|
@Column
|
||||||
|
String createdDate;
|
||||||
|
@Column
|
||||||
|
String modifiedBy;
|
||||||
|
@Column
|
||||||
|
String modifiedDate;
|
||||||
|
@Column
|
||||||
|
int status;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String instId;
|
||||||
|
|
||||||
|
private String instName;
|
||||||
|
|
||||||
|
public LdapContext() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProduct() {
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProduct(String product) {
|
||||||
|
this.product = product;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProviderUrl() {
|
||||||
|
return providerUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProviderUrl(String providerUrl) {
|
||||||
|
this.providerUrl = providerUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrincipal() {
|
||||||
|
return principal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrincipal(String principal) {
|
||||||
|
this.principal = principal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCredentials() {
|
||||||
|
return credentials;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCredentials(String credentials) {
|
||||||
|
this.credentials = credentials;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFilters() {
|
||||||
|
return filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilters(String filters) {
|
||||||
|
this.filters = filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBasedn() {
|
||||||
|
return basedn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBasedn(String basedn) {
|
||||||
|
this.basedn = basedn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsadDomain() {
|
||||||
|
return msadDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsadDomain(String msadDomain) {
|
||||||
|
this.msadDomain = msadDomain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSslSwitch() {
|
||||||
|
return sslSwitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSslSwitch(String sslSwitch) {
|
||||||
|
this.sslSwitch = sslSwitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTrustStore() {
|
||||||
|
return trustStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrustStore(String trustStore) {
|
||||||
|
this.trustStore = trustStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTrustStorePassword() {
|
||||||
|
return trustStorePassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTrustStorePassword(String trustStorePassword) {
|
||||||
|
this.trustStorePassword = trustStorePassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatedBy() {
|
||||||
|
return createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedBy(String createdBy) {
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreatedDate() {
|
||||||
|
return createdDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedDate(String createdDate) {
|
||||||
|
this.createdDate = createdDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModifiedBy() {
|
||||||
|
return modifiedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifiedBy(String modifiedBy) {
|
||||||
|
this.modifiedBy = modifiedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModifiedDate() {
|
||||||
|
return modifiedDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifiedDate(String modifiedDate) {
|
||||||
|
this.modifiedDate = modifiedDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInstId() {
|
||||||
|
return instId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstId(String instId) {
|
||||||
|
this.instId = instId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInstName() {
|
||||||
|
return instName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstName(String instName) {
|
||||||
|
this.instName = instName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("LdapContext [id=");
|
||||||
|
builder.append(id);
|
||||||
|
builder.append(", product=");
|
||||||
|
builder.append(product);
|
||||||
|
builder.append(", providerUrl=");
|
||||||
|
builder.append(providerUrl);
|
||||||
|
builder.append(", principal=");
|
||||||
|
builder.append(principal);
|
||||||
|
builder.append(", credentials=");
|
||||||
|
builder.append(credentials);
|
||||||
|
builder.append(", filters=");
|
||||||
|
builder.append(filters);
|
||||||
|
builder.append(", basedn=");
|
||||||
|
builder.append(basedn);
|
||||||
|
builder.append(", msadDomain=");
|
||||||
|
builder.append(msadDomain);
|
||||||
|
builder.append(", sslSwitch=");
|
||||||
|
builder.append(sslSwitch);
|
||||||
|
builder.append(", trustStore=");
|
||||||
|
builder.append(trustStore);
|
||||||
|
builder.append(", trustStorePassword=");
|
||||||
|
builder.append(trustStorePassword);
|
||||||
|
builder.append(", description=");
|
||||||
|
builder.append(description);
|
||||||
|
builder.append(", createdBy=");
|
||||||
|
builder.append(createdBy);
|
||||||
|
builder.append(", createdDate=");
|
||||||
|
builder.append(createdDate);
|
||||||
|
builder.append(", modifiedBy=");
|
||||||
|
builder.append(modifiedBy);
|
||||||
|
builder.append(", modifiedDate=");
|
||||||
|
builder.append(modifiedDate);
|
||||||
|
builder.append(", status=");
|
||||||
|
builder.append(status);
|
||||||
|
builder.append(", instId=");
|
||||||
|
builder.append(instId);
|
||||||
|
builder.append(", instName=");
|
||||||
|
builder.append(instName);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.entity;
|
package org.maxkey.entity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.persistence.db;
|
package org.maxkey.persistence.repository;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -34,8 +34,8 @@ import org.springframework.jdbc.core.RowMapper;
|
|||||||
import com.github.benmanes.caffeine.cache.Cache;
|
import com.github.benmanes.caffeine.cache.Cache;
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
|
|
||||||
public class InstitutionService {
|
public class InstitutionsRepository {
|
||||||
private static Logger _logger = LoggerFactory.getLogger(InstitutionService.class);
|
private static Logger _logger = LoggerFactory.getLogger(InstitutionsRepository.class);
|
||||||
|
|
||||||
private static final String SELECT_STATEMENT =
|
private static final String SELECT_STATEMENT =
|
||||||
"select * from mxk_institutions where domain = ? and status = " + ConstantsStatus.ACTIVE;
|
"select * from mxk_institutions where domain = ? and status = " + ConstantsStatus.ACTIVE;
|
||||||
@ -53,7 +53,7 @@ public class InstitutionService {
|
|||||||
|
|
||||||
protected JdbcTemplate jdbcTemplate;
|
protected JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
public InstitutionService(JdbcTemplate jdbcTemplate) {
|
public InstitutionsRepository(JdbcTemplate jdbcTemplate) {
|
||||||
this.jdbcTemplate = jdbcTemplate;
|
this.jdbcTemplate = jdbcTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.maxkey.persistence.db;
|
package org.maxkey.persistence.repository;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -33,8 +33,8 @@ import org.springframework.jdbc.core.RowMapper;
|
|||||||
import com.github.benmanes.caffeine.cache.Cache;
|
import com.github.benmanes.caffeine.cache.Cache;
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
|
|
||||||
public class LocalizationService {
|
public class LocalizationRepository {
|
||||||
private static Logger _logger = LoggerFactory.getLogger(LocalizationService.class);
|
private static Logger _logger = LoggerFactory.getLogger(LocalizationRepository.class);
|
||||||
private static final String INSERT_STATEMENT ="insert into mxk_localization (id, property,langzh,langen,status,description,instid)values(?,?,?,?,?,?,?)";
|
private static final String INSERT_STATEMENT ="insert into mxk_localization (id, property,langzh,langen,status,description,instid)values(?,?,?,?,?,?,?)";
|
||||||
private static final String UPDATE_STATEMENT ="update mxk_localization set langzh = ? , langen =? where id = ?";
|
private static final String UPDATE_STATEMENT ="update mxk_localization set langzh = ? , langen =? where id = ?";
|
||||||
private static final String DELETE_STATEMENT ="delete from mxk_localization where id = ?";
|
private static final String DELETE_STATEMENT ="delete from mxk_localization where id = ?";
|
||||||
@ -42,7 +42,7 @@ public class LocalizationService {
|
|||||||
|
|
||||||
private static final Pattern PATTERN_HTML = Pattern.compile("<[^>]+>", Pattern.CASE_INSENSITIVE);
|
private static final Pattern PATTERN_HTML = Pattern.compile("<[^>]+>", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
protected InstitutionService institutionService;
|
protected InstitutionsRepository institutionService;
|
||||||
|
|
||||||
JdbcTemplate jdbcTemplate;
|
JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ public class LocalizationService {
|
|||||||
.expireAfterWrite(ConstantsTimeInterval.ONE_HOUR, TimeUnit.SECONDS)
|
.expireAfterWrite(ConstantsTimeInterval.ONE_HOUR, TimeUnit.SECONDS)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public LocalizationService() {
|
public LocalizationRepository() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ public class LocalizationService {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInstitutionService(InstitutionService institutionService) {
|
public void setInstitutionService(InstitutionsRepository institutionService) {
|
||||||
this.institutionService = institutionService;
|
this.institutionService = institutionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ public class LocalizationService {
|
|||||||
return (localizations==null || localizations.size()==0) ? null : localizations.get(0);
|
return (localizations==null || localizations.size()==0) ? null : localizations.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalizationService(JdbcTemplate jdbcTemplate,InstitutionService institutionService) {
|
public LocalizationRepository(JdbcTemplate jdbcTemplate,InstitutionsRepository institutionService) {
|
||||||
super();
|
super();
|
||||||
this.institutionService = institutionService;
|
this.institutionService = institutionService;
|
||||||
this.jdbcTemplate = jdbcTemplate;
|
this.jdbcTemplate = jdbcTemplate;
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.persistence.db;
|
package org.maxkey.persistence.repository;
|
||||||
|
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
@ -25,8 +25,8 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
|
||||||
public class LoginHistoryService {
|
public class LoginHistoryRepository {
|
||||||
private static Logger _logger = LoggerFactory.getLogger(LoginHistoryService.class);
|
private static Logger _logger = LoggerFactory.getLogger(LoginHistoryRepository.class);
|
||||||
|
|
||||||
private static final String HISTORY_LOGIN_INSERT_STATEMENT = "insert into mxk_history_login (id , sessionid , userid , username , displayname , logintype , message , code , provider , sourceip , browser , platform , application , loginurl , sessionstatus ,instid)values( ? , ? , ? , ? , ? , ? , ?, ? , ? , ?, ? , ? , ?, ? , ? , ?)";
|
private static final String HISTORY_LOGIN_INSERT_STATEMENT = "insert into mxk_history_login (id , sessionid , userid , username , displayname , logintype , message , code , provider , sourceip , browser , platform , application , loginurl , sessionstatus ,instid)values( ? , ? , ? , ? , ? , ? , ?, ? , ? , ?, ? , ? , ?, ? , ? , ?)";
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public class LoginHistoryService {
|
|||||||
|
|
||||||
protected JdbcTemplate jdbcTemplate;
|
protected JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
public LoginHistoryService(JdbcTemplate jdbcTemplate) {
|
public LoginHistoryRepository(JdbcTemplate jdbcTemplate) {
|
||||||
this.jdbcTemplate = jdbcTemplate;
|
this.jdbcTemplate = jdbcTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.persistence.db;
|
package org.maxkey.persistence.repository;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -35,8 +35,8 @@ import org.springframework.jdbc.core.RowMapper;
|
|||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
|
||||||
public class LoginService {
|
public class LoginRepository {
|
||||||
private static Logger _logger = LoggerFactory.getLogger(LoginService.class);
|
private static Logger _logger = LoggerFactory.getLogger(LoginRepository.class);
|
||||||
|
|
||||||
private static final String LOCK_USER_UPDATE_STATEMENT = "update mxk_userinfo set islocked = ? , unlocktime = ? where id = ?";
|
private static final String LOCK_USER_UPDATE_STATEMENT = "update mxk_userinfo set islocked = ? , unlocktime = ? where id = ?";
|
||||||
|
|
||||||
@ -69,11 +69,11 @@ public class LoginService {
|
|||||||
*/
|
*/
|
||||||
public static int LOGIN_ATTRIBUTE_TYPE = 2;
|
public static int LOGIN_ATTRIBUTE_TYPE = 2;
|
||||||
|
|
||||||
public LoginService(){
|
public LoginRepository(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginService(JdbcTemplate jdbcTemplate){
|
public LoginRepository(JdbcTemplate jdbcTemplate){
|
||||||
this.jdbcTemplate=jdbcTemplate;
|
this.jdbcTemplate=jdbcTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.persistence.db;
|
package org.maxkey.persistence.repository;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -0,0 +1,185 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package org.maxkey.persistence.repository;
|
||||||
|
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.maxkey.constants.ConstantsProperties;
|
||||||
|
import org.maxkey.entity.PasswordPolicy;
|
||||||
|
import org.passay.CharacterOccurrencesRule;
|
||||||
|
import org.passay.CharacterRule;
|
||||||
|
import org.passay.DictionaryRule;
|
||||||
|
import org.passay.EnglishCharacterData;
|
||||||
|
import org.passay.EnglishSequenceData;
|
||||||
|
import org.passay.IllegalSequenceRule;
|
||||||
|
import org.passay.LengthRule;
|
||||||
|
import org.passay.Rule;
|
||||||
|
import org.passay.UsernameRule;
|
||||||
|
import org.passay.WhitespaceRule;
|
||||||
|
import org.passay.dictionary.Dictionary;
|
||||||
|
import org.passay.dictionary.DictionaryBuilder;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
import com.github.benmanes.caffeine.cache.Cache;
|
||||||
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
|
|
||||||
|
public class PasswordPolicyRepository {
|
||||||
|
private static Logger _logger = LoggerFactory.getLogger(PasswordPolicyRepository.class);
|
||||||
|
|
||||||
|
//Dictionary topWeakPassword Source
|
||||||
|
public static final String topWeakPasswordPropertySource =
|
||||||
|
"classpath:/top_weak_password.txt";
|
||||||
|
|
||||||
|
//Cache PasswordPolicy in memory ONE_HOUR
|
||||||
|
protected static final Cache<String, PasswordPolicy> passwordPolicyStore =
|
||||||
|
Caffeine.newBuilder()
|
||||||
|
.expireAfterWrite(60, TimeUnit.MINUTES)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
protected PasswordPolicy passwordPolicy;
|
||||||
|
|
||||||
|
protected JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
|
ArrayList <Rule> passwordPolicyRuleList;
|
||||||
|
|
||||||
|
private static final String PASSWORD_POLICY_KEY = "PASSWORD_POLICY_KEY";
|
||||||
|
|
||||||
|
private static final String PASSWORD_POLICY_SELECT_STATEMENT = "select * from mxk_password_policy ";
|
||||||
|
|
||||||
|
public PasswordPolicyRepository(JdbcTemplate jdbcTemplate) {
|
||||||
|
this.jdbcTemplate = jdbcTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* init PasswordPolicy and load Rules
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public PasswordPolicy getPasswordPolicy() {
|
||||||
|
passwordPolicy = passwordPolicyStore.getIfPresent(PASSWORD_POLICY_KEY);
|
||||||
|
|
||||||
|
if (passwordPolicy == null) {
|
||||||
|
passwordPolicy = jdbcTemplate.queryForObject(PASSWORD_POLICY_SELECT_STATEMENT,
|
||||||
|
new PasswordPolicyRowMapper());
|
||||||
|
_logger.debug("query PasswordPolicy : " + passwordPolicy);
|
||||||
|
passwordPolicyStore.put(PASSWORD_POLICY_KEY,passwordPolicy);
|
||||||
|
|
||||||
|
//RandomPasswordLength =(MaxLength +MinLength)/2
|
||||||
|
passwordPolicy.setRandomPasswordLength(
|
||||||
|
Math.round(
|
||||||
|
(
|
||||||
|
passwordPolicy.getMaxLength() +
|
||||||
|
passwordPolicy.getMinLength()
|
||||||
|
)/2
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
passwordPolicyRuleList = new ArrayList<Rule>();
|
||||||
|
passwordPolicyRuleList.add(new WhitespaceRule());
|
||||||
|
passwordPolicyRuleList.add(new LengthRule(passwordPolicy.getMinLength(), passwordPolicy.getMaxLength()));
|
||||||
|
|
||||||
|
if(passwordPolicy.getUpperCase()>0) {
|
||||||
|
passwordPolicyRuleList.add(new CharacterRule(EnglishCharacterData.UpperCase, passwordPolicy.getUpperCase()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(passwordPolicy.getLowerCase()>0) {
|
||||||
|
passwordPolicyRuleList.add(new CharacterRule(EnglishCharacterData.LowerCase, passwordPolicy.getLowerCase()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(passwordPolicy.getDigits()>0) {
|
||||||
|
passwordPolicyRuleList.add(new CharacterRule(EnglishCharacterData.Digit, passwordPolicy.getDigits()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(passwordPolicy.getSpecialChar()>0) {
|
||||||
|
passwordPolicyRuleList.add(new CharacterRule(EnglishCharacterData.Special, passwordPolicy.getSpecialChar()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(passwordPolicy.getUsername()>0) {
|
||||||
|
passwordPolicyRuleList.add(new UsernameRule());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(passwordPolicy.getOccurances()>0) {
|
||||||
|
passwordPolicyRuleList.add(new CharacterOccurrencesRule(passwordPolicy.getOccurances()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(passwordPolicy.getAlphabetical()>0) {
|
||||||
|
passwordPolicyRuleList.add(new IllegalSequenceRule(EnglishSequenceData.Alphabetical, 4, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(passwordPolicy.getNumerical()>0) {
|
||||||
|
passwordPolicyRuleList.add(new IllegalSequenceRule(EnglishSequenceData.Numerical, 4, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(passwordPolicy.getQwerty()>0) {
|
||||||
|
passwordPolicyRuleList.add(new IllegalSequenceRule(EnglishSequenceData.USQwerty, 4, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(passwordPolicy.getDictionary()>0 ) {
|
||||||
|
try {
|
||||||
|
ClassPathResource dictFile=
|
||||||
|
new ClassPathResource(
|
||||||
|
ConstantsProperties.classPathResource(topWeakPasswordPropertySource));
|
||||||
|
Dictionary dictionary =new DictionaryBuilder().addReader(new InputStreamReader(dictFile.getInputStream())).build();
|
||||||
|
passwordPolicyRuleList.add(new DictionaryRule(dictionary));
|
||||||
|
}catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return passwordPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ArrayList<Rule> getPasswordPolicyRuleList() {
|
||||||
|
return passwordPolicyRuleList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class PasswordPolicyRowMapper implements RowMapper<PasswordPolicy> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PasswordPolicy mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
|
PasswordPolicy passwordPolicy = new PasswordPolicy();
|
||||||
|
passwordPolicy.setId(rs.getString("ID"));
|
||||||
|
passwordPolicy.setMinLength(rs.getInt("MINLENGTH"));
|
||||||
|
passwordPolicy.setMaxLength(rs.getInt("MAXLENGTH"));
|
||||||
|
passwordPolicy.setLowerCase(rs.getInt("LOWERCASE"));
|
||||||
|
passwordPolicy.setUpperCase(rs.getInt("UPPERCASE"));
|
||||||
|
passwordPolicy.setDigits(rs.getInt("DIGITS"));
|
||||||
|
passwordPolicy.setSpecialChar(rs.getInt("SPECIALCHAR"));
|
||||||
|
passwordPolicy.setAttempts(rs.getInt("ATTEMPTS"));
|
||||||
|
passwordPolicy.setDuration(rs.getInt("DURATION"));
|
||||||
|
passwordPolicy.setExpiration(rs.getInt("EXPIRATION"));
|
||||||
|
passwordPolicy.setUsername(rs.getInt("USERNAME"));
|
||||||
|
passwordPolicy.setHistory(rs.getInt("HISTORY"));
|
||||||
|
passwordPolicy.setDictionary(rs.getInt("DICTIONARY"));
|
||||||
|
passwordPolicy.setAlphabetical(rs.getInt("ALPHABETICAL"));
|
||||||
|
passwordPolicy.setNumerical(rs.getInt("NUMERICAL"));
|
||||||
|
passwordPolicy.setQwerty(rs.getInt("QWERTY"));
|
||||||
|
passwordPolicy.setOccurances(rs.getInt("OCCURANCES"));
|
||||||
|
return passwordPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -15,21 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.persistence.db;
|
package org.maxkey.persistence.repository;
|
||||||
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
import org.maxkey.constants.ConstantsPasswordSetType;
|
import org.maxkey.constants.ConstantsPasswordSetType;
|
||||||
import org.maxkey.constants.ConstantsProperties;
|
|
||||||
import org.maxkey.constants.ConstantsStatus;
|
import org.maxkey.constants.ConstantsStatus;
|
||||||
import org.maxkey.crypto.password.PasswordGen;
|
import org.maxkey.crypto.password.PasswordGen;
|
||||||
import org.maxkey.entity.PasswordPolicy;
|
import org.maxkey.entity.PasswordPolicy;
|
||||||
@ -37,48 +30,19 @@ import org.maxkey.entity.UserInfo;
|
|||||||
import org.maxkey.util.StringUtils;
|
import org.maxkey.util.StringUtils;
|
||||||
import org.maxkey.web.WebConstants;
|
import org.maxkey.web.WebConstants;
|
||||||
import org.maxkey.web.WebContext;
|
import org.maxkey.web.WebContext;
|
||||||
import org.passay.CharacterOccurrencesRule;
|
|
||||||
import org.passay.CharacterRule;
|
|
||||||
import org.passay.DictionaryRule;
|
|
||||||
import org.passay.EnglishCharacterData;
|
|
||||||
import org.passay.EnglishSequenceData;
|
|
||||||
import org.passay.IllegalSequenceRule;
|
|
||||||
import org.passay.LengthRule;
|
|
||||||
import org.passay.PasswordData;
|
import org.passay.PasswordData;
|
||||||
import org.passay.PasswordValidator;
|
import org.passay.PasswordValidator;
|
||||||
import org.passay.Rule;
|
|
||||||
import org.passay.RuleResult;
|
import org.passay.RuleResult;
|
||||||
import org.passay.UsernameRule;
|
|
||||||
import org.passay.WhitespaceRule;
|
|
||||||
import org.passay.dictionary.Dictionary;
|
|
||||||
import org.passay.dictionary.DictionaryBuilder;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
|
||||||
import org.springframework.security.authentication.BadCredentialsException;
|
import org.springframework.security.authentication.BadCredentialsException;
|
||||||
|
|
||||||
import com.github.benmanes.caffeine.cache.Cache;
|
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
|
||||||
|
|
||||||
public class PasswordPolicyValidator {
|
public class PasswordPolicyValidator {
|
||||||
private static Logger _logger = LoggerFactory.getLogger(PasswordPolicyValidator.class);
|
private static Logger _logger = LoggerFactory.getLogger(PasswordPolicyValidator.class);
|
||||||
|
|
||||||
//Dictionary topWeakPassword Source
|
PasswordPolicyRepository passwordPolicyRepository;
|
||||||
public static final String topWeakPasswordPropertySource =
|
|
||||||
"classpath:/top_weak_password.txt";
|
|
||||||
|
|
||||||
//Cache PasswordPolicy in memory ONE_HOUR
|
|
||||||
protected static final Cache<String, PasswordPolicy> passwordPolicyStore =
|
|
||||||
Caffeine.newBuilder()
|
|
||||||
.expireAfterWrite(60, TimeUnit.MINUTES)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
protected PasswordPolicy passwordPolicy;
|
|
||||||
|
|
||||||
ArrayList <Rule> passwordPolicyRuleList;
|
|
||||||
|
|
||||||
protected JdbcTemplate jdbcTemplate;
|
protected JdbcTemplate jdbcTemplate;
|
||||||
|
|
||||||
@ -86,12 +50,8 @@ public class PasswordPolicyValidator {
|
|||||||
|
|
||||||
public static final String PASSWORD_POLICY_VALIDATE_RESULT = "PASSWORD_POLICY_SESSION_VALIDATE_RESULT_KEY";
|
public static final String PASSWORD_POLICY_VALIDATE_RESULT = "PASSWORD_POLICY_SESSION_VALIDATE_RESULT_KEY";
|
||||||
|
|
||||||
private static final String PASSWORD_POLICY_KEY = "PASSWORD_POLICY_KEY";
|
|
||||||
|
|
||||||
private static final String LOCK_USER_UPDATE_STATEMENT = "update mxk_userinfo set islocked = ? , unlocktime = ? where id = ?";
|
private static final String LOCK_USER_UPDATE_STATEMENT = "update mxk_userinfo set islocked = ? , unlocktime = ? where id = ?";
|
||||||
|
|
||||||
private static final String PASSWORD_POLICY_SELECT_STATEMENT = "select * from mxk_password_policy ";
|
|
||||||
|
|
||||||
private static final String UNLOCK_USER_UPDATE_STATEMENT = "update mxk_userinfo set islocked = ? , unlocktime = ? where id = ?";
|
private static final String UNLOCK_USER_UPDATE_STATEMENT = "update mxk_userinfo set islocked = ? , unlocktime = ? where id = ?";
|
||||||
|
|
||||||
private static final String BADPASSWORDCOUNT_UPDATE_STATEMENT = "update mxk_userinfo set badpasswordcount = ? , badpasswordtime = ? where id = ?";
|
private static final String BADPASSWORDCOUNT_UPDATE_STATEMENT = "update mxk_userinfo set badpasswordcount = ? , badpasswordtime = ? where id = ?";
|
||||||
@ -104,84 +64,8 @@ public class PasswordPolicyValidator {
|
|||||||
public PasswordPolicyValidator(JdbcTemplate jdbcTemplate,MessageSource messageSource) {
|
public PasswordPolicyValidator(JdbcTemplate jdbcTemplate,MessageSource messageSource) {
|
||||||
this.messageSource=messageSource;
|
this.messageSource=messageSource;
|
||||||
this.jdbcTemplate = jdbcTemplate;
|
this.jdbcTemplate = jdbcTemplate;
|
||||||
}
|
this.passwordPolicyRepository = new PasswordPolicyRepository(jdbcTemplate);
|
||||||
|
|
||||||
/**
|
|
||||||
* init PasswordPolicy and load Rules
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public PasswordPolicy getPasswordPolicy() {
|
|
||||||
passwordPolicy = passwordPolicyStore.getIfPresent(PASSWORD_POLICY_KEY);
|
|
||||||
|
|
||||||
if (passwordPolicy == null) {
|
|
||||||
passwordPolicy = jdbcTemplate.queryForObject(PASSWORD_POLICY_SELECT_STATEMENT,
|
|
||||||
new PasswordPolicyRowMapper());
|
|
||||||
_logger.debug("query PasswordPolicy : " + passwordPolicy);
|
|
||||||
passwordPolicyStore.put(PASSWORD_POLICY_KEY,passwordPolicy);
|
|
||||||
|
|
||||||
//RandomPasswordLength =(MaxLength +MinLength)/2
|
|
||||||
passwordPolicy.setRandomPasswordLength(
|
|
||||||
Math.round(
|
|
||||||
(
|
|
||||||
passwordPolicy.getMaxLength() +
|
|
||||||
passwordPolicy.getMinLength()
|
|
||||||
)/2
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
passwordPolicyRuleList = new ArrayList<Rule>();
|
|
||||||
passwordPolicyRuleList.add(new WhitespaceRule());
|
|
||||||
passwordPolicyRuleList.add(new LengthRule(passwordPolicy.getMinLength(), passwordPolicy.getMaxLength()));
|
|
||||||
|
|
||||||
if(passwordPolicy.getUpperCase()>0) {
|
|
||||||
passwordPolicyRuleList.add(new CharacterRule(EnglishCharacterData.UpperCase, passwordPolicy.getUpperCase()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(passwordPolicy.getLowerCase()>0) {
|
|
||||||
passwordPolicyRuleList.add(new CharacterRule(EnglishCharacterData.LowerCase, passwordPolicy.getLowerCase()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(passwordPolicy.getDigits()>0) {
|
|
||||||
passwordPolicyRuleList.add(new CharacterRule(EnglishCharacterData.Digit, passwordPolicy.getDigits()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(passwordPolicy.getSpecialChar()>0) {
|
|
||||||
passwordPolicyRuleList.add(new CharacterRule(EnglishCharacterData.Special, passwordPolicy.getSpecialChar()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(passwordPolicy.getUsername()>0) {
|
|
||||||
passwordPolicyRuleList.add(new UsernameRule());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(passwordPolicy.getOccurances()>0) {
|
|
||||||
passwordPolicyRuleList.add(new CharacterOccurrencesRule(passwordPolicy.getOccurances()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(passwordPolicy.getAlphabetical()>0) {
|
|
||||||
passwordPolicyRuleList.add(new IllegalSequenceRule(EnglishSequenceData.Alphabetical, 4, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(passwordPolicy.getNumerical()>0) {
|
|
||||||
passwordPolicyRuleList.add(new IllegalSequenceRule(EnglishSequenceData.Numerical, 4, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(passwordPolicy.getQwerty()>0) {
|
|
||||||
passwordPolicyRuleList.add(new IllegalSequenceRule(EnglishSequenceData.USQwerty, 4, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(passwordPolicy.getDictionary()>0 ) {
|
|
||||||
try {
|
|
||||||
ClassPathResource dictFile=
|
|
||||||
new ClassPathResource(
|
|
||||||
ConstantsProperties.classPathResource(topWeakPasswordPropertySource));
|
|
||||||
Dictionary dictionary =new DictionaryBuilder().addReader(new InputStreamReader(dictFile.getInputStream())).build();
|
|
||||||
passwordPolicyRuleList.add(new DictionaryRule(dictionary));
|
|
||||||
}catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return passwordPolicy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,10 +84,8 @@ public class PasswordPolicyValidator {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
getPasswordPolicy();
|
|
||||||
|
|
||||||
PasswordValidator validator = new PasswordValidator(
|
PasswordValidator validator = new PasswordValidator(
|
||||||
new PasswordPolicyMessageResolver(messageSource),passwordPolicyRuleList);
|
new PasswordPolicyMessageResolver(messageSource),passwordPolicyRepository.getPasswordPolicyRuleList());
|
||||||
|
|
||||||
RuleResult result = validator.validate(new PasswordData(username,password));
|
RuleResult result = validator.validate(new PasswordData(username,password));
|
||||||
|
|
||||||
@ -230,8 +112,8 @@ public class PasswordPolicyValidator {
|
|||||||
*/
|
*/
|
||||||
public boolean passwordPolicyValid(UserInfo userInfo) {
|
public boolean passwordPolicyValid(UserInfo userInfo) {
|
||||||
|
|
||||||
getPasswordPolicy();
|
PasswordPolicy passwordPolicy = passwordPolicyRepository.getPasswordPolicy();
|
||||||
|
|
||||||
DateTime currentdateTime = new DateTime();
|
DateTime currentdateTime = new DateTime();
|
||||||
/*
|
/*
|
||||||
* check login attempts fail times
|
* check login attempts fail times
|
||||||
@ -285,7 +167,8 @@ public class PasswordPolicyValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void applyPasswordPolicy(UserInfo userInfo) {
|
public void applyPasswordPolicy(UserInfo userInfo) {
|
||||||
getPasswordPolicy();
|
PasswordPolicy passwordPolicy = passwordPolicyRepository.getPasswordPolicy();
|
||||||
|
|
||||||
DateTime currentdateTime = new DateTime();
|
DateTime currentdateTime = new DateTime();
|
||||||
//initial password need change
|
//initial password need change
|
||||||
if(userInfo.getLoginCount()<=0) {
|
if(userInfo.getLoginCount()<=0) {
|
||||||
@ -417,7 +300,8 @@ public class PasswordPolicyValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String generateRandomPassword() {
|
public String generateRandomPassword() {
|
||||||
getPasswordPolicy();
|
PasswordPolicy passwordPolicy = passwordPolicyRepository.getPasswordPolicy();
|
||||||
|
|
||||||
PasswordGen passwordGen = new PasswordGen(
|
PasswordGen passwordGen = new PasswordGen(
|
||||||
passwordPolicy.getRandomPasswordLength()
|
passwordPolicy.getRandomPasswordLength()
|
||||||
);
|
);
|
||||||
@ -428,36 +312,9 @@ public class PasswordPolicyValidator {
|
|||||||
passwordPolicy.getDigits(),
|
passwordPolicy.getDigits(),
|
||||||
passwordPolicy.getSpecialChar());
|
passwordPolicy.getSpecialChar());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPasswordPolicy(PasswordPolicy passwordPolicy) {
|
|
||||||
this.passwordPolicy = passwordPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public PasswordPolicyRepository getPasswordPolicyRepository() {
|
||||||
public class PasswordPolicyRowMapper implements RowMapper<PasswordPolicy> {
|
return passwordPolicyRepository;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PasswordPolicy mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
||||||
PasswordPolicy passwordPolicy = new PasswordPolicy();
|
|
||||||
passwordPolicy.setId(rs.getString("ID"));
|
|
||||||
passwordPolicy.setMinLength(rs.getInt("MINLENGTH"));
|
|
||||||
passwordPolicy.setMaxLength(rs.getInt("MAXLENGTH"));
|
|
||||||
passwordPolicy.setLowerCase(rs.getInt("LOWERCASE"));
|
|
||||||
passwordPolicy.setUpperCase(rs.getInt("UPPERCASE"));
|
|
||||||
passwordPolicy.setDigits(rs.getInt("DIGITS"));
|
|
||||||
passwordPolicy.setSpecialChar(rs.getInt("SPECIALCHAR"));
|
|
||||||
passwordPolicy.setAttempts(rs.getInt("ATTEMPTS"));
|
|
||||||
passwordPolicy.setDuration(rs.getInt("DURATION"));
|
|
||||||
passwordPolicy.setExpiration(rs.getInt("EXPIRATION"));
|
|
||||||
passwordPolicy.setUsername(rs.getInt("USERNAME"));
|
|
||||||
passwordPolicy.setHistory(rs.getInt("HISTORY"));
|
|
||||||
passwordPolicy.setDictionary(rs.getInt("DICTIONARY"));
|
|
||||||
passwordPolicy.setAlphabetical(rs.getInt("ALPHABETICAL"));
|
|
||||||
passwordPolicy.setNumerical(rs.getInt("NUMERICAL"));
|
|
||||||
passwordPolicy.setQwerty(rs.getInt("QWERTY"));
|
|
||||||
passwordPolicy.setOccurances(rs.getInt("OCCURANCES"));
|
|
||||||
return passwordPolicy;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -24,8 +24,8 @@ import javax.servlet.http.HttpSessionListener;
|
|||||||
|
|
||||||
import org.apache.mybatis.jpa.util.WebContext;
|
import org.apache.mybatis.jpa.util.WebContext;
|
||||||
import org.maxkey.entity.UserInfo;
|
import org.maxkey.entity.UserInfo;
|
||||||
import org.maxkey.persistence.db.LoginHistoryService;
|
import org.maxkey.persistence.repository.LoginHistoryRepository;
|
||||||
import org.maxkey.persistence.db.LoginService;
|
import org.maxkey.persistence.repository.LoginRepository;
|
||||||
import org.maxkey.util.DateUtils;
|
import org.maxkey.util.DateUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -35,26 +35,26 @@ public class SessionListenerAdapter implements HttpSessionListener {
|
|||||||
|
|
||||||
private static final Logger _logger = LoggerFactory.getLogger(SessionListenerAdapter.class);
|
private static final Logger _logger = LoggerFactory.getLogger(SessionListenerAdapter.class);
|
||||||
|
|
||||||
LoginService loginService;
|
LoginRepository loginRepository;
|
||||||
|
|
||||||
LoginHistoryService loginHistoryService;
|
LoginHistoryRepository loginHistoryRepository;
|
||||||
|
|
||||||
public SessionListenerAdapter() {
|
public SessionListenerAdapter() {
|
||||||
super();
|
super();
|
||||||
_logger.debug("SessionListenerAdapter inited . ");
|
_logger.debug("SessionListenerAdapter inited . ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionListenerAdapter(LoginService loginService, LoginHistoryService loginHistoryService) {
|
public SessionListenerAdapter(LoginRepository loginRepository, LoginHistoryRepository loginHistoryRepository) {
|
||||||
super();
|
super();
|
||||||
this.loginService = loginService;
|
this.loginRepository = loginRepository;
|
||||||
this.loginHistoryService = loginHistoryService;
|
this.loginHistoryRepository = loginHistoryRepository;
|
||||||
_logger.debug("SessionListenerAdapter inited . ");
|
_logger.debug("SessionListenerAdapter inited . ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
if(loginService == null ) {
|
if(loginRepository == null ) {
|
||||||
loginService = (LoginService)WebContext.getBean("loginService");
|
loginRepository = (LoginRepository)WebContext.getBean("loginRepository");
|
||||||
loginHistoryService = (LoginHistoryService)WebContext.getBean("loginHistoryService");
|
loginHistoryRepository = (LoginHistoryRepository)WebContext.getBean("loginHistoryRepository");
|
||||||
_logger.debug("SessionListenerAdapter function inited . ");
|
_logger.debug("SessionListenerAdapter function inited . ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,8 +78,8 @@ public class SessionListenerAdapter implements HttpSessionListener {
|
|||||||
init();
|
init();
|
||||||
UserInfo userInfo = (UserInfo)session.getAttribute(WebConstants.CURRENT_USER);
|
UserInfo userInfo = (UserInfo)session.getAttribute(WebConstants.CURRENT_USER);
|
||||||
userInfo.setLastLogoffTime(DateUtils.formatDateTime(new Date()));
|
userInfo.setLastLogoffTime(DateUtils.formatDateTime(new Date()));
|
||||||
loginService.updateLastLogoff(userInfo);
|
loginRepository.updateLastLogoff(userInfo);
|
||||||
loginHistoryService.logoff(userInfo.getLastLogoffTime(), sessionIdAttribute.toString());
|
loginHistoryRepository.logoff(userInfo.getLastLogoffTime(), sessionIdAttribute.toString());
|
||||||
|
|
||||||
_logger.debug(
|
_logger.debug(
|
||||||
"session {} Destroyed as {} userId : {} , username : {}" ,
|
"session {} Destroyed as {} userId : {} , username : {}" ,
|
||||||
@ -91,12 +91,12 @@ public class SessionListenerAdapter implements HttpSessionListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoginService(LoginService loginService) {
|
public void setLoginRepository(LoginRepository loginRepository) {
|
||||||
this.loginService = loginService;
|
this.loginRepository = loginRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoginHistoryService(LoginHistoryService loginHistoryService) {
|
public void setLoginHistoryRepository(LoginHistoryRepository loginHistoryRepository) {
|
||||||
this.loginHistoryService = loginHistoryService;
|
this.loginHistoryRepository = loginHistoryRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.maxkey.configuration.ApplicationConfig;
|
import org.maxkey.configuration.ApplicationConfig;
|
||||||
import org.maxkey.entity.Institutions;
|
import org.maxkey.entity.Institutions;
|
||||||
import org.maxkey.persistence.db.InstitutionService;
|
import org.maxkey.persistence.repository.InstitutionsRepository;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.filter.GenericFilterBean;
|
import org.springframework.web.filter.GenericFilterBean;
|
||||||
@ -39,7 +39,7 @@ public class WebInstRequestFilter extends GenericFilterBean {
|
|||||||
|
|
||||||
public final static String HEADER_HOST = "host";
|
public final static String HEADER_HOST = "host";
|
||||||
|
|
||||||
InstitutionService institutionService;
|
InstitutionsRepository institutionsRepository;
|
||||||
|
|
||||||
ApplicationConfig applicationConfig;
|
ApplicationConfig applicationConfig;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public class WebInstRequestFilter extends GenericFilterBean {
|
|||||||
if(host.indexOf(":")> -1 ) {
|
if(host.indexOf(":")> -1 ) {
|
||||||
host = host.split(":")[0];
|
host = host.split(":")[0];
|
||||||
}
|
}
|
||||||
Institutions institution =institutionService.findByDomain(host);
|
Institutions institution =institutionsRepository.findByDomain(host);
|
||||||
_logger.trace("{}" ,institution);
|
_logger.trace("{}" ,institution);
|
||||||
request.getSession().setAttribute(WebConstants.CURRENT_INST, institution);
|
request.getSession().setAttribute(WebConstants.CURRENT_INST, institution);
|
||||||
WebContext.setCookie((HttpServletResponse)servletResponse, host, WebConstants.INST_COOKIE_NAME, institution.getId());
|
WebContext.setCookie((HttpServletResponse)servletResponse, host, WebConstants.INST_COOKIE_NAME, institution.getId());
|
||||||
@ -66,9 +66,9 @@ public class WebInstRequestFilter extends GenericFilterBean {
|
|||||||
chain.doFilter(servletRequest, servletResponse);
|
chain.doFilter(servletRequest, servletResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebInstRequestFilter(InstitutionService institutionService,ApplicationConfig applicationConfig) {
|
public WebInstRequestFilter(InstitutionsRepository institutionsRepository,ApplicationConfig applicationConfig) {
|
||||||
super();
|
super();
|
||||||
this.institutionService = institutionService;
|
this.institutionsRepository = institutionsRepository;
|
||||||
this.applicationConfig = applicationConfig;
|
this.applicationConfig = applicationConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import java.io.IOException;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.maxkey.persistence.db.LocalizationService;
|
import org.maxkey.persistence.repository.LocalizationRepository;
|
||||||
import org.maxkey.web.WebContext;
|
import org.maxkey.web.WebContext;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -51,7 +51,7 @@ public class LocaleTagDirective implements TemplateDirectiveModel {
|
|||||||
private HttpServletRequest request;
|
private HttpServletRequest request;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
LocalizationService localizationService;
|
LocalizationRepository localizationService;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.gateway;
|
package org.gateway;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.gateway.controller;
|
package org.gateway.controller;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.gateway.filter;
|
package org.gateway.filter;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
package org.gateway.route;
|
package org.gateway.route;
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.identity.scim.resources;
|
package org.maxkey.identity.scim.resources;
|
||||||
|
|
||||||
import org.maxkey.identity.scim.controller.ScimServiceProviderConfigController;
|
import org.maxkey.identity.scim.controller.ScimServiceProviderConfigController;
|
||||||
|
|||||||
@ -24,11 +24,11 @@ import org.maxkey.crypto.password.PasswordReciprocal;
|
|||||||
import org.maxkey.entity.Accounts;
|
import org.maxkey.entity.Accounts;
|
||||||
import org.maxkey.entity.ChangePassword;
|
import org.maxkey.entity.ChangePassword;
|
||||||
import org.maxkey.entity.UserInfo;
|
import org.maxkey.entity.UserInfo;
|
||||||
import org.maxkey.persistence.db.PasswordPolicyValidator;
|
|
||||||
import org.maxkey.persistence.kafka.KafkaIdentityAction;
|
import org.maxkey.persistence.kafka.KafkaIdentityAction;
|
||||||
import org.maxkey.persistence.kafka.KafkaIdentityTopic;
|
import org.maxkey.persistence.kafka.KafkaIdentityTopic;
|
||||||
import org.maxkey.persistence.kafka.KafkaPersistService;
|
import org.maxkey.persistence.kafka.KafkaPersistService;
|
||||||
import org.maxkey.persistence.mapper.UserInfoMapper;
|
import org.maxkey.persistence.mapper.UserInfoMapper;
|
||||||
|
import org.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||||
import org.maxkey.util.DateUtils;
|
import org.maxkey.util.DateUtils;
|
||||||
import org.maxkey.util.StringUtils;
|
import org.maxkey.util.StringUtils;
|
||||||
import org.maxkey.web.WebContext;
|
import org.maxkey.web.WebContext;
|
||||||
|
|||||||
@ -18,7 +18,7 @@ import org.maxkey.authn.AbstractAuthenticationProvider;
|
|||||||
import org.maxkey.authn.SigninPrincipal;
|
import org.maxkey.authn.SigninPrincipal;
|
||||||
import org.maxkey.authn.online.OnlineTicket;
|
import org.maxkey.authn.online.OnlineTicket;
|
||||||
import org.maxkey.entity.UserInfo;
|
import org.maxkey.entity.UserInfo;
|
||||||
import org.maxkey.persistence.db.LoginService;
|
import org.maxkey.persistence.repository.LoginRepository;
|
||||||
import org.maxkey.web.WebConstants;
|
import org.maxkey.web.WebConstants;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -35,18 +35,12 @@ public class OAuth2UserDetailsService implements UserDetailsService {
|
|||||||
private static final Logger _logger =
|
private static final Logger _logger =
|
||||||
LoggerFactory.getLogger(OAuth2UserDetailsService.class);
|
LoggerFactory.getLogger(OAuth2UserDetailsService.class);
|
||||||
|
|
||||||
LoginService loginService;
|
LoginRepository loginRepository;
|
||||||
|
|
||||||
|
|
||||||
public void setLoginService(LoginService loginService) {
|
|
||||||
this.loginService = loginService;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||||
UserInfo userInfo;
|
UserInfo userInfo;
|
||||||
try {
|
try {
|
||||||
userInfo = loginService.find(username, "");
|
userInfo = loginRepository.find(username, "");
|
||||||
} catch (NoSuchClientException e) {
|
} catch (NoSuchClientException e) {
|
||||||
throw new UsernameNotFoundException(e.getMessage(), e);
|
throw new UsernameNotFoundException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
@ -58,7 +52,7 @@ public class OAuth2UserDetailsService implements UserDetailsService {
|
|||||||
//set OnlineTicket
|
//set OnlineTicket
|
||||||
signinPrincipal.setOnlineTicket(onlineTicket);
|
signinPrincipal.setOnlineTicket(onlineTicket);
|
||||||
|
|
||||||
ArrayList<GrantedAuthority> grantedAuthoritys = loginService.grantAuthority(userInfo);
|
ArrayList<GrantedAuthority> grantedAuthoritys = loginRepository.grantAuthority(userInfo);
|
||||||
signinPrincipal.setAuthenticated(true);
|
signinPrincipal.setAuthenticated(true);
|
||||||
|
|
||||||
for(GrantedAuthority administratorsAuthority : AbstractAuthenticationProvider.grantedAdministratorsAuthoritys) {
|
for(GrantedAuthority administratorsAuthority : AbstractAuthenticationProvider.grantedAdministratorsAuthoritys) {
|
||||||
@ -74,4 +68,9 @@ public class OAuth2UserDetailsService implements UserDetailsService {
|
|||||||
return signinPrincipal;
|
return signinPrincipal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLoginRepository(LoginRepository loginRepository) {
|
||||||
|
this.loginRepository = loginRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,8 +43,8 @@ import org.maxkey.configuration.oidc.OIDCProviderMetadataDetails;
|
|||||||
import org.maxkey.crypto.jose.keystore.JWKSetKeyStore;
|
import org.maxkey.crypto.jose.keystore.JWKSetKeyStore;
|
||||||
import org.maxkey.crypto.jwt.encryption.service.impl.DefaultJwtEncryptionAndDecryptionService;
|
import org.maxkey.crypto.jwt.encryption.service.impl.DefaultJwtEncryptionAndDecryptionService;
|
||||||
import org.maxkey.crypto.jwt.signer.service.impl.DefaultJwtSigningAndValidationService;
|
import org.maxkey.crypto.jwt.signer.service.impl.DefaultJwtSigningAndValidationService;
|
||||||
import org.maxkey.persistence.db.LoginService;
|
|
||||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||||
|
import org.maxkey.persistence.repository.LoginRepository;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
@ -303,11 +303,11 @@ public class Oauth20AutoConfiguration implements InitializingBean {
|
|||||||
@Bean(name = "oauth20UserAuthenticationManager")
|
@Bean(name = "oauth20UserAuthenticationManager")
|
||||||
public ProviderManager oauth20UserAuthenticationManager(
|
public ProviderManager oauth20UserAuthenticationManager(
|
||||||
PasswordEncoder passwordEncoder,
|
PasswordEncoder passwordEncoder,
|
||||||
LoginService loginService
|
LoginRepository loginRepository
|
||||||
) {
|
) {
|
||||||
|
|
||||||
OAuth2UserDetailsService userDetailsService =new OAuth2UserDetailsService();
|
OAuth2UserDetailsService userDetailsService =new OAuth2UserDetailsService();
|
||||||
userDetailsService.setLoginService(loginService);
|
userDetailsService.setLoginRepository(loginRepository);
|
||||||
|
|
||||||
DaoAuthenticationProvider daoAuthenticationProvider= new DaoAuthenticationProvider();
|
DaoAuthenticationProvider daoAuthenticationProvider= new DaoAuthenticationProvider();
|
||||||
daoAuthenticationProvider.setPasswordEncoder(passwordEncoder);
|
daoAuthenticationProvider.setPasswordEncoder(passwordEncoder);
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.boot.monitor;
|
package org.maxkey.boot.monitor;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.maxkey.boot.monitor;
|
package org.maxkey.boot.monitor;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|||||||
@ -45,12 +45,12 @@ import org.maxkey.password.onetimepwd.impl.sms.SmsOtpAuthnAliyun;
|
|||||||
import org.maxkey.password.onetimepwd.impl.sms.SmsOtpAuthnTencentCloud;
|
import org.maxkey.password.onetimepwd.impl.sms.SmsOtpAuthnTencentCloud;
|
||||||
import org.maxkey.password.onetimepwd.impl.sms.SmsOtpAuthnYunxin;
|
import org.maxkey.password.onetimepwd.impl.sms.SmsOtpAuthnYunxin;
|
||||||
import org.maxkey.password.onetimepwd.token.RedisOtpTokenStore;
|
import org.maxkey.password.onetimepwd.token.RedisOtpTokenStore;
|
||||||
import org.maxkey.persistence.db.LoginHistoryService;
|
|
||||||
import org.maxkey.persistence.db.LoginService;
|
|
||||||
import org.maxkey.persistence.db.PasswordPolicyValidator;
|
|
||||||
import org.maxkey.persistence.ldap.ActiveDirectoryUtils;
|
import org.maxkey.persistence.ldap.ActiveDirectoryUtils;
|
||||||
import org.maxkey.persistence.ldap.LdapUtils;
|
import org.maxkey.persistence.ldap.LdapUtils;
|
||||||
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
import org.maxkey.persistence.redis.RedisConnectionFactory;
|
||||||
|
import org.maxkey.persistence.repository.LoginHistoryRepository;
|
||||||
|
import org.maxkey.persistence.repository.LoginRepository;
|
||||||
|
import org.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||||
import org.maxkey.persistence.service.UserInfoService;
|
import org.maxkey.persistence.service.UserInfoService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -152,8 +152,8 @@ public class MaxKeyConfig implements InitializingBean {
|
|||||||
public JdbcAuthenticationRealm authenticationRealm(
|
public JdbcAuthenticationRealm authenticationRealm(
|
||||||
PasswordEncoder passwordEncoder,
|
PasswordEncoder passwordEncoder,
|
||||||
PasswordPolicyValidator passwordPolicyValidator,
|
PasswordPolicyValidator passwordPolicyValidator,
|
||||||
LoginService loginService,
|
LoginRepository loginService,
|
||||||
LoginHistoryService loginHistoryService,
|
LoginHistoryRepository loginHistoryService,
|
||||||
AbstractRemeberMeService remeberMeService,
|
AbstractRemeberMeService remeberMeService,
|
||||||
UserInfoService userInfoService,
|
UserInfoService userInfoService,
|
||||||
JdbcTemplate jdbcTemplate,
|
JdbcTemplate jdbcTemplate,
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import java.util.regex.Pattern;
|
|||||||
import org.maxkey.configuration.EmailConfig;
|
import org.maxkey.configuration.EmailConfig;
|
||||||
import org.maxkey.entity.UserInfo;
|
import org.maxkey.entity.UserInfo;
|
||||||
import org.maxkey.password.onetimepwd.AbstractOtpAuthn;
|
import org.maxkey.password.onetimepwd.AbstractOtpAuthn;
|
||||||
import org.maxkey.persistence.db.PasswordPolicyValidator;
|
import org.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||||
import org.maxkey.persistence.service.UserInfoService;
|
import org.maxkey.persistence.service.UserInfoService;
|
||||||
import org.maxkey.web.WebConstants;
|
import org.maxkey.web.WebConstants;
|
||||||
import org.maxkey.web.WebContext;
|
import org.maxkey.web.WebContext;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import org.maxkey.constants.ConstantsPasswordSetType;
|
|||||||
import org.maxkey.constants.ConstantsTimeInterval;
|
import org.maxkey.constants.ConstantsTimeInterval;
|
||||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||||
import org.maxkey.entity.UserInfo;
|
import org.maxkey.entity.UserInfo;
|
||||||
import org.maxkey.persistence.db.PasswordPolicyValidator;
|
import org.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||||
import org.maxkey.persistence.service.UserInfoService;
|
import org.maxkey.persistence.service.UserInfoService;
|
||||||
import org.maxkey.util.StringUtils;
|
import org.maxkey.util.StringUtils;
|
||||||
import org.maxkey.web.WebConstants;
|
import org.maxkey.web.WebConstants;
|
||||||
|
|||||||
@ -24,8 +24,8 @@ import org.maxkey.authn.online.OnlineTicketServices;
|
|||||||
import org.maxkey.constants.ConstantsOperateMessage;
|
import org.maxkey.constants.ConstantsOperateMessage;
|
||||||
import org.maxkey.entity.HistoryLogin;
|
import org.maxkey.entity.HistoryLogin;
|
||||||
import org.maxkey.entity.UserInfo;
|
import org.maxkey.entity.UserInfo;
|
||||||
import org.maxkey.persistence.db.LoginHistoryService;
|
import org.maxkey.persistence.repository.LoginHistoryRepository;
|
||||||
import org.maxkey.persistence.db.LoginService;
|
import org.maxkey.persistence.repository.LoginRepository;
|
||||||
import org.maxkey.persistence.service.HistoryLoginService;
|
import org.maxkey.persistence.service.HistoryLoginService;
|
||||||
import org.maxkey.util.DateUtils;
|
import org.maxkey.util.DateUtils;
|
||||||
import org.maxkey.util.StringUtils;
|
import org.maxkey.util.StringUtils;
|
||||||
@ -60,10 +60,10 @@ public class LoginSessionController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
HistoryLoginService historyLoginService;
|
HistoryLoginService historyLoginService;
|
||||||
@Autowired
|
@Autowired
|
||||||
LoginService loginService;
|
LoginRepository loginRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
LoginHistoryService loginHistoryService;
|
LoginHistoryRepository loginHistoryRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
OnlineTicketServices onlineTicketServices;
|
OnlineTicketServices onlineTicketServices;
|
||||||
@ -108,8 +108,8 @@ public class LoginSessionController {
|
|||||||
}
|
}
|
||||||
UserInfo userInfo = WebContext.getUserInfo();
|
UserInfo userInfo = WebContext.getUserInfo();
|
||||||
String lastLogoffTime = DateUtils.formatDateTime(new Date());
|
String lastLogoffTime = DateUtils.formatDateTime(new Date());
|
||||||
loginService.updateLastLogoff(userInfo);
|
loginRepository.updateLastLogoff(userInfo);
|
||||||
loginHistoryService.logoff(lastLogoffTime, sessionId);
|
loginHistoryRepository.logoff(lastLogoffTime, sessionId);
|
||||||
onlineTicketServices.remove("OT-" + sessionId);
|
onlineTicketServices.remove("OT-" + sessionId);
|
||||||
}
|
}
|
||||||
isTerminated = true;
|
isTerminated = true;
|
||||||
|
|||||||
@ -19,9 +19,9 @@ package org.maxkey;
|
|||||||
|
|
||||||
import org.maxkey.password.onetimepwd.AbstractOtpAuthn;
|
import org.maxkey.password.onetimepwd.AbstractOtpAuthn;
|
||||||
import org.maxkey.password.onetimepwd.impl.TimeBasedOtpAuthn;
|
import org.maxkey.password.onetimepwd.impl.TimeBasedOtpAuthn;
|
||||||
import org.maxkey.persistence.db.LoginHistoryService;
|
import org.maxkey.persistence.repository.LoginHistoryRepository;
|
||||||
import org.maxkey.persistence.db.LoginService;
|
import org.maxkey.persistence.repository.LoginRepository;
|
||||||
import org.maxkey.persistence.db.PasswordPolicyValidator;
|
import org.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||||
import org.maxkey.persistence.service.UserInfoService;
|
import org.maxkey.persistence.service.UserInfoService;
|
||||||
import org.maxkey.authn.realm.jdbc.JdbcAuthenticationRealm;
|
import org.maxkey.authn.realm.jdbc.JdbcAuthenticationRealm;
|
||||||
import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
|
import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
|
||||||
@ -42,8 +42,8 @@ public class MaxKeyMgtConfig implements InitializingBean {
|
|||||||
public JdbcAuthenticationRealm authenticationRealm(
|
public JdbcAuthenticationRealm authenticationRealm(
|
||||||
PasswordEncoder passwordEncoder,
|
PasswordEncoder passwordEncoder,
|
||||||
PasswordPolicyValidator passwordPolicyValidator,
|
PasswordPolicyValidator passwordPolicyValidator,
|
||||||
LoginService loginService,
|
LoginRepository loginRepository,
|
||||||
LoginHistoryService loginHistoryService,
|
LoginHistoryRepository loginHistoryRepository,
|
||||||
AbstractRemeberMeService remeberMeService,
|
AbstractRemeberMeService remeberMeService,
|
||||||
UserInfoService userInfoService,
|
UserInfoService userInfoService,
|
||||||
JdbcTemplate jdbcTemplate) {
|
JdbcTemplate jdbcTemplate) {
|
||||||
@ -51,8 +51,8 @@ public class MaxKeyMgtConfig implements InitializingBean {
|
|||||||
JdbcAuthenticationRealm authenticationRealm = new JdbcAuthenticationRealm(
|
JdbcAuthenticationRealm authenticationRealm = new JdbcAuthenticationRealm(
|
||||||
passwordEncoder,
|
passwordEncoder,
|
||||||
passwordPolicyValidator,
|
passwordPolicyValidator,
|
||||||
loginService,
|
loginRepository,
|
||||||
loginHistoryService,
|
loginHistoryRepository,
|
||||||
remeberMeService,
|
remeberMeService,
|
||||||
userInfoService,
|
userInfoService,
|
||||||
jdbcTemplate);
|
jdbcTemplate);
|
||||||
|
|||||||
@ -20,7 +20,7 @@ package org.maxkey.web.contorller;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.maxkey.constants.ConstantsOperateMessage;
|
import org.maxkey.constants.ConstantsOperateMessage;
|
||||||
import org.maxkey.entity.Localization;
|
import org.maxkey.entity.Localization;
|
||||||
import org.maxkey.persistence.db.LocalizationService;
|
import org.maxkey.persistence.repository.LocalizationRepository;
|
||||||
import org.maxkey.web.WebContext;
|
import org.maxkey.web.WebContext;
|
||||||
import org.maxkey.web.message.Message;
|
import org.maxkey.web.message.Message;
|
||||||
import org.maxkey.web.message.MessageType;
|
import org.maxkey.web.message.MessageType;
|
||||||
@ -43,7 +43,7 @@ public class LocalizationController {
|
|||||||
final static Logger _logger = LoggerFactory.getLogger(LocalizationController.class);
|
final static Logger _logger = LoggerFactory.getLogger(LocalizationController.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LocalizationService localizationService;
|
private LocalizationRepository localizationRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 读取
|
* 读取
|
||||||
@ -51,7 +51,7 @@ public class LocalizationController {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping(value={"/forward/{property}"})
|
@RequestMapping(value={"/forward/{property}"})
|
||||||
public ModelAndView forward(@PathVariable("property") String property){
|
public ModelAndView forward(@PathVariable("property") String property){
|
||||||
Localization localization = localizationService.get(property,WebContext.getUserInfo().getInstId());
|
Localization localization = localizationRepository.get(property,WebContext.getUserInfo().getInstId());
|
||||||
if(localization == null )localization = new Localization();
|
if(localization == null )localization = new Localization();
|
||||||
localization.setProperty(property);
|
localization.setProperty(property);
|
||||||
localization.setInstId(WebContext.getUserInfo().getInstId());
|
localization.setInstId(WebContext.getUserInfo().getInstId());
|
||||||
@ -70,13 +70,13 @@ public class LocalizationController {
|
|||||||
localization.setInstId(WebContext.getUserInfo().getInstId());
|
localization.setInstId(WebContext.getUserInfo().getInstId());
|
||||||
if(StringUtils.isBlank(localization.getId())){
|
if(StringUtils.isBlank(localization.getId())){
|
||||||
localization.setId(localization.generateId());
|
localization.setId(localization.generateId());
|
||||||
if(localizationService.insert(localization)) {
|
if(localizationRepository.insert(localization)) {
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
|
||||||
} else {
|
} else {
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if(localizationService.update(localization)) {
|
if(localizationRepository.update(localization)) {
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
|
||||||
} else {
|
} else {
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
|
||||||
|
|||||||
@ -24,8 +24,8 @@ import org.maxkey.authn.online.OnlineTicketServices;
|
|||||||
import org.maxkey.constants.ConstantsOperateMessage;
|
import org.maxkey.constants.ConstantsOperateMessage;
|
||||||
import org.maxkey.entity.HistoryLogin;
|
import org.maxkey.entity.HistoryLogin;
|
||||||
import org.maxkey.entity.UserInfo;
|
import org.maxkey.entity.UserInfo;
|
||||||
import org.maxkey.persistence.db.LoginHistoryService;
|
import org.maxkey.persistence.repository.LoginHistoryRepository;
|
||||||
import org.maxkey.persistence.db.LoginService;
|
import org.maxkey.persistence.repository.LoginRepository;
|
||||||
import org.maxkey.persistence.service.HistoryLoginService;
|
import org.maxkey.persistence.service.HistoryLoginService;
|
||||||
import org.maxkey.util.DateUtils;
|
import org.maxkey.util.DateUtils;
|
||||||
import org.maxkey.util.StringUtils;
|
import org.maxkey.util.StringUtils;
|
||||||
@ -60,10 +60,10 @@ public class LoginSessionController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
HistoryLoginService historyLoginService;
|
HistoryLoginService historyLoginService;
|
||||||
@Autowired
|
@Autowired
|
||||||
LoginService loginService;
|
LoginRepository loginRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
LoginHistoryService loginHistoryService;
|
LoginHistoryRepository loginHistoryRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
OnlineTicketServices onlineTicketServices;
|
OnlineTicketServices onlineTicketServices;
|
||||||
@ -106,8 +106,8 @@ public class LoginSessionController {
|
|||||||
}
|
}
|
||||||
UserInfo userInfo = WebContext.getUserInfo();
|
UserInfo userInfo = WebContext.getUserInfo();
|
||||||
String lastLogoffTime = DateUtils.formatDateTime(new Date());
|
String lastLogoffTime = DateUtils.formatDateTime(new Date());
|
||||||
loginService.updateLastLogoff(userInfo);
|
loginRepository.updateLastLogoff(userInfo);
|
||||||
loginHistoryService.logoff(lastLogoffTime, sessionId);
|
loginHistoryRepository.logoff(lastLogoffTime, sessionId);
|
||||||
onlineTicketServices.remove("OT-" + sessionId);
|
onlineTicketServices.remove("OT-" + sessionId);
|
||||||
}
|
}
|
||||||
isTerminated = true;
|
isTerminated = true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user