mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-06 17:08:29 +08:00
v1.2.2 RC
This commit is contained in:
parent
c70aa8df95
commit
6ce1481df5
7
.checkstyle
Normal file
7
.checkstyle
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
|
||||
<fileset name="all" enabled="true" check-config-name="checkstyle-rules" local="false">
|
||||
<file-match-pattern match-pattern=".*" include-pattern="true"/>
|
||||
</fileset>
|
||||
</fileset-config>
|
||||
6
.project
6
.project
@ -15,9 +15,15 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
||||
@ -1,18 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="bin/main" path="src/main/java">
|
||||
<classpathentry kind="src" output="bin/main"
|
||||
path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="main" />
|
||||
<attribute name="gradle_used_by_scope" value="main,test" />
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="bin/test" path="src/test/java">
|
||||
<classpathentry kind="src" output="bin/test"
|
||||
path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="test" />
|
||||
<attribute name="gradle_used_by_scope" value="test" />
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="con"
|
||||
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/" />
|
||||
<classpathentry kind="con"
|
||||
path="org.eclipse.buildship.core.gradleclasspathcontainer" />
|
||||
<classpathentry kind="output" path="bin/default" />
|
||||
</classpath>
|
||||
|
||||
@ -25,11 +25,17 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-modules id="moduleCoreId"
|
||||
project-version="1.5.0">
|
||||
<wb-module deploy-name="maxkey-core">
|
||||
<wb-resource deploy-path="/" source-path="/src/main/java" />
|
||||
<wb-resource deploy-path="/" source-path="/src/test/java" />
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -19,7 +19,6 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
|
||||
|
||||
/**
|
||||
* login Authentication abstract class
|
||||
*
|
||||
@ -56,9 +55,10 @@ public abstract class AbstractAuthenticationProvider{
|
||||
}
|
||||
|
||||
/*
|
||||
* authenticate
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.security.authentication.AuthenticationProvider#authenticate(org.springframework.security.core.Authentication)
|
||||
* authenticate (non-Javadoc)
|
||||
*
|
||||
* @see org.springframework.security.authentication.AuthenticationProvider#
|
||||
* authenticate(org.springframework.security.core.Authentication)
|
||||
*/
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
_logger.debug("Trying to authenticate user '{}' via {}", authentication.getPrincipal(), getProviderName());
|
||||
@ -67,7 +67,8 @@ public abstract class AbstractAuthenticationProvider{
|
||||
authentication = doInternalAuthenticate(authentication);
|
||||
} catch (AuthenticationException e) {
|
||||
e.printStackTrace();
|
||||
_logger.error("Failed to authenticate user {} via {}: {}", new Object[]{authentication.getPrincipal(), getProviderName(), e.getMessage()});
|
||||
_logger.error("Failed to authenticate user {} via {}: {}",
|
||||
new Object[] { authentication.getPrincipal(), getProviderName(), e.getMessage() });
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -83,7 +84,8 @@ public abstract class AbstractAuthenticationProvider{
|
||||
_logger.debug("'{}' authenticated successfully by {}.", authentication.getPrincipal(), getProviderName());
|
||||
|
||||
UserInfo userInfo = WebContext.getUserInfo();
|
||||
Object password_set_type=WebContext.getSession().getAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE);
|
||||
Object password_set_type = WebContext.getSession()
|
||||
.getAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE);
|
||||
// 登录完成后切换SESSION
|
||||
_logger.debug("Login Session {}.", WebContext.getSession().getId());
|
||||
WebContext.getSession().invalidate();
|
||||
@ -98,14 +100,14 @@ public abstract class AbstractAuthenticationProvider{
|
||||
WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE, password_set_type);
|
||||
|
||||
// create new authentication response containing the user and it's authorities
|
||||
UsernamePasswordAuthenticationToken simpleUserAuthentication = new UsernamePasswordAuthenticationToken(userInfo.getUsername(), authentication.getCredentials(), authentication.getAuthorities());
|
||||
UsernamePasswordAuthenticationToken simpleUserAuthentication = new UsernamePasswordAuthenticationToken(
|
||||
userInfo.getUsername(), authentication.getCredentials(), authentication.getAuthorities());
|
||||
return simpleUserAuthentication;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* session validate
|
||||
*
|
||||
* @param j_username
|
||||
* @param j_cname
|
||||
* @param sessionId
|
||||
@ -120,16 +122,16 @@ public abstract class AbstractAuthenticationProvider{
|
||||
|
||||
/**
|
||||
* session validate
|
||||
*
|
||||
* @param j_username
|
||||
* @param j_cname
|
||||
* @param sessionId
|
||||
*/
|
||||
protected void jwtTokenValid(String j_jwtToken) {
|
||||
/*if(j_jwtToken!=null && ! j_jwtToken.equals("")){
|
||||
if(jwtLoginService.jwtTokenValidation(j_jwtToken)){
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
* if(j_jwtToken!=null && ! j_jwtToken.equals("")){
|
||||
* if(jwtLoginService.jwtTokenValidation(j_jwtToken)){ return; } }
|
||||
*/
|
||||
String message = WebContext.getI18nValue("login.error.session");
|
||||
_logger.debug("login session valid error.");
|
||||
throw new BadCredentialsException(message);
|
||||
@ -142,8 +144,10 @@ public abstract class AbstractAuthenticationProvider{
|
||||
throw new BadCredentialsException(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* captcha validate
|
||||
*
|
||||
* @param j_username
|
||||
* @param j_cname
|
||||
* @param captcha
|
||||
@ -151,9 +155,10 @@ public abstract class AbstractAuthenticationProvider{
|
||||
protected void captchaValid(String j_captcha, String j_auth_type) {
|
||||
if (applicationConfig.getLoginConfig().isCaptcha()) {// for basic
|
||||
if (j_auth_type.equalsIgnoreCase("common")) {
|
||||
_logger.info("captcha : "+WebContext.getSession().getAttribute(WebConstants.KAPTCHA_SESSION_KEY).toString());
|
||||
if(j_captcha==null
|
||||
|| !j_captcha.equals(WebContext.getSession().getAttribute(WebConstants.KAPTCHA_SESSION_KEY).toString())){
|
||||
_logger.info("captcha : "
|
||||
+ WebContext.getSession().getAttribute(WebConstants.KAPTCHA_SESSION_KEY).toString());
|
||||
if (j_captcha == null || !j_captcha
|
||||
.equals(WebContext.getSession().getAttribute(WebConstants.KAPTCHA_SESSION_KEY).toString())) {
|
||||
String message = WebContext.getI18nValue("login.error.captcha");
|
||||
_logger.debug("login captcha valid error.");
|
||||
throw new BadCredentialsException(message);
|
||||
@ -164,6 +169,7 @@ public abstract class AbstractAuthenticationProvider{
|
||||
|
||||
/**
|
||||
* captcha validate
|
||||
*
|
||||
* @param j_username
|
||||
* @param j_cname
|
||||
* @param j_otp_captcha
|
||||
@ -188,9 +194,9 @@ public abstract class AbstractAuthenticationProvider{
|
||||
}
|
||||
|
||||
/**
|
||||
* login user by j_username and j_cname
|
||||
* first query user by j_cname
|
||||
* if first step userinfo is null,query user from system
|
||||
* login user by j_username and j_cname first query user by j_cname if first
|
||||
* step userinfo is null,query user from system
|
||||
*
|
||||
* @param j_username
|
||||
* @param j_cname
|
||||
* @return
|
||||
@ -209,9 +215,9 @@ public abstract class AbstractAuthenticationProvider{
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check input password empty
|
||||
*
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
@ -224,6 +230,7 @@ public abstract class AbstractAuthenticationProvider{
|
||||
|
||||
/**
|
||||
* check input username or password empty
|
||||
*
|
||||
* @param j_username
|
||||
* @param password
|
||||
* @return
|
||||
@ -237,6 +244,7 @@ public abstract class AbstractAuthenticationProvider{
|
||||
|
||||
/**
|
||||
* check input username empty
|
||||
*
|
||||
* @param j_username
|
||||
* @return
|
||||
*/
|
||||
@ -255,11 +263,11 @@ public abstract class AbstractAuthenticationProvider{
|
||||
loginUser.setId(loginUser.generateId());
|
||||
loginUser.setDisplayName("not exist");
|
||||
loginUser.setLoginCount(0);
|
||||
authenticationRealm.insertLoginHistory(loginUser,LOGINTYPE.LOCAL,"",WebContext.getI18nValue("login.error.username"),"user not exist");
|
||||
authenticationRealm.insertLoginHistory(loginUser, LOGINTYPE.LOCAL, "",
|
||||
WebContext.getI18nValue("login.error.username"), "user not exist");
|
||||
throw new BadCredentialsException(WebContext.getI18nValue("login.error.username"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -87,6 +87,7 @@ public class BasicAuthentication implements Authentication{
|
||||
public String getJ_sessionid() {
|
||||
return j_sessionid;
|
||||
}
|
||||
|
||||
public String getSessionid() {
|
||||
return j_sessionid;
|
||||
}
|
||||
@ -150,6 +151,4 @@ public class BasicAuthentication implements Authentication{
|
||||
+ j_auth_type + ", j_jwtToken=" + j_jwt_token + ", authenticated=" + authenticated + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -25,11 +25,17 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
||||
@ -75,8 +75,8 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
||||
}
|
||||
|
||||
public int getExpiresIn() {
|
||||
return expiration != null ? Long.valueOf((expiration.getTime() - System.currentTimeMillis()) / 1000L)
|
||||
.intValue() : 0;
|
||||
return expiration != null ? Long.valueOf((expiration.getTime() - System.currentTimeMillis()) / 1000L).intValue()
|
||||
: 0;
|
||||
}
|
||||
|
||||
protected void setExpiresIn(int delta) {
|
||||
@ -111,8 +111,9 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
||||
}
|
||||
|
||||
/**
|
||||
* The token type, as introduced in draft 11 of the OAuth 2 spec. The spec doesn't define (yet) that the valid token
|
||||
* types are, but says it's required so the default will just be "undefined".
|
||||
* The token type, as introduced in draft 11 of the OAuth 2 spec. The spec
|
||||
* doesn't define (yet) that the valid token types are, but says it's required
|
||||
* so the default will just be "undefined".
|
||||
*
|
||||
* @return The token type, as introduced in draft 11 of the OAuth 2 spec.
|
||||
*/
|
||||
@ -123,7 +124,8 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
||||
/**
|
||||
* The token type, as introduced in draft 11 of the OAuth 2 spec.
|
||||
*
|
||||
* @param tokenType The token type, as introduced in draft 11 of the OAuth 2 spec.
|
||||
* @param tokenType The token type, as introduced in draft 11 of the OAuth 2
|
||||
* spec.
|
||||
*/
|
||||
public void setTokenType(String tokenType) {
|
||||
this.tokenType = tokenType;
|
||||
@ -141,7 +143,8 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
||||
/**
|
||||
* The refresh token associated with the access token, if any.
|
||||
*
|
||||
* @param refreshToken The refresh token associated with the access token, if any.
|
||||
* @param refreshToken The refresh token associated with the access token, if
|
||||
* any.
|
||||
*/
|
||||
public void setRefreshToken(OAuth2RefreshToken refreshToken) {
|
||||
this.refreshToken = refreshToken;
|
||||
@ -187,8 +190,7 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
||||
long expiration = 0;
|
||||
try {
|
||||
expiration = Long.parseLong(String.valueOf(tokenParams.get(EXPIRES_IN)));
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
} catch (NumberFormatException e) {
|
||||
// fall through...
|
||||
}
|
||||
token.setExpiration(new Date(System.currentTimeMillis() + (expiration * 1000L)));
|
||||
@ -217,7 +219,8 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional information that token granters would like to add to the token, e.g. to support new token types.
|
||||
* Additional information that token granters would like to add to the token,
|
||||
* e.g. to support new token types.
|
||||
*
|
||||
* @return the additional information (default empty)
|
||||
*/
|
||||
@ -226,9 +229,11 @@ public class DefaultOAuth2AccessToken implements Serializable, OAuth2AccessToken
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional information that token granters would like to add to the token, e.g. to support new token types. If
|
||||
* the values in the map are primitive then remote communication is going to always work. It should also be safe to
|
||||
* use maps (nested if desired), or something that is explicitly serializable by Jackson.
|
||||
* Additional information that token granters would like to add to the token,
|
||||
* e.g. to support new token types. If the values in the map are primitive then
|
||||
* remote communication is going to always work. It should also be safe to use
|
||||
* maps (nested if desired), or something that is explicitly serializable by
|
||||
* Jackson.
|
||||
*
|
||||
* @param additionalInformation the additional information to set
|
||||
*/
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
package org.maxkey.authz.oauth2.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An OAuth 2 refresh token.
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
package org.maxkey;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.apache.ibatis.io.VFS;
|
||||
import org.apache.mybatis.jpa.SpringBootVFS;
|
||||
import org.maxkey.web.InitApplicationContext;
|
||||
@ -19,9 +17,13 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
public class MaxKeyApplication extends SpringBootServletInitializer {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(MaxKeyApplication.class);
|
||||
|
||||
/**
|
||||
* @param args args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
VFS.addImplClass(SpringBootVFS.class);
|
||||
ConfigurableApplicationContext applicationContext =SpringApplication.run(MaxKeyApplication.class, args);
|
||||
ConfigurableApplicationContext applicationContext =
|
||||
SpringApplication.run(MaxKeyApplication.class, args);
|
||||
InitApplicationContext initWebContext = new InitApplicationContext(applicationContext);
|
||||
try {
|
||||
initWebContext.init(null);
|
||||
@ -30,7 +32,8 @@ public class MaxKeyApplication extends SpringBootServletInitializer {
|
||||
_logger.error("", e);
|
||||
}
|
||||
_logger.info("MaxKey at " + new Date(applicationContext.getStartupDate()));
|
||||
_logger.info("MaxKey Server Port "+applicationContext.getBean(MaxKeyConfig.class).getPort());
|
||||
_logger.info("MaxKey Server Port "
|
||||
+ applicationContext.getBean(MaxKeyConfig.class).getPort());
|
||||
_logger.info("MaxKey started.");
|
||||
}
|
||||
|
||||
|
||||
@ -43,8 +43,7 @@ public class MaxKeyConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置默认错误页面(仅用于内嵌tomcat启动时)
|
||||
* 使用这种方式,在打包为war后不起作用
|
||||
* 配置默认错误页面(仅用于内嵌tomcat启动时) 使用这种方式,在打包为war后不起作用
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ -57,7 +56,6 @@ public class MaxKeyConfig {
|
||||
ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/exception/error/404");
|
||||
ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/exception/error/500");
|
||||
factory.addErrorPages(errorPage400, errorPage404, errorPage500);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package org.maxkey.web.contorller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.maxkey.constants.OPERATEMESSAGE;
|
||||
import org.maxkey.constants.PROTOCOLS;
|
||||
import org.maxkey.crypto.ReciprocalUtils;
|
||||
@ -27,9 +26,15 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* AppListController.
|
||||
*
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class AppListController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(AppListController.class);
|
||||
static final Logger _logger = LoggerFactory.getLogger(AppListController.class);
|
||||
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
@ -46,22 +51,26 @@ public class AppListController{
|
||||
@Autowired
|
||||
AppsService appsService;
|
||||
|
||||
/**
|
||||
* gridList.
|
||||
* @param gridList 类型
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = { "/appList" })
|
||||
public ModelAndView appList(@RequestParam(value="gridList",required = false) String gridList) {
|
||||
public ModelAndView appList(
|
||||
@RequestParam(value = "gridList", required = false) String gridList) {
|
||||
ModelAndView modelAndView = new ModelAndView("main/appList");
|
||||
|
||||
if (gridList != null && !gridList.equals("")) {
|
||||
int intGridList = Integer.parseInt(gridList);
|
||||
jdbcTemplate.update("UPDATE USERINFO SET GRIDLIST = ? WHERE ID = ?",
|
||||
intGridList,WebContext.getUserInfo().getId());
|
||||
jdbcTemplate.update("UPDATE USERINFO SET GRIDLIST = ? WHERE ID = ?", intGridList,
|
||||
WebContext.getUserInfo().getId());
|
||||
WebContext.getUserInfo().setGridList(intGridList);
|
||||
}
|
||||
modelAndView.addObject("appList", queryAccessableApps());
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = { "/appConfigList" })
|
||||
public ModelAndView appConfigList() {
|
||||
ModelAndView modelAndView = new ModelAndView("main/appConfigList");
|
||||
@ -69,7 +78,6 @@ public class AppListController{
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
|
||||
private List<UserApps> queryAccessableApps() {
|
||||
UserApps userApplications = new UserApps();
|
||||
userApplications.setUsername(WebContext.getUserInfo().getUsername());
|
||||
@ -82,11 +90,16 @@ public class AppListController{
|
||||
return appList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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){
|
||||
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();
|
||||
@ -104,6 +117,15 @@ public class AppListController{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* appLoginConfig.
|
||||
* @param protocol protocol
|
||||
* @param credential credential
|
||||
* @param appId appId
|
||||
* @param protectedappId protectedappId
|
||||
* @param password password
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping(value = { "/appProtectedConfig" })
|
||||
public Message appLoginConfig(
|
||||
@ -111,15 +133,15 @@ public class AppListController{
|
||||
@RequestParam("credential") int credential,
|
||||
@RequestParam("appId") String appId,
|
||||
@RequestParam("protectedappId") String protectedappId,
|
||||
@RequestParam("password") String password
|
||||
){
|
||||
@RequestParam("password") String password) {
|
||||
|
||||
UserInfo userInfo = WebContext.getUserInfo();
|
||||
String userAppProtectedPassword = ReciprocalUtils.decoder(userInfo.getAppLoginPassword());
|
||||
if (userAppProtectedPassword.equals(password)) {
|
||||
|
||||
if (protectedappId.equalsIgnoreCase("YES")) {
|
||||
if(userInfo.getProtectedApps()!=null&&userInfo.getProtectedApps().indexOf(appId)<0){
|
||||
if (userInfo.getProtectedApps() != null
|
||||
&& userInfo.getProtectedApps().indexOf(appId) < 0) {
|
||||
userInfo.setProtectedApps(userInfo.getProtectedApps() + "," + appId);
|
||||
if (userInfo.getProtectedAppsMap() != null) {
|
||||
userInfo.getProtectedAppsMap().put(appId, appId);
|
||||
@ -128,7 +150,8 @@ public class AppListController{
|
||||
userInfo.setProtectedApps("," + appId);
|
||||
}
|
||||
} else {
|
||||
if(userInfo.getProtectedApps()!=null&&userInfo.getProtectedApps().indexOf(appId)>-1){
|
||||
if (userInfo.getProtectedApps() != null
|
||||
&& userInfo.getProtectedApps().indexOf(appId) > -1) {
|
||||
// userInfo.setSecondProtectedApps(userInfo.getSecondProtectedApps()+","+appId);
|
||||
String[] protectedApps = userInfo.getProtectedApps().split(",");
|
||||
String protectedAppIds = "";
|
||||
@ -136,7 +159,10 @@ public class AppListController{
|
||||
userInfo.getProtectedAppsMap().remove(appId);
|
||||
}
|
||||
for (String protectedAppId : protectedApps) {
|
||||
if(protectedAppId.equalsIgnoreCase(appId)||protectedAppId.trim().equals(""))continue;
|
||||
if (protectedAppId.equalsIgnoreCase(appId)
|
||||
|| protectedAppId.trim().equals("")) {
|
||||
continue;
|
||||
}
|
||||
protectedAppIds = protectedAppIds + "," + protectedAppId;
|
||||
}
|
||||
userInfo.setProtectedApps(protectedAppIds);
|
||||
@ -151,12 +177,9 @@ public class AppListController{
|
||||
return new Message(WebContext.getI18nValue(OPERATEMESSAGE.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){
|
||||
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);
|
||||
|
||||
@ -164,16 +187,12 @@ public class AppListController{
|
||||
UserInfo userInfo = WebContext.getUserInfo();
|
||||
if (credential == Apps.CREDENTIALS.USER_DEFINED) {
|
||||
appUsers = appUsersService.load(new Accounts(userInfo.getId(), appId));
|
||||
if(protocol.equalsIgnoreCase(PROTOCOLS.DESKTOP)||
|
||||
protocol.equalsIgnoreCase(PROTOCOLS.FORMBASED)||
|
||||
protocol.equalsIgnoreCase(PROTOCOLS.BASIC)||
|
||||
protocol.equalsIgnoreCase(PROTOCOLS.EXTEND_API)
|
||||
){
|
||||
if (protocol.equalsIgnoreCase(PROTOCOLS.DESKTOP) || protocol.equalsIgnoreCase(PROTOCOLS.FORMBASED)
|
||||
|| protocol.equalsIgnoreCase(PROTOCOLS.BASIC) || protocol.equalsIgnoreCase(PROTOCOLS.EXTEND_API)) {
|
||||
|
||||
modelAndView.addObject("username", true);
|
||||
modelAndView.addObject("password", true);
|
||||
}else if(protocol.equalsIgnoreCase(PROTOCOLS.SAML20)
|
||||
){
|
||||
} else if (protocol.equalsIgnoreCase(PROTOCOLS.SAML20)) {
|
||||
modelAndView.addObject("username", true);
|
||||
modelAndView.addObject("password", false);
|
||||
} else {
|
||||
@ -202,13 +221,9 @@ public class AppListController{
|
||||
|
||||
@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
|
||||
){
|
||||
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();
|
||||
|
||||
@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = { "/forgotpassword" })
|
||||
public class ForgotPasswordContorller {
|
||||
@ -38,14 +37,12 @@ public class ForgotPasswordContorller {
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
|
||||
@RequestMapping(value = { "/forward" })
|
||||
public ModelAndView forwardreg() {
|
||||
_logger.debug("Registration /forgotpassword/forward.");
|
||||
return new ModelAndView("forgotpassword/forward");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = { "/email" })
|
||||
public ModelAndView email(@RequestParam String email) {
|
||||
_logger.debug("Registration /forgotpassword/email.");
|
||||
@ -68,15 +65,16 @@ public class ForgotPasswordContorller {
|
||||
try {
|
||||
hemail.setHostName(applicationConfig.getEmailConfig().getSmtpHost());
|
||||
hemail.setSmtpPort(applicationConfig.getEmailConfig().getPort());
|
||||
hemail.setAuthenticator(new DefaultAuthenticator(applicationConfig.getEmailConfig().getUsername(), applicationConfig.getEmailConfig().getPassword()));
|
||||
hemail.setAuthenticator(new DefaultAuthenticator(applicationConfig.getEmailConfig().getUsername(),
|
||||
applicationConfig.getEmailConfig().getPassword()));
|
||||
|
||||
hemail.addTo(userInfo.getEmail(), userInfo.getNickName());
|
||||
hemail.setFrom(applicationConfig.getEmailConfig().getSenderMail(), "ConnSec");
|
||||
hemail.setSubject("ConnSec Cloud Identity & Access ReSet Password .");
|
||||
|
||||
// set the html message
|
||||
String forgotPasswordUrl=WebContext.getHttpContextPath()+"/forgotpassword/resetpwd/"+forgotPassword.getId();
|
||||
|
||||
String forgotPasswordUrl = WebContext.getHttpContextPath() + "/forgotpassword/resetpwd/"
|
||||
+ forgotPassword.getId();
|
||||
|
||||
// set the html message
|
||||
String emailText = "<html>";
|
||||
@ -113,7 +111,8 @@ public class ForgotPasswordContorller {
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/setpassword/{id}" })
|
||||
public ModelAndView setPassWord(@PathVariable("id") String id,@RequestParam String password,@RequestParam String confirmpassword) {
|
||||
public ModelAndView setPassWord(@PathVariable("id") String id, @RequestParam String password,
|
||||
@RequestParam String confirmpassword) {
|
||||
_logger.debug("forgotPassword /forgotPassword/pwdreseted.");
|
||||
ModelAndView modelAndView = new ModelAndView("forgotpassword/pwdreseted");
|
||||
if (password.equals(confirmpassword)) {
|
||||
|
||||
@ -2,13 +2,12 @@ package org.maxkey.web.contorller;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||
import org.maxkey.dao.service.HistoryLoginAppsService;
|
||||
import org.maxkey.dao.service.HistoryLoginService;
|
||||
import org.maxkey.dao.service.HistoryLogsService;
|
||||
import org.maxkey.domain.HistoryLoginApps;
|
||||
import org.maxkey.domain.HistoryLogin;
|
||||
import org.maxkey.domain.HistoryLoginApps;
|
||||
import org.maxkey.domain.HistoryLogs;
|
||||
import org.maxkey.util.DateUtils;
|
||||
import org.maxkey.web.WebContext;
|
||||
@ -24,7 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* 登录日志和操作日志查询
|
||||
* 登录日志和操作日志查询.
|
||||
*
|
||||
* @author Crystal.sea
|
||||
*
|
||||
@ -33,7 +32,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Controller
|
||||
@RequestMapping(value = { "/historys" })
|
||||
public class HistorysController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(HistorysController.class);
|
||||
static final Logger _logger = LoggerFactory.getLogger(HistorysController.class);
|
||||
|
||||
@Autowired
|
||||
HistoryLoginService historyLoginService;
|
||||
@ -49,9 +48,9 @@ final static Logger _logger = LoggerFactory.getLogger(HistorysController.class);
|
||||
return "historys/logsList";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询操作日志
|
||||
* 查询操作日志.
|
||||
*
|
||||
* @param logs
|
||||
* @return
|
||||
*/
|
||||
@ -68,7 +67,8 @@ final static Logger _logger = LoggerFactory.getLogger(HistorysController.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询登录日志
|
||||
* 查询登录日志.
|
||||
*
|
||||
* @param logsAuth
|
||||
* @return
|
||||
*/
|
||||
@ -86,13 +86,15 @@ final static Logger _logger = LoggerFactory.getLogger(HistorysController.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单点登录日志
|
||||
* 查询单点登录日志.
|
||||
*
|
||||
* @param logsSso
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = { "/loginApps/grid" })
|
||||
@ResponseBody
|
||||
public JpaPageResults<HistoryLoginApps> logsSsoGrid(@ModelAttribute("historyLoginApps") HistoryLoginApps historyLoginApps){
|
||||
public JpaPageResults<HistoryLoginApps> logsSsoGrid(
|
||||
@ModelAttribute("historyLoginApps") HistoryLoginApps historyLoginApps) {
|
||||
_logger.debug("history/loginApps/grid/ logsGrid() " + historyLoginApps);
|
||||
historyLoginApps.setId(null);
|
||||
|
||||
@ -100,9 +102,6 @@ final static Logger _logger = LoggerFactory.getLogger(HistorysController.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@InitBinder
|
||||
public void initBinder(WebDataBinder binder) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DateUtils.FORMAT_DATE_HH_MM_SS);
|
||||
|
||||
@ -2,7 +2,6 @@ package org.maxkey.web.contorller;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.maxkey.crypto.Base32Utils;
|
||||
import org.maxkey.crypto.password.PasswordReciprocal;
|
||||
@ -11,8 +10,8 @@ import org.maxkey.crypto.password.opt.algorithm.OTPSecret;
|
||||
import org.maxkey.dao.service.UserInfoService;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
import org.maxkey.util.RQCodeUtils;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.maxkey.web.ImageEndpoint;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -23,13 +22,14 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
|
||||
/**
|
||||
* .
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = { "/safe/otp" })
|
||||
public class OneTimePasswordController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(OneTimePasswordController.class);
|
||||
static final Logger _logger = LoggerFactory.getLogger(OneTimePasswordController.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("userInfoService")
|
||||
@ -52,7 +52,7 @@ public class OneTimePasswordController {
|
||||
String otpauth = keyUriFormat.format(userInfo.getUsername());
|
||||
byte[] byteSharedSecret = Base32Utils.decode(sharedSecret);
|
||||
String hexSharedSecret = Hex.encodeHexString(byteSharedSecret);
|
||||
modelAndView.addObject("id", genRQCode(otpauth));
|
||||
modelAndView.addObject("id", genRqCode(otpauth));
|
||||
modelAndView.addObject("userInfo", userInfo);
|
||||
modelAndView.addObject("format", keyUriFormat);
|
||||
modelAndView.addObject("sharedSecret", sharedSecret);
|
||||
@ -84,7 +84,7 @@ public class OneTimePasswordController {
|
||||
|
||||
byte[] byteSharedSecret = Base32Utils.decode(sharedSecret);
|
||||
String hexSharedSecret = Hex.encodeHexString(byteSharedSecret);
|
||||
modelAndView.addObject("id", genRQCode(otpauth));
|
||||
modelAndView.addObject("id", genRqCode(otpauth));
|
||||
modelAndView.addObject("userInfo", userInfo);
|
||||
modelAndView.addObject("format", keyUriFormat);
|
||||
modelAndView.addObject("sharedSecret", sharedSecret);
|
||||
@ -116,7 +116,7 @@ public class OneTimePasswordController {
|
||||
String otpauth = keyUriFormat.format(userInfo.getUsername());
|
||||
byte[] byteSharedSecret = Base32Utils.decode(sharedSecret);
|
||||
String hexSharedSecret = Hex.encodeHexString(byteSharedSecret);
|
||||
modelAndView.addObject("id", genRQCode(otpauth));
|
||||
modelAndView.addObject("id", genRqCode(otpauth));
|
||||
modelAndView.addObject("userInfo", userInfo);
|
||||
modelAndView.addObject("format", keyUriFormat);
|
||||
modelAndView.addObject("sharedSecret", sharedSecret);
|
||||
@ -139,7 +139,7 @@ public class OneTimePasswordController {
|
||||
}
|
||||
|
||||
|
||||
public String genRQCode(String otpauth){
|
||||
public String genRqCode(String otpauth) {
|
||||
BufferedImage bufferedImage = RQCodeUtils.write2BufferedImage(otpauth, "gif", 300, 300);
|
||||
byte[] imageByte = ImageEndpoint.bufferedImage2Byte(bufferedImage);
|
||||
String uuid = UUID.randomUUID().toString().toLowerCase();
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package org.maxkey.web.contorller;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.maxkey.constants.OPERATEMESSAGE;
|
||||
import org.maxkey.dao.service.MyProfileService;
|
||||
import org.maxkey.dao.service.UserInfoService;
|
||||
@ -20,11 +19,10 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = { "/profile" })
|
||||
public class ProfileController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(ProfileController.class);
|
||||
static final Logger _logger = LoggerFactory.getLogger(ProfileController.class);
|
||||
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
@ -32,7 +30,6 @@ public class ProfileController {
|
||||
@Autowired
|
||||
private MyProfileService myProfileService;
|
||||
|
||||
|
||||
@RequestMapping(value = { "/myProfile" })
|
||||
public ModelAndView forwardBasic() {
|
||||
ModelAndView modelAndView = new ModelAndView("profile/myProfile");
|
||||
@ -43,20 +40,22 @@ public class ProfileController {
|
||||
// extraAttributeMap=(HashMap<String,Object>)JsonUtils.json2Object(userInfo.getExtraAttribute(),extraAttributeMap);
|
||||
// modelAndView.addObject("extraAttributeMap", extraAttributeMap);
|
||||
// _logger.info("extraAttributeMap : "+extraAttributeMap);
|
||||
|
||||
//
|
||||
modelAndView.addObject("model", userInfo);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
* 修改用户.
|
||||
*
|
||||
* @param userInfo
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/update/myProfile")
|
||||
public ModelAndView updatebasic(@Valid @ModelAttribute("userInfo")UserInfo userInfo,BindingResult result) {
|
||||
public ModelAndView updatebasic(
|
||||
@Valid @ModelAttribute("userInfo") UserInfo userInfo,
|
||||
BindingResult result) {
|
||||
_logger.debug(userInfo.toString());
|
||||
|
||||
// if(userInfo.getExtraAttributeValue()!=null){
|
||||
@ -71,7 +70,10 @@ public class ProfileController {
|
||||
// }
|
||||
|
||||
if (myProfileService.updateProfile(userInfo) > 0) {
|
||||
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB);
|
||||
new Message(
|
||||
WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_SUCCESS),
|
||||
userInfo, MessageType.success,
|
||||
OperateType.add, MessageScope.DB);
|
||||
|
||||
} else {
|
||||
new Message(WebContext.getI18nValue(OPERATEMESSAGE.UPDATE_ERROR), MessageType.error);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package org.maxkey.web.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
@ -12,7 +11,6 @@ import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.maxkey.config.ApplicationConfig;
|
||||
import org.maxkey.domain.IpAddrFilter;
|
||||
import org.maxkey.web.WebContext;
|
||||
@ -43,7 +41,9 @@ public class IpAddressFilter implements Filter {
|
||||
throws IOException, ServletException {
|
||||
if (applicationConfig == null) {
|
||||
_logger.info("applicationConfig init .");
|
||||
applicationConfig=WebApplicationContextUtils.getWebApplicationContext(request.getServletContext()).getBean("applicationConfig", ApplicationConfig.class);
|
||||
applicationConfig = WebApplicationContextUtils.getWebApplicationContext(
|
||||
request.getServletContext())
|
||||
.getBean("applicationConfig", ApplicationConfig.class);
|
||||
}
|
||||
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
|
||||
@ -68,7 +68,6 @@ public class IpAddressFilter implements Filter {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
|
||||
@ -10,20 +10,24 @@ import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.maxkey.util.StringUtils;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* SingleSignOnFilter.
|
||||
* @author Crystal.Sea
|
||||
*/
|
||||
|
||||
public class SingleSignOnFilter implements Filter {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(SingleSignOnFilter.class);
|
||||
|
||||
public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
|
||||
/**
|
||||
*doFilter.
|
||||
*/
|
||||
public void doFilter(ServletRequest request,
|
||||
ServletResponse response, FilterChain chain)throws IOException, ServletException {
|
||||
|
||||
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
|
||||
@ -33,7 +37,8 @@ public class SingleSignOnFilter implements Filter {
|
||||
// 鑾峰彇鏈<EFBFBD>鍚庝竴涓<EFBFBD>"/"鐨勬暟鎹綔涓篴ppid锛屼繚瀛樺湪session涓<EFBFBD>
|
||||
if (StringUtils.isNullOrBlank(appId)) {
|
||||
String uir = httpServletRequest.getRequestURI();
|
||||
session.setAttribute(WebConstants.SINGLE_SIGN_ON_APP_ID, uir.substring(uir.lastIndexOf("/")+1));
|
||||
session.setAttribute(WebConstants.SINGLE_SIGN_ON_APP_ID,
|
||||
uir.substring(uir.lastIndexOf("/") + 1));
|
||||
session.setAttribute("protocol", "formbase");
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
package org.maxkey.web.interceptor;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint;
|
||||
import org.maxkey.dao.service.AppsService;
|
||||
import org.maxkey.dao.service.HistoryLoginAppsService;
|
||||
@ -28,23 +26,28 @@ public class HistoryLoginAppAdapter extends HandlerInterceptorAdapter {
|
||||
@Autowired
|
||||
@Qualifier("appsService")
|
||||
protected AppsService appsService;
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#preHandle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object)
|
||||
|
||||
/**
|
||||
* postHandle .
|
||||
* @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#preHandle(
|
||||
* javax.servlet.http.HttpServletRequest,
|
||||
* javax.servlet.http.HttpServletResponse, java.lang.Object)
|
||||
*/
|
||||
public void postHandle(HttpServletRequest request,HttpServletResponse response, Object handler,ModelAndView modelAndView) throws Exception {
|
||||
public void postHandle(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
Object handler,ModelAndView modelAndView) throws Exception {
|
||||
_logger.debug("postHandle");
|
||||
String appId = null;
|
||||
if (WebContext.getAttribute(WebConstants.SINGLE_SIGN_ON_APP_ID) != null) {
|
||||
appId = WebContext.getAttribute(WebConstants.SINGLE_SIGN_ON_APP_ID).toString();
|
||||
}
|
||||
if (appId == null) {
|
||||
PreLoginAppAdapter.getAppIdFromRequestURI(request);
|
||||
PreLoginAppAdapter.getAppIdFromRequestUrl(request);
|
||||
}
|
||||
//Applications app=applicationsService.get(appId);
|
||||
Apps app=(Apps)WebContext.getAttribute(AuthorizeBaseEndpoint.class.getName());
|
||||
final Apps app = (Apps)WebContext.getAttribute(AuthorizeBaseEndpoint.class.getName());
|
||||
String sessionId = (String)WebContext.getAttribute(WebConstants.CURRENT_USER_SESSION_ID);
|
||||
UserInfo userInfo =WebContext.getUserInfo();
|
||||
final UserInfo userInfo = WebContext.getUserInfo();
|
||||
_logger.debug("sessionId : " + sessionId + " ,appId : " + appId);
|
||||
HistoryLoginApps historyLoginApps = new HistoryLoginApps();
|
||||
historyLoginApps.setId(historyLoginApps.generateId());
|
||||
|
||||
@ -2,7 +2,6 @@ package org.maxkey.web.interceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.maxkey.dao.service.HistoryLogsService;
|
||||
import org.maxkey.domain.HistoryLogs;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
@ -19,7 +18,6 @@ import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
/**
|
||||
* Contorller调用完成后进行日志操作
|
||||
*
|
||||
* 日志处理需在parasec-servlet.xml中配置
|
||||
* mvc:interceptors log
|
||||
* @author Crystal.Sea
|
||||
@ -33,13 +31,19 @@ public class HistoryLogsAdapter extends HandlerInterceptorAdapter {
|
||||
@Qualifier("historyLogsService")
|
||||
private HistoryLogsService historyLogsService;
|
||||
|
||||
// after the handler is executed
|
||||
public void postHandle(HttpServletRequest request,HttpServletResponse response, Object handler,ModelAndView modelAndView) throws Exception {
|
||||
/**
|
||||
* after the handler is executed.
|
||||
*/
|
||||
public void postHandle(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
Object handler,ModelAndView modelAndView) throws Exception {
|
||||
_logger.debug("postHandle");
|
||||
Message message = WebContext.getMessage();//读取session中message
|
||||
|
||||
if (message != null) {
|
||||
if(message.getMessageScope() == MessageScope.DB || message.getMessageScope() == MessageScope.DB_CLIENT) {//判断message类型
|
||||
//判断message类型
|
||||
if (message.getMessageScope() == MessageScope.DB
|
||||
|| message.getMessageScope() == MessageScope.DB_CLIENT) {
|
||||
UserInfo userInfo = WebContext.getUserInfo();//取得当前用户信息
|
||||
|
||||
//创建日志记录
|
||||
@ -56,7 +60,8 @@ public class HistoryLogsAdapter extends HandlerInterceptorAdapter {
|
||||
);
|
||||
_logger.debug("insert db historyLogs content : " + historyLogs);
|
||||
historyLogsService.insert(historyLogs);//日志插入数据库
|
||||
if(message.getMessageScope() == MessageScope.DB) {//message类型仅插入数据库
|
||||
//message类型仅插入数据库
|
||||
if (message.getMessageScope() == MessageScope.DB) {
|
||||
WebContext.clearMessage();//清除message
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
package org.maxkey.web.interceptor;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.maxkey.config.ApplicationConfig;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.slf4j.Logger;
|
||||
@ -13,10 +11,10 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
/**
|
||||
* 权限Interceptor处理
|
||||
* 权限处理需在servlet.xml中配置
|
||||
* mvc:interceptors permission
|
||||
* 权限Interceptor处理 权限处理需在servlet.xml中配置 mvc:interceptors permission
|
||||
*
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
@ -29,40 +27,42 @@ public class PermissionAdapter extends HandlerInterceptorAdapter {
|
||||
private ApplicationConfig applicationConfig;
|
||||
|
||||
static ConcurrentHashMap<String, String> navigationsMap = null;
|
||||
|
||||
/*
|
||||
* 请求前处理
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#preHandle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object)
|
||||
* 请求前处理 (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.springframework.web.servlet.handler.HandlerInterceptorAdapter#preHandle(
|
||||
* javax.servlet.http.HttpServletRequest,
|
||||
* javax.servlet.http.HttpServletResponse, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request,HttpServletResponse response, Object handler) throws Exception {
|
||||
public boolean preHandle(HttpServletRequest request,
|
||||
HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
_logger.trace("PermissionAdapter preHandle");
|
||||
//判断用户是否登录
|
||||
if(WebContext.getAuthentication()==null||WebContext.getAuthentication().getAuthorities()==null){//判断用户和角色,判断用户是否登录用户
|
||||
// 判断用户是否登录, 判断用户和角色,判断用户是否登录用户
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
boolean hasAccess = true;
|
||||
|
||||
|
||||
/*
|
||||
boolean preHandler = super.preHandle(request, response, handler);
|
||||
|
||||
if(preHandler) {
|
||||
preHandler = false;
|
||||
|
||||
|
||||
if(!preHandler){//无权限转向
|
||||
log.debug("You do not have permission to access "+accessUrl);
|
||||
RequestDispatcher dispatcher = request.getRequestDispatcher("/accessdeny");
|
||||
dispatcher.forward(request, response);
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
* boolean preHandler = super.preHandle(request, response, handler);
|
||||
*
|
||||
* if(preHandler) { preHandler = false;
|
||||
*
|
||||
*
|
||||
* if(!preHandler){//无权限转向
|
||||
* log.debug("You do not have permission to access "+accessUrl);
|
||||
* RequestDispatcher dispatcher = request.getRequestDispatcher("/accessdeny");
|
||||
* dispatcher.forward(request, response); return false; } }
|
||||
*/
|
||||
return hasAccess;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
package org.maxkey.web.interceptor;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.maxkey.domain.UserInfo;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.maxkey.web.WebContext;
|
||||
@ -11,36 +9,41 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
|
||||
public class PreLoginAppAdapter extends HandlerInterceptorAdapter {
|
||||
|
||||
|
||||
private static final Logger _logger = LoggerFactory.getLogger(PreLoginAppAdapter.class);
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request,HttpServletResponse response, Object handler) throws Exception {
|
||||
public boolean preHandle(HttpServletRequest request,
|
||||
HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
_logger.debug("preHandle");
|
||||
UserInfo userInfo = WebContext.getUserInfo();
|
||||
String redirect_uri = request.getRequestURL().toString();
|
||||
String appId=getAppIdFromRequestURI(request);
|
||||
String appId = getAppIdFromRequestUrl(request);
|
||||
_logger.debug("preHandle app Id " + appId);
|
||||
Object singlesignon_uri = WebContext.getAttribute(WebConstants.CURRENT_SINGLESIGNON_URI);
|
||||
if (singlesignon_uri != null && singlesignon_uri.equals(redirect_uri)) {
|
||||
return true;
|
||||
}
|
||||
/*if(userInfo.getProtectedAppsMap().get(appId)!=null){
|
||||
|
||||
request.setAttribute("redirect_uri",redirect_uri);
|
||||
_logger.debug(""+redirect_uri);
|
||||
RequestDispatcher dispatcher = request.getRequestDispatcher("/authorize/protected/forward");
|
||||
dispatcher.forward(request, response);
|
||||
return false;
|
||||
}*/
|
||||
/*
|
||||
* if(userInfo.getProtectedAppsMap().get(appId)!=null){
|
||||
*
|
||||
* request.setAttribute("redirect_uri",redirect_uri);
|
||||
* _logger.debug(""+redirect_uri); RequestDispatcher dispatcher =
|
||||
* request.getRequestDispatcher("/authorize/protected/forward");
|
||||
* dispatcher.forward(request, response); return false; }
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getAppIdFromRequestURI(HttpServletRequest request){
|
||||
/**
|
||||
* Request URL .
|
||||
* @param request http
|
||||
* @return .
|
||||
*/
|
||||
public static String getAppIdFromRequestUrl(HttpServletRequest request) {
|
||||
String[] uri = request.getRequestURI().split("/");
|
||||
String appId = uri[uri.length - 1];
|
||||
return appId;
|
||||
|
||||
324
style/checkstyle-rules.xml
Normal file
324
style/checkstyle-rules.xml
Normal file
@ -0,0 +1,324 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
|
||||
<!--
|
||||
Checkstyle configuration that checks the Google coding conventions from Google Java Style
|
||||
that can be found at https://google.github.io/styleguide/javaguide.html
|
||||
Checkstyle is very configurable. Be sure to read the documentation at
|
||||
http://checkstyle.org (or in your downloaded distribution).
|
||||
To completely disable a check, just comment it out or delete it from the file.
|
||||
To suppress certain violations please review suppression filters.
|
||||
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
|
||||
-->
|
||||
|
||||
<module name = "Checker">
|
||||
<property name="charset" value="UTF-8"/>
|
||||
|
||||
<property name="severity" value="warning"/>
|
||||
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
<!-- Excludes all 'module-info.java' files -->
|
||||
<!-- See https://checkstyle.org/config_filefilters.html -->
|
||||
<module name="BeforeExecutionExclusionFileFilter">
|
||||
<property name="fileNamePattern" value="module\-info\.java$"/>
|
||||
</module>
|
||||
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
|
||||
<module name="SuppressionFilter">
|
||||
<property name="file" value="${org.checkstyle.google.suppressionfilter.config}"
|
||||
default="checkstyle-suppressions.xml" />
|
||||
<property name="optional" value="true"/>
|
||||
</module>
|
||||
|
||||
<!-- Checks for whitespace -->
|
||||
<!-- See http://checkstyle.org/config_whitespace.html -->
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
|
||||
<module name="LineLength">
|
||||
<property name="fileExtensions" value="java"/>
|
||||
<property name="max" value="100"/>
|
||||
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="IllegalTokenText">
|
||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||
<property name="format"
|
||||
value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||
<property name="message"
|
||||
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
|
||||
</module>
|
||||
<module name="AvoidEscapedUnicodeCharacters">
|
||||
<property name="allowEscapesForControlCharacters" value="true"/>
|
||||
<property name="allowByTailComment" value="true"/>
|
||||
<property name="allowNonPrintableEscapes" value="true"/>
|
||||
</module>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="OneTopLevelClass"/>
|
||||
<module name="NoLineWrap">
|
||||
<property name="tokens" value="PACKAGE_DEF, IMPORT, STATIC_IMPORT"/>
|
||||
</module>
|
||||
<module name="EmptyBlock">
|
||||
<property name="option" value="TEXT"/>
|
||||
<property name="tokens"
|
||||
value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
|
||||
</module>
|
||||
<module name="NeedBraces">
|
||||
<property name="tokens"
|
||||
value="LITERAL_DO, LITERAL_ELSE, LITERAL_FOR, LITERAL_IF, LITERAL_WHILE"/>
|
||||
</module>
|
||||
<module name="LeftCurly">
|
||||
<property name="tokens"
|
||||
value="ANNOTATION_DEF, CLASS_DEF, CTOR_DEF, ENUM_CONSTANT_DEF, ENUM_DEF,
|
||||
INTERFACE_DEF, LAMBDA, LITERAL_CASE, LITERAL_CATCH, LITERAL_DEFAULT,
|
||||
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF,
|
||||
LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, METHOD_DEF,
|
||||
OBJBLOCK, STATIC_INIT"/>
|
||||
</module>
|
||||
<module name="RightCurly">
|
||||
<property name="id" value="RightCurlySame"/>
|
||||
<property name="tokens"
|
||||
value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE,
|
||||
LITERAL_DO"/>
|
||||
</module>
|
||||
<module name="RightCurly">
|
||||
<property name="id" value="RightCurlyAlone"/>
|
||||
<property name="option" value="alone"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT,
|
||||
INSTANCE_INIT, ANNOTATION_DEF, ENUM_DEF"/>
|
||||
</module>
|
||||
<module name="SuppressionXpathSingleFilter">
|
||||
<!-- suppresion is required till https://github.com/checkstyle/checkstyle/issues/7541 -->
|
||||
<property name="id" value="RightCurlyAlone"/>
|
||||
<property name="query" value="//RCURLY[parent::SLIST[count(./*)=1]
|
||||
or preceding-sibling::*[last()][self::LCURLY]]"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="allowEmptyConstructors" value="true"/>
|
||||
<property name="allowEmptyLambdas" value="true"/>
|
||||
<property name="allowEmptyMethods" value="true"/>
|
||||
<property name="allowEmptyTypes" value="true"/>
|
||||
<property name="allowEmptyLoops" value="true"/>
|
||||
<property name="tokens"
|
||||
value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR,
|
||||
BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, DO_WHILE, EQUAL, GE, GT, LAMBDA, LAND,
|
||||
LCURLY, LE, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY,
|
||||
LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SWITCH, LITERAL_SYNCHRONIZED,
|
||||
LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN,
|
||||
NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR,
|
||||
SR_ASSIGN, STAR, STAR_ASSIGN, LITERAL_ASSERT, TYPE_EXTENSION_AND"/>
|
||||
<message key="ws.notFollowed"
|
||||
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
|
||||
<message key="ws.notPreceded"
|
||||
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
||||
</module>
|
||||
<module name="OneStatementPerLine"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="FallThrough"/>
|
||||
<module name="UpperEll"/>
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="tokens"
|
||||
value="PACKAGE_DEF, IMPORT, STATIC_IMPORT, CLASS_DEF, INTERFACE_DEF, ENUM_DEF,
|
||||
STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="id" value="SeparatorWrapDot"/>
|
||||
<property name="tokens" value="DOT"/>
|
||||
<property name="option" value="nl"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="id" value="SeparatorWrapComma"/>
|
||||
<property name="tokens" value="COMMA"/>
|
||||
<property name="option" value="EOL"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<!-- ELLIPSIS is EOL until https://github.com/google/styleguide/issues/258 -->
|
||||
<property name="id" value="SeparatorWrapEllipsis"/>
|
||||
<property name="tokens" value="ELLIPSIS"/>
|
||||
<property name="option" value="EOL"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<!-- ARRAY_DECLARATOR is EOL until https://github.com/google/styleguide/issues/259 -->
|
||||
<property name="id" value="SeparatorWrapArrayDeclarator"/>
|
||||
<property name="tokens" value="ARRAY_DECLARATOR"/>
|
||||
<property name="option" value="EOL"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="id" value="SeparatorWrapMethodRef"/>
|
||||
<property name="tokens" value="METHOD_REF"/>
|
||||
<property name="option" value="nl"/>
|
||||
</module>
|
||||
<module name="PackageName">
|
||||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Package name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="TypeName">
|
||||
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ParameterName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LambdaParameterName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Lambda parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="CatchParameterName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LocalVariableName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ClassTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MethodTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="InterfaceTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="NoFinalizer"/>
|
||||
<module name="GenericWhitespace">
|
||||
<message key="ws.followed"
|
||||
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
|
||||
<message key="ws.preceded"
|
||||
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
|
||||
<message key="ws.illegalFollow"
|
||||
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
|
||||
<message key="ws.notPreceded"
|
||||
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||
</module>
|
||||
<module name="Indentation">
|
||||
<property name="basicOffset" value="4"/>
|
||||
<property name="braceAdjustment" value="0"/>
|
||||
<property name="caseIndent" value="4"/>
|
||||
<property name="throwsIndent" value="8"/>
|
||||
<property name="lineWrappingIndentation" value="8"/>
|
||||
<property name="arrayInitIndent" value="4"/>
|
||||
</module>
|
||||
<module name="AbbreviationAsWordInName">
|
||||
<property name="ignoreFinal" value="false"/>
|
||||
<property name="allowedAbbreviationLength" value="1"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF,
|
||||
PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF"/>
|
||||
</module>
|
||||
<module name="OverloadMethodsDeclarationOrder"/>
|
||||
<module name="VariableDeclarationUsageDistance"/>
|
||||
<module name="CustomImportOrder">
|
||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||
<property name="separateLineBetweenGroups" value="true"/>
|
||||
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
|
||||
<property name="tokens" value="IMPORT, STATIC_IMPORT, PACKAGE_DEF"/>
|
||||
</module>
|
||||
<module name="MethodParamPad">
|
||||
<property name="tokens"
|
||||
value="CTOR_DEF, LITERAL_NEW, METHOD_CALL, METHOD_DEF,
|
||||
SUPER_CTOR_CALL, ENUM_CONSTANT_DEF"/>
|
||||
</module>
|
||||
<module name="NoWhitespaceBefore">
|
||||
<property name="tokens"
|
||||
value="COMMA, SEMI, POST_INC, POST_DEC, DOT, ELLIPSIS, METHOD_REF"/>
|
||||
<property name="allowLineBreaks" value="true"/>
|
||||
</module>
|
||||
<module name="ParenPad">
|
||||
<property name="tokens"
|
||||
value="ANNOTATION, ANNOTATION_FIELD_DEF, CTOR_CALL, CTOR_DEF, DOT, ENUM_CONSTANT_DEF,
|
||||
EXPR, LITERAL_CATCH, LITERAL_DO, LITERAL_FOR, LITERAL_IF, LITERAL_NEW,
|
||||
LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_WHILE, METHOD_CALL,
|
||||
METHOD_DEF, QUESTION, RESOURCE_SPECIFICATION, SUPER_CTOR_CALL, LAMBDA"/>
|
||||
</module>
|
||||
<module name="OperatorWrap">
|
||||
<property name="option" value="NL"/>
|
||||
<property name="tokens"
|
||||
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR,
|
||||
LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR, METHOD_REF "/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="id" value="AnnotationLocationMostCases"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="id" value="AnnotationLocationVariables"/>
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
||||
</module>
|
||||
<module name="NonEmptyAtclauseDescription"/>
|
||||
<module name="InvalidJavadocPosition"/>
|
||||
<module name="JavadocTagContinuationIndentation"/>
|
||||
<module name="SummaryJavadoc">
|
||||
<property name="forbiddenSummaryFragments"
|
||||
value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
|
||||
</module>
|
||||
<module name="JavadocParagraph"/>
|
||||
<module name="AtclauseOrder">
|
||||
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
|
||||
<property name="target"
|
||||
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
|
||||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<property name="scope" value="public"/>
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
<property name="allowedAnnotations" value="Override, Test"/>
|
||||
<property name="tokens" value="METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF"/>
|
||||
</module>
|
||||
<module name="MissingJavadocMethod">
|
||||
<property name="scope" value="public"/>
|
||||
<property name="minLineCount" value="2"/>
|
||||
<property name="allowedAnnotations" value="Override, Test"/>
|
||||
<property name="tokens" value="METHOD_DEF, CTOR_DEF, ANNOTATION_FIELD_DEF"/>
|
||||
</module>
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Method name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="SingleLineJavadoc">
|
||||
<property name="ignoreInlineTags" value="false"/>
|
||||
</module>
|
||||
<module name="EmptyCatchBlock">
|
||||
<property name="exceptionVariableName" value="expected"/>
|
||||
</module>
|
||||
<module name="CommentsIndentation">
|
||||
<property name="tokens" value="SINGLE_LINE_COMMENT, BLOCK_COMMENT_BEGIN"/>
|
||||
</module>
|
||||
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
|
||||
<module name="SuppressionXpathFilter">
|
||||
<property name="file" value="${org.checkstyle.google.suppressionxpathfilter.config}"
|
||||
default="checkstyle-xpath-suppressions.xml" />
|
||||
<property name="optional" value="true"/>
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
||||
Loading…
x
Reference in New Issue
Block a user