Back-end 65

0. 자바의 정석 ch6(객체지향 프로그래밍)

1. 객체와 인스턴스 클래스를 인스턴스화 한 것이 인스턴스(객체)이다. 객체의 구성요소로는 속성과 기능이 있으며 여기서 속성이란 멤버 변수를 의미하고 기능이란 메서드(함수)를 의미한다. Ex). Class Tv{ String color; Boolean power; ..... void power() {power =! power;} //껐다 켰다 true, false로 변경 가능 void channelUp() ....... } 2. 인스턴스의 생성과 사용 Tv t1 = new Tv(); Tv t2 = new Tv(); t2=t1; //t1이 저장하고 있는 값(주소)을 t2에 저장하면서 참조 변수 t2가 가리키는 인스턴스는 가비지 컬렉터에 의해 자동적으로 메모리에서 제거된다. t1. color = red; /..

JSP 태그 라이브러리

스프링 MVC는 , 등 HTML 폼과 커맨드 객체를 연동하기 위한 JSP 태그 라이브러리를 제공한다. 1. -> id대신 modelAttribute 지정하면 커맨드 객체 이름 설정할 수 있다. 예를 들어 modelAttibute = "loginCommand"라는 커맨드 객체와 연결해주고 여기서 이메일, 비밀번호 꺼내와서 authInfo라는 커맨드 객체에 다시 값을 넣어준 뒤 세션을 만드는 컨트롤러를 보자. @PostMapping public String submit( LoginCommand loginCommand, Errors errors, HttpSession session, HttpServletResponse response) { new LoginCommandValidator().validate(lo..

0. Java-iterator에 관하여

1. 의미 : Iterator는 java CollectionFramework에 저장되어 있는 요소들을 읽어오는 방법을 표준화한 것이다. 대표적으로 Set,List,Map에서 iterator 기능 사용가능하다. 2. 기능 : Boolean hasNext() : 읽어올 요소가 남아있는지 확인하고 있으면 true, 없으면 false Object next() : hasNext()가 true이면 다음 요소를 읽어오게 하는 것이다. void remove() : next()로 읽어온 요소를 삭제한다. next()를 호출 한 다음에 remove()를 호출해야한다. 3. 사용예시 ex1) 표준 List list = new ArrayList(); Iterator it = list.iterator(); while(it.ha..

+a, SpringSecurity 인증, 인가 처리 과정 정리

1. Spring Security 구조도 : 2. 인증, 인가 처리 과정 - 대략적인 과정 : SecurityContextPersistence Filter를 가장 먼저 적용해서 SecurityContext에 Authentication 객체를 보관한다. 이후, 인증을 위해 SecurityContext를 이용해 Authentication객체를 구하고 Authentication에 포함되어있는 권한 목록(GrantedAuthority)을 확인해 특정경로에 접근할 권한이 있는지 파악한다. UsernamePasswordAuthenticationToken클래스 : Authetication(interface)을 implement한 AbstractAuthenticationToken의 하위 클래스로 첫 번째 생성자 : 인..

- SecurityContext, SecurityContextHolder, Authentication간의 관계, 현재 로그인 중인 사용자 가져오기

1. Authentication : Authentication에는 사용자의 인증 여부(enabled), 사용자가 가진 권한(authority), 이름 및 접근 주체(username=principa)에 대한 정보를 담고 있다 - 관계 : SecurityContextHolder class의 getContext() 메서드는 SecurityContext 객체를 리턴하고, 이 SecurityCotnext 객체의 getAuthentication() 메서드는 Authentication을 리턴함 따라서 현재 로그인한 사용자명을 획득하기 위해서는 //String username = SecurityContextHolder.getContext().getAuthentication().getName(); public Calen..