File tree Expand file tree Collapse file tree 4 files changed +14
-8
lines changed
main/java/com/spotify/github/v3
java/com/spotify/github/v3/repos
resources/com/spotify/github/v3/repos Expand file tree Collapse file tree 4 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 2121package com .spotify .github .v3 .clients ;
2222
2323import io .jsonwebtoken .Jwts ;
24- import io .jsonwebtoken .SignatureAlgorithm ;
2524
2625import java .security .KeyFactory ;
2726import java .security .NoSuchAlgorithmException ;
3433/** The helper Jwt token issuer. */
3534public 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}
Original file line number Diff line number Diff 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 ();
Original file line number Diff line number Diff 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" ));
Original file line number Diff line number Diff line change 11{
22 "id" : 1296269 ,
3+ "node_id" : " MDEwOlJlcG9zaXRvcnkxMjk2MjY5" ,
34 "owner" : {
45 "login" : " octocat" ,
56 "id" : 1 ,
You can’t perform that action at this time.
0 commit comments