AffirmativeBased 를 생성 시 한글 변환 안 되게 해결
486
작성한 질문수 8
섹션 5. 웹 기반 인가처리 DB 연동에서 AffirmativeBased 를 생성해서 사용할 때 AccessDeniedException 발생 시 메시지가 한글로 변환되는 현상
위 질문 내용 해결한 것 같아요.
선생님.. 맞는지만 봐주세요.
스프링시큐리티가 초기화 될 때 ApplicationContextAwareProcessor 클래스의 invokeAwareInterfaces() 메소드에서 내부적으로 사용하는 AffirmativeBased 의 setMessageSource(this.applicationContext); 를 호출하네요. applicationContext는 ConfigurableApplicationContext 클래스로 선언되어 있습니다.
그래서 security/configs/SecurityConig 에서 동일하게 선언을 하고
@Autowired
ConfigurableApplicationContext applicationContext;setMessageSource() 에 전달했습니다.
private AccessDecisionManager affirmativeBased() {
AffirmativeBased affirmativeBased = new AffirmativeBased(getAccessDecisionVoters());
affirmativeBased.setMessageSource(this.applicationContext);
return affirmativeBased;
}그러니 메시지가 한글로 변환되지 않고 영문으로 잘 나오네요.
그리고 applicationContext 가 동일한 객체이냐 가 궁금해서 디버깅을 해보면 먼저 SecurityConfig에서 AffirmativeBased 생성을 먼저 시작하는데 이때 applicationContext 는 디버깅 창에서
applicationContext = {AnnotationConfigServletWebServerApplicationContext@9659} "org.springframework.boot.web.servlet.context.AnnotationConfigSevletWebServerApplicationContext@6ae4b437, ..." 이렇게 표현됩니다.
그 다음 ApplicationContextAwareProcessor 의 invokeAwareInterfaces() 가 호출되는데.
여기서 120줄 에서 break point 잡고 this.applicationContext 을 디버깅 해보면
this.applicationContext = {AnnotationConfigServletWebServerApplicationContext@9659} "org.springframework.boot.web.servlet.context.AnnotationConfigSevletWebServerApplicationContext@6ae4b437, ..." 로 동일하네요. 맞는 것 같은데..
이렇게 구현하면 되는지요?
답변 2
1
아 네
해결되어서 다행입니다
그리고 현진님께서 디버깅을 통한 해결과정이 너무 돋보입니다
결국 초기화 과정속에서 시큐리티가 어떤 설정 과정을 거치는지 파악함으로써 동일한 프로세스를 적용한 것이 정확하게 맞아떨어졌네요^^
저도 현진님과 비슷한 방식으로 해결점을 찾아나갑니다
시큐리티 공부 버전 질문
0
175
1
[해결 방법] MethodSecurityConfig.customMethodSecurityMetadataSource() 호출하지 않는 이슈
0
186
1
AbstractSecurityInterceptor.class.beforeInvocation()를 2번 실행하는 경우
0
174
1
강의 코드가 왜이렇게 뒤죽박죽인가요...
0
249
1
메인 페이지로 접속해도 login url로 리다이렉트가 되지 않습니다..
0
236
1
파라미터값이 넘어가지 않습니다 ....
0
374
1
security filterChain 설정 질문이 있습니다.
0
332
1
소스 부분 질문 드립니다.
0
208
2
섹션4 7번 강의 문제가 있는거 같네요.
0
344
2
파일이 수시로 이름이 바껴있네요 ㄷㄷ
0
304
1
HttpSessionSecurityContextRepository를 사용안하는 문제
0
555
2
error , exception 이 잘 안됩니다.
0
282
2
thymeleaf tag 질문합니다.
0
196
2
버전업하면서 deprecated된 것들이 너무많아요
0
478
1
spring security 패치 관련
0
437
1
모바일을 사용할때 토큰말고 세션
0
846
2
DB 연동한 인가 부분에 대한 질문입니다!
0
264
1
Ajax방식도 똑같이 Session방식을 사용하는건가요?
0
307
1
Config 파일 생성 시 질문이 있습니다.
0
225
1
강사님 몇일동안 구글 검색만 100개 했는데도 이유를 모르겠습니다..
1
429
2
403 에러 뜹니다.
0
813
2
login_proc의 존재에 대한 간략한 설명입니다
0
276
1
top.html에 로그인 링크를 만들어서 로그인을 해봤습니다
0
283
2
안녕하세요. DB에 저장될 때 이해 안 가는 값이 있어서 질문드립니다!
0
189
1





