大量代码调整和优化
This commit is contained in:
@@ -22,7 +22,7 @@ package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.GroupPermissions;
|
||||
import org.dromara.maxkey.entity.Access;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
@@ -30,12 +30,12 @@ import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
*
|
||||
*/
|
||||
|
||||
public interface GroupPermissionsMapper extends IJpaMapper<GroupPermissions> {
|
||||
public interface AccessMapper extends IJpaMapper<Access> {
|
||||
|
||||
public List<GroupPermissions>appsInGroup(GroupPermissions entity);
|
||||
public List<Access>appsInGroup(Access entity);
|
||||
|
||||
|
||||
public List<GroupPermissions> appsNotInGroup(GroupPermissions entity);
|
||||
public List<Access> appsNotInGroup(Access entity);
|
||||
|
||||
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.dromara.maxkey.entity.Accounts;
|
||||
import org.dromara.maxkey.entity.AccountsStrategy;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ package org.dromara.maxkey.persistence.mapper;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.AccountsStrategy;
|
||||
import org.dromara.maxkey.entity.Roles;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
import org.dromara.maxkey.entity.LdapContext;
|
||||
import org.dromara.maxkey.entity.cnf.CnfEmailSenders;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
public interface LdapContextMapper extends IJpaMapper<LdapContext> {
|
||||
public interface CnfEmailSendersMapper extends IJpaMapper<CnfEmailSenders> {
|
||||
|
||||
}
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
import org.dromara.maxkey.entity.EmailSenders;
|
||||
import org.dromara.maxkey.entity.cnf.CnfLdapContext;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
public interface EmailSendersMapper extends IJpaMapper<EmailSenders> {
|
||||
public interface CnfLdapContextMapper extends IJpaMapper<CnfLdapContext> {
|
||||
|
||||
}
|
||||
@@ -20,14 +20,14 @@
|
||||
*/
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import org.dromara.maxkey.entity.PasswordPolicy;
|
||||
import org.dromara.maxkey.entity.cnf.CnfPasswordPolicy;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
* @author Crystal.sea
|
||||
*
|
||||
*/
|
||||
public interface PasswordPolicyMapper extends IJpaMapper<PasswordPolicy> {
|
||||
public interface CnfPasswordPolicyMapper extends IJpaMapper<CnfPasswordPolicy> {
|
||||
|
||||
|
||||
}
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import org.dromara.maxkey.entity.SmsProvider;
|
||||
import org.dromara.maxkey.entity.cnf.CnfSmsProvider;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
public interface SmsProviderMapper extends IJpaMapper<SmsProvider> {
|
||||
public interface CnfSmsProviderMapper extends IJpaMapper<CnfSmsProvider> {
|
||||
|
||||
}
|
||||
@@ -22,11 +22,11 @@ package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.GroupMember;
|
||||
import org.dromara.maxkey.entity.Groups;
|
||||
import org.dromara.maxkey.entity.RoleMember;
|
||||
import org.dromara.maxkey.entity.Roles;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.GroupMember;
|
||||
import org.dromara.maxkey.entity.idm.Groups;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.entity.permissions.RoleMember;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.Groups;
|
||||
import org.dromara.maxkey.entity.idm.Groups;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
|
||||
import org.dromara.maxkey.entity.HistoryConnector;
|
||||
import org.dromara.maxkey.entity.history.HistoryConnector;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import org.dromara.maxkey.entity.HistoryLoginApps;
|
||||
import org.dromara.maxkey.entity.history.HistoryLoginApps;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.HistoryLogin;
|
||||
import org.dromara.maxkey.entity.history.HistoryLogin;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
|
||||
import org.dromara.maxkey.entity.HistorySynchronizer;
|
||||
import org.dromara.maxkey.entity.history.HistorySynchronizer;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import org.dromara.maxkey.entity.HistorySystemLogs;
|
||||
import org.dromara.maxkey.entity.history.HistorySystemLogs;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.Organizations;
|
||||
import org.dromara.maxkey.entity.OrganizationsCast;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
public interface OrganizationsCastMapper extends IJpaMapper<OrganizationsCast> {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.dromara.maxkey.persistence.mapper;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.dromara.maxkey.entity.Organizations;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
public interface OrganizationsMapper extends IJpaMapper<Organizations> {
|
||||
|
||||
@@ -22,7 +22,7 @@ package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.GroupPrivileges;
|
||||
import org.dromara.maxkey.entity.permissions.Permission;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
@@ -30,12 +30,12 @@ import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
*
|
||||
*/
|
||||
|
||||
public interface GroupPrivilegesMapper extends IJpaMapper<GroupPrivileges> {
|
||||
public interface PermissionMapper extends IJpaMapper<Permission> {
|
||||
|
||||
public int insertGroupPrivileges(List<GroupPrivileges> groupPrivilegesList);
|
||||
public int insertGroupPrivileges(List<Permission> groupPrivilegesList);
|
||||
|
||||
public int deleteGroupPrivileges(List<GroupPrivileges> groupPrivilegesList);
|
||||
public int deleteGroupPrivileges(List<Permission> groupPrivilegesList);
|
||||
|
||||
public List<GroupPrivileges> queryGroupPrivileges(GroupPrivileges groupPrivileges);
|
||||
public List<Permission> queryGroupPrivileges(Permission groupPrivileges);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.permissions.PermissionRole;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
* @author Crystal.sea
|
||||
*
|
||||
*/
|
||||
|
||||
public interface PermissionRoleMapper extends IJpaMapper<PermissionRole> {
|
||||
|
||||
public int insertPermissionRoles(List<PermissionRole> permissionRolesList);
|
||||
|
||||
public int deletePermissionRoles(List<PermissionRole> permissionRolesList);
|
||||
|
||||
public List<PermissionRole> queryPermissionRoles(PermissionRole permissionRole);
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ package org.dromara.maxkey.persistence.mapper;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.Register;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import org.dromara.maxkey.entity.Resources;
|
||||
import org.dromara.maxkey.entity.permissions.Resources;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.entity.permissions.RoleMember;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
* @author Crystal.sea
|
||||
*
|
||||
*/
|
||||
|
||||
public interface RoleMemberMapper extends IJpaMapper<RoleMember> {
|
||||
|
||||
public List<RoleMember> memberInRole(RoleMember entity);
|
||||
|
||||
public List<RoleMember> memberNotInRole(RoleMember entity);
|
||||
|
||||
public List<RoleMember> memberPostNotInRole(RoleMember entity);
|
||||
|
||||
public List<Roles> rolesNoMember(RoleMember entity);
|
||||
|
||||
public int addDynamicRoleMember(Roles dynamicRole);
|
||||
|
||||
public int deleteDynamicRoleMember(Roles dynamicRole);
|
||||
|
||||
public int deleteByRoleId(String roleId);
|
||||
|
||||
public List<UserInfo> queryMemberByRoleId(String roleId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.dromara.maxkey.persistence.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
/**
|
||||
* @author Crystal.sea
|
||||
*
|
||||
*/
|
||||
|
||||
public interface RolesMapper extends IJpaMapper<Roles> {
|
||||
|
||||
public List<Roles> queryDynamicRoles(Roles groups);
|
||||
|
||||
public List<Roles> queryRolesByUserId(String userId);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package org.dromara.maxkey.persistence.mapper;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.SocialsAssociate;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
public interface SocialsAssociateMapper extends IJpaMapper<SocialsAssociate> {
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.entity.ChangePassword;
|
||||
import org.dromara.maxkey.entity.Organizations;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.mybatis.jpa.IJpaMapper;
|
||||
|
||||
|
||||
|
||||
@@ -29,11 +29,12 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
public class InstitutionsRepository {
|
||||
private static Logger _logger = LoggerFactory.getLogger(InstitutionsRepository.class);
|
||||
static final Logger _logger = LoggerFactory.getLogger(InstitutionsRepository.class);
|
||||
|
||||
private static final String SELECT_STATEMENT =
|
||||
"select * from mxk_institutions where id = ? or domain = ? or consoledomain = ?" ;
|
||||
@@ -46,7 +47,7 @@ public class InstitutionsRepository {
|
||||
.build();
|
||||
|
||||
//id domain mapping
|
||||
protected static final ConcurrentHashMap<String,String> mapper = new ConcurrentHashMap<String,String>();
|
||||
protected static final ConcurrentHashMap<String,String> mapper = new ConcurrentHashMap<>();
|
||||
|
||||
protected JdbcTemplate jdbcTemplate;
|
||||
|
||||
@@ -71,7 +72,7 @@ public class InstitutionsRepository {
|
||||
List<Institutions> institutions =
|
||||
jdbcTemplate.query(SELECT_STATEMENT,new InstitutionsRowMapper(),instIdOrDomain,instIdOrDomain,instIdOrDomain);
|
||||
|
||||
if (institutions != null && institutions.size() > 0) {
|
||||
if (CollectionUtils.isNotEmpty(institutions)) {
|
||||
inst = institutions.get(0);
|
||||
}
|
||||
if(inst != null ) {
|
||||
@@ -96,7 +97,6 @@ public class InstitutionsRepository {
|
||||
institution.setFrontTitle(rs.getString("fronttitle"));
|
||||
institution.setConsoleDomain(rs.getString("consoledomain"));
|
||||
institution.setConsoleTitle(rs.getString("consoletitle"));
|
||||
institution.setCaptcha(rs.getString("captcha"));
|
||||
institution.setDefaultUri(rs.getString("defaultUri"));
|
||||
return institution;
|
||||
}
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
/*
|
||||
* 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.dromara.maxkey.persistence.repository;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.dromara.maxkey.constants.ConstsTimeInterval;
|
||||
import org.dromara.maxkey.entity.Localization;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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 LocalizationRepository {
|
||||
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 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 SELECT_STATEMENT ="select * from mxk_localization where ( id = ? ) or (property = ? and instid = ?)";
|
||||
|
||||
private static final Pattern PATTERN_HTML = Pattern.compile("<[^>]+>", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
protected InstitutionsRepository institutionService;
|
||||
|
||||
JdbcTemplate jdbcTemplate;
|
||||
|
||||
protected static final Cache<String, String> localizationStore =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(ConstsTimeInterval.ONE_HOUR, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
public LocalizationRepository() {
|
||||
|
||||
}
|
||||
|
||||
public String getLocale(String code,String htmlTag,Locale locale,String inst) {
|
||||
String message = "";
|
||||
htmlTag = (htmlTag == null ||htmlTag.equalsIgnoreCase("true")) ? "tag" : "rtag";
|
||||
|
||||
if(code.equals("global.logo")) {
|
||||
message = institutionService.get(inst).getLogo();
|
||||
}else if(code.equals("global.title")) {
|
||||
message = getFromStore(code, htmlTag, locale, inst);
|
||||
if(message == null) {
|
||||
message = institutionService.get(inst).getFrontTitle();
|
||||
}
|
||||
}else if(code.equals("global.consoleTitle")) {
|
||||
message = getFromStore(code, htmlTag, locale, inst);
|
||||
if(message == null) {
|
||||
message = institutionService.get(inst).getConsoleTitle();
|
||||
}
|
||||
}else {
|
||||
message = getFromStore(code, htmlTag, locale, inst);
|
||||
}
|
||||
if(htmlTag.equalsIgnoreCase("rtag")) {
|
||||
message = clearHTMLToString(message);
|
||||
}
|
||||
_logger.trace("{} = {}" , code , message);
|
||||
return message == null ? "" : message;
|
||||
}
|
||||
|
||||
public String clearHTMLToString(String message) {
|
||||
return PATTERN_HTML.matcher(message).replaceAll("");
|
||||
}
|
||||
|
||||
public String getFromStore(String code,String htmlTag,Locale locale,String inst) {
|
||||
String message = localizationStore.getIfPresent(code+"_"+locale.getLanguage()+"_"+inst);
|
||||
if(message != null) return message;
|
||||
Localization localization = get(code,inst);
|
||||
if(localization != null) {
|
||||
localizationStore.put(code+"_en_"+inst, localization.getLangEn());
|
||||
localizationStore.put(code+"_zh_"+inst, localization.getLangZh());
|
||||
if(locale.getLanguage().equals("en")) {
|
||||
message = localization.getLangEn();
|
||||
}else {
|
||||
message = localization.getLangZh();
|
||||
}
|
||||
if(message != null) return message;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setInstitutionService(InstitutionsRepository institutionService) {
|
||||
this.institutionService = institutionService;
|
||||
}
|
||||
|
||||
public boolean insert(Localization localization) {
|
||||
return jdbcTemplate.update(INSERT_STATEMENT,
|
||||
new Object[] {localization.getId(),localization.getProperty(),
|
||||
localization.getLangZh(),localization.getLangEn(),
|
||||
localization.getStatus(),localization.getDescription(),
|
||||
localization.getInstId()},
|
||||
new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER,
|
||||
Types.VARCHAR, Types.VARCHAR,}) > 0;
|
||||
}
|
||||
|
||||
public boolean update(Localization localization) {
|
||||
jdbcTemplate.update(UPDATE_STATEMENT,localization.getLangZh(),localization.getLangEn(),localization.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean remove(String id) {
|
||||
return jdbcTemplate.update(DELETE_STATEMENT,id) > 0;
|
||||
}
|
||||
|
||||
public Localization get(String property,String instId) {
|
||||
_logger.debug("load property from database , property {} ,instId {}",property, instId);
|
||||
List<Localization> localizations =
|
||||
jdbcTemplate.query(
|
||||
SELECT_STATEMENT,new LocalizationRowMapper(),property,property,instId);
|
||||
return (localizations==null || localizations.size()==0) ? null : localizations.get(0);
|
||||
}
|
||||
|
||||
public LocalizationRepository(JdbcTemplate jdbcTemplate,InstitutionsRepository institutionService) {
|
||||
super();
|
||||
this.institutionService = institutionService;
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
public class LocalizationRowMapper implements RowMapper<Localization> {
|
||||
@Override
|
||||
public Localization mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
Localization localization = new Localization();
|
||||
localization.setId(rs.getString("id"));
|
||||
localization.setProperty(rs.getString("property"));
|
||||
localization.setLangZh(rs.getString("langzh"));
|
||||
localization.setLangEn(rs.getString("langen"));
|
||||
localization.setStatus(rs.getInt("status"));
|
||||
localization.setDescription(rs.getString("description"));
|
||||
localization.setInstId(rs.getString("instid"));
|
||||
return localization;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package org.dromara.maxkey.persistence.repository;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import org.dromara.maxkey.entity.HistoryLogin;
|
||||
import org.dromara.maxkey.entity.history.HistoryLogin;
|
||||
import org.dromara.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -28,8 +28,8 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsRoles;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.entity.Groups;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.Groups;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.util.StrUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -62,7 +62,7 @@ public class LoginRepository {
|
||||
|
||||
private static final String DEFAULT_USERINFO_SELECT_STATEMENT_USERNAME_MOBILE_EMAIL = "select * from mxk_userinfo where (username = ? or mobile = ? or email = ?) ";
|
||||
|
||||
private static final String DEFAULT_MYAPPS_SELECT_STATEMENT = "select distinct app.id,app.appname from mxk_apps app,mxk_group_permissions gp,mxk_groups g where app.id=gp.appid and app.status = 1 and gp.groupid=g.id and g.id in(%s)";
|
||||
private static final String DEFAULT_MYAPPS_SELECT_STATEMENT = "select distinct app.id,app.appname from mxk_apps app,mxk_access gp,mxk_groups g where app.id=gp.appid and app.status = 1 and gp.groupid=g.id and g.id in(%s)";
|
||||
|
||||
protected JdbcTemplate jdbcTemplate;
|
||||
|
||||
|
||||
@@ -21,10 +21,11 @@ import java.io.InputStreamReader;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.dromara.maxkey.constants.ConstsProperties;
|
||||
import org.dromara.maxkey.entity.PasswordPolicy;
|
||||
import org.dromara.maxkey.entity.cnf.CnfPasswordPolicy;
|
||||
import org.passay.CharacterOccurrencesRule;
|
||||
import org.passay.CharacterRule;
|
||||
import org.passay.DictionaryRule;
|
||||
@@ -46,19 +47,18 @@ 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);
|
||||
static final Logger _logger = LoggerFactory.getLogger(PasswordPolicyRepository.class);
|
||||
|
||||
//Dictionary topWeakPassword Source
|
||||
public static final String topWeakPasswordPropertySource =
|
||||
"classpath:/top_weak_password.txt";
|
||||
public static final String TOPWEAKPASSWORD_PROPERTYSOURCE = "classpath:/top_weak_password.txt";
|
||||
|
||||
//Cache PasswordPolicy in memory ONE_HOUR
|
||||
protected static final Cache<String, PasswordPolicy> passwordPolicyStore =
|
||||
protected static final Cache<String, CnfPasswordPolicy> passwordPolicyStore =
|
||||
Caffeine.newBuilder()
|
||||
.expireAfterWrite(60, TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
protected PasswordPolicy passwordPolicy;
|
||||
protected CnfPasswordPolicy passwordPolicy;
|
||||
|
||||
protected JdbcTemplate jdbcTemplate;
|
||||
|
||||
@@ -66,7 +66,7 @@ public class PasswordPolicyRepository {
|
||||
|
||||
private static final String PASSWORD_POLICY_KEY = "PASSWORD_POLICY_KEY";
|
||||
|
||||
private static final String PASSWORD_POLICY_SELECT_STATEMENT = "select * from mxk_password_policy ";
|
||||
private static final String PASSWORD_POLICY_SELECT_STATEMENT = "select * from mxk_cnf_password_policy ";
|
||||
|
||||
public PasswordPolicyRepository(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
@@ -76,13 +76,13 @@ public class PasswordPolicyRepository {
|
||||
* init PasswordPolicy and load Rules
|
||||
* @return
|
||||
*/
|
||||
public PasswordPolicy getPasswordPolicy() {
|
||||
public CnfPasswordPolicy getPasswordPolicy() {
|
||||
passwordPolicy = passwordPolicyStore.getIfPresent(PASSWORD_POLICY_KEY);
|
||||
|
||||
if (passwordPolicy == null) {
|
||||
passwordPolicy = jdbcTemplate.queryForObject(PASSWORD_POLICY_SELECT_STATEMENT,
|
||||
new PasswordPolicyRowMapper());
|
||||
_logger.debug("query PasswordPolicy : " + passwordPolicy);
|
||||
_logger.debug("query PasswordPolicy : {}" , passwordPolicy);
|
||||
passwordPolicyStore.put(PASSWORD_POLICY_KEY,passwordPolicy);
|
||||
|
||||
//RandomPasswordLength =(MaxLength +MinLength)/2
|
||||
@@ -95,7 +95,7 @@ public class PasswordPolicyRepository {
|
||||
)
|
||||
);
|
||||
|
||||
passwordPolicyRuleList = new ArrayList<Rule>();
|
||||
passwordPolicyRuleList = new ArrayList<>();
|
||||
passwordPolicyRuleList.add(new WhitespaceRule());
|
||||
passwordPolicyRuleList.add(new LengthRule(passwordPolicy.getMinLength(), passwordPolicy.getMaxLength()));
|
||||
|
||||
@@ -139,7 +139,7 @@ public class PasswordPolicyRepository {
|
||||
try {
|
||||
ClassPathResource dictFile=
|
||||
new ClassPathResource(
|
||||
ConstsProperties.classPathResource(topWeakPasswordPropertySource));
|
||||
ConstsProperties.classPathResource(TOPWEAKPASSWORD_PROPERTYSOURCE));
|
||||
Dictionary dictionary =new DictionaryBuilder().addReader(new InputStreamReader(dictFile.getInputStream())).build();
|
||||
passwordPolicyRuleList.add(new DictionaryRule(dictionary));
|
||||
}catch(Exception e) {
|
||||
@@ -151,35 +151,35 @@ public class PasswordPolicyRepository {
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<Rule> getPasswordPolicyRuleList() {
|
||||
public List<Rule> getPasswordPolicyRuleList() {
|
||||
getPasswordPolicy();
|
||||
return passwordPolicyRuleList;
|
||||
}
|
||||
|
||||
|
||||
public class PasswordPolicyRowMapper implements RowMapper<PasswordPolicy> {
|
||||
public class PasswordPolicyRowMapper implements RowMapper<CnfPasswordPolicy> {
|
||||
|
||||
@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;
|
||||
public CnfPasswordPolicy mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
CnfPasswordPolicy newPasswordPolicy = new CnfPasswordPolicy();
|
||||
newPasswordPolicy.setId(rs.getString("id"));
|
||||
newPasswordPolicy.setMinLength(rs.getInt("minlength"));
|
||||
newPasswordPolicy.setMaxLength(rs.getInt("maxlength"));
|
||||
newPasswordPolicy.setLowerCase(rs.getInt("lowercase"));
|
||||
newPasswordPolicy.setUpperCase(rs.getInt("uppercase"));
|
||||
newPasswordPolicy.setDigits(rs.getInt("digits"));
|
||||
newPasswordPolicy.setSpecialChar(rs.getInt("specialchar"));
|
||||
newPasswordPolicy.setAttempts(rs.getInt("attempts"));
|
||||
newPasswordPolicy.setDuration(rs.getInt("duration"));
|
||||
newPasswordPolicy.setExpiration(rs.getInt("expiration"));
|
||||
newPasswordPolicy.setUsername(rs.getInt("username"));
|
||||
newPasswordPolicy.setHistory(rs.getInt("history"));
|
||||
newPasswordPolicy.setDictionary(rs.getInt("dictionary"));
|
||||
newPasswordPolicy.setAlphabetical(rs.getInt("alphabetical"));
|
||||
newPasswordPolicy.setNumerical(rs.getInt("numerical"));
|
||||
newPasswordPolicy.setQwerty(rs.getInt("qwerty"));
|
||||
newPasswordPolicy.setOccurances(rs.getInt("occurances"));
|
||||
return newPasswordPolicy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.dromara.maxkey.constants.ConstsPasswordSetType;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.crypto.password.PasswordGen;
|
||||
import org.dromara.maxkey.entity.ChangePassword;
|
||||
import org.dromara.maxkey.entity.PasswordPolicy;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.cnf.CnfPasswordPolicy;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.web.WebConstants;
|
||||
import org.dromara.maxkey.web.WebContext;
|
||||
import org.joda.time.DateTime;
|
||||
@@ -41,7 +41,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
|
||||
public class PasswordPolicyValidator {
|
||||
private static Logger _logger = LoggerFactory.getLogger(PasswordPolicyValidator.class);
|
||||
static final Logger _logger = LoggerFactory.getLogger(PasswordPolicyValidator.class);
|
||||
|
||||
PasswordPolicyRepository passwordPolicyRepository;
|
||||
|
||||
@@ -80,7 +80,12 @@ public class PasswordPolicyValidator {
|
||||
String password = changePassword.getPassword();
|
||||
String username = changePassword.getUsername();
|
||||
|
||||
if(password.equals("") || password==null){
|
||||
if(StringUtils.isBlank(username)){
|
||||
_logger.debug("username is Empty ");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(password)){
|
||||
_logger.debug("password is Empty ");
|
||||
return false;
|
||||
}
|
||||
@@ -113,7 +118,7 @@ public class PasswordPolicyValidator {
|
||||
*/
|
||||
public boolean passwordPolicyValid(UserInfo userInfo) {
|
||||
|
||||
PasswordPolicy passwordPolicy = passwordPolicyRepository.getPasswordPolicy();
|
||||
CnfPasswordPolicy passwordPolicy = passwordPolicyRepository.getPasswordPolicy();
|
||||
|
||||
DateTime currentdateTime = new DateTime();
|
||||
/*
|
||||
@@ -163,7 +168,7 @@ public class PasswordPolicyValidator {
|
||||
}
|
||||
|
||||
public void applyPasswordPolicy(UserInfo userInfo) {
|
||||
PasswordPolicy passwordPolicy = passwordPolicyRepository.getPasswordPolicy();
|
||||
CnfPasswordPolicy passwordPolicy = passwordPolicyRepository.getPasswordPolicy();
|
||||
|
||||
DateTime currentdateTime = new DateTime();
|
||||
//initial password need change
|
||||
@@ -282,7 +287,7 @@ public class PasswordPolicyValidator {
|
||||
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
||||
userInfo.setBadPasswordCount(userInfo.getBadPasswordCount() + 1);
|
||||
setBadPasswordCount(userInfo.getId(),userInfo.getBadPasswordCount());
|
||||
PasswordPolicy passwordPolicy = passwordPolicyRepository.getPasswordPolicy();
|
||||
CnfPasswordPolicy passwordPolicy = passwordPolicyRepository.getPasswordPolicy();
|
||||
if(userInfo.getBadPasswordCount() >= passwordPolicy.getAttempts()) {
|
||||
_logger.debug("Bad Password Count {} , Max Attempts {}",
|
||||
userInfo.getBadPasswordCount() + 1,passwordPolicy.getAttempts());
|
||||
@@ -300,7 +305,7 @@ public class PasswordPolicyValidator {
|
||||
}
|
||||
|
||||
public String generateRandomPassword() {
|
||||
PasswordPolicy passwordPolicy = passwordPolicyRepository.getPasswordPolicy();
|
||||
CnfPasswordPolicy passwordPolicy = passwordPolicyRepository.getPasswordPolicy();
|
||||
|
||||
PasswordGen passwordGen = new PasswordGen(
|
||||
passwordPolicy.getRandomPasswordLength()
|
||||
|
||||
@@ -17,24 +17,26 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.PasswordPolicy;
|
||||
import org.dromara.maxkey.persistence.mapper.PasswordPolicyMapper;
|
||||
import org.dromara.maxkey.entity.Access;
|
||||
import org.dromara.maxkey.persistence.mapper.AccessMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class PasswordPolicyService extends JpaService<PasswordPolicy>{
|
||||
|
||||
public PasswordPolicyService() {
|
||||
super(PasswordPolicyMapper.class);
|
||||
public class AccessService extends JpaService<Access>{
|
||||
|
||||
public AccessService() {
|
||||
super(AccessMapper.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public PasswordPolicyMapper getMapper() {
|
||||
return (PasswordPolicyMapper)super.getMapper();
|
||||
public AccessMapper getMapper() {
|
||||
return (AccessMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import org.dromara.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.dromara.maxkey.entity.Accounts;
|
||||
import org.dromara.maxkey.entity.AccountsStrategy;
|
||||
import org.dromara.maxkey.entity.OrganizationsCast;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.AccountsMapper;
|
||||
import org.dromara.maxkey.provision.ProvisionAction;
|
||||
import org.dromara.maxkey.provision.ProvisionService;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.AccountsStrategy;
|
||||
import org.dromara.maxkey.entity.Roles;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.AccountsStrategyMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -17,25 +17,26 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.LdapContext;
|
||||
import org.dromara.maxkey.persistence.mapper.LdapContextMapper;
|
||||
|
||||
import org.dromara.maxkey.entity.cnf.CnfEmailSenders;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfEmailSendersMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public class LdapContextService extends JpaService<LdapContext>{
|
||||
public class CnfEmailSendersService extends JpaService<CnfEmailSenders>{
|
||||
|
||||
public LdapContextService() {
|
||||
super(LdapContextMapper.class);
|
||||
public CnfEmailSendersService() {
|
||||
super(CnfEmailSendersMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public LdapContextMapper getMapper() {
|
||||
return (LdapContextMapper)super.getMapper();
|
||||
public CnfEmailSendersMapper getMapper() {
|
||||
return (CnfEmailSendersMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,25 +17,25 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.SmsProvider;
|
||||
import org.dromara.maxkey.persistence.mapper.SmsProviderMapper;
|
||||
import org.dromara.maxkey.entity.cnf.CnfLdapContext;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfLdapContextMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public class SmsProviderService extends JpaService<SmsProvider>{
|
||||
public class CnfLdapContextService extends JpaService<CnfLdapContext>{
|
||||
|
||||
public SmsProviderService() {
|
||||
super(SmsProviderMapper.class);
|
||||
public CnfLdapContextService() {
|
||||
super(CnfLdapContextMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public SmsProviderMapper getMapper() {
|
||||
return (SmsProviderMapper)super.getMapper();
|
||||
public CnfLdapContextMapper getMapper() {
|
||||
return (CnfLdapContextMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,26 +17,24 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.GroupPermissions;
|
||||
import org.dromara.maxkey.persistence.mapper.GroupPermissionsMapper;
|
||||
import org.dromara.maxkey.entity.cnf.CnfPasswordPolicy;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfPasswordPolicyMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class GroupPermissionssService extends JpaService<GroupPermissions>{
|
||||
|
||||
public GroupPermissionssService() {
|
||||
super(GroupPermissionsMapper.class);
|
||||
}
|
||||
|
||||
public class CnfPasswordPolicyService extends JpaService<CnfPasswordPolicy>{
|
||||
|
||||
public CnfPasswordPolicyService() {
|
||||
super(CnfPasswordPolicyMapper.class);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public GroupPermissionsMapper getMapper() {
|
||||
return (GroupPermissionsMapper)super.getMapper();
|
||||
public CnfPasswordPolicyMapper getMapper() {
|
||||
return (CnfPasswordPolicyMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -17,26 +17,25 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
|
||||
import org.dromara.maxkey.entity.EmailSenders;
|
||||
import org.dromara.maxkey.persistence.mapper.EmailSendersMapper;
|
||||
import org.dromara.maxkey.entity.cnf.CnfSmsProvider;
|
||||
import org.dromara.maxkey.persistence.mapper.CnfSmsProviderMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Repository
|
||||
public class EmailSendersService extends JpaService<EmailSenders>{
|
||||
public class CnfSmsProviderService extends JpaService<CnfSmsProvider>{
|
||||
|
||||
public EmailSendersService() {
|
||||
super(EmailSendersMapper.class);
|
||||
public CnfSmsProviderService() {
|
||||
super(CnfSmsProviderMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public EmailSendersMapper getMapper() {
|
||||
return (EmailSendersMapper)super.getMapper();
|
||||
public CnfSmsProviderMapper getMapper() {
|
||||
return (CnfSmsProviderMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.GroupMember;
|
||||
import org.dromara.maxkey.entity.Groups;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.GroupMember;
|
||||
import org.dromara.maxkey.entity.idm.Groups;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.GroupMemberMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.dromara.mybatis.jpa.entity.JpaPageResults;
|
||||
|
||||
@@ -25,9 +25,9 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.entity.Groups;
|
||||
import org.dromara.maxkey.entity.Institutions;
|
||||
import org.dromara.maxkey.entity.Roles;
|
||||
import org.dromara.maxkey.entity.idm.Groups;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.GroupsMapper;
|
||||
import org.dromara.maxkey.util.StrUtils;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.HistoryConnector;
|
||||
import org.dromara.maxkey.entity.history.HistoryConnector;
|
||||
import org.dromara.maxkey.persistence.mapper.HistoryConnectorMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.HistoryLoginApps;
|
||||
import org.dromara.maxkey.entity.history.HistoryLoginApps;
|
||||
import org.dromara.maxkey.persistence.mapper.HistoryLoginAppsMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.HistoryLogin;
|
||||
import org.dromara.maxkey.entity.history.HistoryLogin;
|
||||
import org.dromara.maxkey.persistence.mapper.HistoryLoginMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.dromara.mybatis.jpa.entity.JpaPageResults;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.HistorySynchronizer;
|
||||
import org.dromara.maxkey.entity.history.HistorySynchronizer;
|
||||
import org.dromara.maxkey.persistence.mapper.HistorySynchronizerMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -19,16 +19,19 @@ package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import org.dromara.maxkey.entity.Accounts;
|
||||
import org.dromara.maxkey.entity.ChangePassword;
|
||||
import org.dromara.maxkey.entity.HistorySystemLogs;
|
||||
import org.dromara.maxkey.entity.Organizations;
|
||||
import org.dromara.maxkey.entity.Resources;
|
||||
import org.dromara.maxkey.entity.RoleMember;
|
||||
import org.dromara.maxkey.entity.GroupPermissions;
|
||||
import org.dromara.maxkey.entity.GroupPrivileges;
|
||||
import org.dromara.maxkey.entity.Roles;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.dromara.maxkey.entity.Access;
|
||||
import org.dromara.maxkey.entity.SocialsProvider;
|
||||
import org.dromara.maxkey.entity.Synchronizers;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.history.HistorySystemLogs;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.entity.permissions.Permission;
|
||||
import org.dromara.maxkey.entity.permissions.Resources;
|
||||
import org.dromara.maxkey.entity.permissions.RoleMember;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.HistorySystemLogsMapper;
|
||||
import org.dromara.maxkey.util.JsonUtils;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
@@ -38,16 +41,13 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class HistorySystemLogsService extends JpaService<HistorySystemLogs>{
|
||||
final static Logger _logger = LoggerFactory.getLogger(HistorySystemLogsService.class);
|
||||
static final Logger _logger = LoggerFactory.getLogger(HistorySystemLogsService.class);
|
||||
|
||||
public HistorySystemLogsService() {
|
||||
super(HistorySystemLogsMapper.class);
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public HistorySystemLogsMapper getMapper() {
|
||||
return (HistorySystemLogsMapper)super.getMapper();
|
||||
@@ -56,28 +56,28 @@ public class HistorySystemLogsService extends JpaService<HistorySystemLogs>{
|
||||
public void insert(String topic,Object entity,String action,String result,UserInfo operator) {
|
||||
String message = "";
|
||||
if(entity != null) {
|
||||
if(entity instanceof UserInfo) {
|
||||
message = buildMsg((UserInfo)entity);
|
||||
}else if(entity instanceof Organizations) {
|
||||
message = buildMsg((Organizations)entity);
|
||||
}else if(entity instanceof ChangePassword) {
|
||||
message = buildMsg((ChangePassword)entity);
|
||||
}else if(entity instanceof Accounts) {
|
||||
message = buildMsg((Accounts)entity);
|
||||
}else if(entity instanceof Roles) {
|
||||
message = buildMsg((Roles)entity);
|
||||
}else if(entity instanceof RoleMember) {
|
||||
message = buildMsg((RoleMember)entity);
|
||||
}else if(entity instanceof GroupPermissions) {
|
||||
message = buildMsg((GroupPermissions)entity);
|
||||
}else if(entity instanceof Resources) {
|
||||
message = buildMsg((Resources)entity);
|
||||
}else if(entity instanceof Synchronizers) {
|
||||
message = buildMsg((Synchronizers)entity);
|
||||
}else if(entity instanceof SocialsProvider) {
|
||||
message = buildMsg((SocialsProvider)entity);
|
||||
}else if(entity instanceof GroupPrivileges) {
|
||||
message = buildMsg((GroupPrivileges)entity);
|
||||
if(entity instanceof UserInfo userInfo) {
|
||||
message = buildMsg(userInfo);
|
||||
}else if(entity instanceof Organizations organization) {
|
||||
message = buildMsg(organization);
|
||||
}else if(entity instanceof ChangePassword changePassword) {
|
||||
message = buildMsg(changePassword);
|
||||
}else if(entity instanceof Accounts account) {
|
||||
message = buildMsg(account);
|
||||
}else if(entity instanceof Roles role) {
|
||||
message = buildMsg(role);
|
||||
}else if(entity instanceof RoleMember roleMember) {
|
||||
message = buildMsg(roleMember);
|
||||
}else if(entity instanceof Access access) {
|
||||
message = buildMsg(access);
|
||||
}else if(entity instanceof Resources resource) {
|
||||
message = buildMsg(resource);
|
||||
}else if(entity instanceof Synchronizers synchronizer) {
|
||||
message = buildMsg(synchronizer);
|
||||
}else if(entity instanceof SocialsProvider socialsProvider) {
|
||||
message = buildMsg(socialsProvider);
|
||||
}else if(entity instanceof Permission permission) {
|
||||
message = buildMsg(permission);
|
||||
}else if(entity instanceof String) {
|
||||
message = entity.toString();
|
||||
}
|
||||
@@ -99,6 +99,7 @@ public class HistorySystemLogsService extends JpaService<HistorySystemLogs>{
|
||||
systemLog.setDisplayName(operator.getDisplayName());
|
||||
systemLog.setInstId(operator.getInstId());
|
||||
systemLog.setJsonCotent(JsonUtils.gsonToString(entity));
|
||||
systemLog.setExecuteTime(new Date());
|
||||
_logger.trace("System Log {}" ,systemLog);
|
||||
getMapper().insert(systemLog);
|
||||
}
|
||||
@@ -157,7 +158,7 @@ public class HistorySystemLogsService extends JpaService<HistorySystemLogs>{
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(GroupPermissions permission) {
|
||||
public String buildMsg(Access permission) {
|
||||
return new StringBuilder()
|
||||
.append(permission.getGroupName())
|
||||
.append("[")
|
||||
@@ -166,7 +167,7 @@ public class HistorySystemLogsService extends JpaService<HistorySystemLogs>{
|
||||
.toString();
|
||||
}
|
||||
|
||||
public String buildMsg(GroupPrivileges privilege) {
|
||||
public String buildMsg(Permission privilege) {
|
||||
return new StringBuilder()
|
||||
.append(privilege.getGroupId())
|
||||
.append("[")
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.dromara.maxkey.entity.Organizations;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.maxkey.persistence.mapper.OrganizationsMapper;
|
||||
import org.dromara.maxkey.provision.ProvisionAction;
|
||||
import org.dromara.maxkey.provision.ProvisionService;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.permissions.PermissionRole;
|
||||
import org.dromara.maxkey.persistence.mapper.PermissionRoleMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class PermissionRoleService extends JpaService<PermissionRole>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(PermissionRoleService.class);
|
||||
|
||||
|
||||
public PermissionRoleService() {
|
||||
super(PermissionRoleMapper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionRoleMapper getMapper() {
|
||||
return (PermissionRoleMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public boolean insertPermissionRoles(List<PermissionRole> permissionRolesList) {
|
||||
return getMapper().insertPermissionRoles(permissionRolesList)>0;
|
||||
}
|
||||
|
||||
public boolean deletePermissionRoles(List<PermissionRole> permissionRolesList) {
|
||||
return getMapper().deletePermissionRoles(permissionRolesList)>=0;
|
||||
}
|
||||
|
||||
public List<PermissionRole> queryPermissionRoles(PermissionRole permissionRole){
|
||||
return getMapper().queryPermissionRoles(permissionRole);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,39 +19,39 @@ package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.GroupPrivileges;
|
||||
import org.dromara.maxkey.persistence.mapper.GroupPrivilegesMapper;
|
||||
import org.dromara.maxkey.entity.permissions.Permission;
|
||||
import org.dromara.maxkey.persistence.mapper.PermissionMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class GroupPrivilegesService extends JpaService<GroupPrivileges>{
|
||||
final static Logger _logger = LoggerFactory.getLogger(GroupPrivilegesService.class);
|
||||
public class PermissionService extends JpaService<Permission>{
|
||||
static final Logger _logger = LoggerFactory.getLogger(PermissionService.class);
|
||||
|
||||
|
||||
public GroupPrivilegesService() {
|
||||
super(GroupPrivilegesMapper.class);
|
||||
public PermissionService() {
|
||||
super(PermissionMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public GroupPrivilegesMapper getMapper() {
|
||||
return (GroupPrivilegesMapper)super.getMapper();
|
||||
public PermissionMapper getMapper() {
|
||||
return (PermissionMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public boolean insertGroupPrivileges(List<GroupPrivileges> rolePermissionsList) {
|
||||
public boolean insertGroupPrivileges(List<Permission> rolePermissionsList) {
|
||||
return getMapper().insertGroupPrivileges(rolePermissionsList)>0;
|
||||
};
|
||||
|
||||
public boolean deleteGroupPrivileges(List<GroupPrivileges> rolePermissionsList) {
|
||||
public boolean deleteGroupPrivileges(List<Permission> rolePermissionsList) {
|
||||
return getMapper().deleteGroupPrivileges(rolePermissionsList)>=0;
|
||||
}
|
||||
|
||||
public List<GroupPrivileges> queryGroupPrivileges(GroupPrivileges rolePermissions){
|
||||
public List<Permission> queryGroupPrivileges(Permission rolePermissions){
|
||||
return getMapper().queryGroupPrivileges(rolePermissions);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ package org.dromara.maxkey.persistence.service;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.Register;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.RegisterMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.Resources;
|
||||
import org.dromara.maxkey.entity.permissions.Resources;
|
||||
import org.dromara.maxkey.persistence.mapper.ResourcesMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.entity.permissions.RoleMember;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.RoleMemberMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.dromara.mybatis.jpa.entity.JpaPageResults;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class RoleMemberService extends JpaService<RoleMember>{
|
||||
final static Logger _logger = LoggerFactory.getLogger(RoleMemberService.class);
|
||||
|
||||
public RoleMemberService() {
|
||||
super(RoleMemberMapper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleMemberMapper getMapper() {
|
||||
return (RoleMemberMapper)super.getMapper();
|
||||
}
|
||||
|
||||
public int addDynamicRoleMember(Roles dynamicGroup) {
|
||||
return getMapper().addDynamicRoleMember(dynamicGroup);
|
||||
}
|
||||
|
||||
public int deleteDynamicRoleMember(Roles dynamicGroup) {
|
||||
return getMapper().deleteDynamicRoleMember(dynamicGroup);
|
||||
}
|
||||
|
||||
public int deleteByRoleId(String groupId) {
|
||||
return getMapper().deleteByRoleId(groupId);
|
||||
}
|
||||
|
||||
public List<UserInfo> queryMemberByRoleId(String groupId){
|
||||
return getMapper().queryMemberByRoleId(groupId);
|
||||
}
|
||||
|
||||
|
||||
public JpaPageResults<Roles> rolesNoMember(RoleMember entity) {
|
||||
entity.setPageSelectId(entity.generateId());
|
||||
entity.setStartRow(calculateStartRow(entity.getPageNumber() ,entity.getPageSize()));
|
||||
|
||||
entity.setPageable(true);
|
||||
List<Roles> resultslist = null;
|
||||
try {
|
||||
resultslist = getMapper().rolesNoMember(entity);
|
||||
} catch (Exception e) {
|
||||
_logger.error("fetchPageResults Exception " , e);
|
||||
}
|
||||
entity.setPageable(false);
|
||||
Integer totalPage = resultslist.size();
|
||||
|
||||
Integer totalCount = 0;
|
||||
if(entity.getPageNumber() == 1 && totalPage < entity.getPageSize()) {
|
||||
totalCount = totalPage;
|
||||
}else {
|
||||
totalCount = parseCount(getMapper().fetchCount(entity));
|
||||
}
|
||||
|
||||
return new JpaPageResults<Roles>(entity.getPageNumber(),entity.getPageSize(),totalPage,totalCount,resultslist);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
|
||||
|
||||
package org.dromara.maxkey.persistence.service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Types;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.entity.Institutions;
|
||||
import org.dromara.maxkey.entity.permissions.Roles;
|
||||
import org.dromara.maxkey.persistence.mapper.RolesMapper;
|
||||
import org.dromara.maxkey.util.StrUtils;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
@Repository
|
||||
public class RolesService extends JpaService<Roles> implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4156671926199393550L;
|
||||
|
||||
static final Logger _logger = LoggerFactory.getLogger(RolesService.class);
|
||||
|
||||
@JsonIgnore
|
||||
@Autowired
|
||||
RoleMemberService roleMemberService;
|
||||
|
||||
@Autowired
|
||||
InstitutionsService institutionsService;
|
||||
|
||||
public RolesService() {
|
||||
super(RolesMapper.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RolesMapper getMapper() {
|
||||
return (RolesMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
public List<Roles> queryDynamicRoles(Roles groups){
|
||||
return this.getMapper().queryDynamicRoles(groups);
|
||||
}
|
||||
|
||||
public boolean deleteById(String groupId) {
|
||||
this.delete(groupId);
|
||||
roleMemberService.deleteByRoleId(groupId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<Roles> queryRolesByUserId(String userId){
|
||||
return this.getMapper().queryRolesByUserId(userId);
|
||||
}
|
||||
|
||||
public void refreshDynamicRoles(Roles dynamicRole){
|
||||
if(dynamicRole.getCategory().equals(Roles.Category.DYNAMIC)) {
|
||||
boolean isDynamicTimeSupport = false;
|
||||
boolean isBetweenEffectiveTime = false;
|
||||
if(StringUtils.isNotBlank(dynamicRole.getResumeTime())
|
||||
&&StringUtils.isNotBlank(dynamicRole.getSuspendTime())
|
||||
&&!dynamicRole.getSuspendTime().equals("00:00")) {
|
||||
LocalTime currentTime = LocalDateTime.now().toLocalTime();
|
||||
LocalTime resumeTime = LocalTime.parse(dynamicRole.getResumeTime());
|
||||
LocalTime suspendTime = LocalTime.parse(dynamicRole.getSuspendTime());
|
||||
|
||||
_logger.info("currentTime: {} , resumeTime : {} , suspendTime: {}" ,
|
||||
currentTime , resumeTime , suspendTime);
|
||||
isDynamicTimeSupport = true;
|
||||
|
||||
if(resumeTime.isBefore(currentTime) && currentTime.isBefore(suspendTime)) {
|
||||
isBetweenEffectiveTime = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(dynamicRole.getOrgIdsList())) {
|
||||
String []orgIds = dynamicRole.getOrgIdsList().split(",");
|
||||
StringBuffer orgIdFilters = new StringBuffer();
|
||||
for(String orgId : orgIds) {
|
||||
if(StringUtils.isNotBlank(orgId)) {
|
||||
if(orgIdFilters.length() > 0) {
|
||||
orgIdFilters.append(",");
|
||||
}
|
||||
orgIdFilters.append("'").append(orgId).append("'");
|
||||
}
|
||||
}
|
||||
if(orgIdFilters.length() > 0) {
|
||||
dynamicRole.setOrgIdsList(orgIdFilters.toString());
|
||||
}
|
||||
}
|
||||
|
||||
String filters = dynamicRole.getFilters();
|
||||
_logger.debug("filters {}" , filters);
|
||||
if(StringUtils.isNotBlank(filters)) {
|
||||
if(StrUtils.filtersSQLInjection(filters.toLowerCase())) {
|
||||
_logger.info("filters include SQL Injection Attack Risk.");
|
||||
return;
|
||||
}
|
||||
filters = filters.replace("&", " AND ");
|
||||
filters = filters.replaceAll("\\|", " OR ");
|
||||
|
||||
_logger.debug("set filters {}" , filters);
|
||||
dynamicRole.setFilters(filters);
|
||||
}
|
||||
|
||||
if(isDynamicTimeSupport) {
|
||||
if(isBetweenEffectiveTime) {
|
||||
roleMemberService.deleteDynamicRoleMember(dynamicRole);
|
||||
roleMemberService.addDynamicRoleMember(dynamicRole);
|
||||
}else {
|
||||
roleMemberService.deleteDynamicRoleMember(dynamicRole);
|
||||
}
|
||||
}else{
|
||||
roleMemberService.deleteDynamicRoleMember(dynamicRole);
|
||||
roleMemberService.addDynamicRoleMember(dynamicRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshAllDynamicRoles(){
|
||||
List<Institutions> instList =
|
||||
institutionsService.find("where status = ? ", new Object[]{ConstsStatus.ACTIVE}, new int[]{Types.INTEGER});
|
||||
for(Institutions inst : instList) {
|
||||
Roles role = new Roles();
|
||||
role.setInstId(inst.getId());
|
||||
List<Roles> rolesList = queryDynamicRoles(role);
|
||||
for(Roles r : rolesList) {
|
||||
_logger.debug("role {}" , r);
|
||||
refreshDynamicRoles(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,7 @@ package org.dromara.maxkey.persistence.service;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.SocialsAssociate;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.SocialsAssociateMapper;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.sql.Types;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.dromara.maxkey.entity.Organizations;
|
||||
import org.dromara.maxkey.entity.SynchroRelated;
|
||||
import org.dromara.maxkey.entity.Synchronizers;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.maxkey.persistence.mapper.SynchroRelatedMapper;
|
||||
import org.dromara.maxkey.util.DateUtils;
|
||||
import org.dromara.mybatis.jpa.JpaService;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.dromara.maxkey.constants.ConstsStatus;
|
||||
import org.dromara.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.dromara.maxkey.entity.Accounts;
|
||||
import org.dromara.maxkey.entity.ChangePassword;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.mapper.UserInfoMapper;
|
||||
import org.dromara.maxkey.persistence.repository.PasswordPolicyValidator;
|
||||
import org.dromara.maxkey.provision.ProvisionAction;
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.dromara.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.dromara.maxkey.entity.ChangePassword;
|
||||
import org.dromara.maxkey.entity.Connectors;
|
||||
import org.dromara.maxkey.entity.Message;
|
||||
import org.dromara.maxkey.entity.Organizations;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.entity.idm.Organizations;
|
||||
import org.dromara.maxkey.entity.idm.UserInfo;
|
||||
import org.dromara.maxkey.persistence.service.ConnectorsService;
|
||||
import org.dromara.maxkey.provision.ProvisionAction;
|
||||
import org.dromara.maxkey.provision.ProvisionMessage;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.maxkey.persistence.mapper.GroupPermissionsMapper" >
|
||||
<mapper namespace="org.dromara.maxkey.persistence.mapper.AccessMapper" >
|
||||
|
||||
<sql id="where_statement">
|
||||
<if test="id != null and id != ''">
|
||||
@@ -18,7 +18,7 @@
|
||||
</sql>
|
||||
|
||||
<!-- AppGroup -->
|
||||
<select id="appsInGroup" parameterType="GroupPermissions" resultType="GroupPermissions">
|
||||
<select id="appsInGroup" parameterType="Access" resultType="Access">
|
||||
select
|
||||
p.id,
|
||||
p.groupid,
|
||||
@@ -34,7 +34,7 @@
|
||||
apps.vendorurl
|
||||
from
|
||||
mxk_apps apps,
|
||||
mxk_group_permissions p,
|
||||
mxk_access p,
|
||||
mxk_groups r
|
||||
where
|
||||
apps.instid = #{instId}
|
||||
@@ -49,7 +49,7 @@
|
||||
<include refid="where_statement"/>
|
||||
</select>
|
||||
|
||||
<select id="appsNotInGroup" parameterType="GroupPermissions" resultType="GroupPermissions">
|
||||
<select id="appsNotInGroup" parameterType="Access" resultType="Access">
|
||||
select
|
||||
*
|
||||
from
|
||||
@@ -60,7 +60,7 @@
|
||||
select
|
||||
appid
|
||||
from
|
||||
mxk_group_permissions
|
||||
mxk_access
|
||||
where
|
||||
groupid = #{groupId}
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.maxkey.persistence.mapper.PasswordPolicyMapper" >
|
||||
<mapper namespace="org.dromara.maxkey.persistence.mapper.CnfPasswordPolicyMapper" >
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.maxkey.persistence.mapper.GroupPrivilegesMapper">
|
||||
<mapper namespace="org.dromara.maxkey.persistence.mapper.PermissionMapper">
|
||||
|
||||
<sql id="where_statement">
|
||||
<if test="id != null and id != ''">
|
||||
@@ -11,11 +11,11 @@
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="queryGroupPrivileges" parameterType="GroupPrivileges" resultType="GroupPrivileges">
|
||||
<select id="queryGroupPrivileges" parameterType="Permission" resultType="Permission">
|
||||
select
|
||||
*
|
||||
from
|
||||
mxk_group_privileges
|
||||
mxk_permission
|
||||
where instid = #{instId}
|
||||
and status = 1
|
||||
<if test="id != null and id != ''">
|
||||
@@ -31,7 +31,7 @@
|
||||
</select>
|
||||
|
||||
<update id="deleteGroupPrivileges" parameterType="java.util.List">
|
||||
update mxk_group_privileges
|
||||
update mxk_permission
|
||||
set status = 9
|
||||
where 1 = 1 and
|
||||
<foreach item="item" collection="list" open="(" separator="or" close=")">
|
||||
@@ -40,7 +40,7 @@
|
||||
</update>
|
||||
|
||||
<insert id="insertGroupPrivileges" parameterType="java.util.List">
|
||||
insert into mxk_group_privileges ( id,appid,groupid,resourceid,status,instid)
|
||||
insert into mxk_permission ( id,appid,groupid,resourceid,status,instid)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(#{item.id},#{item.appId},#{item.groupId},#{item.resourceId},#{item.status},#{item.instId})
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.maxkey.persistence.mapper.PermissionRoleMapper">
|
||||
|
||||
<sql id="where_statement">
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name like '%${name}%'
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="queryPermissionRoles" parameterType="PermissionRole" resultType="PermissionRole">
|
||||
select
|
||||
*
|
||||
from
|
||||
mxk_permission_role
|
||||
where instid = #{instId}
|
||||
and status = 1
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="roleId != null and roleId != ''">
|
||||
and roleid = #{roleId}
|
||||
</if>
|
||||
<if test="appId != null and appId != ''">
|
||||
and appid = #{appId}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<update id="deletePermissionRoles" parameterType="java.util.List">
|
||||
update mxk_permission_role
|
||||
set status = 9
|
||||
where 1 = 1 and
|
||||
<foreach item="item" collection="list" open="(" separator="or" close=")">
|
||||
( id = #{item.id} and instid = #{item.instId} )
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<insert id="insertPermissionRoles" parameterType="java.util.List">
|
||||
insert into mxk_permission_role ( id,appid,roleid,resourceid,createdby,status,instid)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(#{item.id},
|
||||
#{item.appId},
|
||||
#{item.roleId},
|
||||
#{item.resourceId},
|
||||
#{item.createdBy},
|
||||
#{item.status},
|
||||
#{item.instId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.maxkey.persistence.mapper.RoleMemberMapper">
|
||||
|
||||
<sql id="where_statement">
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="roleName != null and roleName != ''">
|
||||
and rolename = #{roleName}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="memberInRole" parameterType="RoleMember" resultType="RoleMember">
|
||||
select distinct
|
||||
rm.id as id,
|
||||
rm.type as type,
|
||||
r.id as roleid,
|
||||
r.rolename,
|
||||
concat(u.displayname,'(',u.username,')') membername,
|
||||
u.jobtitle,
|
||||
u.gender,
|
||||
u.departmentid,
|
||||
u.department,
|
||||
rm.createddate
|
||||
from
|
||||
mxk_userinfo u,
|
||||
mxk_roles r,
|
||||
mxk_role_member rm
|
||||
where u.instid = #{instId}
|
||||
and r.instid = #{instId}
|
||||
and rm.instid = #{instId}
|
||||
and rm.type in( 'USER','USER-DYNAMIC')
|
||||
and rm.roleid = r.id
|
||||
and rm.memberid = u.id
|
||||
<if test="roleId != null and roleId != ''">
|
||||
and rm.roleid = #{roleId}
|
||||
and r.id = #{roleId}
|
||||
</if>
|
||||
<if test="roleName != null and roleName != ''">
|
||||
and r.rolename = #{roleName}
|
||||
</if>
|
||||
<if test="memberName != null and memberName != ''">
|
||||
and (
|
||||
u.username like '%${memberName}%'
|
||||
or u.displayname like '%${memberName}%'
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="memberNotInRole" parameterType="RoleMember" resultType="RoleMember">
|
||||
select distinct
|
||||
u.id,
|
||||
u.username,
|
||||
u.displayname ,
|
||||
u.gender,
|
||||
u.organization,
|
||||
u.departmentid,
|
||||
u.department,
|
||||
u.jobtitle,
|
||||
u.createdby
|
||||
from
|
||||
mxk_userinfo u
|
||||
where
|
||||
u.id not in(
|
||||
select rm.memberid
|
||||
from mxk_roles r,mxk_role_member rm
|
||||
where 1 = 1
|
||||
<if test="roleId != null and roleId != ''">
|
||||
and rm.roleid = #{roleId}
|
||||
and r.id = #{roleId}
|
||||
</if>
|
||||
<if test="roleName != null and roleName != ''">
|
||||
and r.rolename = #{roleName}
|
||||
</if>
|
||||
and rm.type in( 'USER','USER-DYNAMIC')
|
||||
and rm.roleid = r.id
|
||||
)
|
||||
<if test="username != null and username != ''">
|
||||
and u.username = #{username}
|
||||
</if>
|
||||
<if test="displayName != null and displayName != ''">
|
||||
and u.displayname like '%${displayName}%'
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="rolesNoMember" parameterType="RoleMember" resultType="Roles">
|
||||
select distinct
|
||||
r.*
|
||||
from
|
||||
mxk_roles r
|
||||
where
|
||||
r.id not in(
|
||||
select
|
||||
rm.roleid
|
||||
from mxk_role_member rm,mxk_userinfo u
|
||||
where rm.memberid = u.id
|
||||
<if test="username != null and username != ''">
|
||||
and u.username = #{username}
|
||||
</if>
|
||||
<if test="memberId != null and memberId != ''">
|
||||
and rm.memberid = #{memberid}
|
||||
</if>
|
||||
)
|
||||
<if test="roleName != null and roleName != ''">
|
||||
and r.rolename = #{roleName}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- ROLE_MEMBER ROLE Member-->
|
||||
<select id="roleMemberInRole" parameterType="RoleMember" resultType="Roles">
|
||||
select distinct
|
||||
ig.*
|
||||
from
|
||||
mxk_roles ir,
|
||||
mxk_roles r,
|
||||
mxk_role_member rm
|
||||
where
|
||||
1 = 1
|
||||
and rm.roleid = g.id
|
||||
and rm.memberid = ig.id
|
||||
and rm.type = 'ROLE'
|
||||
<if test="roleId != null and roleId != ''">
|
||||
and rm.roleid = #{roleId}
|
||||
and r.id = #{roleId}
|
||||
</if>
|
||||
<if test="roleName != null and roleName != ''">
|
||||
and r.rolename = #{roleName}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<update id="addDynamicRoleMember" parameterType="Roles" >
|
||||
insert into mxk_role_member(
|
||||
id,
|
||||
roleid,
|
||||
memberid,
|
||||
type,
|
||||
instid
|
||||
)
|
||||
select
|
||||
concat('${id}_',u.id) id,
|
||||
'${id}' roleid,
|
||||
u.id memberid,
|
||||
'USER-DYNAMIC' type,
|
||||
'${instId}' instid
|
||||
from mxk_userinfo u
|
||||
where not exists(
|
||||
select 1 from mxk_role_member rm
|
||||
where rm.roleid=#{id}
|
||||
and rm.memberid=u.id
|
||||
and rm.type='USER-DYNAMIC'
|
||||
)
|
||||
<if test="filters != null and filters != ''">
|
||||
and (${filters})
|
||||
</if>
|
||||
<if test="orgIdsList != null and orgIdsList != ''">
|
||||
and u.departmentid in( ${orgIdsList})
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<delete id="deleteDynamicRoleMember" parameterType="Roles" >
|
||||
delete from mxk_role_member rm
|
||||
where type = 'user-dynamic'
|
||||
and rm.roleid=#{id}
|
||||
and not exists(
|
||||
select 1
|
||||
from mxk_userinfo u
|
||||
where 1 = 1
|
||||
and u.id=rm.memberid
|
||||
<if test="filters != null and filters != ''">
|
||||
and (${filters})
|
||||
</if>
|
||||
<if test="orgIdsList != null and orgIdsList != ''">
|
||||
and u.departmentid in ( ${orgIdsList})
|
||||
</if>
|
||||
)
|
||||
</delete>
|
||||
|
||||
<select id="queryMemberByRoleId" parameterType="string" resultType="UserInfo">
|
||||
select distinct
|
||||
r.roleId,
|
||||
r.roleName,
|
||||
u.id,
|
||||
u.username,
|
||||
u.usertype,
|
||||
u.windowsaccount,
|
||||
|
||||
u.displayname ,
|
||||
u.nickname ,
|
||||
u.namezhspell,
|
||||
u.namezhshortspell,
|
||||
u.givenname ,
|
||||
u.middlename ,
|
||||
u.familyname ,
|
||||
|
||||
u.gender,
|
||||
|
||||
u.authntype,
|
||||
u.mobile,
|
||||
u.email,
|
||||
u.workemail,
|
||||
u.workphonenumber,
|
||||
|
||||
u.employeenumber,
|
||||
u.division,
|
||||
u.costcenter,
|
||||
u.organization,
|
||||
u.departmentid,
|
||||
u.department,
|
||||
u.jobtitle,
|
||||
u.joblevel,
|
||||
rm.createddate,
|
||||
u.status
|
||||
from
|
||||
mxk_userinfo u,
|
||||
mxk_roles r,
|
||||
mxk_role_member rm
|
||||
where 1 = 1
|
||||
and rm.roleid = #{value}
|
||||
and g.id = #{value}
|
||||
and rm.type in( 'USER','USER-DYNAMIC')
|
||||
and rm.roleid = r.id
|
||||
and rm.memberid = u.id
|
||||
</select>
|
||||
|
||||
|
||||
<delete id="deleteByRoleId" parameterType="string" >
|
||||
delete from mxk_role_member rm
|
||||
where rm.roleid = #{value} and rolecode != 'ROLE_ALL_USER'
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.maxkey.persistence.mapper.RolesMapper">
|
||||
|
||||
<sql id="where_statement">
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="roleName != null and roleName != ''">
|
||||
and rolename like '%${roleName}%'
|
||||
</if>
|
||||
<if test="appId != null and appId != ''">
|
||||
and appid = #{appId}
|
||||
</if>
|
||||
|
||||
</sql>
|
||||
|
||||
|
||||
|
||||
<select id="fetchPageResults" parameterType="Roles" resultType="Roles">
|
||||
select
|
||||
*
|
||||
from
|
||||
mxk_roles
|
||||
where instid = #{instId}
|
||||
<include refid="where_statement"/>
|
||||
</select>
|
||||
|
||||
<select id="queryDynamicRoles" parameterType="Roles" resultType="Roles">
|
||||
select
|
||||
*
|
||||
from
|
||||
mxk_roles
|
||||
where instid = #{instId}
|
||||
and category = 'dynamic'
|
||||
<include refid="where_statement"/>
|
||||
</select>
|
||||
|
||||
|
||||
<update id="logisticDelete" parameterType="Roles" >
|
||||
update mxk_roles set
|
||||
status = '2'
|
||||
where instid = #{instId}
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="roleName != roleName">
|
||||
and rolename = #{roleName}
|
||||
</if>
|
||||
</update>
|
||||
|
||||
|
||||
<update id="logisticBatchDelete" parameterType="java.util.List">
|
||||
update mxk_roles
|
||||
set status='2'
|
||||
where instid = #{instId}
|
||||
and id in
|
||||
<foreach item="item" collection="list" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
|
||||
<select id="queryRolesByUserId" parameterType="string" resultType="Roles">
|
||||
select distinct
|
||||
r.*
|
||||
from
|
||||
mxk_userinfo u,
|
||||
mxk_roles r,
|
||||
mxk_role_member rm
|
||||
where u.instid = #{instId}
|
||||
and r.instid = #{instId}
|
||||
and rm.instid = #{instId}
|
||||
and rm.memberid = #{value}
|
||||
and u.id = #{value}
|
||||
and rm.type in( 'USER','USER-DYNAMIC')
|
||||
and rm.groupid = r.id
|
||||
and rm.memberid = u.id
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.maxkey.persistence.mapper.PermissionRoleMapper">
|
||||
|
||||
<sql id="where_statement">
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name like '%${name}%'
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="queryPermissionRoles" parameterType="PermissionRole" resultType="PermissionRole">
|
||||
select
|
||||
*
|
||||
from
|
||||
mxk_permission_role
|
||||
where instid = #{instId}
|
||||
and status = 1
|
||||
<if test="id != null and id != ''">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="roleId != null and roleId != ''">
|
||||
and roleid = #{roleId}
|
||||
</if>
|
||||
<if test="appId != null and appId != ''">
|
||||
and appid = #{appId}
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<update id="deletePermissionRoles" parameterType="java.util.List">
|
||||
update mxk_permission_role
|
||||
set status = 9
|
||||
where 1 = 1 and
|
||||
<foreach item="item" collection="list" open="(" separator="or" close=")">
|
||||
( id = #{item.id} and instid = #{item.instId} )
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<insert id="insertPermissionRoles" parameterType="java.util.List">
|
||||
insert into mxk_permission_role ( id,appid,roleid,resourceid,createdby,status,instid)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
(#{item.id},
|
||||
#{item.appId},
|
||||
#{item.roleId},
|
||||
#{item.resourceId},
|
||||
#{item.createdBy},
|
||||
#{item.status},
|
||||
#{item.instId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user