|
|
|
@ -17,6 +17,16 @@
|
|
|
|
|
|
|
|
|
|
package cn.hippo4j.auth.filter;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.FilterChain;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import cn.hippo4j.auth.model.biz.user.JwtUser;
|
|
|
|
|
import cn.hippo4j.auth.model.biz.user.LoginUser;
|
|
|
|
|
import cn.hippo4j.auth.toolkit.JwtTokenUtil;
|
|
|
|
@ -25,6 +35,7 @@ import cn.hippo4j.common.toolkit.JSONUtil;
|
|
|
|
|
import cn.hippo4j.common.web.base.Results;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
import org.springframework.security.authentication.AuthenticationManager;
|
|
|
|
|
import org.springframework.security.authentication.BadCredentialsException;
|
|
|
|
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
|
|
@ -33,15 +44,6 @@ import org.springframework.security.core.AuthenticationException;
|
|
|
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
|
|
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.FilterChain;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import static cn.hippo4j.auth.constant.Constants.SPLIT_COMMA;
|
|
|
|
|
import static cn.hippo4j.common.constant.Constants.BASE_PATH;
|
|
|
|
|
import static cn.hippo4j.common.constant.Constants.MAP_INITIAL_CAPACITY;
|
|
|
|
@ -75,10 +77,9 @@ public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilte
|
|
|
|
|
} catch (BadCredentialsException e) {
|
|
|
|
|
log.warn("BadCredentialsException:{}", e.getMessage());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("attemptauthentication error:", e);
|
|
|
|
|
} finally {
|
|
|
|
|
return authenticate;
|
|
|
|
|
log.error("attemptAuthentication error:", e);
|
|
|
|
|
}
|
|
|
|
|
return authenticate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|