728x90
๋ฐ˜์‘ํ˜•

์ „์ฒด ๊ธ€ 1364

[JAVA] JWT์ธ์ฆ ํ† ํฐ์„ ๊ฑฐ์น˜์ง€ ์•Š๋Š” ์˜ˆ์™ธ API ์„ค์ •ํ•˜๊ธฐ ๋ฐฉ๋ฒ•2

๋ฐฉ๋ฒ• 2: WebSecurityCustomizer๋กœ ๋ณด์•ˆ ๋ฌด์‹œ ์„ค์ •WebSecurityCustomizer๋ฅผ ์‚ฌ์šฉํ•ด ํŠน์ • ๊ฒฝ๋กœ์— ๋Œ€ํ•ด Spring Security์˜ ๋ชจ๋“  ํ•„ํ„ฐ๋ฅผ ๋ฌด์‹œํ•˜๋„๋ก ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.@Beanpublic WebSecurityCustomizer webSecurityCustomizer() { return (web) -> web.ignoring() // JWT ์ธ์ฆ์„ ๊ฑฐ์น˜์ง€ ์•Š๋Š” ๊ฒฝ๋กœ .antMatchers("/api/public/**");}์ฃผ์š” ์‚ฌํ•ญ:๋ณด์•ˆ ๋ฌด์‹œ: ํ•ด๋‹น ๊ฒฝ๋กœ๋Š” Spring Security์˜ ๋ชจ๋“  ํ•„ํ„ฐ๋ฅผ ์šฐํšŒํ•˜๋ฏ€๋กœ, CORS๋‚˜ CSRF ๊ฐ™์€ ์„ค์ •๋„ ์˜ํ–ฅ์„ ๋ฐ›์ง€ ์•Š์Šต๋‹ˆ๋‹ค.๊ฒฝ๋กœ ์˜ˆ์™ธ: ๋ณด์•ˆ์ด ์™„์ „ํžˆ ๋น„ํ™œ์„ฑํ™”๋˜๋ฏ€๋กœ, ์ธ์ฆ์ด ํ•„์š” ์—†๋Š”..

JAVA 2024.11.23

[JAVA] JWT์ธ์ฆ ํ† ํฐ์„ ๊ฑฐ์น˜์ง€ ์•Š๋Š” ์˜ˆ์™ธ API ์„ค์ •ํ•˜๊ธฐ ๋ฐฉ๋ฒ•1

๋ฐฉ๋ฒ• 1: HttpSecurity์—์„œ permitAll() ์‚ฌ์šฉHttpSecurity๋ฅผ ํ™œ์šฉํ•ด ๊ฒฝ๋กœ์— ๋Œ€ํ•ด ๋ช…์‹œ์ ์œผ๋กœ ์ธ์ฆ์„ ๋น„ํ™œ์„ฑํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.@Beanpublic SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { return http .httpBasic().disable() // ๊ธฐ๋ณธ ์ธ์ฆ ๋น„ํ™œ์„ฑํ™” .csrf().disable() // CSRF ๋น„ํ™œ์„ฑํ™” .authorizeHttpRequests() // JWT ์ธ์ฆ ์—†์ด ํ—ˆ์šฉํ•  API ๊ฒฝ๋กœ .antMatchers("/api/public/**").permitA..

JAVA 2024.11.22

[DB][Oracle] Number(1,0)

Oracle์—์„œ ๋ฐ์ดํ„ฐ ์œ ํ˜•์€ NUMBER(1,0)๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ œ์•ฝ ์กฐ๊ฑด์ด ์žˆ๋Š” ์ˆซ์ž ๊ฐ’์„ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.์ •๋ฐ€๋„( 1) : ์ˆซ์ž๋Š” ์ตœ๋Œ€ 1์ž๋ฆฌ๊นŒ์ง€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.ํฌ๊ธฐ( 0) : ์ˆซ์ž์—๋Š” ์†Œ์ˆ˜ ์ž๋ฆฟ์ˆ˜๊ฐ€ ํฌํ•จ๋  ์ˆ˜ ์—†์œผ๋ฉฐ ์ •์ˆ˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.์œ ํšจํ•œ ๊ฐ’๊ฐ’์˜ ๋ฒ”์œ„๋Š” -9๋ถ€ํ„ฐ 9 (ํ•œ ์ž๋ฆฌ ์ •์ˆ˜)๊นŒ์ง€์ž…๋‹ˆ๋‹ค.์œ ํšจํ•œ ๊ฐ’์˜ ์˜ˆ05-3์ž˜๋ชป๋œ ๊ฐ’์˜ ์˜ˆ10(1์ž๋ฆฌ ์ดˆ๊ณผ)1.2(์†Œ์ˆ˜์  ๋ถ€๋ถ„์ด ์žˆ์Œ)0์ด ๋ฐ์ดํ„ฐ ์œ ํ˜•์€ ํ”Œ๋ž˜๊ทธ๋‚˜ ๋ถ€์šธ๊ณผ ๊ฐ™์€ ๊ฐ’( ๋˜๋Š” ) ๊ณผ ๊ฐ™์€ ์ž‘์€ ์ •์ˆ˜๋ฅผ ์ €์žฅํ•˜๋Š” ๋ฐ ์ž์ฃผ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค . ๋” ์—„๊ฒฉํ•œ ๊ฐ’(์˜ˆ: ๋˜๋Š” 1)์„ ์ ์šฉํ•ด์•ผ ํ•˜๋Š” ๊ฒฝ์šฐ ์ผ๋ฐ˜์ ์œผ๋กœ ์ œ์•ฝ ์กฐ๊ฑด์ด๋‚˜ ๊ฒ€์ฆ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋ฅผ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.01

DB 2024.11.21

[JAVA] ๊ธˆ์•ก(BigDecimal)์„ ํ•œ๊ธ€๋กœ ๋ณ€ํ™˜ํ•˜๊ธฐ

import java.math.BigDecimal;public class NumberToKorean { public static String convertToKorean(BigDecimal amount) { if (amount == null || amount.compareTo(BigDecimal.ZERO) == 0) { return "์˜"; } final String[] KOREAN_NUMBERS = { "", "์ผ", "์ด", "์‚ผ", "์‚ฌ", "์˜ค", "์œก", "์น ", "ํŒ”", "๊ตฌ" }; final String[] UNITS = { "", "์‹ญ", "๋ฐฑ", "์ฒœ" }; final String[] LARGE_UNI..

JAVA 2024.11.20

์‹ฑ๊ธ€ ์‚ฌ์ธ ์˜จ(Single Sign-On, SSO)

์‹ฑ๊ธ€ ์‚ฌ์ธ ์˜จ(Single Sign-On, SSO)์€ ์‚ฌ์šฉ์ž๊ฐ€ ๋›ฐ์–ด๋‚œ ์ธ์ฆ ํ”„๋กœ์„ธ์Šค๋ฅผ ํ†ตํ•ด ๋‹ค์–‘ํ•œ ์‹œ์Šคํ…œ์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ด์ฃผ๋Š” ์ง„์ •ํ•œ ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค. ๋ณธ ์„œ๋น„์Šค๋Š” ์‚ฌ์šฉ์ž ๊ฐ ์„œ๋น„์Šค๋งˆ๋‹ค ๋ณ„๋„์˜ ๋กœ๊ทธ์ธ ์ ˆ์ฐจ๋ฅผ ์ œ๊ณตํ•ด์•ผ ํ•˜๋ฉฐ, ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ณด์•ˆ ์—ฐ๊ฒฐ ์„œ๋น„์Šค๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.SSO ์ž‘๋™ ๋ฐฉ์‹์‚ฌ์šฉ์ž ์ธ์ฆ : ์‚ฌ์šฉ์ž๊ฐ€ ์ฒ˜์Œ ๋กœ๊ทธ์ธํ•˜๋ฉด SSO ์‹œ์Šคํ…œ์ด ์ธ์ฆ์„ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.์ธ์ฆ ์™„๋ฃŒ : SSO ์‹œ์Šคํ…œ์ด ์ธ์ฆ์„ ๋ฐ›์€ ํ›„ ์ธ์ฆ(์˜ˆ: SAML, OAuth, JWT)์„ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ธ์ฆํ•ฉ๋‹ˆ๋‹ค.์˜๋ฏธ ์ „๋‹ฌ : ์‚ฌ์šฉ์ž๋Š” ์ด ์˜๋ฏธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ ์„œ๋น„์Šค์— ์ ‘๊ทผํ•˜๋ฉฐ, ์„œ๋น„์Šค๋Š” ์˜๋„๋ฅผ ์ธ์ •ํ•ด ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.์ž๋™ ๋กœ๊ทธ์ธ : ์‚ฌ์šฉ์ž๊ฐ€ ๋‹ค๋ฅธ ์‹œ์Šคํ…œ์— ์ ‘๊ทผํ•  ๋•Œ ๋™๋“ฑํ•œ ์ธ์ฆ ์ •๋ณด๋ฅผ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ ์ถ”๊ฐ€ ๋กœ๊ทธ์ธ ์ ˆ์ฐจ๊ฐ€ ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.SSO์˜ ์ฃผ์š” ํ”„..

IT์ง€์‹ 2024.11.19

[JAVA] ์ด๋ฏธ์ง€ ํŒŒ์ผ์„ Base64๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ์ „์†ก

์ด๋ฏธ์ง€ ํŒŒ์ผ์„ Base64๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•˜๋Š” ๋ฐฉ์‹์€ ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณ€ํ™˜ํ•˜์—ฌ ์ „๋‹ฌํ•˜๋Š” ๋ฐฉ์‹์ž…๋‹ˆ๋‹ค.import java.nio.file.Files;import java.nio.file.Paths;import java.util.Base64;public class ImageBase64Encoder { public static void main(String[] args) { try { // ์ด๋ฏธ์ง€ ํŒŒ์ผ ๊ฒฝ๋กœ String imagePath = "path/to/your/image.jpg"; // ์ด๋ฏธ์ง€ ํŒŒ์ผ ์ฝ๊ธฐ byte[] imageBytes = Files.readAllBytes(Pat..

JAVA 2024.11.18

[JAVA] Stream์œผ๋กœ List ์ค‘๋ณต ์ œ๊ฑฐ

Stream์˜ distinct()๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ฐ„๋‹จํ•œ ์ œ๊ฑฐ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.import java.util.*;import java.util.stream.*;public class RemoveDuplicatesExample { public static void main(String[] args) { List list = Arrays.asList("apple", "banana", "apple", "orange"); // Stream์œผ๋กœ ์ค‘๋ณต ์ œ๊ฑฐ List uniqueList = list.stream() .distinct() ...

JAVA 2024.11.17

[JAVA] ๋‚ ์งœ๋ฐ์ดํ„ฐ ๋…„์›”์ผ๋กœ ๋ณ€ํ™˜ํ•˜๊ธฐ

import java.time.LocalDate;import java.time.format.DateTimeFormatter;public class DateFormatExample { public static void main(String[] args) { // ์ž…๋ ฅ๋œ 8์ž๋ฆฌ ์ˆซ์ž ๋ฌธ์ž์—ด String inputDate = "20241118"; // ์˜ˆ: 2024๋…„ 11์›” 18์ผ // ์›๋ž˜ ํ˜•์‹์˜ DateTimeFormatter ์ •์˜ DateTimeFormatter originalFormatter = DateTimeFormatter.ofPattern("yyyyMMdd"); // ์›ํ•˜๋Š” ์ถœ๋ ฅ ํ˜•์‹ ์ •์˜ (๋…„์›”์ผ) DateTimeF..

JAVA 2024.11.15

[SQL] ๋ฌธ์ž์—ด ๋ฆฌํ„ฐ๋Ÿด์— ์ž‘์€ ๋”ฐ์˜ดํ‘œ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š” ์ด์œ 

SQL์—์„œ ๋ฌธ์ž์—ด ๋ฆฌํ„ฐ๋Ÿด์€ **์ž‘์€ ์ธ์šฉ( ')**๋กœ ๊ฐ์‹ธ์•ผ ํ•ฉ๋‹ˆ๋‹ค. SQL ํ‘œ์ค€(SQL-92)์— ๋”ฐ๋ฅด๋Š” ๊ทœ์น™์ด๋ฉฐ, ๋Œ€๋ถ€๋ถ„์˜ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ฆฌ ์‹œ์Šคํ…œ(DBMS)์—์„œ๋„ ๋™์ผํ•˜๊ฒŒ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.๋ฐ˜๋ฉด์— **ํฐ ์ธ์šฉ( ")**์€ ์ผ๋ฐ˜์ ์œผ๋กœ **์‹๋ณ„์ž(์‹๋ณ„์ž)**๋ฅผ ๊ฐ์‹ธ๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ํ…Œ์ด๋ธ” ์ด๋ฆ„์ด๋‚˜ ์—ด์ด SQL ํ‚ค์›Œ๋“œ(์˜ˆ: SELECT, FROM)์™€ ์ถฉ๋Œํ•˜๊ฑฐ๋‚˜ ๊ณต๋ฐฑ์ด ํฌํ•จ๋œ ๊ฒฝ์šฐ ํฐ ์ธ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.๊ตฌ์„ฑ์š”์†Œ:์ž‘์€ ๋ฆฌํ„ฐ( ') : ๋ฌธ์ž์—ด ๋ฆฌํ„ฐ๋Ÿด์— ์‚ฌ์šฉSELECT * FROM employees WHERE name = 'John'; ํฐ ์ธ์šฉ( ") : ์ธ์šฉ(ํ…Œ์ด๋ธ”๋ช…, ์ถ”์ ๋ช…) ๊ฐ์‹ธ๊ธฐSELECT "first name" AS full_name FROM employees;

DB 2024.11.14
728x90
๋ฐ˜์‘ํ˜•