JWT? ??? ??? ????? ?? ?????. Java??? JJWT ?????? ?? ?? ? ??? ?? ? ????. 1. 2. ??? ??, ?? ?? ? ??? jwtutil ?? ???? ????. 3. JWTFILTER? ???? ??? ?? ?? ?? ?? ???? Bearer ??? ??????. 4. ??? ??? ???? ?? ??? ??? ??? ??????. 5. ???? ??? ? JWT? ???? ?? ??? ?????? ?????. 6. ?? ? ?????? ??? ?? ???? ??? ????? ???? ??? ??? ?? ????? ?? ??? ??????? ??? ??? ? ?? ??? ?? ????? ?????. ?? ??, ?? ?? ? HTTPS ??? ?? ?? ?????????.
?? ? ?????? ???? Java? ???? ??? ?? (??) ? ??? ???? ?? ???? ?? ?????. JWT (JSON Web Token)? ???, ?? ?? ? ??? ??? ???? ?? ?? ??? ?????? ?? ??? ? ????????. ??? JWT? ???? Java ?? ????? ?? ? ??? ???? ??? ?? ?????.

JWT? ??????
JWT? ??? ?? JSON ???? ??? ???? ???? ? ???? ?? ?? (RFC 7519)???. ????? ?? ? ?? ??? ?????. JWT? ? ???? ?????.
- ?? : ?? ?? ? ?? ???? (? : HMAC SHA256)? ???? ????.
- ???? : ??? ID, ??, ?? ?? ?? ?? ???? ???? ????.
- ?? : ?? ???? ???? ???? ???? ?? ?? ? ?????.
??? xxxxx.yyyyy.zzzzz
???

