티스토리 뷰
1. jS - 가위 바위 보 3개의 버튼을 작성후 해당 버튼을 누르면 이미지가 바뀌게 하시오.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<title>jQuery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
/*
window.onload = function() {
var rspImgNode = document.getElementById("rspImg");
rspImgNode.setAttribute("src", "rsp_img/qIcon.png");
rspImgNode.style.width = "300px";
rspImgNode.style.height = "300px";
var sciBtn = document.getElementById("scissors");
sciBtn.onclick = () => {
rspImgNode.setAttribute("src", "rsp_img/sciss.png");
};
var rockBtn = document.getElementById("rock");
rockBtn.onclick = () => {
rspImgNode.setAttribute("src", "rsp_img/rock.png");
};
var paperBtn = document.getElementById("paper");
paperBtn.onclick = () => {
rspImgNode.setAttribute("src", "rsp_img/paper.png");
};
};
*/
$(document).ready( () => {
var rspImgObj = $("#rspImg");
rspImgObj.attr("src", "rsp_img/qIcon.png");
rspImgObj.css("width", "300px");
rspImgObj.css("height", "300px");
$("#scissors").click( function() {
$("#rspImg").attr("src", "rsp_img/sciss.png");
});
$("#rock").click( function() {
$("#rspImg").attr("src", "rsp_img/rock.png");
});
$("#paper").click( function() {
$("#rspImg").attr("src", "rsp_img/paper.png");
})
});
</script>
<style>
body{
text-align: center;
}
#rspImg{
margin-top: 30px;
}
input[type="button"]{
margin: 15px;
}
</style>
</head>
<body>
<img id="rspImg">
<br>
<form id="rspBtn">
<input type="button" id="scissors" value="가위">
<input type="button" id="rock" value="바위">
<input type="button" id="paper" value="보">
</form>
</body>
</html>
|
cs |
2. 스프링 시큐리티 설정을 위한 pom.xml 과 web.xml 및 가장 기본적인 security-context.xml 설정은?
pom.xml에서는 아래의 두 부분이 중요하다.
1
2
3
4
5
6
7
8
9
10
11
|
<properties>
<java-version>1.8</java-version>
<org.springframework-version>5.0.7.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
<org.security-version>5.0.6.RELEASE</org.security-version>
<!-- 스프링 시큐리티는 버전을 맞춰주는 것이 중요하다... -->
<!-- 스프링 스큐리티는 무조건
<org.springframework-version>5.0.7.RELEASE</org.springframework-version>
이 버전보다 낮을 걸 사용해야한다!!-->
</properties>
|
cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${org.security-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<!-- web에서 사용할 거다! -->
<version>${org.security-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${org.security-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${org.security-version}</version>
</dependency>
|
cs |
web.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- The definition of the Root Spring Container shared by all Servlets
and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<!-- 스프링 시큐리티를 위한 xml 추가 -->
<param-value>/WEB-INF/spring/root-context.xml,/WEB-INF/spring/security-context.xml</param-value>
<!-- <param-value>/WEB-INF/spring/security-context.xml</param-value> -->
<!-- 위에처럼 param_value 태그를 각각 따로따로 써주면 안되니 주의하기! -->
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 한글처리 필터 밑에 시큐리티를 위한 필터를 써줘야한다! -->
<!-- Spring Security Filter -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
|
cs |
security-context.xml
위치는 root-context.xml과 동일하다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 스프링 시큐리티가 아래 코드만 있으면 알아서 로그인 폼을 만들어줘서
http://localhost:8282/ex/login로 접근 가능 -->
<http>
<!-- http://localhost:8282/ex/security/all 로 접속하면 모든 사람이 접근할 수 있다. -->
<intercept-url pattern="/security/all" access="permitAll" />
<intercept-url pattern="/security/member" access="hasRole('ROLE_MEMBER')" />
<!-- http://localhost:8282/ex/security/member로 접속하면 권한이 MEMBER인 사람만 접근 가능하다.
MEMBER가 아니면 로그인 페이지를 띄운다. -->
<form-login/>
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="member" password="{noop}member" authorities="ROLE_MEMBER" />
<user name="mananger" password="{noop}mananger" authorities="ROLE_MEMBER" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
|
cs |
3. 인증과 권한에 대하여 설명하시오.
[ 인증(Authorizatoin)과 인가(Authentication) ]
- 인증(Authentication): 해당 사용자가 본인이 맞는지를 확인하는 절차
- 인가(Authorization): 인증된 사용자가 요청한 자원에 접근 가능한지를 결정하는 절차
Spring Security는 기본적으로 인증 절차를 거친 후에 인가 절차를 진행하게 되며, 인가 과젱에서 해당 리소스에 대한 접근 권한이 있는지 확인을 하게 된다. Spring Security에서는 이러한 인증과 인가를 위해 Principal을 아이디로, Credential을 비밀번호로 사용하는 Credential 기반의 인증 방식을 사용한다.
- Principal(접근 주체): 보호받는 Resource에 접근하는 대상
- Credential(비밀번호): Resource에 접근하는 대상의 비밀번호
- 출처: https://mangkyu.tistory.com/76 [MangKyu's Diary]
https://wildeveloperetrain.tistory.com/50
Spring Security 시큐리티 동작 원리 이해하기 - 1
스프링 시큐리티 (Spring Security)는 스프링 기반 어플리케이션의 보안(인증과 권한, 인가)을 담당하는 스프링 하위 프레임워크입니다. 보안과 관련해서 체계적으로 많은 옵션들을 제공해주기 때문
wildeveloperetrain.tistory.com
https://mangkyu.tistory.com/76
[SpringBoot] Spring Security란?
대부분의 시스템에서는 회원의 관리를 하고 있고, 그에 따른 인증(Authentication)과 인가(Authorization)에 대한 처리를 해주어야 한다. Spring에서는 Spring Security라는 별도의 프레임워크에서 관련된 기능
mangkyu.tistory.com
개별진척도 - 1번 가위바위보
'수업문제' 카테고리의 다른 글
[문제] 1월 5일 (js, jquery 가위바위보 게임) (0) | 2022.01.05 |
---|---|
[문제] 1월 4일 (js- 국영수 생성자 & jQurey 이벤트) (0) | 2022.01.04 |
[문제] 12월 23일 (spring mvc_board 게시판, 페이징 sql문, JS class) (0) | 2021.12.23 |
[문제] 12월 21일 (mybatis mvc_board 게시판 만들기 TO DO List) (0) | 2021.12.22 |
- Total
- Today
- Yesterday
- toString
- 세션
- 프로토콜
- 진척도 70번
- compareTo
- object
- SOCKET
- Session
- hashset
- JSP
- equals
- Generic
- abstract
- string
- 참조형
- exception
- Request
- 부트스트랩
- 채팅
- el
- 래퍼 클래스
- 쓰레드
- 제네릭
- TreeSet
- 예외처리
- response
- 입출력
- 사칙연산 계산기
- 쿠키
- Servlet
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |