Updated date method calls.

This commit is contained in:
Micah Silverman 2016-06-25 21:11:56 -04:00
parent bf9c5b3c91
commit df9e4d7ef5
2 changed files with 5 additions and 3 deletions

View File

@ -12,7 +12,7 @@ public class HomeController {
public String home(HttpServletRequest req) {
String requestUrl = getUrl(req);
return "Available commands (assumes httpie - https://github.com/jkbrzt/httpie):\n" +
" http " + requestUrl + "/\n\tThis usage\n" +
" http " + requestUrl + "/\n\tThis usage message\n" +
" http " + requestUrl + "/static-builder\n\tbuild JWT from hardcoded claims\n" +
" http " + requestUrl + "/dynamic-builder-general claim-1=value-1 ... [claim-n=value-n]\n\tbuild JWT from passed in claims (using general claims map)\n" +
" http " + requestUrl + "/dynamic-builder-specific claim-1=value-1 ... [claim-n=value-n]\n\tbuild JWT from passed in claims (using specific claims methods)\n" +

View File

@ -27,14 +27,16 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST;
@RestController
public class StaticJWTController {
@RequestMapping(value = "/static-builder", method = POST)
@RequestMapping(value = "/static-builder", method = GET)
public String fixedBuilder() throws UnsupportedEncodingException {
String jws = Jwts.builder()
.setIssuer("Stormpath")
.setSubject("msilverman")
.setExpiration(Date.from(Instant.now().plus(1, ChronoUnit.DAYS)))
.claim("name", "Micah Silverman")
.claim("scope", "admins")
.setIssuedAt(Date.from(Instant.ofEpochSecond(1466796822))) // Fri Jun 24 2016 15:33:42 GMT-0400 (EDT)
.setExpiration(Date.from(Instant.ofEpochSecond(1466883222))) // Sat Jun 25 2016 15:33:42 GMT-0400 (EDT)
.signWith(
SignatureAlgorithm.HS256,
"secret".getBytes("UTF-8")