|
@@ -32,18 +32,18 @@ import static cn.com.qmth.examcloud.app.model.Constants.PLATFORM_SESSION_EXPIRE_
|
|
*/
|
|
*/
|
|
public class TokenFilter implements Filter {
|
|
public class TokenFilter implements Filter {
|
|
|
|
|
|
- private final static Logger log = LoggerFactory.getLogger(TokenFilter.class);
|
|
|
|
|
|
+ private static final Logger LOG = LoggerFactory.getLogger(TokenFilter.class);
|
|
|
|
|
|
private CoreAuthService authService;
|
|
private CoreAuthService authService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void init(FilterConfig filterConfig) throws ServletException {
|
|
public void init(FilterConfig filterConfig) throws ServletException {
|
|
- log.debug("init");
|
|
|
|
|
|
+ LOG.debug("init");
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void destroy() {
|
|
public void destroy() {
|
|
- log.debug("destroy");
|
|
|
|
|
|
+ LOG.debug("destroy");
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -99,7 +99,7 @@ public class TokenFilter implements Filter {
|
|
}
|
|
}
|
|
|
|
|
|
boolean isOpen = authService.isOpenApp(rootOrgId);
|
|
boolean isOpen = authService.isOpenApp(rootOrgId);
|
|
- log.info("[Check Open APP] Result is " + isOpen);
|
|
|
|
|
|
+ LOG.info("[Check Open APP] Result is " + isOpen);
|
|
if (!isOpen) {
|
|
if (!isOpen) {
|
|
reqContinue.yes = false;
|
|
reqContinue.yes = false;
|
|
this.renderError(response, new Result().error("当前学校尚未开放APP功能!").toString());
|
|
this.renderError(response, new Result().error("当前学校尚未开放APP功能!").toString());
|
|
@@ -107,7 +107,7 @@ public class TokenFilter implements Filter {
|
|
}
|
|
}
|
|
|
|
|
|
boolean isDoing = authService.isDoingExam(rootOrgId, accountType, account);
|
|
boolean isDoing = authService.isDoingExam(rootOrgId, accountType, account);
|
|
- log.info("[Check Doing Exam] Result is " + isDoing);
|
|
|
|
|
|
+ LOG.info("[Check Doing Exam] Result is " + isDoing);
|
|
if (isDoing) {
|
|
if (isDoing) {
|
|
reqContinue.yes = false;
|
|
reqContinue.yes = false;
|
|
this.renderError(response, new Result().error("尚在考试中不允许登录!").toString());
|
|
this.renderError(response, new Result().error("尚在考试中不允许登录!").toString());
|
|
@@ -141,12 +141,12 @@ public class TokenFilter implements Filter {
|
|
if (!isAllow) {
|
|
if (!isAllow) {
|
|
if (loginInfo.hasExpired(PLATFORM_SESSION_EXPIRE_TIME)) {
|
|
if (loginInfo.hasExpired(PLATFORM_SESSION_EXPIRE_TIME)) {
|
|
if (StringUtils.isBlank(loginInfo.getPassword())) {
|
|
if (StringUtils.isBlank(loginInfo.getPassword())) {
|
|
- log.info("Can't reLogin, no password.");
|
|
|
|
|
|
+ LOG.info("Can't reLogin, no password.");
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
boolean isDoing = authService.isDoingExam(loginInfo.getRootOrgId(), loginInfo.getAccountType(), loginInfo.getAccount());
|
|
boolean isDoing = authService.isDoingExam(loginInfo.getRootOrgId(), loginInfo.getAccountType(), loginInfo.getAccount());
|
|
- log.info("[Check Doing Exam] result is " + isDoing);
|
|
|
|
|
|
+ LOG.info("[Check Doing Exam] result is " + isDoing);
|
|
if (isDoing) {
|
|
if (isDoing) {
|
|
reqContinue.yes = false;
|
|
reqContinue.yes = false;
|
|
this.renderError(response, new Result().error("尚在考试中不允许登录!").toString());
|
|
this.renderError(response, new Result().error("尚在考试中不允许登录!").toString());
|
|
@@ -200,17 +200,17 @@ public class TokenFilter implements Filter {
|
|
Result<UserInfo> result = authService.login(loginInfo);
|
|
Result<UserInfo> result = authService.login(loginInfo);
|
|
UserInfo userInfo = result.getData();
|
|
UserInfo userInfo = result.getData();
|
|
if (userInfo == null) {
|
|
if (userInfo == null) {
|
|
- log.debug("reLogin failed,Maybe user's password has changed.");
|
|
|
|
|
|
+ LOG.debug("reLogin failed,Maybe user's password has changed.");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
//登录成功后缓存新的Token信息
|
|
//登录成功后缓存新的Token信息
|
|
- log.info(String.format("key:%s newToken:%s", userInfo.getKey(), userInfo.getToken()));
|
|
|
|
|
|
+ LOG.info(String.format("key:%s newToken:%s", userInfo.getKey(), userInfo.getToken()));
|
|
loginInfo.setUserName(userInfo.getDisplayName());
|
|
loginInfo.setUserName(userInfo.getDisplayName());
|
|
loginInfo.setToken(userInfo.getToken());
|
|
loginInfo.setToken(userInfo.getToken());
|
|
loginInfo.setCreateTime(new Date());
|
|
loginInfo.setCreateTime(new Date());
|
|
authService.cacheLoginInfo(loginInfo, userInfo.getKey());
|
|
authService.cacheLoginInfo(loginInfo, userInfo.getKey());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error(e.getMessage());
|
|
|
|
|
|
+ LOG.error(e.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -235,7 +235,7 @@ public class TokenFilter implements Filter {
|
|
out = response.getWriter();
|
|
out = response.getWriter();
|
|
out.print(json);
|
|
out.print(json);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
- log.error(e.getMessage(), e);
|
|
|
|
|
|
+ LOG.error(e.getMessage(), e);
|
|
} finally {
|
|
} finally {
|
|
if (out != null) {
|
|
if (out != null) {
|
|
out.close();
|
|
out.close();
|