?? ????
- ??? ???, ??? ?? ? ????? ??????
- ?? ?? ?? ??, JWT? ???? ?????? ?????
- ?????? ?? ??? JWT? ????? (?????
Authorization
????) - ??? JWT? ???? ???? ? ??? ???? ???? ?? ??? ??? ???? ??? ?????.
Java JWT? ???? ?? ? ??? ??????
1. ??? ?? (??? Maven? ??)
JJWT ?????? ???? JWT? ??????.
<???> <groupid> io.jsonwebtoken </groupid> <artifactid> jjwt-api </artifactid> <??> 0.11.5 </??> </???> <???> <groupid> io.jsonwebtoken </groupid> <artifactid> jjwt-impl </artifactid> <??> 0.11.5 </??> <Scope> ??? </scope> </???> <???> <groupid> io.jsonwebtoken </groupid> <artifactid> jjwt-jackson </artifactid> <??> 0.11.5 </??> <Scope> ??? </scope> </???>
?? : JJWT 0.11? ???? ???? API, Imp ? Jackson ??? ???????.
2. JWT ?? ???? ????
IO.JSONWEBTOKE ?? ??.*; import io.jsonwebtoken.security.keys; javax.crypto.secretkey import; import java.util.date; ?? ??? jwtutil { ?? ?? ?? ?? ?? _key = keys.secretkeyfor (signaturealgorithm.hs256); ?? ?? ?? ?? ?? ?? _time = 86400000; // 24 ?? // JWT? ????? public static string generateToken (??? ??? ??, ??? ??) { return jwts.builder () .SetSubject (??? ??) .- ?? ( "??", ??) .setissuedat (new date ()) .setexpiration (? ?? (System.CurrentTimeMillis () Expiration_Time))) .Signwith (Secret_key) .???(); } // JWT? ?? ???? ?????? ?? ?? ?? parsetoken (??? ??) { ???? { return jwts.parserBuilder () .SetSigningKey (Secret_key) .??() .parseclaimsjws (??) .getBody (); } catch (expiredjwtexception e) { System.out.println ( "?? ??"); ? ??; } catch (marformedjwtexception | SignatureException e) { System.out.println ( "???? ?? ??"); ? ??; } } // ??? ?? ?? ?? ??? getUserNameFromToken (String Token) { ??? ?? = parsetoken (??); ?? ???! = null? ??. getSubject () : null; } // ?? ?? ?? ?? ?? ??? getRolefromToken (String Token) { ??? ?? = parsetoken (??); return (string) hailss.get ( "??"); } // ??? ??? ?? ?? ?? istokenvalid (??? ??, ??? ??? ??) { String tokenusername = getUserNameFromToken (Token); return (tokenusername! = null && tokenusername.equals (username) && parsetoken (token)! = null); } }
3. ???? ?? : ?? ?? (??)
??? ?? ?? JWT? ???? ?? JwtFilter
????.
javax.servlet.*; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import java.io.ioexception; ?? ??? jwtfilter? ?? { @?? ?? void dofilter (Servletrequest ??, ServletRepronse ??, Filterchain ??) ioexception, servletexception { httpservletrequest httprequest = (httpservletrequest) ??; httpservletresponse httpresponse = (httpservletresponse) ??; String token = httprequest.getheader ( "??"); if (token! = null && token.startswith ( "bearer")) { ?? = Token.substring (7); // "bearer"?? ??? username = jwtutil.getusernamefromtoken (??); if (username! = null && jwtutil.istokenvalid (Token, username)) { // ??? ??? ?? ?? ?? ?? ????? ?? ? ? ????. httprequest.setattribute ( "currentuser", username); httprequest.setattribute ( "??", jwtutil.getrolefromtoken (??)); Chain.dofilter (??, ??); } ? ?? { httpresponse.setstatus (httpservletresponse.sc_unauthorized); httpresponse.getwriter (). ?? ( "???? ??? ?? ? ??"); } } ? ?? { httpresponse.setstatus (httpservletresponse.sc_unauthorized); httpresponse.getwriter (). ?? ( "?? ? ??"); } } }
4. ?? ?? (??? ??? ?? ??)
Spring Boot? ???? ?? ?? ???? ??? ?? ? ? ????.
@? public filterregistrationBean <JwtFilter> jwtfilter () { FilterRegistrationBean <JWTFILTER> rEgistrationBean = New FilterRegistrationBean <> (); registrationBean.setFilter (New JWTFilter ()); registrationbean.addurlpatterns ( "/api/secure/*"); // ?? ? ?? ?? registrationBean; }
5. ??? ????? ??
@postmapping ( "/???") public responsentity <?> ??? (@requestbody userLogInRequest ??) { // ??? : ??, ?????? ????? ??? ??? ?? ???????. String token = jwtutil.generateToken (request.getUserName (), "admin"); return responseentity.ok (). body (map.of ( "??", ??)); } return responseentity.status (401) .Body ( "??? ?? ?? ???? ??"); }
6. ?? ? ????? ??
@GetMapping ( "/Secure/Data") ?? ?? <?> getSecuredata (httpservletrequest ??) { ??? user = (???) request.getAttribute ( "currentUser"); ??? ?? = (???) request.getAttribute ( "??"); if ( "admin".equals (role)) { return responseentity.ok ( "Hello"User ", ??? ??? ??? ????!"); } ? ?? { return responseentity.status (403) .Body ( "??? ? ??"); } }
?? ??
- ? ?? : ??? ?? ?? ?? ???? ?? ?? ?? ?? ?? ??
- ?? ?? ?? : ?? ??? ????? ??????. ??? ??? ?? ??? ???? ?? ????.
- ?? ?? ?? : ?? ?? ?? ?????? ??? ??? ???? ? ????.
- HTTPS : ?? ?? ??? ???? ??? ?? ??? ??????.
- ??? ?? ?? : JWT ????? ??? ?? ??? ???? ???? ????.
??
JWT? ???? Java?? ?? ? ??? ???? ?? ???? ??? ??? ??? ????.
- ??? ? ????? ??? ??????
- ?????? ?? ??? ?????
- ??? ??? ?? ??? ???? ??? ??? ?????.
- ??? ?? ?? ??? ?????
? ????? ?? ???? ??? ?? ??? ??? ?? ?? ? ???? ??? ????? ?????.
??? ??? ?? ?? ????? ??? ?? ?? ? ?? ??? ?? ?? ??? ???? ????.
? ??? JWT?? Java ?? ? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

Maven? Java ???? ?? ? ????? ?? ?????. ?? POM.XML? ???? ???? ??, ??? ??, ?? ??? ??? ??? ? ???? ??? ?????? ??? ????. 1. pom.xml? ???? groupId, artifactid, ?? ? ???? ??????. 2. MVNClean, ???, ???, ???, ?? ? ??? ?? ??? ?? ??; 3. ??? ?? ? ??? ???? ?? ??? ?? ? ??? ?????. 4. ?? ?? ???? ??? ?? ??? ?? ????? ???? ?? POM? ?? ???? ?????. 5.

setupamaven/gradleProjectwithJax-rsddependencies likejersey; 2. createarestresourceUsingAnnotationsSuchas@pathand@get;

Java? ???? ?? ?? ????? MessageDigest ???? ?? ??? ? ????. 1. MD5 ?? SHA-256? ?? ??? ????? ????? ?????. 2. ??? ? ???? ????? .update () ???? ??????. 3. ?? ??? ??? ???? .digest () ???? ??????. 4. ??? ??? ??? ?? 16 ?? ???? ?????. ? ??? ?? ??? ?? ??? ?? .update ()? ?? ? ??????. ??? ???? ?? MD5 ?? SHA-1 ?? SHA-256? ???? ?? ????.

??, ??, ?? ??, ?? ???? ? ???? ??? ?? ??? ?? ?? ??? ?????. 2. ???, ?? ???, ?? ?? ? ? ?? ?? ? ?? ???? ???? SHA-256 ?? ?? ? ?? ?? ??? ?????. 3. ?? ??? ???? ?? ??? ????, ??? ??? ?????, ? ??? ???? ??? ???? ???? ?? ?? ?? ???? ??????. 4. ?? ??? ?? ??? ???? ???? ??? ??? ??? ???? ?? ?? ??? ??????. 5. ??? ?? ???? ???? ??, P2P ????, ??? ??, RESTAPI ? ??? ???; 6. ?? ?? ????? HyperledgerFabric, Web3J ?? Corda? ?? Java ?? ?? ?????? ??? ? ????.

@Property Decorator? ??? ??, ?? ? ?? ??? ???? ?? ???? ???? ???? ? ?????. 1. ?? ?? : @property? ?? ?? ?? ??? ????, ?? ?? ??? ???? ???? ?? ????? ??; 2. ?? ?? : @name.setter ? @name.deleter? ???? ?? ?? ?? ? ?? ??? ?????. 3. ?? ?? ???? : BankAccount? ?? ???? ??? ??? ???? ??? ??? ??? ??????. 4. ?? ?? ?? : ?? ??? ????? ?? ??? ??? ??? ???? ?? ??? ??? ?? ?? ? ?? ??? ?????.

?? JavaScript? ???? ??? ??? ?? ??? ??? ??? ?? ??? ?? ??? ??? ???????. 1. HTML ???? ?? ???? ????? ??? ???? ????. 2. CSS ?? : ??? ?? ?? ??? ???? ?? ??, .dark-mode ???? ??? ?? ??? ???? var ()? ?? ??? ??? ?????. 3. JavaScript? ??? ???? ?? ???? ?? ??? ???? ?? LocalStorage? ????. 4. ??? ?? ? ? HTML ???? Dark-Mode ???? ???? ?? ??? LocalStorage? ?????. 5. ?? ?? ?? ??? 0.3 ? ?? ?????? ???? ???? ??????.

?, ?? CSS ?? ?? ??? JavaScript??? ??? HTML ? CSS? ?? ??? ? ????. 1. ?? UL? Li? ???? ?? ??? ??????. 2. ?? ?? ???? ???? ?????? ???? ??? ???? ???; 3. ?? ?? : ?? Li? ???, ?? ??? ??? ???? ?????. ??; 4. ?? ??? ???? ??? : ??, ????????? : ???? ??; 5. ?? ?? ???? ??? ?? ????, ??? ????, ??? ? ?????? ???? ??? ????? ??? ???? ??? ? ????. ?? ???? ???? JavaScript ??? ???? ???? ??? ?????.

Flexbox ?? ???? ???? ?? ?? ????? ?? ? ? ????. ??? ???? ?? ??? ??? ?? (Min-Height : 100VH)? ??? ????. 2. Flex : 1 ?? ??? ?? ???? ? : Auto1frauto? ???? ??? ??? ??? ??? ???????. 3. ?? ?? ?? : ??? ????? ???? ??? ??? ??; 4. ?? ??? ??? ??? ??? ??????. ? ???? ??? ??? ???? ??? ???, ?? ?? ? ?? ????? ???? ?? ??? ? ?? ?????? ?? ?? ??? ????? ?????.
