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 21
21
package com .spotify .github .v3 .clients ;
22
22
23
23
import io .jsonwebtoken .Jwts ;
24
- import io .jsonwebtoken .SignatureAlgorithm ;
25
24
26
25
import java .security .KeyFactory ;
27
26
import java .security .NoSuchAlgorithmException ;
34
33
/** The helper Jwt token issuer. */
35
34
public class JwtTokenIssuer {
36
35
37
- private static final SignatureAlgorithm SIGNATURE_ALGORITHM = SignatureAlgorithm .RS256 ;
38
36
private static final long TOKEN_TTL = 600000 ;
39
37
40
38
private final PrivateKey signingKey ;
@@ -69,12 +67,14 @@ public static JwtTokenIssuer fromPrivateKey(final byte[] privateKey)
69
67
*/
70
68
public String getToken (final Integer appId ) {
71
69
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 )
78
78
.compact ();
79
79
}
80
80
}
Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ public interface RepositoryBase extends UpdateTracking {
42
42
@ Nullable
43
43
Integer id ();
44
44
45
+ /** Node id */
46
+ @ Nullable
47
+ String nodeId ();
48
+
45
49
/** Name */
46
50
@ Nullable
47
51
String name ();
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ public void setUp() throws Exception {
45
45
public void testDeserialization () throws IOException {
46
46
final Repository repository = Json .create ().fromJson (fixture , Repository .class );
47
47
assertThat (repository .id (), is (1296269 ));
48
+ assertThat (repository .nodeId (), is ("MDEwOlJlcG9zaXRvcnkxMjk2MjY5" ));
48
49
assertUser (repository .owner ());
49
50
assertThat (repository .name (), is ("Hello-World" ));
50
51
assertThat (repository .fullName (), is (repository .owner ().login () + "/Hello-World" ));
Original file line number Diff line number Diff line change 1
1
{
2
2
"id" : 1296269 ,
3
+ "node_id" : " MDEwOlJlcG9zaXRvcnkxMjk2MjY5" ,
3
4
"owner" : {
4
5
"login" : " octocat" ,
5
6
"id" : 1 ,
You can’t perform that action at this time.
0 commit comments