AppList
This commit is contained in:
@@ -109,7 +109,7 @@ xmltoolingVersion =1.4.6
|
||||
javasupportVersion =7.5.1
|
||||
#others
|
||||
thymeleafVersion =3.0.14.RELEASE
|
||||
springbootadminVersion =2.6.5
|
||||
springbootadminVersion =2.6.6
|
||||
nettyVersion =4.1.66.Final
|
||||
hazelcastVersion =4.2.2
|
||||
jakartaannotationVersion =2.0.0
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
package org.maxkey;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.maxkey.authn.AbstractAuthenticationProvider;
|
||||
import org.maxkey.authn.support.basic.BasicEntryPoint;
|
||||
import org.maxkey.authn.support.httpheader.HttpHeaderEntryPoint;
|
||||
@@ -24,6 +26,7 @@ import org.maxkey.authn.support.kerberos.HttpKerberosEntryPoint;
|
||||
import org.maxkey.authn.support.kerberos.KerberosService;
|
||||
import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
|
||||
import org.maxkey.authn.support.rememberme.HttpRemeberMeEntryPoint;
|
||||
import org.maxkey.authn.web.CurrentUserMethodArgumentResolver;
|
||||
import org.maxkey.authn.web.interceptor.PermissionAdapter;
|
||||
import org.maxkey.configuration.ApplicationConfig;
|
||||
import org.maxkey.web.interceptor.HistoryLoginAppAdapter;
|
||||
@@ -34,7 +37,9 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
@@ -143,8 +148,8 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
.addPathPatterns("/profile/**")
|
||||
.addPathPatterns("/safe/**")
|
||||
.addPathPatterns("/historys/**")
|
||||
.addPathPatterns("/session/**")
|
||||
.addPathPatterns("/session/**/**")
|
||||
.addPathPatterns("/access/session/**")
|
||||
.addPathPatterns("/access/session/**/**")
|
||||
.addPathPatterns("/appList")
|
||||
.addPathPatterns("/appList/**")
|
||||
.addPathPatterns("/socialsignon/**")
|
||||
@@ -247,4 +252,14 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
argumentResolvers.add(currentUserMethodArgumentResolver());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CurrentUserMethodArgumentResolver currentUserMethodArgumentResolver() {
|
||||
return new CurrentUserMethodArgumentResolver();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,27 +15,26 @@
|
||||
*/
|
||||
|
||||
|
||||
package org.maxkey.web.historys.contorller;
|
||||
package org.maxkey.web.access.contorller;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||
import org.maxkey.authn.annotation.CurrentUser;
|
||||
import org.maxkey.authn.online.OnlineTicketService;
|
||||
import org.maxkey.constants.ConstsOperateMessage;
|
||||
import org.maxkey.entity.HistoryLogin;
|
||||
import org.maxkey.entity.Message;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.persistence.repository.LoginHistoryRepository;
|
||||
import org.maxkey.persistence.repository.LoginRepository;
|
||||
import org.maxkey.persistence.service.HistoryLoginService;
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.maxkey.util.StringUtils;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.maxkey.web.message.Message;
|
||||
import org.maxkey.web.message.MessageType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
@@ -45,14 +44,14 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* 登录日志查询.
|
||||
* 登录会话管理.
|
||||
*
|
||||
* @author Crystal.sea
|
||||
*
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = { "/session" })
|
||||
@RequestMapping(value = { "/access/session" })
|
||||
public class LoginSessionController {
|
||||
static final Logger _logger = LoggerFactory.getLogger(LoginSessionController.class);
|
||||
|
||||
@@ -65,12 +64,7 @@ public class LoginSessionController {
|
||||
LoginHistoryRepository loginHistoryRepository;
|
||||
|
||||
@Autowired
|
||||
OnlineTicketService onlineTicketServices;
|
||||
|
||||
@RequestMapping(value = { "/sessionList" })
|
||||
public String authList() {
|
||||
return "historys/sessionList";
|
||||
}
|
||||
OnlineTicketService onlineTicketService;
|
||||
|
||||
/**
|
||||
* 查询登录日志.
|
||||
@@ -78,36 +72,36 @@ public class LoginSessionController {
|
||||
* @param logsAuth
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = { "/sessionList/grid" })
|
||||
@RequestMapping(value = { "/fetch" })
|
||||
@ResponseBody
|
||||
public JpaPageResults<HistoryLogin> loginSessionListGrid(@ModelAttribute("historyLogin") HistoryLogin historyLogin) {
|
||||
_logger.debug("history/session/ sessionListGrid() " + historyLogin);
|
||||
historyLogin.setInstId(WebContext.getUserInfo().getInstId());
|
||||
historyLogin.setUserId(WebContext.getUserInfo().getId());
|
||||
return historyLoginService.queryOnlineSession(historyLogin);
|
||||
public ResponseEntity<?> fetch(
|
||||
@ModelAttribute("historyLogin") HistoryLogin historyLogin,
|
||||
@CurrentUser UserInfo currentUser) {
|
||||
_logger.debug("history/session/fetch {}" , historyLogin);
|
||||
historyLogin.setUserId(currentUser.getId());
|
||||
historyLogin.setInstId(currentUser.getInstId());
|
||||
return new Message<JpaPageResults<HistoryLogin>>(
|
||||
historyLoginService.queryOnlineSession(historyLogin)
|
||||
).buildResponse();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/terminate")
|
||||
public Message deleteUsersById(@RequestParam("id") String ids) {
|
||||
public ResponseEntity<?> terminate(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
|
||||
_logger.debug(ids);
|
||||
boolean isTerminated = false;
|
||||
try {
|
||||
String currentUserSessionId = "";
|
||||
|
||||
for(String sessionId : StringUtils.string2List(ids, ",")) {
|
||||
_logger.trace("terminate session Id {} ",sessionId);
|
||||
if(currentUserSessionId.contains(sessionId)) {
|
||||
//skip current session
|
||||
continue;
|
||||
if(currentUser.getOnlineTicket().contains(sessionId)) {
|
||||
continue;//skip current session
|
||||
}
|
||||
UserInfo userInfo = WebContext.getUserInfo();
|
||||
String lastLogoffTime = DateUtils.formatDateTime(new Date());
|
||||
loginRepository.updateLastLogoff(userInfo);
|
||||
loginRepository.updateLastLogoff(currentUser);
|
||||
loginHistoryRepository.logoff(lastLogoffTime, sessionId);
|
||||
onlineTicketServices.remove("OT-" + sessionId);
|
||||
onlineTicketService.remove("OT-" + sessionId);
|
||||
}
|
||||
isTerminated = true;
|
||||
}catch(Exception e) {
|
||||
@@ -115,11 +109,12 @@ public class LoginSessionController {
|
||||
}
|
||||
|
||||
if(isTerminated) {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.success);
|
||||
return new Message<HistoryLogin>(Message.SUCCESS).buildResponse();
|
||||
} else {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_ERROR),MessageType.error);
|
||||
return new Message<HistoryLogin>(Message.ERROR).buildResponse();
|
||||
}
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DateUtils.FORMAT_DATE_HH_MM_SS);
|
||||
@@ -0,0 +1 @@
|
||||
package org.maxkey.web.access.contorller;
|
||||
@@ -17,33 +17,29 @@
|
||||
|
||||
package org.maxkey.web.contorller;
|
||||
|
||||
import java.security.Principal;
|
||||
import java.util.List;
|
||||
|
||||
import org.maxkey.configuration.ApplicationConfig;
|
||||
import org.maxkey.constants.ConstsOperateMessage;
|
||||
import org.maxkey.constants.ConstsProtocols;
|
||||
import org.maxkey.authn.annotation.CurrentUser;
|
||||
import org.maxkey.constants.ConstsStatus;
|
||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||
import org.maxkey.entity.Accounts;
|
||||
import org.maxkey.entity.Message;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.entity.apps.Apps;
|
||||
import org.maxkey.entity.apps.UserApps;
|
||||
import org.maxkey.persistence.service.AccountsService;
|
||||
import org.maxkey.persistence.service.AppsService;
|
||||
import org.maxkey.persistence.service.UserInfoService;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.maxkey.web.message.Message;
|
||||
import org.maxkey.web.message.MessageType;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* AppListController.
|
||||
@@ -54,15 +50,12 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
@Controller
|
||||
public class AppListController {
|
||||
static final Logger _logger = LoggerFactory.getLogger(AppListController.class);
|
||||
|
||||
@Autowired
|
||||
protected ApplicationConfig applicationConfig;
|
||||
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@Autowired
|
||||
AccountsService appUsersService;
|
||||
AccountsService accountsService;
|
||||
|
||||
@Autowired
|
||||
AppsService appsService;
|
||||
@@ -72,202 +65,77 @@ public class AppListController {
|
||||
* @param gridList 类型
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = { "/appList" })
|
||||
public ModelAndView appList(
|
||||
@RequestParam(value = "gridList", required = false) String gridList,Principal principal) {
|
||||
ModelAndView modelAndView = new ModelAndView("main/appList");
|
||||
@RequestMapping(value = { "/appList" }, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ResponseBody
|
||||
public ResponseEntity<?> appList(
|
||||
@RequestParam(value = "gridList", required = false) String gridList,
|
||||
@CurrentUser UserInfo currentUser) {
|
||||
userInfoService.updateGridList(gridList);
|
||||
modelAndView.addObject("appList", queryAccessableApps());
|
||||
modelAndView.addObject("noticesVisible", applicationConfig.isNoticesVisible());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/appConfigList" })
|
||||
public ModelAndView appConfigList() {
|
||||
ModelAndView modelAndView = new ModelAndView("main/appConfigList");
|
||||
modelAndView.addObject("appList", queryAccessableApps());
|
||||
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
private List<UserApps> queryAccessableApps() {
|
||||
UserApps userApplications = new UserApps();
|
||||
userApplications.setUsername(WebContext.getUserInfo().getUsername());
|
||||
userApplications.setInstId(WebContext.getUserInfo().getInstId());
|
||||
List<UserApps> appList = appsService.queryMyApps(userApplications);
|
||||
UserApps userApps = new UserApps();
|
||||
userApps.setUsername(currentUser.getUsername());
|
||||
userApps.setInstId(currentUser.getInstId());
|
||||
List<UserApps> appList = appsService.queryMyApps(userApps);
|
||||
for (UserApps app : appList) {
|
||||
app.transIconBase64();
|
||||
}
|
||||
|
||||
return appList;
|
||||
return new Message<List<UserApps>>(appList).buildResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* forwardAppLoginConfig.
|
||||
* @param protocol protocol
|
||||
* @param credential credential
|
||||
* @param appId appId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = { "/forward/appProtectedConfig/{protocol}/{credential}/{appId}" })
|
||||
public ModelAndView forwardAppLoginConfig(@PathVariable("protocol") String protocol,
|
||||
@PathVariable("credential") int credential, @PathVariable("appId") String appId) {
|
||||
ModelAndView modelAndView = new ModelAndView("main/appProtectedConfig");
|
||||
|
||||
UserInfo userInfo = WebContext.getUserInfo();
|
||||
|
||||
if (userInfo.getProtectedAppsMap().get(appId) != null) {
|
||||
modelAndView.addObject("protectedappId", true);
|
||||
} else {
|
||||
modelAndView.addObject("protectedappId", false);
|
||||
}
|
||||
modelAndView.addObject("userId", userInfo.getId());
|
||||
modelAndView.addObject("appId", appId);
|
||||
modelAndView.addObject("protocol", protocol);
|
||||
modelAndView.addObject("credential", credential);
|
||||
return modelAndView;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* appLoginConfig.
|
||||
* @param protocol protocol
|
||||
* @param credential credential
|
||||
* @param appId appId
|
||||
* @param protectedappId protectedappId
|
||||
* @param password password
|
||||
* @return
|
||||
*/
|
||||
|
||||
|
||||
@RequestMapping(value = { "/account/get" })
|
||||
@ResponseBody
|
||||
@RequestMapping(value = { "/appProtectedConfig" })
|
||||
public Message appLoginConfig(
|
||||
@RequestParam("protocol") String protocol,
|
||||
@RequestParam("credential") int credential,
|
||||
@RequestParam("appId") String appId,
|
||||
@RequestParam("protectedappId") String protectedappId,
|
||||
@RequestParam("password") String password) {
|
||||
|
||||
UserInfo userInfo = WebContext.getUserInfo();
|
||||
String userAppProtectedPassword = PasswordReciprocal.getInstance().decoder(userInfo.getAppLoginPassword());
|
||||
if (userAppProtectedPassword.equals(password)) {
|
||||
|
||||
if (protectedappId.equalsIgnoreCase("YES")) {
|
||||
if (userInfo.getProtectedApps() != null
|
||||
&& userInfo.getProtectedApps().indexOf(appId) < 0) {
|
||||
userInfo.setProtectedApps(userInfo.getProtectedApps() + "," + appId);
|
||||
if (userInfo.getProtectedAppsMap() != null) {
|
||||
userInfo.getProtectedAppsMap().put(appId, appId);
|
||||
}
|
||||
} else {
|
||||
userInfo.setProtectedApps("," + appId);
|
||||
}
|
||||
} else {
|
||||
if (userInfo.getProtectedApps() != null
|
||||
&& userInfo.getProtectedApps().indexOf(appId) > -1) {
|
||||
// userInfo.setSecondProtectedApps(userInfo.getSecondProtectedApps()+","+appId);
|
||||
String[] protectedApps = userInfo.getProtectedApps().split(",");
|
||||
String protectedAppIds = "";
|
||||
if (userInfo.getProtectedAppsMap() != null) {
|
||||
userInfo.getProtectedAppsMap().remove(appId);
|
||||
}
|
||||
for (String protectedAppId : protectedApps) {
|
||||
if (protectedAppId.equalsIgnoreCase(appId)
|
||||
|| protectedAppId.trim().equals("")) {
|
||||
continue;
|
||||
}
|
||||
protectedAppIds = protectedAppIds + "," + protectedAppId;
|
||||
}
|
||||
userInfo.setProtectedApps(protectedAppIds);
|
||||
}
|
||||
}
|
||||
|
||||
userInfoService.updateProtectedApps(userInfo);
|
||||
} else {
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_ERROR), MessageType.error);
|
||||
}
|
||||
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS), MessageType.success);
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/forward/appUserConfig/{protocol}/{credential}/{appId}" })
|
||||
public ModelAndView forwardAppUserConfig(@PathVariable("protocol") String protocol,
|
||||
@PathVariable("credential") int credential, @PathVariable("appId") String appId) {
|
||||
ModelAndView modelAndView = new ModelAndView("main/appUserConfig");
|
||||
// modelAndView.addObject("appList",appList);
|
||||
|
||||
Accounts appUsers = new Accounts();
|
||||
UserInfo userInfo = WebContext.getUserInfo();
|
||||
public ResponseEntity<?> getAccount(
|
||||
@RequestParam("credential") int credential,
|
||||
@RequestParam("appId") String appId,
|
||||
@CurrentUser UserInfo currentUser) {
|
||||
Accounts account = null ;
|
||||
|
||||
if (credential == Apps.CREDENTIALS.USER_DEFINED) {
|
||||
appUsers = appUsersService.load(new Accounts(userInfo.getId(), appId));
|
||||
if (protocol.equalsIgnoreCase(ConstsProtocols.FORMBASED)
|
||||
|| protocol.equalsIgnoreCase(ConstsProtocols.BASIC)
|
||||
|| protocol.equalsIgnoreCase(ConstsProtocols.EXTEND_API)) {
|
||||
|
||||
modelAndView.addObject("username", true);
|
||||
modelAndView.addObject("password", true);
|
||||
} else if (protocol.equalsIgnoreCase(ConstsProtocols.SAML20)) {
|
||||
modelAndView.addObject("username", true);
|
||||
modelAndView.addObject("password", false);
|
||||
} else {
|
||||
modelAndView.addObject("username", false);
|
||||
modelAndView.addObject("password", false);
|
||||
}
|
||||
if (appUsers != null) {
|
||||
modelAndView.addObject("identity_username", appUsers.getRelatedUsername());
|
||||
modelAndView.addObject("identity_password", PasswordReciprocal.getInstance().decoder(appUsers.getRelatedPassword()));
|
||||
} else {
|
||||
modelAndView.addObject("identity_username", "");
|
||||
modelAndView.addObject("identity_password", "");
|
||||
}
|
||||
} else {
|
||||
modelAndView.addObject("username", false);
|
||||
modelAndView.addObject("password", false);
|
||||
account = accountsService.load(new Accounts(currentUser.getId(), appId));
|
||||
account.setRelatedPassword(
|
||||
PasswordReciprocal.getInstance().decoder(
|
||||
account.getRelatedPassword()));
|
||||
}else {
|
||||
account = new Accounts();
|
||||
account.setAppId(appId);
|
||||
account.setUserId(currentUser.getId());
|
||||
account.setUsername(currentUser.getUsername());
|
||||
account.setDisplayName(currentUser.getDisplayName());
|
||||
}
|
||||
|
||||
modelAndView.addObject("userId", userInfo.getId());
|
||||
modelAndView.addObject("appId", appId);
|
||||
modelAndView.addObject("protocol", protocol);
|
||||
modelAndView.addObject("credential", credential);
|
||||
return modelAndView;
|
||||
return new Message<Accounts>(account).buildResponse();
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/account/update" })
|
||||
@ResponseBody
|
||||
@RequestMapping(value = { "/appUserConfig" })
|
||||
public Message appUserConfig(@RequestParam("protocol") String protocol, @RequestParam("credential") int credential,
|
||||
@RequestParam("appId") String appId, @RequestParam("identity_username") String identity_username,
|
||||
@RequestParam("identity_password") String identity_password) {
|
||||
|
||||
Apps app = appsService.get(appId);
|
||||
UserInfo userInfo = WebContext.getUserInfo();
|
||||
|
||||
public ResponseEntity<?> updateAccount(
|
||||
@RequestParam("credential") int credential,
|
||||
@ModelAttribute Accounts account,
|
||||
@CurrentUser UserInfo currentUser) {
|
||||
Accounts appUsers = new Accounts();
|
||||
appUsers.setAppId(appId);
|
||||
appUsers.setUserId(userInfo.getId());
|
||||
|
||||
if (identity_password != null && !identity_password.equals("") && credential == Apps.CREDENTIALS.USER_DEFINED) {
|
||||
appUsers = appUsersService.load(new Accounts(userInfo.getId(), appId));
|
||||
if (credential == Apps.CREDENTIALS.USER_DEFINED) {
|
||||
appUsers = accountsService.load(new Accounts(currentUser.getId(), account.getAppId()));
|
||||
if (appUsers == null) {
|
||||
appUsers = new Accounts();
|
||||
appUsers.setId(appUsers.generateId());
|
||||
appUsers.setAppId(appId);
|
||||
appUsers.setAppName(app.getName());
|
||||
appUsers.setUserId(userInfo.getId());
|
||||
appUsers.setUsername(userInfo.getUsername());
|
||||
appUsers.setDisplayName(userInfo.getDisplayName());
|
||||
appUsers.setUserId(currentUser.getId());
|
||||
appUsers.setUsername(currentUser.getUsername());
|
||||
appUsers.setDisplayName(currentUser.getDisplayName());
|
||||
|
||||
appUsers.setRelatedUsername(identity_username);
|
||||
appUsers.setRelatedPassword(PasswordReciprocal.getInstance().encode(identity_password));
|
||||
appUsers.setInstId(userInfo.getInstId());
|
||||
appUsers.setRelatedPassword(
|
||||
PasswordReciprocal.getInstance().encode(account.getRelatedPassword()));
|
||||
appUsers.setInstId(currentUser.getInstId());
|
||||
appUsers.setStatus(ConstsStatus.ACTIVE);
|
||||
appUsersService.insert(appUsers);
|
||||
accountsService.insert(appUsers);
|
||||
} else {
|
||||
appUsers.setRelatedUsername(identity_username);
|
||||
appUsers.setRelatedPassword(PasswordReciprocal.getInstance().encode(identity_password));
|
||||
appUsersService.update(appUsers);
|
||||
appUsers.setRelatedUsername(account.getRelatedUsername());
|
||||
appUsers.setRelatedPassword(
|
||||
PasswordReciprocal.getInstance().encode(account.getRelatedPassword()));
|
||||
accountsService.update(appUsers);
|
||||
}
|
||||
}
|
||||
|
||||
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS), MessageType.success);
|
||||
return new Message<Accounts>().buildResponse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright [2020] [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.web.historys.contorller;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||
import org.maxkey.entity.HistorySystemLogs;
|
||||
import org.maxkey.persistence.service.HistorySystemLogsService;
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* 操作日志查询.
|
||||
*
|
||||
* @author Crystal.sea
|
||||
*
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = { "/historys" })
|
||||
public class HistorySystemLogsController {
|
||||
static final Logger _logger = LoggerFactory.getLogger(HistorySystemLogsController.class);
|
||||
|
||||
@Autowired
|
||||
HistorySystemLogsService historySystemLogsService;
|
||||
|
||||
@RequestMapping(value = { "/systemLogsList" })
|
||||
public String List() {
|
||||
return "historys/systemLogsList";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询操作日志.
|
||||
*
|
||||
* @param logs
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = { "/systemLogsList/grid" })
|
||||
@ResponseBody
|
||||
public JpaPageResults<HistorySystemLogs> logsDataGrid(@ModelAttribute("historyLogs") HistorySystemLogs historyLogs) {
|
||||
_logger.debug("history/systemLogs/grid/ systemLogs() " + historyLogs);
|
||||
historyLogs.setInstId(WebContext.getUserInfo().getInstId());
|
||||
return historySystemLogsService.queryPageResults(historyLogs);
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DateUtils.FORMAT_DATE_HH_MM_SS);
|
||||
dateFormat.setLenient(false);
|
||||
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
|
||||
}
|
||||
}
|
||||
@@ -20,14 +20,17 @@ package org.maxkey.web.historys.contorller;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||
import org.maxkey.authn.annotation.CurrentUser;
|
||||
import org.maxkey.entity.HistoryLoginApps;
|
||||
import org.maxkey.entity.Message;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.persistence.service.HistoryLoginAppsService;
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
@@ -36,47 +39,42 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* 单点登录日志查询.
|
||||
* 单点登录日志查询
|
||||
*
|
||||
* @author Crystal.sea
|
||||
*
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = { "/historys" })
|
||||
public class HistoryLoginAppsController {
|
||||
static final Logger _logger = LoggerFactory.getLogger(HistoryLoginAppsController.class);
|
||||
@RequestMapping(value={"/historys"})
|
||||
public class LoginAppsHistoryController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(LoginAppsHistoryController.class);
|
||||
|
||||
@Autowired
|
||||
protected HistoryLoginAppsService historyLoginAppsService;
|
||||
|
||||
/**
|
||||
* @param loginAppsHistory
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value={"/loginAppsHistory/fetch"})
|
||||
@ResponseBody
|
||||
public ResponseEntity<?> fetch(
|
||||
@ModelAttribute("historyLoginApp") HistoryLoginApps historyLoginApp,
|
||||
@CurrentUser UserInfo currentUser){
|
||||
_logger.debug("historys/loginAppsHistory/fetch/ {}",historyLoginApp);
|
||||
historyLoginApp.setId(null);
|
||||
historyLoginApp.setUserId(currentUser.getId());
|
||||
historyLoginApp.setInstId(currentUser.getInstId());
|
||||
return new Message<JpaPageResults<HistoryLoginApps>>(
|
||||
historyLoginAppsService.queryPageResults(historyLoginApp)
|
||||
).buildResponse();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
protected HistoryLoginAppsService historyLoginAppsService;
|
||||
|
||||
@RequestMapping(value = { "/loginAppsList" })
|
||||
public String loginAppHistoryList() {
|
||||
return "historys/loginAppsList";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单点登录日志.
|
||||
*
|
||||
* @param logsSso
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = { "/loginAppsList/grid" })
|
||||
@ResponseBody
|
||||
public JpaPageResults<HistoryLoginApps> logsSsoGrid(
|
||||
@ModelAttribute("historyLoginApps") HistoryLoginApps historyLoginApps) {
|
||||
_logger.debug("history/loginApps/grid/ logsGrid() " + historyLoginApps);
|
||||
historyLoginApps.setId(null);
|
||||
historyLoginApps.setInstId(WebContext.getUserInfo().getInstId());
|
||||
historyLoginApps.setUsername(WebContext.getUserInfo().getUsername());
|
||||
return historyLoginAppsService.queryPageResults(historyLoginApps);
|
||||
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DateUtils.FORMAT_DATE_HH_MM_SS);
|
||||
dateFormat.setLenient(false);
|
||||
dateFormat.setLenient(false);
|
||||
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
|
||||
}
|
||||
}
|
||||
@@ -20,14 +20,17 @@ package org.maxkey.web.historys.contorller;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||
import org.maxkey.authn.annotation.CurrentUser;
|
||||
import org.maxkey.entity.HistoryLogin;
|
||||
import org.maxkey.entity.Message;
|
||||
import org.maxkey.entity.UserInfo;
|
||||
import org.maxkey.persistence.service.HistoryLoginService;
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.WebDataBinder;
|
||||
import org.springframework.web.bind.annotation.InitBinder;
|
||||
@@ -36,45 +39,42 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* 登录日志查询.
|
||||
* 登录日志查询
|
||||
*
|
||||
* @author Crystal.sea
|
||||
*
|
||||
*/
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = { "/historys" })
|
||||
public class HistoryLoginController {
|
||||
static final Logger _logger = LoggerFactory.getLogger(HistoryLoginController.class);
|
||||
|
||||
@Autowired
|
||||
HistoryLoginService historyLoginService;
|
||||
|
||||
@RequestMapping(value = { "/loginList" })
|
||||
public String authList() {
|
||||
return "historys/loginList";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询登录日志.
|
||||
*
|
||||
* @param logsAuth
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = { "/loginList/grid" })
|
||||
@ResponseBody
|
||||
public JpaPageResults<HistoryLogin> logAuthsGrid(@ModelAttribute("historyLogin") HistoryLogin historyLogin) {
|
||||
_logger.debug("history/login/grid/ logsGrid() " + historyLogin);
|
||||
historyLogin.setUserId(WebContext.getUserInfo().getId());
|
||||
historyLogin.setInstId(WebContext.getUserInfo().getInstId());
|
||||
return historyLoginService.queryPageResults(historyLogin);
|
||||
}
|
||||
|
||||
|
||||
@InitBinder
|
||||
@RequestMapping(value={"/historys"})
|
||||
public class LoginHistoryController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(LoginHistoryController.class);
|
||||
|
||||
@Autowired
|
||||
HistoryLoginService loginHistoryService;
|
||||
|
||||
/**
|
||||
* @param HistoryLogin
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value={"/loginHistory/fetch"})
|
||||
@ResponseBody
|
||||
public ResponseEntity<?> fetch(
|
||||
@ModelAttribute("historyLogin") HistoryLogin historyLogin,
|
||||
@CurrentUser UserInfo currentUser
|
||||
){
|
||||
_logger.debug("historys/loginHistory/fetch/ {}",historyLogin);
|
||||
historyLogin.setInstId(currentUser.getInstId());
|
||||
historyLogin.setUserId(currentUser.getId());
|
||||
return new Message<JpaPageResults<HistoryLogin>>(
|
||||
loginHistoryService.queryPageResults(historyLogin)
|
||||
).buildResponse();
|
||||
}
|
||||
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DateUtils.FORMAT_DATE_HH_MM_SS);
|
||||
dateFormat.setLenient(false);
|
||||
dateFormat.setLenient(false);
|
||||
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user