fengxiang
2018-02-02 4690a0958f00d096858c44d58a892fa48e12feaf
安全跨域设置
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,6 +43,11 @@
            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,7 +53,6 @@
        response.setStatus(HttpStatus.OK.value());
        response.setContentType(MediaType.APPLICATION_JSON_VALUE);
        mapper.writeValue(response.getWriter(), tokenMap);
        clearAuthenticationAttributes(request);
    }