fengxiang
2018-02-02 65669a27226805fc91f349512f5384729c2b5273
安全跨域设置
3 files modified
10 ■■■■■ changed files
src/main/java/com/moral/security/auth/jwt/JwtTokenAuthenticationProcessingFilter.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/security/auth/login/LoginAwareAuthenticationFailureHandler.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/security/auth/login/LoginAwareAuthenticationSuccessHandler.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/security/auth/jwt/JwtTokenAuthenticationProcessingFilter.java
@@ -43,11 +43,6 @@
            throws AuthenticationException, IOException, ServletException {
        String tokenPayload = request.getHeader(WebSecurityConfig.AUTHENTICATION_HEADER_NAME);
        RawAccessJwtToken token = new RawAccessJwtToken(tokenExtractor.extract(tokenPayload));
        try {
            throw new Exception("11111111111111111");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return getAuthenticationManager().authenticate(new JwtAuthenticationToken(token));
    }
src/main/java/com/moral/security/auth/login/LoginAwareAuthenticationFailureHandler.java
@@ -47,7 +47,7 @@
        } else if (e instanceof AuthMethodNotSupportedException) {
            mapper.writeValue(response.getWriter(), ErrorResponse.of(e.getMessage(), ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
        }
        mapper.writeValue(response.getWriter(), ErrorResponse.of("Authentication failed", ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
//        mapper.writeValue(response.getWriter(), ErrorResponse.of(e.getMessage(), ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
//        mapper.writeValue(response.getWriter(), ErrorResponse.of("Authentication failed", ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
        mapper.writeValue(response.getWriter(), ErrorResponse.of(e.getMessage(), ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED));
    }
}
src/main/java/com/moral/security/auth/login/LoginAwareAuthenticationSuccessHandler.java
@@ -53,6 +53,7 @@
        response.setStatus(HttpStatus.OK.value());
        response.setContentType(MediaType.APPLICATION_JSON_VALUE);
        mapper.writeValue(response.getWriter(), tokenMap);
        clearAuthenticationAttributes(request);
    }