Merge branch 'master' into master_dev_lyp

This commit is contained in:
MaxKey
2020-11-10 12:19:10 +08:00
committed by GitHub
201 changed files with 13529 additions and 2822 deletions

View File

@@ -87,7 +87,7 @@ public class GroupMemberController {
@ResponseBody
public JpaPageResults<GroupMember> queryMemberInGroup(@ModelAttribute("groupMember") GroupMember groupMember) {
_logger.debug("groupMember : "+groupMember);
if(groupMember.getGroupId()==null||groupMember.getGroupId().equals("")||groupMember.getGroupId().equals("ALL_USER_GROUP")){
if(groupMember.getGroupId()==null||groupMember.getGroupId().equals("")||groupMember.getGroupId().equals("ROLE_ALL_USER")){
return groupMemberService.queryPageResults("allMemberInGroup",groupMember);
}else{
return groupMemberService.queryPageResults("memberInGroup",groupMember);

View File

@@ -196,116 +196,5 @@ public class UserInfoController {
* @return
*/
@RequestMapping(value = "/update")
public ModelAndView updateUsers(@Valid @ModelAttribute("userInfo") UserInfo userInfo, BindingResult result) {
_logger.debug(userInfo.toString());
if (result.hasErrors()) {
// new Message(WebContext.getValidErrorText(),result);
}
_logger.info(userInfo.getExtraAttributeName());
_logger.info(userInfo.getExtraAttributeValue());
//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
convertExtraAttribute(userInfo);
_logger.info(userInfo.getExtraAttribute());
if (userInfoService.update(userInfo)) {
new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS), userInfo, MessageType.success, OperateType.add, MessageScope.DB);
}
new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR), MessageType.error);
return WebContext.forward("forwardUpdate/" + userInfo.getId());
}
/**
* 批量删除用户
*
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value = "/batchDelete")
public Message batchDeleteUsers(@RequestParam("id") String id) {
_logger.debug(id);
if (userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS), MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR), MessageType.error);
}
}
/**
* 根据用户id删除用户
*
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value = "/delete")
public Message deleteUsersById(@RequestParam("id") String id) {
_logger.debug(id);
if (userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
//provisioningPrepare.prepare(userInfo, OPERATEACTION.DELETE_ACTION);
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS), MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR), MessageType.error);
}
}
protected void convertExtraAttribute(UserInfo userInfo) {
if (userInfo.getExtraAttributeValue() != null) {
String[] extraAttributeLabel = userInfo.getExtraAttributeName().split(",");
String[] extraAttributeValue = userInfo.getExtraAttributeValue().split(",");
Map<String, String> extraAttributeMap = new HashMap<String, String>();
for (int i = 0; i < extraAttributeLabel.length; i++) {
extraAttributeMap.put(extraAttributeLabel[i], extraAttributeValue[i]);
}
String extraAttribute = JsonUtils.object2Json(extraAttributeMap);
userInfo.setExtraAttribute(extraAttribute);
}
}
@RequestMapping(value = {"/forwardChangePassword/{id}"})
public ModelAndView forwardChangePassword(@PathVariable("id") String id) {
ModelAndView modelAndView = new ModelAndView("/userinfo/changePassword");
UserInfo userInfo = userInfoService.get(id);
modelAndView.addObject("model", userInfo);
return modelAndView;
}
@ResponseBody
@RequestMapping(value = "/changePassword")
public Message changePassword(@ModelAttribute("userInfo") UserInfo userInfo) {
_logger.debug(userInfo.getId());
if (userInfoService.changePassword(userInfo)) {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS), MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR), MessageType.error);
}
}
@InitBinder
public void binder(WebDataBinder binder) {
binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
@Override
public void setAsText(String value) {
if (StringUtils.isNullOrBlank(value)) {
setValue(null);
} else {
setValue(value);
}
}
});
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
}

View File

@@ -21,7 +21,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.AbstractAuthenticationProvider;
import org.maxkey.authn.BasicAuthentication;
import org.maxkey.authn.LoginCredential;
import org.maxkey.authn.support.jwt.JwtLoginService;
import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
import org.maxkey.configuration.ApplicationConfig;
@@ -110,12 +110,12 @@ public class LoginEndpoint {
}
@RequestMapping(value={"/logon.do"})
public ModelAndView logon(@ModelAttribute("authentication") BasicAuthentication authentication) {
public ModelAndView logon(@ModelAttribute("loginCredential") LoginCredential loginCredential) {
if(WebContext.isAuthenticated()){
return WebContext.redirect("/main");
}else{
authenticationProvider.authenticate(authentication);
authenticationProvider.authenticate(loginCredential);
return WebContext.redirect("/login");
}
}

View File

@@ -23,13 +23,13 @@ import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.maxkey.authn.SigninPrincipal;
import org.maxkey.configuration.ApplicationConfig;
import org.maxkey.web.WebContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
/**
@@ -48,6 +48,7 @@ public class PermissionAdapter extends HandlerInterceptorAdapter {
private ApplicationConfig applicationConfig;
static ConcurrentHashMap<String ,String >navigationsMap=null;
/*
* 请求前处理
* (non-Javadoc)
@@ -58,13 +59,21 @@ public class PermissionAdapter extends HandlerInterceptorAdapter {
_logger.trace("PermissionAdapter preHandle");
//判断用户是否登录
if(WebContext.getAuthentication()==null||WebContext.getAuthentication().getAuthorities()==null){//判断用户和角色,判断用户是否登录用户
_logger.trace("No Authentication ... forward to /login");
RequestDispatcher dispatcher = request.getRequestDispatcher("/login");
dispatcher.forward(request, response);
return false;
}
if(WebContext.getAuthentication()==null
||WebContext.getAuthentication().getAuthorities()==null){//判断用户和角色,判断用户是否登录用户
_logger.trace("No Authentication ... forward to /login");
RequestDispatcher dispatcher = request.getRequestDispatcher("/login");
dispatcher.forward(request, response);
return false;
}
//非管理员用户直接注销
if (!((SigninPrincipal) WebContext.getAuthentication().getPrincipal()).isRoleAdministrators()) {
_logger.debug("Not ADMINISTRATORS Authentication .");
RequestDispatcher dispatcher = request.getRequestDispatcher("/logout");
dispatcher.forward(request, response);
return false;
}
boolean hasAccess=true;