@@ -191,7 +191,7 @@ private static class CredentialsTokenProvider extends TokenProvider {
191
191
private final GitHubAppCredentials credentials ;
192
192
193
193
CredentialsTokenProvider (GitHubAppCredentials credentials ) {
194
- super (credentials .appID , credentials .privateKey .getPlainText ());
194
+ super (credentials .getAppID () , credentials .getPrivateKey () .getPlainText ());
195
195
this .credentials = credentials ;
196
196
}
197
197
@@ -284,17 +284,17 @@ private static long getExpirationSeconds(GHAppInstallationToken appInstallationT
284
284
285
285
@ NonNull
286
286
String actualApiUri () {
287
- return Util .fixEmpty (apiUri ) == null ? "https://api.github.com" : apiUri ;
287
+ return Util .fixEmpty (getApiUri ()) == null ? "https://api.github.com" : getApiUri () ;
288
288
}
289
289
290
290
private AppInstallationToken getToken (GitHub gitHub ) {
291
291
synchronized (this ) {
292
292
try {
293
293
if (cachedToken == null || cachedToken .isStale ()) {
294
- LOGGER .log (Level .FINE , "Generating App Installation Token for app ID {0}" , appID );
294
+ LOGGER .log (Level .FINE , "Generating App Installation Token for app ID {0}" , getAppID () );
295
295
cachedToken = generateAppInstallationToken (
296
- gitHub , appID , privateKey .getPlainText (), actualApiUri (), owner );
297
- LOGGER .log (Level .FINER , "Retrieved GitHub App Installation Token for app ID {0}" , appID );
296
+ gitHub , getAppID (), getPrivateKey () .getPlainText (), actualApiUri (), getOwner () );
297
+ LOGGER .log (Level .FINER , "Retrieved GitHub App Installation Token for app ID {0}" , getAppID () );
298
298
}
299
299
} catch (Exception e ) {
300
300
if (cachedToken != null && !cachedToken .isExpired ()) {
@@ -304,14 +304,14 @@ private AppInstallationToken getToken(GitHub gitHub) {
304
304
LOGGER .log (
305
305
Level .WARNING ,
306
306
"Failed to generate new GitHub App Installation Token for app ID "
307
- + appID
307
+ + getAppID ()
308
308
+ ": cached token is stale but has not expired" ,
309
309
e );
310
310
} else {
311
311
throw e ;
312
312
}
313
313
}
314
- LOGGER .log (Level .FINEST , "Returned GitHub App Installation Token for app ID {0}" , appID );
314
+ LOGGER .log (Level .FINEST , "Returned GitHub App Installation Token for app ID {0}" , getAppID () );
315
315
316
316
return cachedToken ;
317
317
}
@@ -328,7 +328,7 @@ public Secret getPassword() {
328
328
@ NonNull
329
329
@ Override
330
330
public String getUsername () {
331
- return appID ;
331
+ return getAppID () ;
332
332
}
333
333
334
334
@ Override
@@ -338,9 +338,9 @@ public boolean isUsernameSecret() {
338
338
339
339
@ NonNull
340
340
public synchronized GitHubAppCredentials withOwner (@ NonNull String owner ) {
341
- if (this .owner != null ) {
342
- if (!owner .equals (this .owner )) {
343
- throw new IllegalArgumentException ("Owner mismatch: " + this .owner + " vs. " + owner );
341
+ if (this .getOwner () != null ) {
342
+ if (!owner .equals (this .getOwner () )) {
343
+ throw new IllegalArgumentException ("Owner mismatch: " + this .getOwner () + " vs. " + owner );
344
344
}
345
345
return this ;
346
346
}
@@ -349,17 +349,17 @@ public synchronized GitHubAppCredentials withOwner(@NonNull String owner) {
349
349
}
350
350
return byOwner .computeIfAbsent (owner , k -> {
351
351
GitHubAppCredentials clone =
352
- new GitHubAppCredentials (getScope (), getId (), getDescription (), appID , privateKey );
353
- clone .apiUri = apiUri ;
354
- clone .owner = owner ;
352
+ new GitHubAppCredentials (getScope (), getId (), getDescription (), getAppID (), getPrivateKey () );
353
+ clone .apiUri = getApiUri () ;
354
+ clone .owner = getOwner () ;
355
355
return clone ;
356
356
});
357
357
}
358
358
359
359
@ NonNull
360
360
@ Override
361
361
public Credentials forRun (Run <?, ?> context ) {
362
- if (owner != null ) {
362
+ if (getOwner () != null ) {
363
363
return this ;
364
364
}
365
365
Job <?, ?> job = context .getParent ();
@@ -523,12 +523,12 @@ private static final class DelegatingGitHubAppCredentials extends BaseStandardCr
523
523
DelegatingGitHubAppCredentials (GitHubAppCredentials onMaster ) {
524
524
super (onMaster .getScope (), onMaster .getId (), onMaster .getDescription ());
525
525
JenkinsJVM .checkJenkinsJVM ();
526
- appID = onMaster .appID ;
526
+ appID = onMaster .getAppID () ;
527
527
JSONObject j = new JSONObject ();
528
528
j .put ("appID" , appID );
529
- j .put ("privateKey" , onMaster .privateKey .getPlainText ());
529
+ j .put ("privateKey" , onMaster .getPrivateKey () .getPlainText ());
530
530
j .put ("apiUri" , onMaster .actualApiUri ());
531
- j .put ("owner" , onMaster .owner );
531
+ j .put ("owner" , onMaster .getOwner () );
532
532
tokenRefreshData = Secret .fromString (j .toString ()).getEncryptedValue ();
533
533
534
534
// Check token is valid before sending it to the agent.
@@ -541,7 +541,7 @@ private static final class DelegatingGitHubAppCredentials extends BaseStandardCr
541
541
LOGGER .log (
542
542
Level .FINEST ,
543
543
"Checking App Installation Token for app ID {0} before sending to agent" ,
544
- onMaster .appID );
544
+ onMaster .getAppID () );
545
545
onMaster .getPassword ();
546
546
} catch (Exception e ) {
547
547
LOGGER .log (
0 commit comments