본문 바로가기

▶ Back-End114

VERIFY JWT(nimbus) JWT 검증 메소드 *JWE *자세한 설명 생략 /** * JWT VERIFY * * @param HttpServletRequest * @param resVO * @return CmmResVO */ public CmmResVO JWTVerify(HttpServletRequest req, CmmResVO resVO) { try { final String jwt = req.getHeader("Authorization"); if(CmmUtile.nullCheck(jwt)) { return resVO.ERR_9005(); } /** JWE RSA KEYPAIR */ final KeyFactory keyFactory = KeyFactory.getInstance("RSA"); /* Decryption Key */ .. 2023. 10. 12.
Create JWT(nimbus) JWT 생성 메소드 *JWE *자세한 설명 생략 /** * JWT CREATE * * @return String */ public String JWTCreate() { String jwt = ""; try { /** JWE RSA KEYPAIR */ final KeyFactory keyFactory = KeyFactory.getInstance("RSA"); /* Encryption Key */ final X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(Base64.getDecoder().decode(publicKey)); final RSAPublicKey rsaPublicKey = (RSAPublicKey) keyFactory.generat.. 2023. 10. 12.
Cassandra Snapshot Backup And Restore 방법 Cassandra에서 Snapshot을 이용한 Backup 및 Restore 방법 *Cassandra 설치 환경 생략 *Cassandra 기본 설정으로 진행 *자세한 설명 생략 ▷ Table 생성 *Snapshot은 원하는 시점에 생성할 수 있다.( nodetool snapshot --table {table} {keyspace} ) *여기서는 Table 삭제 시 자동으로 생성된 Snapshot으로 진행 CREATE TABLE {Keyspace}.TB_TEST ( TEST_CD TEXT, TEST_NM TEXT, PRIMARY KEY ((TEST_CD)) ); ▷ Cassandra Backup 확인 *Data 생성 후에도 Cassandra Backup 폴더는 변하지 않는다. #Cassandra Backup.. 2023. 10. 4.
SpringBoot Security Login 기능 추가 아주 간단한 Spring Security Login 기능 추가 방법 *Maven 사용 *Spring Boot Project 생성 과정 생략 *자세한 설명 생략 ▷ pom.xml *의존성 추가 org.springframework.boot spring-boot-starter-security ▷ application.properties *사용자 지정 ID/PWD 설정 * Default user ID : user * Default user Pwd : 서버 실행 시 제공( Using generated security password: fd67f8d9-652b-46cd-a147-4b6681292d50 ) spring.security.user.name = test spring.security.user.password.. 2023. 9. 26.
Objcet to String Object를 String으로 변환하는 간단한 방법 /** * * Object to String * * @param Object * @return String */ public static String getObjStr(Object obj) { String str = ""; try { str = new ObjectMapper().writeValueAsString(obj); } catch (Exception e) { log.error("getObjStr Err : {}", e); } return str; } 2023. 9. 21.
@Value 사용법 application.properties에 설정한 값을 가져와 사용하는 @Value *자세한 설명 생략 ▷ application.properties *Test를 위한 값 설정 # value test.val = HELLO # map test.mapInt = {W:0, O:1, R:2, L:3, D:4} test.mapStr = {W:'w', O:'o', R:'r', L:'l', D:'d'} # list test.listInt = 0, 1, 2, 3, 4 test.listStr = H, E, L, L, O ▷ Application.java *간단한 Test를 위해 Application.java에서 진행 *Bean이 생성된 후 사용해야 하기 때문에 CommandLineRunner 사용 *CommandLineR.. 2023. 9. 21.
LocalTime AVG LocalTime 평균 구하기 *parameter는 상황에 따라 변경해서 사용(LocalTime t1, LocalTime...ts) /** * LocalTime AVG * * @param List * @return AVG LocalTime */ public static LocalTime getLocalTimeAVG(List list) { LocalTime result = LocalTime.of(0, 0, 0); if (!list.isEmpty()) { long nanoSum = 0L; for (LocalTime time : list) { nanoSum += time.toNanoOfDay(); } result = LocalTime.ofNanoOfDay(nanoSum / (list.size())); } re.. 2023. 9. 21.
String to LocalTime String time format은 상황에 따라 변경해서 사용 /** * String(HHmmss) to LocalTime * * @param String(HHmmss) * @return LocalTime(HH:mm:ss) */ public static LocalTime getStrLocalTime(String str) { return LocalTime.parse(str, DateTimeFormatter.ofPattern("HHmmss")); } 2023. 9. 21.
String to LocalDate String date format은 상황에 따라 변경해서 사용 /** * String(yyyyMMdd) to LocalDate * * @param String(yyyyMMdd) * @return LocalDate(pattern) */ public static LocalDate getStrLocalDate(String str) { return LocalDate.parse(str, DateTimeFormatter.ofPattern("yyyyMMdd")); } *개선한 버전 /** * String(yyyyMMdd) to LocalDate * * @param String(yyyyMMdd) * @return LocalDate(pattern) */ public static LocalDate getStrLocalDa.. 2023. 9. 21.
728x90
728x90