code stringlengths 41 34.3k | lang stringclasses 8
values | review stringlengths 1 4.74k |
|---|---|---|
@@ -0,0 +1,80 @@
+import React from 'react';
+import Comment from './Comment';
+import './CommentList.scss';
+
+class CommentList extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ commentInput: '',
+ newComment: [],
+ nickname: '',
+ commentList: [],
+ c... | JavaScript | ์์์ ๋ฐ์์จ 'wecode-bootcamp' ๋ผ๋ id ๊ฐ์ ๋ฐ์์ค๊ธฐ ์ํด ์ฌ์ฉํ๋๋ฐ, ํ์คํ id ๋ผ๋๊ฒ์ ์ ์ ์น ์์ nickname ์ผ๋ก ์์ ํ์ต๋๋ค! |
@@ -0,0 +1,80 @@
+import React from 'react';
+import Comment from './Comment';
+import './CommentList.scss';
+
+class CommentList extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ commentInput: '',
+ newComment: [],
+ nickname: '',
+ commentList: [],
+ c... | JavaScript | ์ง์ ์ต๋๋ค! |
@@ -1,13 +1,92 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
class LoginAh extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ idInput: '',
+ pwInput: '',
+ };
+ }
+
+ loginTest = () => {
+ fetch('users/... | JavaScript | ์์ ํ์ต๋๋ค! |
@@ -1,13 +1,92 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
class LoginAh extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ idInput: '',
+ pwInput: '',
+ };
+ }
+
+ loginTest = () => {
+ fetch('users/... | JavaScript | defaultColor๋ ์์ ์ง์ฐ๊ณ ์ผํญ์ฐ์ฐ์๋ฅผ ์ด์ฉํ ํด๊ฒฐ๋ฐฉ๋ฒ์ ๋ฐ์ ์ฃผ์
์ ๊ทธ๊ฑฐ๋ก ์์ ๋ณํ๊น์ง ์ ์ฉํ์์ต๋๋ค. ์ํ๊ฐ ๋ณํ๋ค๊ณ ์๊ฐ๋๋๊ฒ์ ์๊พธ state๋ฅผ ์ด์ฉํ๊ฒ ๋๋๊ฑฐ ๊ฐ์ ๋ ๊ณต๋ถํ๊ฒ ์ต๋๋ค. |
@@ -1,13 +1,92 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
class LoginAh extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ idInput: '',
+ pwInput: '',
+ };
+ }
+
+ loginTest = () => {
+ fetch('users/... | JavaScript | ์์ ํ์ต๋๋ค! |
@@ -1,13 +1,92 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
class LoginAh extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ idInput: '',
+ pwInput: '',
+ };
+ }
+
+ loginTest = () => {
+ fetch('users/... | JavaScript | ํ๋จ์ ์ฃผ์ ํด๊ฒฐ๋ฒ์ผ๋ก ์์ ํ์ต๋๋ค! |
@@ -1,13 +1,92 @@
import React from 'react';
+import { withRouter } from 'react-router-dom';
+import './Login.scss';
class LoginAh extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ idInput: '',
+ pwInput: '',
+ };
+ }
+
+ loginTest = () => {
+ fetch('users/... | JavaScript | ์ ๋ง ๊ฐ์ฌํฉ๋๋ค. ๋ฌด์กฐ๊ฑด constructor ๋จ์์ ๋ณํ์ํค๋ ์ค ์๊ณ ๊ทธ๊ณณ์์๋ง ํด๊ฒฐํ๋ ค๊ณ ํ๋๋ฐ render์์ ๋ณ๊ฒฝํ๋ฉด ๋ ๊ฐ๋จํ๊ฒ ๋๋ ๊ฒ ๊ฐ์ต๋๋ค. inline ์คํ์ผ๋ง ์ง์ํ๊ฒ ์ต๋๋ค!!! |
@@ -1,26 +1,39 @@
package nextstep.app;
+import jakarta.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
import nextstep.app.domain.Member;
import nextstep.app.domain.MemberRepository;
import nextstep.security.authentication.AuthenticationException;
import nextstep.security.authentication.BasicAuthe... | Java | ์ ์ถ๊ฐํด์ฃผ์
จ๋ค์ ๐ |
@@ -2,7 +2,10 @@
import nextstep.app.domain.Member;
import nextstep.app.domain.MemberRepository;
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authentication.AuthenticationException;
import nextstep.security.authorization.Secured;
+import nextstep.security.context.SecurityConte... | Java | ์ด๋ฏธ Filter์์ ์ฒ๋ฆฌํ๊ณ ์๋๋ฐ ๋ถํ์ํ ๋ก์ง์ด ์๋๊น์? |
@@ -0,0 +1,20 @@
+package nextstep.security.util;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.http.HttpMethod;
+
+public class MvcRequestMatcher implements RequestMatcher {
+
+ private final HttpMethod method;
+ private final String pattern;
+
+ public MvcRequestMatcher(HttpM... | Java | ```suggestion
return this.method.equals(HttpMethod.valueOf(request.getMethod())) && pattern.equals(request.getRequestURI());
```
null-safe ๊ด์ ์์๋ ํ๋ผ๋ฏธํฐ๋ก ๋ค์ด์ค๋ `request.getRequestURI()`๋ null์ผ ์ ์๊ธฐ ๋๋ฌธ์ ๋ณ๋๋ก null ์ฒดํฌ๋ฅผ ํ์ง ์๋ ์ด์ ์์ ๊ฐ์ด ํํํ๋ ๊ฒ์ด npe๊ฐ ๋ฐ์ํ์ง ์๋ ์์ ํ ์ฝ๋๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค. |
@@ -0,0 +1,14 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.web.AuthorizationResult;
+
+@FunctionalInterface
+public interface AuthorizationManager<T> {
+ @Deprecated
+ AuthorizationDecision check(Authentication auth... | Java | ํ์ฌ spring security๋ฅผ ํ์ธํด๋ณด์๋ฉด `check`๋ deprecated๋์๋๋ฐ์. `AuthorizationDecision`์ด๋ผ๋ ํด๋์ค๋ ๊ตฌํํด์ฃผ์ ๊ฒ์ฒ๋ผ ๊ตฌํ์ฒด๋ก ๋์ด์๊ณ , ๋ณดํต์ ํ๋ ์์ํฌ๋ค์ ๊ท๋ชจ๊ฐ ์ปค์ง์๋ก ๋ง๋ค์ด๋ ๊ตฌํ์ฒด๋ค์ ์ถ์ํํ๋ ํํ๋ก ๊ฐ์ ํด๋๊ฐ๋๋ค.
`check`๊ฐ deprecated๋จ์ ๋ฐ๋ผ ํด๋น ๊ธฐ๋ฅ์ด ๋งํ ๊ฒ์ ์๋๊ณ ์ด๋ฅผ ์ถ์ํํ `AuthorizationResult`๋ฅผ ๋ฐํํ๋ ๋ฉ์๋ ์ฌ์ฉ์ ๊ถ์ฅํ๊ณ ์์ผ๋ ์ฐธ๊ณ ํด์ฃผ์๋ฉด ์ข์ ๊ฒ ๊ฐ์์ :)
https://github.com/franticticktick/spring-s... |
@@ -0,0 +1,14 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.web.AuthorizationResult;
+
+@FunctionalInterface
+public interface AuthorizationManager<T> {
+ @Deprecated
+ AuthorizationDecision check(Authentication auth... | Java | ์คํ๋์ด ์๊ฐํ์๊ธฐ์ ์ ํ์ฌํญ์ผ๋ก ์ฃผ์ด์ง `verfiy`๋ `check`์ ๋น๊ตํ์ฌ ์ด๋ค ์ํฉ์์ ์ฌ์ฉํ๋ฉด ์ข์ ๊ฒ ๊ฐ์ผ์ ๊ฐ์? |
@@ -0,0 +1,22 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authorization.web.AuthorizationResult;
+
+public class AuthorizationDecision implements AuthorizationResult {
+ public static final AuthorizationDecision ALLOW = new AuthorizationDecision(true);
+ public static final Authorizat... | Java | true ํน์ false๋ง ๊ฐ์ง๋ `AuthorizationDecision`์ด ์์ฃผ ์ฌ์ฉ๋๋๋ฐ ์ฌ์ฉ๋ ๋๋ง๋ค ์ธ์คํด์คํํ๊ธฐ๋ณด๋ค๋ ๋ถ๋ณ์์ ํ์ฉํ์ฌ ๋ฏธ๋ฆฌ ๋ง๋ค์ด์ค ์์๋ฅผ ์ฌ์ฉํ๋๋ก ์ ๋ํ ์ ์์ ๊ฒ ๊ฐ๋ค์. |
@@ -0,0 +1,38 @@
+package nextstep.security.authorization.web;
+
+import java.util.Collection;
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authentication.AuthenticationException;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization... | Java | ์ค์ spring security์์๋ ์ฑ๋ฅ์ ๋ฌธ์ ๋ก ์ธํด stream ์ฌ์ฉ์ ์ ํํ๊ณ ์์ต๋๋ค.
https://github.com/spring-projects/spring-security/issues/7154 |
@@ -0,0 +1,28 @@
+package nextstep.security.authorization.web;
+
+import jakarta.servlet.http.HttpServletRequest;
+import java.util.List;
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.AuthorizationManager;
... | Java | getter๋ก ํธ์ถํ์ฌ ์ผ์น ์ฌ๋ถ๋ฅผ ํ์ธํ๋ ๊ฒ๋ณด๋ค๋ `mapping`์์ ์ฒ๋ฆฌํ๋๋ก ์์ ํ๋ฉด ์ฑ
์์ด ๋ช
ํํ๊ฒ ๋์ด๊ฐ ์ ์๊ฒ ๋ค์ :) |
@@ -0,0 +1,43 @@
+package nextstep.security.authorization.method;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextst... | Java | `AuthorityAuthorizationManager`์ ๋ก์ง๊ณผ ํจ๊ป๋ณด๋ฉด
```java
boolean hasAuthority = authentication.getAuthorities().stream()
.anyMatch(authorities::contains);
return new AuthorizationDecision(hasAuthority);
```
๋ถ๋ถ์ด ๋์ผํ ๊ฒ์ ํ์ธํด๋ณผ ์ ์์ด์. ๊ฐ `AuthorizatinManager`๋ ๋จ์ผ์์ ๊ฐ๊ฐ ๋ณธ์ธ์ ๊ฒ์ ๋ชจ๋ ๊ตฌ์ฑํ๋ ๊ฒ์ด ์๋ ์๋ก ์ ๊ธฐ์ ์ผ๋ก ๊ฒฐํฉ๋์ด ์ฌ์ฉํ๊ธฐ๋ ํ๋๋ฐ์.
... |
@@ -0,0 +1,18 @@
+package nextstep.security.fixture;
+
+import java.util.Base64;
+import java.util.Set;
+import nextstep.app.domain.Member;
+
+public class MemberTestFixture {
+ public static final Member TEST_ADMIN_MEMBER = new Member("a@a.com", "password", "a", "", Set.of("ADMIN"));
+ public static final Member... | Java | (๋ฐ์ํ์ง ์์ผ์
๋ ๋ฉ๋๋ค.) ๊ฐ์ธ์ ์ผ๋ก๋ enum์์ ์ง์๋๋ ๋ฉ์๋๋ค์ ํ์ฉํ๋ ๊ฒฝ์ฐ๋ ๋ง์ ํน์ ๋๋ฉ์ธ์ fixture๋ enum ์ผ๋ก ์์ฑํ๋ ํธ์
๋๋ค ๐ |
@@ -2,7 +2,10 @@
import nextstep.app.domain.Member;
import nextstep.app.domain.MemberRepository;
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authentication.AuthenticationException;
import nextstep.security.authorization.Secured;
+import nextstep.security.context.SecurityConte... | Java | ์ ํด๋น appํจํค์ง์ ์ปจํธ๋กค๋ฌ๋
๊ฐ์์ค์์ ์ค์ต์ดํ ์ฒด๋ฆฌํฝ ํด์จ๊ฒ์ด๋ผ ์ด์ด๋ณผ ์๊ฐ์ ๋ชปํ๋ค์.
์์ ํด๋๊ฒ ์ต๋๋ค! |
@@ -0,0 +1,20 @@
+package nextstep.security.util;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.http.HttpMethod;
+
+public class MvcRequestMatcher implements RequestMatcher {
+
+ private final HttpMethod method;
+ private final String pattern;
+
+ public MvcRequestMatcher(HttpM... | Java | ๊ฐ๊ณผํ๊ณ ์์๋ค์. ์์ ํด๋๊ฒ ์ต๋๋ค! ๐ |
@@ -0,0 +1,14 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.web.AuthorizationResult;
+
+@FunctionalInterface
+public interface AuthorizationManager<T> {
+ @Deprecated
+ AuthorizationDecision check(Authentication auth... | Java | ์ค.. ๋ถ๊ณผ 4๋ฌ์ ์ ์
๋ฐ์ดํธ๋ ๊ธฐ๋ฅ์ด๊ตฐ์!
ํผ๋๋ฐฑ ์ฃผ์ ๋๋ก ๋ฐ์ํด๋ณด๋ฉด์ ์ด๋ค ์์ผ๋ก
์คํ์์ค๊ฐ ๊ฐ์ ๋์ด ๋๊ฐ๋์ง ์ฒดํ ํด ๋ณผ ์ ์์๋ค์ ๊ฐ์ฌํฉ๋๋ค. |
@@ -0,0 +1,22 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authorization.web.AuthorizationResult;
+
+public class AuthorizationDecision implements AuthorizationResult {
+ public static final AuthorizationDecision ALLOW = new AuthorizationDecision(true);
+ public static final Authorizat... | Java | ํ ์ํฉ์์ ๋ฉ๋ชจ๋ฆฌ ํจ์จ์ฑ์ ๋ ๋์ผ ์ ์๊ฒ ๋ค์! |
@@ -0,0 +1,38 @@
+package nextstep.security.authorization.web;
+
+import java.util.Collection;
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authentication.AuthenticationException;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization... | Java | ๊ฐ๋
์ฑ ๋๋ฌธ์ stream์ ์ ํธํ๋ ํธ์ธ๋ฐ, spring security๊ฐ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ์ฑ๋ฅ์ด ์ค์ํ๋ค๋ณด๋ ๊ทธ๋ ๊ฒ ๋๊ฑฐ๊ตฐ์..
๊ตฌํ์ฒด ์ฝ๋ ๋ณด๋ฉด์ ๊ฐ๋
์ฑ์ด ์๊ฐ๋งํผ์ ์๋๊ฒ ๊ฐ์๋๋ฐ, ๊ทธ ์ํ๊ฐ์ด ์ฌ๊ธฐ์ ๊ธฐ์ธํ ๊ฒ ๊ฐ์ต๋๋ค. |
@@ -0,0 +1,28 @@
+package nextstep.security.authorization.web;
+
+import jakarta.servlet.http.HttpServletRequest;
+import java.util.List;
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.AuthorizationManager;
... | Java | ์.. ์ ์๊ฐ์ผ๋ก๋ `mapping`์ธ `RequestMatcherEntry`๋ `RequestMatcher`๋ `AuthorizationManager`๋ฅผ
๋จ์ํ ๋ฌถ์ด์ฃผ๋ ์ญํ ์ ์ํํ๋ค๊ณ ์๊ฐํด์,
ํด๋น ๊ฐ์ฒด์ `matches()`์ ๋ก์ง๊น์ง ์์ผ๋ฉด ์คํ๋ ค ์ฑ
์์ด ๊ณผํด์ง๊ณ ,
์๋ RequestMatcher์ ์ญํ ์ด ํ๋ ค์ง๊ฒ ๊ฐ์ getter๋ก ํธ์ถํด์ ์ผ์น ์ฌ๋ถ๋ฅผ ํ์ธํ์ต๋๋ค.
์ ๊ฐ ์ ๋๋ก ์ดํดํ๊ฑฐ๋ผ๋ฉด ์ง์๋ ์๊ฐ์ด ๊ถ๊ธํฉ๋๋ค! |
@@ -0,0 +1,18 @@
+package nextstep.security.fixture;
+
+import java.util.Base64;
+import java.util.Set;
+import nextstep.app.domain.Member;
+
+public class MemberTestFixture {
+ public static final Member TEST_ADMIN_MEMBER = new Member("a@a.com", "password", "a", "", Set.of("ADMIN"));
+ public static final Member... | Java | 3๋จ๊ณ ์ํํ๋ฉด์ ๋ณ๊ฒฝํด ๋ณด๊ฒ ์ต๋๋ค! ๐ |
@@ -0,0 +1,43 @@
+package nextstep.security.authorization.method;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextst... | Java | [83a4efd](https://github.com/next-step/spring-security-authorization/pull/15/commits/83a4efd95662b7e9d2590f72ee5a56173a16477d)
์ผ๋ก ๋ฐ์ํด๋ณด์์ต๋๋ค!
๊ฐ์์ Manager๊ฐ ๋จ์ผ ์ฑ
์์ด ์๋ ๊ฒฐํฉํด์ ์ฌ์ฉํ๊ธฐ๋ ํ๋๊ตฐ์!
์ ๋ ์์
ํ๋ฉด์ ๊ฐ์ ๋ก์ง์ด ๋ค์ด๊ฐ๋ค๊ณ ์๊ฐ์ด ๋ค์๋๋ฐ,
์ด๋ฐ์์ผ๋ก๋ ์ญํ ๊ณผ ์ฑ
์ ๋ถ๋ฐฐ๋ฅผ ๊ฐ์ ธ๊ฐ ์ ์๊ฒ ๋ค์!
ํ์ฌ ๋ง์ํด์ฃผ์ `AuthoritiesAuthorizationManager` ์ฒ๋ผ ๋ค์ํ ๊ถํ ์ฒด๊ณ๋ ์๊ธฐ ๋๋ฌธ์
๊ธฐ์กด `Se... |
@@ -0,0 +1,14 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.web.AuthorizationResult;
+
+@FunctionalInterface
+public interface AuthorizationManager<T> {
+ @Deprecated
+ AuthorizationDecision check(Authentication auth... | Java | ์.. ๊ฒฐ๊ตญ์ **์ธ๊ฐ์คํจ์ ์์ธ๋ฅผ ๋ฐ์์ํจ๋ค.** ๊ฐ ํต์ฌ์ด๋ผ๊ณ ์๊ฐํด์.
check๋ก๋ null์ด ์ฌ ์๋ ์๊ณ , ๊ถํ์ด ์๋ค ํ ์ง์ด๋ ์๋ฌ์ฝ๋ ๋ฑ์์ ๊ฐ๋ฐ์ ๋ง์๋๋ก ํธ๋ค๋ง ํ ์ ์๋ ๋ฐ๋ฉด์,
verify๋ ์ธ๊ฐ์ ์คํจํ ๊ฒฝ์ฐ ๋์ผํ ์๋ฌ๊ฐ ๋ฐ์๋๋ค. ๋ผ๋ ์ ์์ ์ถ์ ์ ์ฉ์ดํ ๊ฒ ๊ฐ๊ณ , ์ธ์ ์ค๋ฅ๋ฅผ ์ต์ํ ํ ์ ์์ ๊ฒ ๊ฐ๋ค๊ณ ์๊ฐ์ด ๋๋ค์!
๋ฐ๋ผ์ ๊ด๋ฆฌ์ ์ ์ฉ API๋ฑ ๊ถํ์ด ์์ผ๋ฉด ์ถ๊ฐ์ ์ธ ๋ก์ง ์์ด ๋ฐ๋ก ์์ธ๋ฅผ ๋์ง๋ ์ฌ์ฉํ๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค~ |
@@ -0,0 +1,14 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.web.AuthorizationResult;
+
+@FunctionalInterface
+public interface AuthorizationManager<T> {
+ @Deprecated
+ AuthorizationDecision check(Authentication auth... | Java | ๋ค ์ฌ์ค `verify`๋ฅผ ๋จ์ผ๋ก ์ฐ๋ฉด ์ ํฌ๊ฐ ํํ ์๊ณ ์๋ฏ ์์ธ๋ฅผ ๋ฐ์์ํฌ ์ ์๋ ๊ณณ์์ ์์ธ๋ฅผ ๋ฐ์์ํค๋ ๊ฒ์ด ๋ง๊ธฐ๋ ํฉ๋๋ค.
๋ค๋ง `AuthorizationManager`์ ์๋ ์ฑ
์์ ์ธ๊ฐ๊ฐ ๋ ์ ์ ์ธ์ง๋ฅผ ํ์ธํ๋ ๊ฒ์ด๊ณ ์ด๊ฑด ์ธ๊ฐ๊ฐ ์คํจ๋์๋ค๋ ๊ฒ์ด ์๋ฌ ์ํฉ์ด ์๋ ์ ์์ ์ธ ๋น์ฆ๋์ค์ ํ๋ฆ์ด๋ผ๊ณ ๋ณผ ์ ์์ด์. ์ธ๊ฐ๊ฐ ์คํจํ ๊ฒ์ ๋ํ ๊ฒฐ๊ณผ๊ฐ ์์ธ๊ฐ ๋๋ ๊ฒ์ `AuthorizationFilter`๊ฐ ์ธ๊ฐ ์คํจ์ ๊ฒฐ๊ณผ๊ฐ ์์ธ์ด๋ค๋ผ๋ ๊ฒ์ ์คํํ๋ ๊ฒ์ผ๋ฟ์ธ ๊ฒ์ด๊ตฌ์.
์ค์ `AuthorizationManager`๋ค์ ๊ตฌํ์ฒด๋ฅผ ๋ณด์๋ฉด ์ด๋ฐ ์ด์ ... |
@@ -0,0 +1,28 @@
+package nextstep.security.authorization.web;
+
+import jakarta.servlet.http.HttpServletRequest;
+import java.util.List;
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.AuthorizationManager;
... | Java | ```suggestion
if (mapping.matches(request)) {
```
์ ๊ฐ ์๋ ๋๋ ธ๋ ๋ด์ฉ์ getter๋ฅผ ๊บผ๋ด์์ ๋ค์ ํธ์ถํ๋ ๊ฒ์ด ์๋ ํด๋น ๊ฐ์ฒด ๋ด์์ ์ฒ๋ฆฌํ ์ ์๊ฒ ๋ฉ์์ง๋ฅผ ๋์ง๋ ํํ๋ฅผ ๋ง์๋๋ฆฐ ๊ฒ์ด์์ด์. getter๋ฅผ ํธ์ถํด์ ๋ฉ์๋ ์ฒด์ด๋์ด ๋๋ ๊ฒ์ ๊ฐ์ฒด์ ์ญํ ์ด ์๋ค๊ธฐ๋ณด๋จ ๋จ์ํ ๋ํํด๋์ค๊ฐ ๋์ด๋ฒ๋ ค ์ฑ
์๊ณผ ์ญํ ์ด ๋ถ๋ถ๋ช
ํด์ง ์ ์์ต๋๋ค.
```java
public boolean matches(HttpServletRequest request) {
return reque... |
@@ -0,0 +1,13 @@
+package nextstep.security.authorization.web;
+
+import jakarta.servlet.http.HttpServletRequest;
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.AuthorizationManager;
+
+public class DenyAllA... | Java | ```suggestion
public AuthorizationResult check(Authentication authentication, HttpServletRequest object) {
```
๋ฐํ ํ์
๋ค๋ ์ ์ถ์ํํด์ฃผ์ ํด๋์ค๋ก ๋ง๋ค์ด์ฃผ๋ฉด ์ข๊ฒ ๋ค์ :) |
@@ -0,0 +1,22 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authorization.web.AuthorizationResult;
+
+public class AuthorizationDecision implements AuthorizationResult {
+ public static final AuthorizationDecision ALLOW = new AuthorizationDecision(true);
+ public static final Authorizat... | Java | ```suggestion
public static AuthorizationDecision from(boolean granted) {
```
๊ด์ต์ ์ผ๋ก ์ ์ ํฉํ ๋ฆฌ ๋ฉ์๋๋ ํ๋ผ๋ฏธํฐ๊ฐ ํ๋์ผ๋ from, ์ฌ๋ฌ๊ฐ์ผ๋ of๋ฅผ ํ์ฉํฉ๋๋ค. |
@@ -0,0 +1,15 @@
+{
+ "arrowParens": "always",
+ "bracketSpacing": true,
+ "jsxBracketSameLine": false,
+ "jsxSingleQuote": false,
+ "printWidth": 80,
+ "proseWrap": "always",
+ "quoteProps": "as-needed",
+ "semi": true,
+ "singleQuote": false,
+ "tabWidth": 2,
+ "trailingComma": "es5",
+ "useTabs": false,
... | Unknown | EOL์ด ์๋ค์ |
@@ -10,7 +10,17 @@
"@babel/core": "^7.23.0",
"@babel/preset-env": "^7.22.20",
"babel-jest": "^29.7.0",
- "jest": "29.6.0"
+ "eslint": "^8.56.0",
+ "eslint-config-airbnb": "^19.0.4",
+ "eslint-config-prettier": "^9.1.0",
+ "eslint-plugin-import": "^2.29.1",
+ "eslint-plugin-jsx-a11y": "^... | Unknown | ์ค.. husky๊น์ง |
@@ -0,0 +1,28 @@
+import GameMessage from "./GameMessage.js";
+import { VALID_INPUT_LENGTH } from "./gameConstants.js";
+
+class Validator {
+ static isValidInput(input) {
+ if (!this.isNumber(input))
+ throw new Error(GameMessage.INVALID_INPUT_NOT_A_NUMBER);
+ if (!this.isValidLength(input))
+ throw n... | JavaScript | 3์ด๋ผ๋ ์ซ์๋ ์ด๋ค ์๋ฏธ๋ฅผ ๊ฐ์ง๊ณ ์๋ ์ซ์ ๊ฐ์๋ฐ์,
์ด๋ฌํ ์ซ์๊ฐ ์ซ์ ๊ทธ๋๋ก ์กด์ฌํ๋ ๊ฒ์ ํํ ๋งค์ง๋๋ฒ๋ผ๊ณ ๋ถ๋ฆ
๋๋ค.
๋ฐ๋ผ์ ์ด๋ฌํ ์ซ์๋ ๋ค์์ ์ด์ ๋ก ์์ํ ํด์ฃผ๋ ๊ฒ์ด ์ข์ต๋๋ค.
1. ์์๋ก ์ซ์์ผ๊ตฌ ๊ฒ์์ ์ซ์๊ฐฏ์๊ฐ 4๋ก ๋์ด๋ฌ๋ค. ๊ทธ๋ ๋ค๋ฉด ๋ชจ๋ ํ์ผ์ ๋ค์ ธ์ 3์ 4๋ก ๊ณ ์ณ์ผํ๋ค. (๋ณ๊ฒฝ์ ์ฉ์ดํ์ง ์๋ค.)
2. ์ฒ์ ์จ๋ณด๋ฉ ํ๋ ์ฌ๋์ ์ด ์ซ์์ ์๋ฏธ๋ฅผ ํ์
ํ๊ธฐ ํ๋ค๋ค. ์ฝ๋ ๊ฐ๋
์ฑ์ด ์ค์ด๋ ๋ค. |
@@ -0,0 +1,28 @@
+import GameMessage from "./GameMessage.js";
+import { VALID_INPUT_LENGTH } from "./gameConstants.js";
+
+class Validator {
+ static isValidInput(input) {
+ if (!this.isNumber(input))
+ throw new Error(GameMessage.INVALID_INPUT_NOT_A_NUMBER);
+ if (!this.isValidLength(input))
+ throw n... | JavaScript | 1. ์ฝ๋๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ๊ณ ์น๋ฉด ๋ ์ค์ด๋ญ๋๋ค ใ
ใ
```suggestion
const newArr = [...new Set(input)]
```
2. newArr์ด๋ผ๋ ์์๋ช
์ด ์ด๋ค ์๋ฏธ๋ฅผ ๋ด๊ณ ์๋ ์ด๋ฆ์ธ๊ฐ์? ์๋ฏธ๊ฐ ์๊ณ , ๋จ๋ฐ์ฑ์ผ๋ก ์ฌ์ฉ๋๋ ์ธก๋ฉด์์
์ด๋ ๊ฒ ์์ฑํด๋ ๋ ๊ฒ ๊ฐ์์.
```js
isDuplicate(input) {
if ([...new Set(input)].length !== 3) throw new Error(GameMessage.INVALID_INPUT_IS_DUPLICATED)
return true;
}... |
@@ -0,0 +1,28 @@
+import GameMessage from "./GameMessage.js";
+import { VALID_INPUT_LENGTH } from "./gameConstants.js";
+
+class Validator {
+ static isValidInput(input) {
+ if (!this.isNumber(input))
+ throw new Error(GameMessage.INVALID_INPUT_NOT_A_NUMBER);
+ if (!this.isValidLength(input))
+ throw n... | JavaScript | 1. ๊ฐ์ธ์ ์ธ ๊ฒฌํด๋ก๋ ๊ฒ์ฆํจ์์์๋ ํด๋น input์ด ์ ํจํ์ง/์ํ์ง(boolean) ํ๊ฐํ ๋ค์,
์ด ๊ฒฐ๊ณผ์ ๋ฐ๋ผ ์๋ฌ๋ฅผ ๋์ ธ์ฃผ๋ ํจํด์ ์ ํธํฉ๋๋ค.
๋ค์ ๋งํ๋ฉด ์๋ฌ๋ฅผ ๋์ ธ์ฃผ๋ ๋ถ๋ถ์ ์ด ํจ์(is..)๋ฅผ ํธ์ถํ๋ ๋ถ๋ถ์ผ๋ก ๋๊ธฐ๋ ๋ฐฉ์์ผ๋ก ํ๊ณคํฉ๋๋ค
2. ์ด๊ฒ static method๊ฐ ์๋ method์ผ ์ด์ ๊ฐ ์๋์? |
@@ -0,0 +1,28 @@
+import GameMessage from "./GameMessage.js";
+import { VALID_INPUT_LENGTH } from "./gameConstants.js";
+
+class Validator {
+ static isValidInput(input) {
+ if (!this.isNumber(input))
+ throw new Error(GameMessage.INVALID_INPUT_NOT_A_NUMBER);
+ if (!this.isValidLength(input))
+ throw n... | JavaScript | ํ์์๋ ์ฃผ์์ ์ง์ฐ๋ฉด ์ข๊ฒ ์ต๋๋ค ! |
@@ -0,0 +1,28 @@
+import GameMessage from "./GameMessage.js";
+import { VALID_INPUT_LENGTH } from "./gameConstants.js";
+
+class Validator {
+ static isValidInput(input) {
+ if (!this.isNumber(input))
+ throw new Error(GameMessage.INVALID_INPUT_NOT_A_NUMBER);
+ if (!this.isValidLength(input))
+ throw n... | JavaScript | boolean์ ๋ฆฌํดํ ๋๋ ๋ฉ์๋์ prefix์ is, has๋ฅผ ๋ถ์ฌ์ฃผ๋ ๊ฒ์ด ๊ด๋ก์
๋๋คใ
_ใ
|
@@ -0,0 +1,49 @@
+import { Random } from "@woowacourse/mission-utils";
+import {
+ VALID_INPUT_LENGTH,
+ MIN_RANDOM_NUMBER,
+ MAX_RANDOM_NUMBER,
+} from "./gameConstants.js";
+
+class Computer {
+ #solution;
+
+ seeSolution() {
+ return this.#solution;
+ }
+
+ makeSolution() {
+ const computer = [];
+ w... | JavaScript | ์ด๋ค ๊ตฌ๋ฌธ์๋ ์ธ๋ฏธ์ฝ๋ก ์ด ์๊ณ , ์ด๋ค ๊ตฌ๋ฌธ์๋ ์ธ๋ฏธ์ฝ๋ก ์ด ์์ง ์๋ค์.
๋ ์ค ํ๋๋ง ํ์๋ ๊ฑธ ์ถ์ฒ๋๋ฆฌ๊ณ , ๊ฐ์ ํ๊ณ ์ถ๋ค๋ฉด prettier๋ฑ์ ์ด์ฉํด๋ณด์ธ์. |
@@ -0,0 +1,49 @@
+import { Random } from "@woowacourse/mission-utils";
+import {
+ VALID_INPUT_LENGTH,
+ MIN_RANDOM_NUMBER,
+ MAX_RANDOM_NUMBER,
+} from "./gameConstants.js";
+
+class Computer {
+ #solution;
+
+ seeSolution() {
+ return this.#solution;
+ }
+
+ makeSolution() {
+ const computer = [];
+ w... | JavaScript | 1. ์ด๋ ๊ฒ๋ ๋ฉ๋๋ค.
```suggestion
const userInput = input.split("").map(Number);
```
2. ๋ฐฐ์ด์ด๋ฉด.. s๊ฐ ๋ถ์ผ๋ฉด ์ข์ง ์์๊น์? |
@@ -0,0 +1,49 @@
+import { Random } from "@woowacourse/mission-utils";
+import {
+ VALID_INPUT_LENGTH,
+ MIN_RANDOM_NUMBER,
+ MAX_RANDOM_NUMBER,
+} from "./gameConstants.js";
+
+class Computer {
+ #solution;
+
+ seeSolution() {
+ return this.#solution;
+ }
+
+ makeSolution() {
+ const computer = [];
+ w... | JavaScript | reduce๋ฅผ ์จ์๋ ๊ตฌํํ ์ ์๊ฒ ๋ค์
```js
const strikeAndBall = userInput.reduce((acc, cur) => {
if ((this.#solution.indexOf(item) === index) && this.#solution.includes(item)) return { ...acc, strike: acc.strike + 1 }
if ((this.#solution.indexOf(item) !== index) && this.#solution.includes(item)) return { ...acc, ball:acc.ball... |
@@ -0,0 +1,15 @@
+{
+ "arrowParens": "always",
+ "bracketSpacing": true,
+ "jsxBracketSameLine": false,
+ "jsxSingleQuote": false,
+ "printWidth": 80,
+ "proseWrap": "always",
+ "quoteProps": "as-needed",
+ "semi": true,
+ "singleQuote": false,
+ "tabWidth": 2,
+ "trailingComma": "es5",
+ "useTabs": false,
... | Unknown | ์ฝ๋๋ฅผ ๋ณด๋ฉด prettier๊ฐ ์ ์ฉ๋์ด์์ง ์์๋ฐ, ํ์ธํ๋ฒ ํด๋ณด์ธ์ฉ |
@@ -0,0 +1,49 @@
+import { Random } from "@woowacourse/mission-utils";
+import {
+ VALID_INPUT_LENGTH,
+ MIN_RANDOM_NUMBER,
+ MAX_RANDOM_NUMBER,
+} from "./gameConstants.js";
+
+class Computer {
+ #solution;
+
+ seeSolution() {
+ return this.#solution;
+ }
+
+ makeSolution() {
+ const computer = [];
+ w... | JavaScript | ์ด๊ฑธ ๋ฆฌํดํ๋ ์ด์ ๊ฐ ๋ญ๊ฐ์ ? |
@@ -1,5 +1,62 @@
+import { Console } from "@woowacourse/mission-utils";
+import User from "./User.js";
+import Computer from "./Computer.js";
+import Validator from "./Validator.js";
+import GameMessage from "./GameMessage.js";
+import { RETRY_RESPONSE, FULL_STRIKE } from "./gameConstants.js";
+
class App {
- async p... | JavaScript | indent๊ฐ.. |
@@ -1,5 +1,62 @@
+import { Console } from "@woowacourse/mission-utils";
+import User from "./User.js";
+import Computer from "./Computer.js";
+import Validator from "./Validator.js";
+import GameMessage from "./GameMessage.js";
+import { RETRY_RESPONSE, FULL_STRIKE } from "./gameConstants.js";
+
class App {
- async p... | JavaScript | ๋งค์ง๋๋ฒ๊ฐ ์ด์์ด์๋ค์ฉ |
@@ -1,5 +1,62 @@
+import { Console } from "@woowacourse/mission-utils";
+import User from "./User.js";
+import Computer from "./Computer.js";
+import Validator from "./Validator.js";
+import GameMessage from "./GameMessage.js";
+import { RETRY_RESPONSE, FULL_STRIKE } from "./gameConstants.js";
+
class App {
- async p... | JavaScript | ์ด๋ ๊ฒ eslint ๊ท์น์ ๋ฌด์ํ ๊ฑฐ๋ฉด eslint๋ฅผ ์ ์ฌ์ฉํ์๋์? |
@@ -1,20 +1,36 @@
package model;
+import java.util.ArrayList;
import java.util.List;
public class Lotto {
- private List<String> lottoNumbers;
+ private List<LottoNo> lottoNumbers;
- public Lotto(List<String> lottoNumbers) {
+ public Lotto(List<LottoNo> lottoNumbers) {
this.lottoNumbers ... | Java | ๋ก๋ ๋ฒํธ๋ฅผ Set ์ผ๋ก ๊ตฌํํ๋ ๊ฒ๊ณผ List ๋ก ๊ตฌํํ๋ ๊ฒ์ ๋น๊ตํด ๋ณด์์ ๋ ์ด๋ค ์ฅ๋จ์ ์ด ์์๊น์? ์ฌ๊ธฐ์๋ ์ด๋ค ์๋ฃ๊ตฌ์กฐ๊ฐ ์ด์ธ๋ฆด๊น์? |
@@ -1,20 +1,36 @@
package model;
+import java.util.ArrayList;
import java.util.List;
public class Lotto {
- private List<String> lottoNumbers;
+ private List<LottoNo> lottoNumbers;
- public Lotto(List<String> lottoNumbers) {
+ public Lotto(List<LottoNo> lottoNumbers) {
this.lottoNumbers ... | Java | ํ์ค์ด๋๋ผ๋ ๊ดํธ๋ฅผ ๋ถ์ฌ์ฃผ๋๊ฑธ ์ปจ๋ฒค์
์ผ๋ก ํฉ์๋ค.
์ด๊ฒ์ด ๊ฐ๊ฒฐํ๋๋ผ๋ ์ฝ๋ ์ฌ๋ ์
์ฅ์ผ๋ก ์ฝ๋๋ฅผ ๋ณด๋ฉด
๋น์ฐํ ์์ด์ผํ ๊ณณ์ ๋ฌด์ธ๊ฐ๊ฐ ๋น ์ง๊ฒ ๋๋ฉด ๊ฐ๋
์ฑ์ด ์ ํ๋ฉ๋๋ค. (์ฑ
์ฝ์ ๋์ ๋น์ท)
๊ทธ๋ฆฌ๊ณ ์์ฑ์์์ ๋ญ๊ฐ ๋ง์ ์ผ์ ํด์ฃผ๋๊ฒ ์์ฝ๋ค์ |
@@ -1,20 +1,36 @@
package model;
+import java.util.ArrayList;
import java.util.List;
public class Lotto {
- private List<String> lottoNumbers;
+ private List<LottoNo> lottoNumbers;
- public Lotto(List<String> lottoNumbers) {
+ public Lotto(List<LottoNo> lottoNumbers) {
this.lottoNumbers ... | Java | boolean์ int ๋ก ๋ณํํด์ฃผ๋ ์ด์ ๋ ๋ญ๊ฐ์? |
@@ -1,20 +1,36 @@
package model;
+import java.util.ArrayList;
import java.util.List;
public class Lotto {
- private List<String> lottoNumbers;
+ private List<LottoNo> lottoNumbers;
- public Lotto(List<String> lottoNumbers) {
+ public Lotto(List<LottoNo> lottoNumbers) {
this.lottoNumbers ... | Java | ์ด ๋ถ๋ถ ์ข ๋ ๊ฐ์ ํด๋ณด์ธ์ |
@@ -1,20 +1,36 @@
package model;
+import java.util.ArrayList;
import java.util.List;
public class Lotto {
- private List<String> lottoNumbers;
+ private List<LottoNo> lottoNumbers;
- public Lotto(List<String> lottoNumbers) {
+ public Lotto(List<LottoNo> lottoNumbers) {
this.lottoNumbers ... | Java | x ๋ฅผ ์ข ๋ ์๋ฏธ์๋ ๋ณ์์ด๋ฆ์ผ๋ก ์ง์์ผ๋ฉด ์ข์์ ๊ฒ ๊ฐ์ต๋๋ค.
๊ทธ๋ฆฌ๊ณ ๋ฉ์๋ ์ฒด์ด๋ ๋ฐฉ์์์๋ ๊ธธ์ด๊ฐ ๊ธธ์ด์ง๋ฉด IDE์์ ํ๋์ ํ์ธํ๊ธฐ ํ๋๋๊น
๊ฐ๋
์ฑ์ ์ํด ์ํฐ๋ก ๋ผ์ธ์ ๋ฆฌ๋ฅผ ์ด๋์ ๋ ํด์ฃผ๋ ๊ฒ์ด ์ข์ต๋๋ค.
์ด๋ฅผ ์ํ ์ปจ๋ฒค์
๋ intellij code style ์์ ์๋์ ๋ ฌ ์ค์ ํ ์ ์๊ธด ํฉ๋๋ค(์ ๋ ์ฌ์ฉ์ค) |
@@ -1,10 +1,8 @@
package model;
-import util.ListGenerator;
import util.SplitGenerator;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -13,43 +11,44 @@ public class LottoMachine {
private static int LOTTO_NUMBER_RANGE = 45;
private stat... | Java | getter ์ ํท๊ฐ๋ฆฌ๋ฏ๋ก calculateRandomNumbers ์ฒ๋ผ ๋ค๋ฅธ ๋จ์ด๋ฅผ ํ์ฉํด๋ณด์๋๊ฑธ ์ถ์ฒ |
@@ -1,20 +1,36 @@
package model;
+import java.util.ArrayList;
import java.util.List;
public class Lotto {
- private List<String> lottoNumbers;
+ private List<LottoNo> lottoNumbers;
- public Lotto(List<String> lottoNumbers) {
+ public Lotto(List<LottoNo> lottoNumbers) {
this.lottoNumbers ... | Java | int ๊ฐ์ผ๋ก ๋ฐํํ๋ ๋ฉ์๋๋ก ์ฒ์ ๊ตฌํํ์๋๋ฐ ๋ฆฌํฉํ ๋ง ๊ณผ์ ์์ boolean ํ์
์ผ๋ก ๋ฐ๊ฟ๋ ๊น๋นกํ ๊ฒ๊ฐ๋ค์.. ์ค์ํ์ง ์๋๋ก ์ฃผ์ํ๊ฒ ์ต๋๋ค |
@@ -1,20 +1,36 @@
package model;
+import java.util.ArrayList;
import java.util.List;
public class Lotto {
- private List<String> lottoNumbers;
+ private List<LottoNo> lottoNumbers;
- public Lotto(List<String> lottoNumbers) {
+ public Lotto(List<LottoNo> lottoNumbers) {
this.lottoNumbers ... | Java | set๊ณผ List์ ๊ฐ์ฅ ํฐ ์ฐจ์ด์ ์ ์ค๋ณต์ ํ์ฉํ๋์ง ์ํ๋์ง๋ก ์๊ณ ์์ต๋๋ค.
์ด๋ถ๋ถ์์ set์ ํ์ฉํ์๋ ๋ก๋ ๋ฒํธ๊ฐ 6๊ฐ๊ฐ ๋ ๋๊น์ง ๋๋ค ์ซ์๋ฅผ ๋ฐ๋ ๋ฐฉ๋ฒ์ด ์๊ฒ ๋ค์ ์๋ํด๋ณด๊ฒ ์ต๋๋ค. |
@@ -1,5 +1,12 @@
+import EventController from "./controller/EventController.js";
+
class App {
- async run() {}
+ constructor() {
+ this.eventController = new EventController();
+ }
+ async run() {
+ await this.eventController.eventStart();
+ }
}
export default App; | JavaScript | App ์์ฒด๊ฐ Controller๋ผ๊ณ ์๊ฐํ๊ณ ๊ตฌํ์ ํ๋ ๋ฐฉ๋ฒ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค |
@@ -0,0 +1,111 @@
+import { MENU, MESSAGE, ARRAY, CALENDAR, BENEFIT_AMOUNT, BADGE, BOUNDARY } from "../commons/constants.js";
+import Order from "./Order.js";
+import { getMenu, getMenuCount } from "../commons/utils.js";
+
+class Benefit {
+ #date;
+ #menu;
+ #order;
+ #benefitResult;
+
+ constructor(date, menu) {... | JavaScript | benefitResult๋ฅผ Obejct๋ก ๊ตฌํํ๋ฉด ์ข ๋ ๊ฐ๋
์ฑ์ด ์ข์ง ์์๊น ์ถ์ต๋๋ค |
@@ -0,0 +1,88 @@
+import Benefit from "../src/model/Benefit.js";
+import { orderIntoArray } from "../src/commons/utils.js";
+
+describe("Benefit ํด๋์ค ํ
์คํธ(ํํ ์๋ ๊ฒฝ์ฐ)", () => {
+ //given
+ const date = "3";
+ const menu = orderIntoArray("ํฐ๋ณธ์คํ
์ดํฌ-1,๋ฐ๋นํ๋ฆฝ-1,์ด์ฝ์ผ์ดํฌ-2,์ ๋ก์ฝ๋ผ-1");
+ const benefit = new Benefit(date, menu);
+
+ ... | JavaScript | ํ
์คํธ๊ฐ ๋๋ฌด ํ์ ๋์ด ์๋๊ฒ ๊ฐ์ต๋๋ค test.each๋ฅผ ์ฌ์ฉํ์ฌ ์ข ๋ ๋ฒ์์ฑ ์๊ฒ ํ
์คํธ๋ฅผ ๊ตฌํํ๋ ๋ฐฉ๋ฒ์ด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค |
@@ -0,0 +1,63 @@
+import InputView from "../view/InputView.js";
+import OutputView from "../view/OutputView.js";
+import Order from "../model/Order.js";
+import Benefit from "../model/Benefit.js";
+import { print } from "../commons/utils.js";
+import { MENU } from "../commons/constants.js";
+
+class EventController {
+... | JavaScript | ๊ฐ๊ฐ์ ๋๋ ํ ๋ฆฌ์ index.js ๋ฅผ ์ถ๊ฐํ๊ณ , ๊ณตํต๋๊ฒ export ์ํค๋ฉด, import ๋ฅผ ๊ฐ๋จํ๊ฒ ํ ์ ์์ต๋๋ค!
*view/index.js*
```javascript
export {default as InputView.js} from './InputView.js'
export {default as OutputView.js} from './OutputView.js'
```
*EventController.js*
```javascript
import { InputView, OutputView } '../view/index.js'
``` |
@@ -0,0 +1,111 @@
+import { MENU, MESSAGE, ARRAY, CALENDAR, BENEFIT_AMOUNT, BADGE, BOUNDARY } from "../commons/constants.js";
+import Order from "./Order.js";
+import { getMenu, getMenuCount } from "../commons/utils.js";
+
+class Benefit {
+ #date;
+ #menu;
+ #order;
+ #benefitResult;
+
+ constructor(date, menu) {... | JavaScript | ```javascript
this.#benefitResult = Array.from({length:5(ํํ์ ๊ธธ์ด๋ฅผ ๋ํ๋ด๋ ์์๋ก ์์ )}, () => 0)
```
์ ๊ฐ์ด ๋ฐ๊พธ๋ ๊ฒ์ ์ด๋จ๊น์? |
@@ -0,0 +1,111 @@
+import { MENU, MESSAGE, ARRAY, CALENDAR, BENEFIT_AMOUNT, BADGE, BOUNDARY } from "../commons/constants.js";
+import Order from "./Order.js";
+import { getMenu, getMenuCount } from "../commons/utils.js";
+
+class Benefit {
+ #date;
+ #menu;
+ #order;
+ #benefitResult;
+
+ constructor(date, menu) {... | JavaScript | ํด๋์ค ๋ถ๋ฆฌ์ ๋๋ฌด ์ง์คํ๋๋ผ
ํํ์ ํ์ธํ๋ ํด๋์ค์ ํํ์ ์ ์ฉํ๋ ํด๋์ค๋ก ๋ถ๋ฆฌํด์ ์์ฑํ์๋๋ฐ,
ํ๋์ ํด๋์ค์ ๋ฌถ์ด์ ์์ฑํ๋ ๊ฒ๋ ๊ด์ฐฎ์ ๋ณด์ด๋ค์๐ |
@@ -0,0 +1,63 @@
+import InputView from "../view/InputView.js";
+import OutputView from "../view/OutputView.js";
+import Order from "../model/Order.js";
+import Benefit from "../model/Benefit.js";
+import { print } from "../commons/utils.js";
+import { MENU } from "../commons/constants.js";
+
+class EventController {
+... | JavaScript | Controller์ ํ๋๋ model์ ํ๋๋ฅผ ํตํด ๋ถ๋ฌ์ฌ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค!
ํ๋๋ฅผ ์ค์ฌ๋ณด๋๊ฑด ์ด๋จ๊น์? |
@@ -0,0 +1,63 @@
+import InputView from "../view/InputView.js";
+import OutputView from "../view/OutputView.js";
+import Order from "../model/Order.js";
+import Benefit from "../model/Benefit.js";
+import { print } from "../commons/utils.js";
+import { MENU } from "../commons/constants.js";
+
+class EventController {
+... | JavaScript | ERROR์ ์ถ๋ ฅ๋ util ์ด ์๋ OutputView ์์ ํด์ฃผ๋๊ฑด ์ด๋จ๊น์? |
@@ -0,0 +1,56 @@
+import { print, priceToString } from "../commons/utils.js";
+import { MESSAGE, ARRAY, BENEFIT_AMOUNT } from "../commons/constants.js";
+
+const OutputView = {
+ printStart() {
+ print(MESSAGE.START);
+ },
+
+ printOrderInformation(date, menu) {
+ print(MESSAGE.MONTH + date + MESSAGE.SHOW_BENE... | JavaScript | else ๋ฅผ ์ง์ํ๋ผ๋ ์๊ตฌ์ฌํญ์ด ์์ด์,
์์ if๋ฌธ์ return ํด์ฃผ๋ ๋ฐฉ์์ ์ถ์ฒํฉ๋๋ค! |
@@ -0,0 +1,135 @@
+package christmas.validator;
+
+import christmas.constant.Constants;
+import christmas.constant.ErrorMessage;
+import christmas.constant.Menu;
+import christmas.util.Utils;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+impo... | Java | https://www.inflearn.com/questions/819415/verify-validate-check-is
verify, validate, check, is ์ ๋ค์ด๋ฐ ์ฐจ์ด์ ๋ํด์ ์ค๋ช
ํ๋ ๊ธ์ธ๋ฐ ์ฐธ๊ณ ํ์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,25 @@
+package christmas.validator;
+
+import christmas.constant.ErrorMessage;
+
+public class DateValidator implements Validator{
+ @Override
+ public void check(final String input) {
+ checkInteger(input);
+ checkOutOfRange(input);
+ }
+
+ private void checkInteger(final String in... | Java | 1๊ณผ 31์ด ๋งค์ง๋๋ฒ๋ผ๊ณ ์๊ฐํด์! ์์๋ก ๋นผ์ฃผ๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,28 @@
+package christmas.domain;
+
+import christmas.util.Utils;
+import christmas.view.OutputView;
+
+public class OrderPrice {
+ // ๊ธ์ก๊ณผ ๊ด๋ จ๋ ํด๋์ค์
๋๋ค.
+ // ํ ์ธ ์ ์ด ์ฃผ๋ฌธ๊ธ์ก, ํ ์ธ ํ ์์ ๊ฒฐ์ ๊ธ์ก ๋ฑ์ ๊ด๋ฆฌํ๋ ํด๋์ค ์
๋๋ค.
+ private static final String UNIT = "์";
+ private OrderRepository orders;
+ private int total... | Java | '์' ๊ฐ์ ๋จ์๋ ์ถ๋ ฅ ๋ฐ ํฌ๋งคํ
๊ณผ ๊ด๊ณ์์ผ๋ฏ๋ก OutputView์ ์๋ ๊ฒ์ด ์ข ๋ ์ ์ ํ๋ค๊ณ ์๊ฐํ๋๋ฐ ์ด๋ป๊ฒ ์๊ฐํ์๋์??ใ
ใ
|
@@ -0,0 +1,40 @@
+package christmas.domain;
+
+import christmas.view.OutputView;
+
+public class EventBadge {
+ // ์ด๋ฒคํธ ๋ฑ์ง๋ฅผ ๊ด๋ฆฌ ํ๋ ํด๋์ค ์
๋๋ค.
+ private static final int SANTA_MINIMUM_LIMIT = 20000;
+ private static final int TREE_MINIMUM_LIMIT = 20000;
+ private static final int STAR_MINIMUM_LIMIT = 20000;
+ ... | Java | ์ฒ์๋ณด๋ ์ฌ๋์ discountAmount์ -๋ฅผ ์ ๋ถ์ด์ง? ๋ผ๊ณ ์๊ฐํ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค!
์ ๋ ๋น์ทํ๊ฒ ๊ตฌํํ๊ณ ํผ๋๋ฐฑ์ ๋ฐ์๋๋ฐ
๋ณ์์ด๋ฆ๊ณผ final์ ์ด์ฉํด -๋ฅผ ๋ถ์ธ ๋ณ์๊ฐ ๋ฌด์์ ๋ปํ๋์ง ํ๋ฒ ๋ ์ ์ํด์ฃผ๋ ๊ฒ๋ ์ข๋ค๊ณ ์๊ฐํด์! |
@@ -0,0 +1,178 @@
+package christmas.domain;
+
+import christmas.constant.Constants;
+import christmas.constant.Menu;
+import christmas.constant.MenuType;
+import christmas.util.Utils;
+import christmas.view.OutputView;
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.... | Java | ๋งค์ง๋๋ฒ๊ฐ ๋ง์ด ์ฐ์ธ ๊ฒ ๊ฐ์ต๋๋ค! ์์์ ์์๋ก ์ ์ธํด์ฃผ๋ฉด ์ข์ ๊ฒ ๊ฐ์์~!! |
@@ -0,0 +1,105 @@
+package christmas.controller;
+
+import christmas.domain.BenefitInformation;
+import christmas.domain.Date;
+import christmas.domain.EventBadge;
+import christmas.domain.GiftMenu;
+import christmas.domain.Order;
+import christmas.domain.OrderManager;
+import christmas.domain.OrderPrice;
+import chris... | Java | ๋๋ฉ์ธ๋ณด๋ค๋ controller์์ outputView๋ฅผ ํธ์ถํด์ฃผ๋ ๊ตฌ์กฐ๊ฐ ๋์ด์ผํ๋ค๊ณ ์๊ฐํฉ๋๋ค ใ
ใ
๋ง์ฝ mvc ๊ตฌ์กฐ๋ผ๋ฉด์!! |
@@ -0,0 +1,21 @@
+package christmas.constant;
+
+public enum Constants {
+ EVENT_START_DATE(1),
+ EVENT_END_DATE(25),
+ MENU_LIMIT(20),
+ CHAMPAGNE_LIMIT(120000),
+ MINIMUM_DISCOUNT_ABLE_AMOUNT(10000),
+ THIS_YEAR(2023),
+ EVENT_MONTH(12);
+
+ public int constants;
+
+ Constants(final int con... | Java | ํด๋น ์์ ๊ฐ๋ค์ ํ์ํ ๊ฐ ๋๋ฉ์ธ์ด ๋ค๊ณ ์๋ ๊ฒ์ ์ด๋ค๊ฐ์~~?? ๊ทธ๋ ๊ฒ ํ๋ฉด ํด๋์ค์ ์์ง๋๋ฅผ ์กฐ๊ธ ๋ ๋์ผ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค! |
@@ -0,0 +1,13 @@
+package christmas.domain;
+
+public class Date {
+ private int date;
+
+ public Date(final int date) {
+ this.date = date;
+ }
+
+ public int getDate() {
+ return this.date;
+ }
+}
\ No newline at end of file | Java | ํด๋น ํด๋์ค๊ฐ ์กด์ฌํ๋ ์ด์ ๊ฐ ์๋์?!! ํด๋์ค๋ก์ ์์ ํ๋ ค๋ฉด Date์ ๊ด๋ จ๋ validate ์ฝ๋๊ฐ ์์ฑ์ ์์ ์์ด์ผํ ๊ฒ ๊ฐ์ต๋๋ค..!!! |
@@ -0,0 +1,13 @@
+package christmas.domain;
+
+public class Date {
+ private int date;
+
+ public Date(final int date) {
+ this.date = date;
+ }
+
+ public int getDate() {
+ return this.date;
+ }
+}
\ No newline at end of file | Java | ๋ํ record๋ก ๋ฐ๊ฟ๋ ์ข์ ๊ฒ ๊ฐ๋ค์ ใ
ใ
|
@@ -0,0 +1,21 @@
+package christmas.constant;
+
+public enum Constants {
+ EVENT_START_DATE(1),
+ EVENT_END_DATE(25),
+ MENU_LIMIT(20),
+ CHAMPAGNE_LIMIT(120000),
+ MINIMUM_DISCOUNT_ABLE_AMOUNT(10000),
+ THIS_YEAR(2023),
+ EVENT_MONTH(12);
+
+ public int constants;
+
+ Constants(final int con... | Java | ๊ฐ ๋๋ฉ์ธ์ด ๋ค๋ฉฐ ์์ง๋๋ฅผ ๋ํ๋ ๋ฐฉ๋ฒ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋ค! ๐ซ |
@@ -0,0 +1,105 @@
+package christmas.controller;
+
+import christmas.domain.BenefitInformation;
+import christmas.domain.Date;
+import christmas.domain.EventBadge;
+import christmas.domain.GiftMenu;
+import christmas.domain.Order;
+import christmas.domain.OrderManager;
+import christmas.domain.OrderPrice;
+import chris... | Java | MVC ๋ง์ด ๊ณต๋ถํด์ผ ๊ฒ ๋ค์ ใ
ใ
|
@@ -0,0 +1,13 @@
+package christmas.domain;
+
+public class Date {
+ private int date;
+
+ public Date(final int date) {
+ this.date = date;
+ }
+
+ public int getDate() {
+ return this.date;
+ }
+}
\ No newline at end of file | Java | recordํ์ ์์ฐ๋ ์ฝ๋ ๋ณด๋ฉด์ ์ฒ์ ๋ฐฐ์ ๋๋ฐ ์ ์ฉํ๊ฒ ์ ์ฌ์ฉํ ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค !
`date`์ `validate`๊ฐ ์๋ ์ด์์ ์ฌ์ค ์๋ฏธ๊ฐ ์๋๊ฑฐ ๊ฐ๋ค์,,ใ
ใ
|
@@ -0,0 +1,40 @@
+package christmas.domain;
+
+import christmas.view.OutputView;
+
+public class EventBadge {
+ // ์ด๋ฒคํธ ๋ฑ์ง๋ฅผ ๊ด๋ฆฌ ํ๋ ํด๋์ค ์
๋๋ค.
+ private static final int SANTA_MINIMUM_LIMIT = 20000;
+ private static final int TREE_MINIMUM_LIMIT = 20000;
+ private static final int STAR_MINIMUM_LIMIT = 20000;
+ ... | Java | ๋ชจ๋ฅด๋ ์ฌ๋์ด ์ฝ๋๋ฅผ ๋ณด๋ฉด ์ ์์ง? ์๊ฐํ ์๋ ์๊ฒ ๋ค์!
๋ณ์๋ช
๊ณผ, ์ฃผ์์ ํตํด ์๋ฏธ๋ฅผ ๋ํ๋ด๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ธ ๊ฒ ๊ฐ๋ค์ ๐ซ |
@@ -0,0 +1,28 @@
+package christmas.domain;
+
+import christmas.util.Utils;
+import christmas.view.OutputView;
+
+public class OrderPrice {
+ // ๊ธ์ก๊ณผ ๊ด๋ จ๋ ํด๋์ค์
๋๋ค.
+ // ํ ์ธ ์ ์ด ์ฃผ๋ฌธ๊ธ์ก, ํ ์ธ ํ ์์ ๊ฒฐ์ ๊ธ์ก ๋ฑ์ ๊ด๋ฆฌํ๋ ํด๋์ค ์
๋๋ค.
+ private static final String UNIT = "์";
+ private OrderRepository orders;
+ private int total... | Java | ๋ฐ๋ก OutputView ํด๋์ค์ ์ ์ธํ๋๊ฒ ์ข ๋ ์ ์ ํด ๋ณด์ด๋ค์ ใ
ใ
|
@@ -0,0 +1,135 @@
+package christmas.validator;
+
+import christmas.constant.Constants;
+import christmas.constant.ErrorMessage;
+import christmas.constant.Menu;
+import christmas.util.Utils;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+impo... | Java | ์ข์ ์ ๋ณด ๊ฐ์ฌํฉ๋๋ค ๐ฅ๐ฅ |
@@ -0,0 +1,29 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authentication.AuthenticationException;
+import org.aopalliance.intercept.MethodInvocation;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+public class SecuredA... | Java | method.getAnnotation(Secured.class)๋ฅผ ์ฌ์ฉํ์ฌ `@Secured` ์ด๋
ธํ
์ด์
์ ์กฐํํ๊ณ ์๋ค์.
Spring AOP ํ๊ฒฝ์์๋ ๋ฉ์๋๊ฐ ํ๋ก์ ๊ฐ์ฒด๋ก ๊ฐ์ธ์ง ์ ์๊ธฐ ๋๋ฌธ์, ํ๋ก์๋ ๋ฉ์๋๋ฅผ ์กฐํํ ๊ฒฝ์ฐ ์ค์ ๊ตฌํ์ฒด์ ๋ฉ์๋์์ ์ ์ธ๋ `@Secured` ์ด๋
ธํ
์ด์
์ ์ฐพ์ง ๋ชปํ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค.
method.getAnnotation ์ AopUtils.getMostSpecificMethod() ์ด๋ค ์ฐจ์ด๊ฐ ์์๊น์? ๐ |
@@ -23,7 +23,7 @@
@AutoConfigureMockMvc
class BasicAuthTest {
private final Member TEST_ADMIN_MEMBER = new Member("a@a.com", "password", "a", "", Set.of("ADMIN"));
- private final Member TEST_USER_MEMBER = new Member("b@b.com", "password", "b", "", Set.of());
+ private final Member TEST_USER_MEMBER = new M... | Java | ํ
์คํธ ์ฝ๋ ๐ |
@@ -0,0 +1,29 @@
+package nextstep.security.authorization;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authentication.AuthenticationException;
+import org.aopalliance.intercept.MethodInvocation;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+public class SecuredA... | Java | AopUtils.getMostSpecificMethod()๋ฅผ ์ฌ์ฉํ๋ฉด ํ๋ก์ ๊ฐ์ฒด๋ ์๋๋ ์ค์ ๊ฐ์ฒด์ ๋ฉ์๋๋ฅผ ์กฐํํ์ฌ @Secured ์ด๋
ธํ
์ด์
์ ๋ชป์ฐพ๋ ๊ฒฝ์ฐ๊ฐ ๋ฐ์ํ์ง ์๊ฒ ๋ค์!
๊ฐ์ฌํฉ๋๋ค :) |
@@ -0,0 +1,88 @@
+import { createGlobalStyle } from 'styled-components'
+import reset from 'styled-reset'
+
+const MainStyles = createGlobalStyle`
+ .relative{position:relative}
+ .absolute{position:absolute}
+ .fixed{position:fixed}
+
+ .flex-center-between {
+ display: flex;
+ align-ite... | TypeScript | ์ด๋ ๊ฒ ์ฐ๊ณ ์ถ๋ค๋ฉด, ๊ด๋ จ `styles/mixin.ts`์ mixin ํจ์๋ฅผ ๋ง๋ค ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค.
// flex๊ด๋ จ mixin
```suggestion
interface FlexMixin={
justifyContent?:'center' | 'flex-end' | 'flex-start' | 'space-evenly'
alignItems? :'center' | 'flex-end'
}
export const MixinFlex({ alignItems,justifyContent } : FlexMixin) {
... |
@@ -0,0 +1,41 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.Secured;
+import org.aopalliance.intercept.MethodInvocation;
+import org.springframework.co... | Java | ```suggestion
if (authentication == null) {
return AuthorizationDecision.ACCESS_DENIED;
}
```
๊ถํ์ ๋ฐ๋ฅธ ์์ธ ์ฒ๋ฆฌ๋ Interceptor์ ์ญํ ๋ก ๋๊ฒจ์ฃผ๋ฉด ์ด๋จ๊น์? |
@@ -0,0 +1,28 @@
+package nextstep.security.authorization.manager;
+
+import jakarta.servlet.http.HttpServletRequest;
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.access.RequestMatcherEntry;
+
+import java... | Java | AuthorizationManager์ ๋ํ ์ถ์ํ๋ฅผ ์ ํด์ฃผ์
จ๋ค์ ๐ |
@@ -1,13 +1,23 @@
package nextstep.app;
+import jakarta.servlet.http.HttpServletRequest;
import nextstep.app.domain.Member;
import nextstep.app.domain.MemberRepository;
import nextstep.security.authentication.AuthenticationException;
import nextstep.security.authentication.BasicAuthenticationFilter;
import next... | Java | `๊ทธ ์ธ ๋ชจ๋ ์์ฒญ์ ๊ถํ์ ์ ํํ๊ธฐ ์ํด DenyAllAuthorizationManager๋ก ์ฒ๋ฆฌ`
ํด๋น ์๊ตฌ์ฌํญ์ด ๋ฐ์ ์๋์ด ์๋ ๊ฒ ๊ฐ๋ค์! |
@@ -1,13 +1,23 @@
package nextstep.app;
+import jakarta.servlet.http.HttpServletRequest;
import nextstep.app.domain.Member;
import nextstep.app.domain.MemberRepository;
import nextstep.security.authentication.AuthenticationException;
import nextstep.security.authentication.BasicAuthenticationFilter;
import next... | Java | ๋ช
ํํ ์ญํ ์ ๊ตฌ๋ถํ๊ธฐ ์ํด AuthenticatedAuthorizationManager์ HasAuthorityAuthorizationManager๋ฅผ ๋ถ๋ฆฌํด์ ๊ตฌํํด๋ด๋ ์ข๊ฒ ๋ค์! |
@@ -0,0 +1,41 @@
+package nextstep.security.authorization.manager;
+
+import nextstep.security.authentication.Authentication;
+import nextstep.security.authorization.AuthorizationDecision;
+import nextstep.security.authorization.Secured;
+import org.aopalliance.intercept.MethodInvocation;
+import org.springframework.co... | Java | ์์ธ ์ฑ
์์ Interceptor์์ ํ๋ ๊ฒ์ด ๋ง๋ ๊ฒ ๊ฐ์์ ์์ ํ์์ต๋๋ค ! |
@@ -1,13 +1,23 @@
package nextstep.app;
+import jakarta.servlet.http.HttpServletRequest;
import nextstep.app.domain.Member;
import nextstep.app.domain.MemberRepository;
import nextstep.security.authentication.AuthenticationException;
import nextstep.security.authentication.BasicAuthenticationFilter;
import next... | Java | ์ ์ด๋ถ๋ถ์ ๋นผ๋จน์๊ตฐ์ ใ
ใ
ใ
permitAll()์ด ์๋๋ผ denyAll()๋ก ์ฒ๋ฆฌํ ๋ค, ํ
์คํธ ์ถ๊ฐํ๋๋ก ํ๊ฒ ์ต๋๋ค. |
@@ -1,13 +1,23 @@
package nextstep.app;
+import jakarta.servlet.http.HttpServletRequest;
import nextstep.app.domain.Member;
import nextstep.app.domain.MemberRepository;
import nextstep.security.authentication.AuthenticationException;
import nextstep.security.authentication.BasicAuthenticationFilter;
import next... | Java | ์๋
ํ์ธ์ ์ฌ์ฐ๋ !
์ ๊ฐ ์ด๋ถ๋ถ ์ฝ๋ฉํธ๋ฅผ ์ ํํ๊ฒ ์ดํดํ์ง๋ ๋ชปํ ๊ฒ ๊ฐ์ต๋๋ค.
๊ธฐ์กด ์ ๊ฐ ๊ตฌํํ ๋ถ๋ถ์ AuthorityAuthorizationManager<T>์์ ์ฒ๋ฆฌํ ๊ถํ๋ค์ ๊ฐ์ง๊ณ ์๊ณ , AuthoritiesAuthorizationManager๋ ์ ๋ฌ๋ฐ์ Role๋ค๋ก ๊ฒ์ฌ๋ง ํ๋ ์ฑ
์์ ๊ฐ์ง๊ณ ์๋๋ฐ์.
HasAuthorityAuthorizationManager๋ผ๋ ๊ฒ์ delegateํ์ง ์๊ณ , ์ค์ค๋ก ์ฒ๋ฆฌํ ์ญํ ์ ์๊ณ ์๊ณ ์ฒ๋ฆฌํ๋ ๊ฐ์ฒด๋ฅผ ์๋ฏธํ์๋ ๊ฒ ๋ง์๊น์!? |
@@ -1,13 +1,23 @@
package nextstep.app;
+import jakarta.servlet.http.HttpServletRequest;
import nextstep.app.domain.Member;
import nextstep.app.domain.MemberRepository;
import nextstep.security.authentication.AuthenticationException;
import nextstep.security.authentication.BasicAuthenticationFilter;
import next... | Java | ํด๋น ์ฝ๋ฉํธ๋ ํด๋น ๊ฐ์ฒด๊ฐ ํ๋์ ์ญํ ๋ง ๋ด๋นํ๋ฉด ๊ฐ๋
์ฑ์ด ๋ ์ข์์ง ๊ฒ ๊ฐ์ ๋จ๊ธด๊ฑด๋ฐ์.
์คํ๋ง ์ํ๋ฆฌํฐ๋ ์ฐฌํธ๋์ด ๊ตฌํํ์ ๋ฐฉ์์ฒ๋ผ ๋ถ๋ฆฌ๋์ด ์์ง ์์ ์ฝ๋๋ผ์ ๊ผญ ๋ฐ์ํ์ค ํ์๋ ์์ง๋ง..
์ ๊ฐ ๋ดค์ ๋ ์คํ๋ง ์ํ๋ฆฌํฐ๋ ์ญํ ์ ๊ตฌ๋ถํ๋ฉด ๋ ๊ฐ๋
์ฑ์ด ์ข์์ง ๊ฒ ๊ฐ์์ ใ
ใ
ํ ๋ฒ ๊ณ ๋ฏผํด๋ณด์๋ฉด ์ข์ ๊ฒ ๊ฐ์ ์ฝ๋ฉํธ๋ฅผ ๋จ๊ฒผ์ต๋๋ค~ |
@@ -0,0 +1,35 @@
+package db;
+
+import db.HttpSessions;
+import model.User;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import webserver.domain.Session;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class HttpSessionsTest {
+
+ @Test
+ @DisplayName("์ธ์
... | Java | ํ
์คํธ๋ Session ์ถ๊ฐ์์ ๊ฐ์ด ํด์ฃผ์
จ๋ค์. ๐ |
@@ -0,0 +1,35 @@
+package db;
+
+import db.HttpSessions;
+import model.User;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import webserver.domain.Session;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class HttpSessionsTest {
+
+ @Test
+ @DisplayName("์ธ์
... | Java | ๋ถ์ผ์น๊น์ง ๐ |
@@ -0,0 +1,35 @@
+package db;
+
+import db.HttpSessions;
+import model.User;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import webserver.domain.Session;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class HttpSessionsTest {
+
+ @Test
+ @DisplayName("์ธ์
... | Java | ์ฌ์ฉํ์ง ์๋ import๋ ์ ๊ฑฐํ์ฃ ๐ |
@@ -16,10 +16,10 @@ public class HttpResponse {
private HttpStatusCode httpStatusCode;
private Map<String, String> headers;
- private List<Cookie> cookies;
+ private Cookies cookies;
private byte[] body;
- public HttpResponse(HttpStatusCode httpStatusCode, Map<String, String> headers, List<C... | Java | ์ง๊ธ์ ์ ๊ฑฐํ์
จ์ง๋ง ๋๋ฒ๊น
๋ชฉ์ ์ผ๋ก System.out.println์ด ์๋๋ผ logger.debug๋ฅผ ์ฌ์ฉํด์ฃผ์
จ์๋ค์. ๐ฏ |
@@ -105,9 +105,15 @@ public String getBody() {
}
public boolean containsCookie(String cookie) {
- return this.headers
- .get(HttpHeader.COOKIE)
- .contains(cookie);
+ String requestCookie = this.headers.get(HttpHeader.COOKIE);
+ if (requestCookie != null) {... | Java | ์ฝ๊ฐ์ ๊ฐ์ธ์ ์ธ ์ ํธ์ธ๋ฐ ์ง๊ธ์ ๋ณต์กํ์ง ์์์ ์ฐจ์ด๊ฐ ํฌ์ง ์์ง๋ง ์ฌ๋์ ๋ถ์ ๋ณด๋ค๋ ๊ธ์ ์ ๋ ์์ฐ์ค๋ฝ๊ฒ ์ฝ๋ ๊ฒฝํฅ์ด ์์ด์ ๊ฐ๋ฅํ๋ค๋ฉด ๊ธ์ ์ ์กฐ๊ฑด์ ์ ํํ๋ ํธ์
๋๋ค.
```java
if (StringUtils.hasText(requestCookie)) {
return requestCookie.contains(cookie);
}
return false;
```
๋น ๋ฌธ์์ด์ผ ๋๋ ์ด๋ป๊ฒ ํด์ผํ ์ง๋ ์ด์ง ๊ณ ๋ฏผ๋๋ค์. |
@@ -0,0 +1,31 @@
+package db;
+
+import webserver.domain.Session;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class HttpSessions {
+ private static final Map<String, Session> sessions = new HashMap<>();
+
+ public static String getId() {
+ return UUID.randomUUID().... | Java | ์ ํ๋ฆฌ์ผ์ด์
๊ณตํต์ ์ผ๋ก ์ฌ์ฉ๋ ์ ์๊ฒ DB๋ก ์ฌ์ฉํด ์ฃผ์
จ๋ค์ ๐ |
@@ -0,0 +1,31 @@
+package db;
+
+import webserver.domain.Session;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class HttpSessions {
+ private static final Map<String, Session> sessions = new HashMap<>();
+
+ public static String getId() {
+ return UUID.randomUUID().... | Java | ํค ์์ฑ์ ์ด๋ป๊ฒ ํ ๊น ๊ณ ๋ฏผํ๋ค๊ฐ DB๊ฐ ํค์์ฑ์ ํ๋๊ฑธ ๊ณ ๋ คํ์ฌ ์ฌ๊ธฐ ๋ฃ์ด ์ฃผ์ ๊ฒ ๊ฐ๋ค์.
DB์์ ๋ณดํต ์ด์ ๊ฐ์ ๋์๋ก ํค๋ฅผ ๋ง๋ค์ง๋ ์๊ณ , HttpSessions๊ฐ ์๋ ๋ค๋ฅธ DB, ์๋ฅผ ๋ค๋ฉด Redis๋ฅผ ์ฌ์ฉํ๋ฉด ๋จ์ํ DB๋ฅผ ๋ฐ๊พธ๋ ๊ฑธ๋ก ์์
์ด ๋๋์ง ์๊ณ ๋์ ์์ฑ์ ๋ํ ๊ณ ๋ฏผ์ ํ์
์ผ ํ ํ
๋ฐ ์ด์ ๋ํ ์ญํ ์ DB๊ฐ ์๋ ๊ณณ์ผ๋ก ๋๊ฒจ๋ณด์ฃ .
์ด๊ฑด ์๋ Request๊ด๋ จ ๋ด์ฉ์ ๋จ๊ธธ๊ฒ์! |
@@ -1,24 +1,43 @@
package webserver.controller;
import db.DataBase;
+import db.HttpSessions;
import model.User;
+import org.checkerframework.checker.units.qual.C;
import webserver.domain.*;
+import java.util.UUID;
+
public class LoginController extends AbstractController {
@Override
public HttpRespon... | Java | Session์ ๋ํ ์ถ๊ฐ๋ก ์๋นํ ๋ณต์กํด์ก๋ค์.
Controller์ ๋๋ถ๋ถ์ ์ฝ๋๊ฐ Http์ ๋ํ ์์
์ธ๋ฐ Session๋ ๊ฒฐ๊ตญ Http์ ์คํ์ธ๊ฑธ ๊ณ ๋ คํด์ Request, Response๋ฅผ ํตํด ๊ด๋ฆฌํ ์ ์์ง ์์๊น์? (์์ ๋ง์๋๋ฆฐ session id์ ์ถ๊ฐ ๋ํ ๋ง์ด์ฃ .)
๊ทธ๋ฌ๋ฉด Controller๋ Session์ ๊ฐ์ ธ์ค๊ณ , ์ถ๊ฐ ์์ฒญ๋ง ํ๋ ๋ฐฉ๋ฒ์ผ๋ก ์ฌ์ฉํ๊ธฐ๋ง ํ ์ ์์ ๊ฒ ๊ฐ์์. |
@@ -1,21 +1,27 @@
package webserver.domain;
+
+import java.util.Objects;
+
public class Cookie {
+ public static final String PATH = "Path";
private String name;
private String value;
- private String pathName;
- private String pathValue;
+ private String path;
public Cookie(String name... | Java | `cookieString` ํ์
์ ๋ณ์๋ช
์ ์จ์ค ํ์๋ ์์ต๋๋ค! |
@@ -0,0 +1,42 @@
+package webserver.domain;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.StringUtils;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Cookies {
+ private static final Logger logger = LoggerFactory.getLogger... | Java | [Java8 Stream์ loop๊ฐ ์๋๋ค.](https://www.popit.kr/java8-stream%EC%9D%80-loop%EA%B0%80-%EC%95%84%EB%8B%88%EB%8B%A4/)
```java
for (String str : cookiesString.trim().split(";")) {
String[] keyValue = str.split("=");
cookies.put(keyValue[0].trim(), new Cookie(keyValue[0].trim(), keyValue... |
@@ -0,0 +1,29 @@
+package webserver.domain;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Session {
+ private Map<String, Object> attribute;
+
+ public Session() {
+ this.attribute = new HashMap<>();
+ }
+
+ public Object getAttribute(String name) {
+ return attribute.g... | Java | ๊ตฐ๋๋๊ธฐ ์์ด ์ ๊ตฌํํ๋ค์. ๐ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.