mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-23 16:58:10 +08:00
日志优化
This commit is contained in:
@@ -38,13 +38,13 @@ import jakarta.servlet.ServletException;
|
||||
@EnableDiscoveryClient
|
||||
@MapperScan("org.dromara.maxkey.persistence.mapper,")
|
||||
public class MaxKeyApplication extends SpringBootServletInitializer {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(MaxKeyApplication.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(MaxKeyApplication.class);
|
||||
|
||||
/**
|
||||
* @param args start parameter
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
_logger.info("Start MaxKey Application ...");
|
||||
logger.info("Start MaxKey Application ...");
|
||||
|
||||
VFS.addImplClass(SpringBootVFS.class);
|
||||
ConfigurableApplicationContext applicationContext =
|
||||
@@ -53,12 +53,12 @@ public class MaxKeyApplication extends SpringBootServletInitializer {
|
||||
try {
|
||||
initWebContext.init(null);
|
||||
} catch (ServletException e) {
|
||||
_logger.error("ServletException", e);
|
||||
logger.error("ServletException", e);
|
||||
}
|
||||
_logger.info("MaxKey at {}" , new DateTime());
|
||||
_logger.info("MaxKey Server Port {}"
|
||||
logger.info("MaxKey at {}" , new DateTime());
|
||||
logger.info("MaxKey Server Port {}"
|
||||
,applicationContext.getBean(ApplicationConfig.class).getPort());
|
||||
_logger.info("MaxKey started.");
|
||||
logger.info("MaxKey started.");
|
||||
}
|
||||
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
|
||||
@@ -74,7 +74,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
"org.maxkey.authz.token.endpoint"
|
||||
})
|
||||
public class MaxKeyConfig implements InitializingBean {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(MaxKeyConfig.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(MaxKeyConfig.class);
|
||||
|
||||
|
||||
@Bean
|
||||
@@ -91,7 +91,7 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
int period) {
|
||||
|
||||
OtpKeyUriFormat otpKeyUriFormat=new OtpKeyUriFormat(type,issuer,domain,digits,period);
|
||||
_logger.debug("OTP KeyUri Format " + otpKeyUriFormat);
|
||||
logger.debug("OTP KeyUri Format {}" , otpKeyUriFormat);
|
||||
return otpKeyUriFormat;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
MailOtpAuthnService otpAuthnService,
|
||||
LdapContextService ldapContextService) {
|
||||
LdapAuthenticationRealmService ldapRealmService = new LdapAuthenticationRealmService(ldapContextService);
|
||||
JdbcAuthenticationRealm authenticationRealm = new JdbcAuthenticationRealm(
|
||||
return new JdbcAuthenticationRealm(
|
||||
passwordEncoder,
|
||||
passwordPolicyValidator,
|
||||
loginService,
|
||||
@@ -116,8 +116,6 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
jdbcTemplate,
|
||||
ldapRealmService
|
||||
);
|
||||
|
||||
return authenticationRealm;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -127,7 +125,7 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
@Value("${maxkey.otp.policy.period:30}")
|
||||
int period) {
|
||||
TimeBasedOtpAuthn tfaOtpAuthn = new TimeBasedOtpAuthn(digits , period);
|
||||
_logger.debug("TimeBasedOtpAuthn inited.");
|
||||
logger.debug("TimeBasedOtpAuthn inited.");
|
||||
return tfaOtpAuthn;
|
||||
}
|
||||
|
||||
@@ -141,7 +139,7 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
@Value("${maxkey.server.persistence}") int persistence,
|
||||
RedisConnectionFactory redisConnFactory) {
|
||||
AbstractOtpAuthn tfaOtpAuthn = new TimeBasedOtpAuthn(digits , period);
|
||||
_logger.debug("TimeBasedOtpAuthn inited.");
|
||||
logger.debug("TimeBasedOtpAuthn inited.");
|
||||
|
||||
if (persistence == ConstsPersistence.REDIS) {
|
||||
RedisOtpTokenStore redisOptTokenStore = new RedisOtpTokenStore(redisConnFactory);
|
||||
@@ -171,16 +169,16 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
messageTemplate = bufferedReader.lines().collect(Collectors.joining("\n"));
|
||||
bufferedReader.close();
|
||||
} catch (IOException e) {
|
||||
_logger.error("mailOtpAuthn IOException ",e);
|
||||
logger.error("mailOtpAuthn IOException ",e);
|
||||
}
|
||||
}
|
||||
_logger.trace("messageTemplate \n" +messageTemplate);
|
||||
logger.trace("messageTemplate \n {}" ,messageTemplate);
|
||||
MailOtpAuthn mailOtpAuthn = new MailOtpAuthn();
|
||||
mailOtpAuthn.setSubject(messageSubject);
|
||||
mailOtpAuthn.setMessageTemplate(messageTemplate);
|
||||
mailOtpAuthn.setEmailConfig(emailConfig);
|
||||
mailOtpAuthn.setInterval(messageValidity);
|
||||
_logger.debug("MailOtpAuthn inited.");
|
||||
logger.debug("MailOtpAuthn inited.");
|
||||
return mailOtpAuthn;
|
||||
}
|
||||
|
||||
@@ -204,11 +202,11 @@ public class MaxKeyConfig implements InitializingBean {
|
||||
kerberosProxy.setUserdomain(userDomain);
|
||||
kerberosProxy.setRedirectUri(redirectUri);
|
||||
|
||||
List<KerberosProxy> kerberosProxysList = new ArrayList<KerberosProxy>();
|
||||
List<KerberosProxy> kerberosProxysList = new ArrayList<>();
|
||||
kerberosProxysList.add(kerberosProxy);
|
||||
kerberosService.setKerberosProxys(kerberosProxysList);
|
||||
|
||||
_logger.debug("RemoteKerberosService inited.");
|
||||
logger.debug("RemoteKerberosService inited.");
|
||||
return kerberosService;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
@EnableWebMvc
|
||||
@AutoConfiguration
|
||||
public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(MaxKeyMvcConfig.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(MaxKeyMvcConfig.class);
|
||||
|
||||
@Value("${maxkey.login.basic.enable:false}")
|
||||
private boolean basicEnable;
|
||||
@@ -75,27 +75,27 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
_logger.debug("add Resource Handlers");
|
||||
_logger.debug("add statics");
|
||||
logger.debug("add Resource Handlers");
|
||||
logger.debug("add statics");
|
||||
registry.addResourceHandler("/static/**")
|
||||
.addResourceLocations("classpath:/static/");
|
||||
|
||||
_logger.debug("add templates");
|
||||
logger.debug("add templates");
|
||||
registry.addResourceHandler("/templates/**")
|
||||
.addResourceLocations("classpath:/templates/");
|
||||
|
||||
_logger.debug("add swagger");
|
||||
logger.debug("add swagger");
|
||||
registry.addResourceHandler("swagger-ui.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
|
||||
_logger.debug("add knife4j");
|
||||
logger.debug("add knife4j");
|
||||
registry.addResourceHandler("doc.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
|
||||
_logger.debug("add Resource Handler finished .");
|
||||
logger.debug("add Resource Handler finished .");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,7 +103,7 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
//addPathPatterns 用于添加拦截规则 , 先把所有路径都加入拦截, 再一个个排除
|
||||
//excludePathPatterns 表示改路径不用拦截
|
||||
|
||||
_logger.debug("add Http Kerberos Entry Point");
|
||||
logger.debug("add Http Kerberos Entry Point");
|
||||
registry.addInterceptor(new HttpKerberosEntryPoint(
|
||||
authenticationProvider,kerberosService,applicationConfig,true))
|
||||
.addPathPatterns("/login");
|
||||
@@ -112,13 +112,13 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
if(httpHeaderEnable) {
|
||||
registry.addInterceptor(new HttpHeaderEntryPoint(httpHeaderName,httpHeaderEnable))
|
||||
.addPathPatterns("/*");
|
||||
_logger.debug("add Http Header Entry Point");
|
||||
logger.debug("add Http Header Entry Point");
|
||||
}
|
||||
|
||||
if(basicEnable) {
|
||||
registry.addInterceptor(new BasicEntryPoint(basicEnable))
|
||||
.addPathPatterns("/*");
|
||||
_logger.debug("add Basic Entry Point");
|
||||
logger.debug("add Basic Entry Point");
|
||||
}
|
||||
|
||||
//for frontend
|
||||
@@ -139,7 +139,7 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
.addPathPatterns("/authz/refused")
|
||||
;
|
||||
|
||||
_logger.debug("add Permission Interceptor");
|
||||
logger.debug("add Permission Interceptor");
|
||||
|
||||
//for Single Sign On
|
||||
registry.addInterceptor(singleSignOnInterceptor)
|
||||
@@ -186,7 +186,7 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
.excludePathPatterns("/onlineticket/ticketValidate")
|
||||
.excludePathPatterns("/onlineticket/ticketValidate/*")
|
||||
;
|
||||
_logger.debug("add Single SignOn Interceptor");
|
||||
logger.debug("add Single SignOn Interceptor");
|
||||
|
||||
registry.addInterceptor(historySignOnAppInterceptor)
|
||||
.addPathPatterns("/authz/basic/*")
|
||||
@@ -207,7 +207,7 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
//OAuth
|
||||
.addPathPatterns("/authz/oauth/v20/approval_confirm")
|
||||
;
|
||||
_logger.debug("add history SignOn App Interceptor");
|
||||
logger.debug("add history SignOn App Interceptor");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Controller
|
||||
@RequestMapping(value = { "/access/session" })
|
||||
public class LoginSessionController {
|
||||
static final Logger _logger = LoggerFactory.getLogger(LoginSessionController.class);
|
||||
static final Logger logger = LoggerFactory.getLogger(LoginSessionController.class);
|
||||
|
||||
@Autowired
|
||||
HistoryLoginService historyLoginService;
|
||||
@@ -70,7 +70,7 @@ public class LoginSessionController {
|
||||
public ResponseEntity<?> fetch(
|
||||
@ModelAttribute("historyLogin") HistoryLogin historyLogin,
|
||||
@CurrentUser UserInfo currentUser) {
|
||||
_logger.debug("history/session/fetch {}" , historyLogin);
|
||||
logger.debug("history/session/fetch {}" , historyLogin);
|
||||
historyLogin.setUserId(currentUser.getId());
|
||||
historyLogin.setInstId(currentUser.getInstId());
|
||||
return new Message<JpaPageResults<HistoryLogin>>(
|
||||
@@ -81,11 +81,11 @@ public class LoginSessionController {
|
||||
@ResponseBody
|
||||
@RequestMapping(value="/terminate")
|
||||
public ResponseEntity<?> terminate(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
|
||||
_logger.debug(ids);
|
||||
logger.debug(ids);
|
||||
boolean isTerminated = false;
|
||||
try {
|
||||
for(String sessionId : StringUtils.string2List(ids, ",")) {
|
||||
_logger.trace("terminate session Id {} ",sessionId);
|
||||
logger.trace("terminate session Id {} ",sessionId);
|
||||
if(currentUser.getSessionId().contains(sessionId)) {
|
||||
continue;//skip current session
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class LoginSessionController {
|
||||
}
|
||||
isTerminated = true;
|
||||
}catch(Exception e) {
|
||||
_logger.debug("terminate Exception .",e);
|
||||
logger.debug("terminate Exception .",e);
|
||||
}
|
||||
|
||||
if(isTerminated) {
|
||||
|
||||
@@ -50,7 +50,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
*/
|
||||
@Controller
|
||||
public class AppListController {
|
||||
static final Logger _logger = LoggerFactory.getLogger(AppListController.class);
|
||||
static final Logger logger = LoggerFactory.getLogger(AppListController.class);
|
||||
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Controller
|
||||
@RequestMapping(value={"/config"})
|
||||
public class ChangePasswodController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(ChangePasswodController.class);
|
||||
static final Logger logger = LoggerFactory.getLogger(ChangePasswodController.class);
|
||||
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
@@ -84,7 +84,7 @@ public class ChangePasswodController {
|
||||
return new Message<ChangePassword>().buildResponse();
|
||||
}else {
|
||||
String message = (String) WebContext.getAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT);
|
||||
_logger.info("-message:",message);
|
||||
logger.info("-message:",message);
|
||||
return new Message<ChangePassword>(Message.ERROR,message).buildResponse();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Controller
|
||||
@RequestMapping(value = { "/forgotpassword" })
|
||||
public class ForgotPasswordContorller {
|
||||
private static Logger _logger = LoggerFactory.getLogger(ForgotPasswordContorller.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(ForgotPasswordContorller.class);
|
||||
|
||||
Pattern emailRegex = Pattern.compile(
|
||||
"^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$");
|
||||
@@ -102,8 +102,8 @@ public class ForgotPasswordContorller {
|
||||
@RequestParam String state,
|
||||
@RequestParam String captcha,
|
||||
@RequestParam String otpCaptcha) {
|
||||
_logger.debug("forgotpassword /forgotpassword/validateCaptcha.");
|
||||
_logger.debug(" userId {}: " ,userId);
|
||||
logger.debug("forgotpassword /forgotpassword/validateCaptcha.");
|
||||
logger.debug(" userId {}: " ,userId);
|
||||
UserInfo userInfo = userInfoService.get(userId);
|
||||
if(userInfo != null) {
|
||||
AbstractOtpAuthn smsOtpAuthn = smsOtpAuthnService.getByInstId(userInfo.getInstId());
|
||||
@@ -122,15 +122,15 @@ public class ForgotPasswordContorller {
|
||||
@RequestParam String mobile,
|
||||
@RequestParam String state,
|
||||
@RequestParam String captcha) {
|
||||
_logger.debug("forgotpassword /forgotpassword/produceOtp.");
|
||||
_logger.debug(" Mobile {}: " ,mobile);
|
||||
logger.debug("forgotpassword /forgotpassword/produceOtp.");
|
||||
logger.debug(" Mobile {}: " ,mobile);
|
||||
if (!authTokenService.validateCaptcha(state,captcha)) {
|
||||
_logger.debug("login captcha valid error.");
|
||||
logger.debug("login captcha valid error.");
|
||||
return new Message<ChangePassword>(Message.FAIL).buildResponse();
|
||||
}
|
||||
|
||||
ChangePassword change = null;
|
||||
_logger.debug("Mobile Regex matches {}",mobileRegex.matcher(mobile).matches());
|
||||
logger.debug("Mobile Regex matches {}",mobileRegex.matcher(mobile).matches());
|
||||
if(StringUtils.isNotBlank(mobile) && mobileRegex.matcher(mobile).matches()) {
|
||||
UserInfo userInfo = userInfoService.findByEmailMobile(mobile);
|
||||
if(userInfo != null) {
|
||||
@@ -151,9 +151,9 @@ public class ForgotPasswordContorller {
|
||||
@RequestParam String email,
|
||||
@RequestParam String state,
|
||||
@RequestParam String captcha) {
|
||||
_logger.debug("/forgotpassword/produceEmailOtp Email {} : " , email);
|
||||
logger.debug("/forgotpassword/produceEmailOtp Email {} : " , email);
|
||||
if (!authTokenService.validateCaptcha(state,captcha)) {
|
||||
_logger.debug("captcha valid error.");
|
||||
logger.debug("captcha valid error.");
|
||||
return new Message<ChangePassword>(Message.FAIL).buildResponse();
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ public class ForgotPasswordContorller {
|
||||
@RequestParam String forgotType,
|
||||
@RequestParam String otpCaptcha,
|
||||
@RequestParam String state) {
|
||||
_logger.debug("forgotPassword /forgotpassword/setpassword.");
|
||||
logger.debug("forgotPassword /forgotpassword/setpassword.");
|
||||
if (StringUtils.isNotBlank(changePassword.getPassword() )
|
||||
&& changePassword.getPassword().equals(changePassword.getConfirmPassword())) {
|
||||
UserInfo loadedUserInfo = userInfoService.get(changePassword.getUserId());
|
||||
|
||||
@@ -31,11 +31,11 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
*/
|
||||
@Controller
|
||||
public class IndexEndpoint {
|
||||
private static Logger _logger = LoggerFactory.getLogger(IndexEndpoint.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(IndexEndpoint.class);
|
||||
|
||||
@RequestMapping(value={"/"})
|
||||
public ModelAndView index() {
|
||||
_logger.debug("IndexEndpoint /.");
|
||||
logger.debug("IndexEndpoint /.");
|
||||
return new ModelAndView("index")
|
||||
.addObject("appVersion", WebContext.properties.getProperty("application.formatted-version"));
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
@Controller
|
||||
@RequestMapping(value = "/login")
|
||||
public class LoginEntryPoint {
|
||||
private static Logger _logger = LoggerFactory.getLogger(LoginEntryPoint.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(LoginEntryPoint.class);
|
||||
|
||||
Pattern mobileRegex = Pattern.compile("^(13[4,5,6,7,8,9]|15[0,8,9,1,7]|188|187)\\\\d{8}$");
|
||||
|
||||
@@ -108,7 +108,7 @@ public class LoginEntryPoint {
|
||||
@RequestMapping(value={"/get"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
public ResponseEntity<?> get(
|
||||
@RequestParam(value = "remember_me", required = false) String rememberMeJwt) {
|
||||
_logger.debug("/get.");
|
||||
logger.debug("/get.");
|
||||
//Remember Me
|
||||
if(StringUtils.isNotBlank(rememberMeJwt)
|
||||
&& authTokenService.validateJwtToken(rememberMeJwt)) {
|
||||
@@ -129,7 +129,7 @@ public class LoginEntryPoint {
|
||||
}
|
||||
}
|
||||
//for normal login
|
||||
HashMap<String , Object> model = new HashMap<String , Object>();
|
||||
HashMap<String , Object> model = new HashMap<>();
|
||||
model.put("isRemeberMe", applicationConfig.getLoginConfig().isRemeberMe());
|
||||
model.put("isKerberos", applicationConfig.getLoginConfig().isKerberos());
|
||||
if(applicationConfig.getLoginConfig().isMfa()) {
|
||||
@@ -219,7 +219,7 @@ public class LoginEntryPoint {
|
||||
Message<AuthJwt> authJwtMessage = new Message<AuthJwt>(Message.FAIL);
|
||||
if(authTokenService.validateJwtToken(credential.getState())){
|
||||
String authType = credential.getAuthType();
|
||||
_logger.debug("Login AuthN Type " + authType);
|
||||
logger.debug("Login AuthN Type {}" , authType);
|
||||
if (StringUtils.isNotBlank(authType)){
|
||||
Authentication authentication = authenticationProvider.authenticate(credential);
|
||||
if(authentication != null) {
|
||||
@@ -238,10 +238,10 @@ public class LoginEntryPoint {
|
||||
String errorMsg = WebContext.getAttribute(WebConstants.LOGIN_ERROR_SESSION_MESSAGE) == null ?
|
||||
"" : WebContext.getAttribute(WebConstants.LOGIN_ERROR_SESSION_MESSAGE).toString();
|
||||
authJwtMessage.setMessage(errorMsg);
|
||||
_logger.debug("login fail , message {}",errorMsg);
|
||||
logger.debug("login fail , message {}",errorMsg);
|
||||
}
|
||||
}else {
|
||||
_logger.error("Login AuthN type must eq normal , tfa or mobile . ");
|
||||
logger.error("Login AuthN type must eq normal , tfa or mobile . ");
|
||||
}
|
||||
}
|
||||
return authJwtMessage.buildResponse();
|
||||
|
||||
@@ -51,7 +51,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
@Tag(name = "1-3-单点注销接口文档模块")
|
||||
@Controller
|
||||
public class LogoutEndpoint {
|
||||
private static Logger _logger = LoggerFactory.getLogger(LogoutEndpoint.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(LogoutEndpoint.class);
|
||||
|
||||
@Autowired
|
||||
ApplicationConfig applicationConfig;
|
||||
@@ -71,13 +71,13 @@ public class LogoutEndpoint {
|
||||
String sessionId = currentUser.getSessionId();
|
||||
Session session = sessionManager.get(sessionId);
|
||||
if(session != null) {
|
||||
_logger.debug("/logout frontend clean Session id {}",session.getId());
|
||||
logger.debug("/logout frontend clean Session id {}",session.getId());
|
||||
Set<Entry<String, Apps>> entrySet = session.getAuthorizedApps().entrySet();
|
||||
|
||||
Iterator<Entry<String, Apps>> iterator = entrySet.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entry<String, Apps> mapEntry = iterator.next();
|
||||
_logger.debug("App Id : "+ mapEntry.getKey()+ " , " +mapEntry.getValue());
|
||||
logger.debug("App Id : {} , {} " , mapEntry.getKey() ,mapEntry.getValue());
|
||||
if( mapEntry.getValue().getLogoutType() == LogoutType.BACK_CHANNEL){
|
||||
SingleLogout singleLogout;
|
||||
if(mapEntry.getValue().getProtocol().equalsIgnoreCase(ConstsProtocols.CAS)) {
|
||||
@@ -104,7 +104,7 @@ public class LogoutEndpoint {
|
||||
@RequestParam(value = "redirect_uri",required = false) String redirect_uri
|
||||
){
|
||||
//invalidate http session
|
||||
_logger.debug("/force/logout http Session id {}",request.getSession().getId());
|
||||
logger.debug("/force/logout http Session id {}",request.getSession().getId());
|
||||
request.getSession().invalidate();
|
||||
StringBuffer logoutUrl = new StringBuffer("");
|
||||
logoutUrl.append(applicationConfig.getFrontendUri()).append("/#/passport/logout");
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Controller
|
||||
@RequestMapping(value = { "/config" })
|
||||
public class OneTimePasswordController {
|
||||
static final Logger _logger = LoggerFactory.getLogger(OneTimePasswordController.class);
|
||||
static final Logger logger = LoggerFactory.getLogger(OneTimePasswordController.class);
|
||||
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Controller
|
||||
@RequestMapping(value = { "/config/profile" })
|
||||
public class ProfileController {
|
||||
static final Logger _logger = LoggerFactory.getLogger(ProfileController.class);
|
||||
static final Logger logger = LoggerFactory.getLogger(ProfileController.class);
|
||||
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
@@ -65,7 +65,7 @@ public class ProfileController {
|
||||
@RequestBody UserInfo userInfo,
|
||||
@CurrentUser UserInfo currentUser,
|
||||
BindingResult result) {
|
||||
_logger.debug(userInfo.toString());
|
||||
logger.debug(userInfo.toString());
|
||||
|
||||
// if(userInfo.getExtraAttributeValue()!=null){
|
||||
// String []extraAttributeLabel=userInfo.getExtraAttributeName().split(",");
|
||||
|
||||
@@ -50,7 +50,7 @@ import jakarta.servlet.ServletException;
|
||||
@Controller
|
||||
@RequestMapping(value={"/signup"})
|
||||
public class RegisterController {
|
||||
private static Logger _logger = LoggerFactory.getLogger(RegisterController.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(RegisterController.class);
|
||||
|
||||
Pattern mobileRegex = Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$");
|
||||
|
||||
@@ -73,9 +73,9 @@ public class RegisterController {
|
||||
@RequestMapping(value = { "/produceOtp" }, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
public ResponseEntity<?> produceOtp(
|
||||
@RequestParam String mobile) {
|
||||
_logger.debug("/signup/produceOtp Mobile {}: " ,mobile);
|
||||
logger.debug("/signup/produceOtp Mobile {}: " ,mobile);
|
||||
|
||||
_logger.debug("Mobile Regex matches {}",mobileRegex.matcher(mobile).matches());
|
||||
logger.debug("Mobile Regex matches {}",mobileRegex.matcher(mobile).matches());
|
||||
if(StringUtils.isNotBlank(mobile) && mobileRegex.matcher(mobile).matches()) {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setUsername(mobile);
|
||||
|
||||
@@ -40,7 +40,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
@Controller
|
||||
@RequestMapping(value={"/safe"})
|
||||
public class SafeController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(SafeController.class);
|
||||
static final Logger logger = LoggerFactory.getLogger(SafeController.class);
|
||||
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Controller
|
||||
@RequestMapping(value={"/config/socialsignon"})
|
||||
public class SocialSignOnListController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(SocialSignOnListController.class);
|
||||
static final Logger logger = LoggerFactory.getLogger(SocialSignOnListController.class);
|
||||
|
||||
@Autowired
|
||||
protected SocialsAssociatesService socialsAssociatesService;
|
||||
@@ -57,7 +57,7 @@ public class SocialSignOnListController {
|
||||
@ResponseBody
|
||||
@RequestMapping(value={"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
public ResponseEntity<?> delete(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
|
||||
_logger.debug("-delete ids : {} " , ids);
|
||||
logger.debug("-delete ids : {} " , ids);
|
||||
if (socialsAssociatesService.deleteBatch(ids)) {
|
||||
return new Message<Apps>(Message.SUCCESS).buildResponse();
|
||||
} else {
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Controller
|
||||
@RequestMapping(value={"/historys"})
|
||||
public class LoginAppsHistoryController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(LoginAppsHistoryController.class);
|
||||
static final Logger logger = LoggerFactory.getLogger(LoginAppsHistoryController.class);
|
||||
|
||||
@Autowired
|
||||
protected HistoryLoginAppsService historyLoginAppsService;
|
||||
@@ -62,7 +62,7 @@ final static Logger _logger = LoggerFactory.getLogger(LoginAppsHistoryController
|
||||
public ResponseEntity<?> fetch(
|
||||
@ModelAttribute("historyLoginApp") HistoryLoginApps historyLoginApp,
|
||||
@CurrentUser UserInfo currentUser){
|
||||
_logger.debug("historys/loginAppsHistory/fetch/ {}",historyLoginApp);
|
||||
logger.debug("historys/loginAppsHistory/fetch/ {}",historyLoginApp);
|
||||
historyLoginApp.setId(null);
|
||||
historyLoginApp.setUserId(currentUser.getId());
|
||||
historyLoginApp.setInstId(currentUser.getInstId());
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
@Controller
|
||||
@RequestMapping(value={"/historys"})
|
||||
public class LoginHistoryController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(LoginHistoryController.class);
|
||||
static final Logger logger = LoggerFactory.getLogger(LoginHistoryController.class);
|
||||
|
||||
@Autowired
|
||||
HistoryLoginService loginHistoryService;
|
||||
@@ -63,7 +63,7 @@ final static Logger _logger = LoggerFactory.getLogger(LoginHistoryController.cla
|
||||
@ModelAttribute("historyLogin") HistoryLogin historyLogin,
|
||||
@CurrentUser UserInfo currentUser
|
||||
){
|
||||
_logger.debug("historys/loginHistory/fetch/ {}",historyLogin);
|
||||
logger.debug("historys/loginHistory/fetch/ {}",historyLogin);
|
||||
historyLogin.setInstId(currentUser.getInstId());
|
||||
historyLogin.setUserId(currentUser.getId());
|
||||
return new Message<JpaPageResults<HistoryLogin>>(
|
||||
|
||||
@@ -38,7 +38,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
@Component
|
||||
public class HistorySignOnAppInterceptor implements AsyncHandlerInterceptor {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(HistorySignOnAppInterceptor.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(HistorySignOnAppInterceptor.class);
|
||||
|
||||
@Autowired
|
||||
HistoryLoginAppsService historyLoginAppsService;
|
||||
@@ -52,10 +52,11 @@ public class HistorySignOnAppInterceptor implements AsyncHandlerInterceptor {
|
||||
* javax.servlet.http.HttpServletRequest,
|
||||
* javax.servlet.http.HttpServletResponse, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
Object handler,ModelAndView modelAndView) throws Exception {
|
||||
_logger.debug("postHandle");
|
||||
logger.debug("postHandle");
|
||||
|
||||
final Apps app = (Apps)WebContext.getAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP);
|
||||
|
||||
@@ -63,7 +64,7 @@ public class HistorySignOnAppInterceptor implements AsyncHandlerInterceptor {
|
||||
if(principal != null && app !=null) {
|
||||
final UserInfo userInfo = principal.getUserInfo();
|
||||
String sessionId = principal.getSession().getId();
|
||||
_logger.debug("sessionId : " + sessionId + " ,appId : " + app.getId());
|
||||
logger.debug("sessionId : {} , appId {}" , sessionId , app.getId());
|
||||
HistoryLoginApps historyLoginApps = new HistoryLoginApps();
|
||||
historyLoginApps.setAppId(app.getId());
|
||||
historyLoginApps.setSessionId(sessionId);
|
||||
|
||||
@@ -43,7 +43,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
@Component
|
||||
public class SingleSignOnInterceptor implements AsyncHandlerInterceptor {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(SingleSignOnInterceptor.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(SingleSignOnInterceptor.class);
|
||||
|
||||
@Autowired
|
||||
ApplicationConfig applicationConfig;
|
||||
@@ -64,7 +64,7 @@ public class SingleSignOnInterceptor implements AsyncHandlerInterceptor {
|
||||
public boolean preHandle(HttpServletRequest request,
|
||||
HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
_logger.trace("Single Sign On Interceptor");
|
||||
logger.trace("Single Sign On Interceptor");
|
||||
|
||||
AuthorizationUtils.authenticateWithCookie(
|
||||
request,authTokenService,sessionManager);
|
||||
@@ -73,7 +73,7 @@ public class SingleSignOnInterceptor implements AsyncHandlerInterceptor {
|
||||
String loginUrl = applicationConfig.getFrontendUri() + "/#/passport/login?redirect_uri=%s";
|
||||
String redirect_uri = UrlUtils.buildFullRequestUrl(request);
|
||||
String base64RequestUrl = Base64Utils.base64UrlEncode(redirect_uri.getBytes());
|
||||
_logger.debug("No Authentication ... Redirect to /passport/login , redirect_uri {} , base64 {}",
|
||||
logger.debug("No Authentication ... Redirect to /passport/login , redirect_uri {} , base64 {}",
|
||||
redirect_uri ,base64RequestUrl);
|
||||
response.sendRedirect(String.format(loginUrl,base64RequestUrl));
|
||||
return false;
|
||||
@@ -81,7 +81,7 @@ public class SingleSignOnInterceptor implements AsyncHandlerInterceptor {
|
||||
|
||||
//判断应用访问权限
|
||||
if(AuthorizationUtils.isAuthenticated()){
|
||||
_logger.debug("preHandle {}",request.getRequestURI());
|
||||
logger.debug("preHandle {}",request.getRequestURI());
|
||||
Apps app = (Apps)WebContext.getAttribute(WebConstants.AUTHORIZE_SIGN_ON_APP);
|
||||
if(app == null) {
|
||||
|
||||
@@ -93,14 +93,13 @@ public class SingleSignOnInterceptor implements AsyncHandlerInterceptor {
|
||||
||requestURI.contains("/authz/api/")
|
||||
||requestURI.contains("/authz/formbased/")
|
||||
||requestURI.contains("/authz/tokenbased/")
|
||||
||requestURI.contains("/authz/api/")
|
||||
||requestURI.contains("/authz/saml20/consumer/")
|
||||
||requestURI.contains("/authz/saml20/idpinit/")
|
||||
||requestURI.contains("/authz/cas/")
|
||||
) {//for id end of URL
|
||||
String [] requestURIs = requestURI.split("/");
|
||||
String appId = requestURIs[requestURIs.length -1];
|
||||
_logger.debug("appId {}",appId);
|
||||
logger.debug("appId {}",appId);
|
||||
app = appsService.get(appId,true);
|
||||
}else if(requestURI.contains("/authz/oauth/v20/authorize")) {//oauth
|
||||
app = appsService.get(
|
||||
@@ -109,18 +108,18 @@ public class SingleSignOnInterceptor implements AsyncHandlerInterceptor {
|
||||
}
|
||||
|
||||
if(app == null) {
|
||||
_logger.debug("preHandle app is not exist . ");
|
||||
logger.debug("preHandle app is not exist . ");
|
||||
return true;
|
||||
}
|
||||
|
||||
SignPrincipal principal = AuthorizationUtils.getPrincipal();
|
||||
if(principal != null && app !=null) {
|
||||
if(principal.getGrantedAuthorityApps().contains(new SimpleGrantedAuthority(app.getId()))) {
|
||||
_logger.trace("preHandle have authority access {}" , app);
|
||||
logger.trace("preHandle have authority access {}" , app);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_logger.debug("preHandle not have authority access " + app);
|
||||
logger.debug("preHandle not have authority access {}" , app);
|
||||
response.sendRedirect(request.getContextPath()+"/authz/refused");
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user