use of com.tony.billing.filters.wapper.TokenServletRequestWrapper in project BillingDubbo by TonyJiangWJ.
the class XssTokenizeFilter method doFilterInternal.
@Override
protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
TokenServletRequestWrapper request;
if (StringUtils.equals(httpServletRequest.getContentType(), MULTIPART_CONTENT)) {
request = new TokenServletRequestWrapperWithFile(new CommonsMultipartResolver().resolveMultipart(httpServletRequest));
} else {
request = new TokenServletRequestWrapper(httpServletRequest);
}
filterChain.doFilter(request, httpServletResponse);
}
use of com.tony.billing.filters.wapper.TokenServletRequestWrapper in project BillingDubbo by TonyJiangWJ.
the class AuthorityInterceptor method isUserLogin.
private boolean isUserLogin(HttpServletRequest request) throws Exception {
Cookie tokenCok = CookieUtil.getCookie(CommonConstants.COOKIE_TOKEN, request);
if (tokenCok != null) {
String tokenId = authUtil.getUserTokenId(tokenCok.getValue());
Optional<Admin> store = redisUtils.get(tokenId, Admin.class);
if (store.isPresent()) {
Admin admin = store.get();
UserIdContainer.setUserId(admin.getId());
if (request instanceof TokenServletRequestWrapper) {
((TokenServletRequestWrapper) request).addParameter(CommonConstants.PARAM_TOKEN_ID, tokenId);
((TokenServletRequestWrapper) request).addParameter(CommonConstants.PARAM_USER_ID, String.valueOf(admin.getId()));
} else if (request instanceof StandardMultipartHttpServletRequest) {
((TokenServletRequestWrapper) ((StandardMultipartHttpServletRequest) request).getRequest()).addParameter("tokenId", tokenId);
((TokenServletRequestWrapper) ((StandardMultipartHttpServletRequest) request).getRequest()).addParameter("userId", String.valueOf(admin.getId()));
}
redisUtils.set(tokenId, admin, 3600 * 24);
return true;
} else {
logger.error("用户未登录:tokenId[{}]", tokenId);
}
}
return false;
}
Aggregations