-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[톰캣 구현하기 1 & 2단계] 오션(김동해) 미션 제출합니다 (#347)
* test: File 경로 찾기 및 파일 내용 읽기 학습 테스트 * test: I/O Stream 학습 테스트 * feat: GET /index.html 응답하기 추가 * feat: CSS 지원 기능 추가 * docs: 요구사항 명세서 추가 * feat: 파비콘 파일 추가 * build: junit 추가 * feat: 쿼리 스트링 파싱 추가 * refactor: 1단계 코드 리팩토링 * docs: 2단계 요구사항 추가 * feat: HTTP Status Code 302 기능 추가 * feat: Post 방식 회원가입 및 Session 기능 추가 * refactor: 쿠키 파싱 로직 수정 * refactor: 절대 경로 조회 로직 수정 * refactor: 개행 수정 * refactor: BufferedReader HttpRequest 로직 수정 * refactor: 존재하지 않는 리소스 404.html 리다이렉트 * refactor: 로그인 세션 생성 로직 수정 * refactor: 코드 리팩토링 * refactor: findSession Optional 반환
- Loading branch information
Showing
31 changed files
with
1,140 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
# 톰캣 구현하기 | ||
|
||
1단계 HTTP 서버 구현하기 | ||
-[x] HTTP 서버 구현하기 | ||
- [x] GET /index.html 응답하기 | ||
- [x] CSS 지원하기 | ||
- [x] Query String 파싱 | ||
|
||
2단계 로그인 구현하기 | ||
- [x] HTTP Status Code 302 | ||
- [x] 로그인 성공시 302반환 및 /index.html로 리다이렉트 | ||
- [x] 로그인 실패 시 401.html로 리다이렉트 | ||
- [x] POST 방식으로 회원가입 | ||
- [x] 회원가입 완료 시 index.html로 리다이렉트 | ||
- [x] 로그인 페이지도 POST 방식 | ||
- [x] Cookie에 JSESSIONID 값 저장 | ||
- [x] Session 구현 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tomcat/src/main/java/org/apache/catalina/session/Session.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.apache.catalina.session; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class Session { | ||
private final String id; | ||
private final Map<String, Object> sessions; | ||
|
||
public Session(final String id) { | ||
this.id = id; | ||
this.sessions = new HashMap<>(); | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public Object getAttribute(final String name) { | ||
return sessions.get(name); | ||
} | ||
|
||
public void setAttribute(final String name, final Object value){ | ||
sessions.put(name,value); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tomcat/src/main/java/org/apache/catalina/session/SessionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.apache.catalina.session; | ||
|
||
import org.apache.catalina.Manager; | ||
|
||
import javax.swing.text.html.Option; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public class SessionManager implements Manager { | ||
|
||
private static final Map<String, Session> SESSIONS = new HashMap<>(); | ||
|
||
@Override | ||
public void add(final Session session) { | ||
SESSIONS.put(session.getId(), session); | ||
} | ||
|
||
@Override | ||
public Optional<Session> findSession(final String id) { | ||
return Optional.ofNullable(SESSIONS.get(id)); | ||
} | ||
|
||
@Override | ||
public void remove(final Session session) { | ||
SESSIONS.remove(session.getId()); | ||
} | ||
} |
Oops, something went wrong.