diff --git a/src/main/java/com/spotify/github/v3/clients/JwtTokenIssuer.java b/src/main/java/com/spotify/github/v3/clients/JwtTokenIssuer.java index 8746eee2..90f7dea7 100644 --- a/src/main/java/com/spotify/github/v3/clients/JwtTokenIssuer.java +++ b/src/main/java/com/spotify/github/v3/clients/JwtTokenIssuer.java @@ -21,7 +21,6 @@ package com.spotify.github.v3.clients; import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; @@ -34,7 +33,6 @@ /** The helper Jwt token issuer. */ public class JwtTokenIssuer { - private static final SignatureAlgorithm SIGNATURE_ALGORITHM = SignatureAlgorithm.RS256; private static final long TOKEN_TTL = 600000; private final PrivateKey signingKey; @@ -69,12 +67,14 @@ public static JwtTokenIssuer fromPrivateKey(final byte[] privateKey) */ public String getToken(final Integer appId) { return Jwts.builder() - .setId("github-auth") - .setSubject("authenticating via private key") - .setIssuer(String.valueOf(appId)) - .signWith(signingKey, SIGNATURE_ALGORITHM) - .setExpiration(new Date(System.currentTimeMillis() + TOKEN_TTL)) - .setIssuedAt(new Date()) + .claims() + .id("github-auth") + .subject("authenticating via private key") + .issuer(String.valueOf(appId)) + .issuedAt(new Date()) + .expiration(new Date(System.currentTimeMillis() + TOKEN_TTL)) + .and() + .signWith(signingKey, Jwts.SIG.RS256) .compact(); } } diff --git a/src/main/java/com/spotify/github/v3/repos/RepositoryBase.java b/src/main/java/com/spotify/github/v3/repos/RepositoryBase.java index 5e91f696..468e5476 100644 --- a/src/main/java/com/spotify/github/v3/repos/RepositoryBase.java +++ b/src/main/java/com/spotify/github/v3/repos/RepositoryBase.java @@ -42,6 +42,10 @@ public interface RepositoryBase extends UpdateTracking { @Nullable Integer id(); + /** Node id */ + @Nullable + String nodeId(); + /** Name */ @Nullable String name(); diff --git a/src/test/java/com/spotify/github/v3/repos/RepositoryTest.java b/src/test/java/com/spotify/github/v3/repos/RepositoryTest.java index 82f28aa7..9738f6b4 100644 --- a/src/test/java/com/spotify/github/v3/repos/RepositoryTest.java +++ b/src/test/java/com/spotify/github/v3/repos/RepositoryTest.java @@ -45,6 +45,7 @@ public void setUp() throws Exception { public void testDeserialization() throws IOException { final Repository repository = Json.create().fromJson(fixture, Repository.class); assertThat(repository.id(), is(1296269)); + assertThat(repository.nodeId(), is("MDEwOlJlcG9zaXRvcnkxMjk2MjY5")); assertUser(repository.owner()); assertThat(repository.name(), is("Hello-World")); assertThat(repository.fullName(), is(repository.owner().login() + "/Hello-World")); diff --git a/src/test/resources/com/spotify/github/v3/repos/repository.json b/src/test/resources/com/spotify/github/v3/repos/repository.json index fdc68ba0..95af9f9d 100644 --- a/src/test/resources/com/spotify/github/v3/repos/repository.json +++ b/src/test/resources/com/spotify/github/v3/repos/repository.json @@ -1,5 +1,6 @@ { "id": 1296269, + "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "owner": { "login": "octocat", "id": 1,