File tree Expand file tree Collapse file tree
jjwt/src/main/java/io/jsonwebtoken/jjwtfun/controller Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55import io .jsonwebtoken .Jwts ;
66import io .jsonwebtoken .SignatureAlgorithm ;
77import io .jsonwebtoken .jjwtfun .model .JwtResponse ;
8+ import org .springframework .beans .factory .annotation .Value ;
89import org .springframework .web .bind .annotation .RequestMapping ;
910import org .springframework .web .bind .annotation .RequestParam ;
1011import org .springframework .web .bind .annotation .RestController ;
1819@ RestController
1920public class StaticJWTController extends BaseController {
2021
22+ @ Value ("#{ @environment['jjwtfun.secret'] ?: 'secret' }" )
23+ String secret ;
24+
2125 @ RequestMapping (value = "/static-builder" , method = GET )
2226 public JwtResponse fixedBuilder () throws UnsupportedEncodingException {
2327
@@ -38,10 +42,10 @@ public JwtResponse fixedBuilder() throws UnsupportedEncodingException {
3842 }
3943
4044 @ RequestMapping (value = "/parser" , method = GET )
41- public JwtResponse fixedParser (@ RequestParam String jws ) throws UnsupportedEncodingException {
45+ public JwtResponse parser (@ RequestParam String jwt ) throws UnsupportedEncodingException {
4246 Jws <Claims > claims = Jwts .parser ()
43- .setSigningKey (" secret" .getBytes ("UTF-8" ))
44- .parseClaimsJws (jws );
47+ .setSigningKey (secret .getBytes ("UTF-8" ))
48+ .parseClaimsJws (jwt );
4549
4650 return new JwtResponse (claims );
4751 }
You can’t perform that action at this time.
0 commit comments