Skip to content

Commit b989d72

Browse files
committed
Fix jwt token creation deprecations
1 parent 44eb801 commit b989d72

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/main/java/com/spotify/github/v3/clients/JwtTokenIssuer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
package com.spotify.github.v3.clients;
2222

2323
import io.jsonwebtoken.Jwts;
24-
import io.jsonwebtoken.SignatureAlgorithm;
2524

2625
import java.security.KeyFactory;
2726
import java.security.NoSuchAlgorithmException;
@@ -34,7 +33,6 @@
3433
/** The helper Jwt token issuer. */
3534
public class JwtTokenIssuer {
3635

37-
private static final SignatureAlgorithm SIGNATURE_ALGORITHM = SignatureAlgorithm.RS256;
3836
private static final long TOKEN_TTL = 600000;
3937

4038
private final PrivateKey signingKey;
@@ -69,12 +67,14 @@ public static JwtTokenIssuer fromPrivateKey(final byte[] privateKey)
6967
*/
7068
public String getToken(final Integer appId) {
7169
return Jwts.builder()
72-
.setId("github-auth")
73-
.setSubject("authenticating via private key")
74-
.setIssuer(String.valueOf(appId))
75-
.signWith(signingKey, SIGNATURE_ALGORITHM)
76-
.setExpiration(new Date(System.currentTimeMillis() + TOKEN_TTL))
77-
.setIssuedAt(new Date())
70+
.claims()
71+
.id("github-auth")
72+
.subject("authenticating via private key")
73+
.issuer(String.valueOf(appId))
74+
.issuedAt(new Date())
75+
.expiration(new Date(System.currentTimeMillis() + TOKEN_TTL))
76+
.and()
77+
.signWith(signingKey, Jwts.SIG.RS256)
7878
.compact();
7979
}
8080
}

src/main/java/com/spotify/github/v3/repos/RepositoryBase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public interface RepositoryBase extends UpdateTracking {
4242
@Nullable
4343
Integer id();
4444

45+
/** Node id */
46+
@Nullable
47+
String nodeId();
48+
4549
/** Name */
4650
@Nullable
4751
String name();

src/test/java/com/spotify/github/v3/repos/RepositoryTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public void setUp() throws Exception {
4545
public void testDeserialization() throws IOException {
4646
final Repository repository = Json.create().fromJson(fixture, Repository.class);
4747
assertThat(repository.id(), is(1296269));
48+
assertThat(repository.nodeId(), is("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"));
4849
assertUser(repository.owner());
4950
assertThat(repository.name(), is("Hello-World"));
5051
assertThat(repository.fullName(), is(repository.owner().login() + "/Hello-World"));

src/test/resources/com/spotify/github/v3/repos/repository.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"id": 1296269,
3+
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
34
"owner": {
45
"login": "octocat",
56
"id": 1,

0 commit comments

Comments
 (0)