2727import static java .util .logging .Level .FINE ;
2828import static java .util .logging .Level .WARNING ;
2929
30- import com .cloudbees .plugins .credentials .CredentialsMatcher ;
31- import com .cloudbees .plugins .credentials .CredentialsMatchers ;
3230import com .cloudbees .plugins .credentials .CredentialsNameProvider ;
3331import com .cloudbees .plugins .credentials .CredentialsProvider ;
3432import com .cloudbees .plugins .credentials .common .StandardCredentials ;
@@ -131,12 +129,11 @@ public static ListBoxModel listScanCredentials(@CheckForNull SCMSourceOwner cont
131129 public static ListBoxModel listScanCredentials (@ CheckForNull Item context , String apiUri ) {
132130 return new StandardListBoxModel ()
133131 .includeEmptyValue ()
134- .includeMatchingAs (
135- context instanceof Queue .Task ? (( Queue . Task ) context ). getDefaultAuthentication () : ACL .SYSTEM ,
132+ .includeAs (
133+ context instanceof Queue .Task t ? t . getDefaultAuthentication2 () : ACL .SYSTEM2 ,
136134 context ,
137- StandardUsernameCredentials .class ,
138- githubDomainRequirements (apiUri ),
139- githubScanCredentialsMatcher ());
135+ StandardUsernamePasswordCredentials .class ,
136+ githubDomainRequirements (apiUri ));
140137 }
141138
142139 /**
@@ -298,16 +295,12 @@ public static StandardCredentials lookupScanCredentials(
298295 if (Util .fixEmpty (scanCredentialsId ) == null ) {
299296 return null ;
300297 }
301- StandardCredentials c = CredentialsMatchers .firstOrNull (
302- CredentialsProvider .lookupCredentialsInItem (
303- StandardUsernameCredentials .class ,
304- context ,
305- context instanceof Queue .Task
306- ? ((Queue .Task ) context ).getDefaultAuthentication2 ()
307- : ACL .SYSTEM2 ,
308- githubDomainRequirements (apiUri )),
309- CredentialsMatchers .allOf (
310- CredentialsMatchers .withId (scanCredentialsId ), githubScanCredentialsMatcher ()));
298+ var c = CredentialsProvider .findCredentialByIdInItem (
299+ scanCredentialsId ,
300+ StandardUsernamePasswordCredentials .class ,
301+ context ,
302+ context instanceof Queue .Task t ? t .getDefaultAuthentication2 () : ACL .SYSTEM2 ,
303+ githubDomainRequirements (apiUri ));
311304 if (c instanceof GitHubAppCredentials && repoOwner != null ) {
312305 // Note: We considered adding an overload so that all existing callers in this plugin could
313306 // specify an exact repository and granular permission, but decided against it. This method
@@ -334,6 +327,7 @@ public static StandardCredentials lookupScanCredentials(
334327 * @return the {@link StandardCredentials} or {@code null}
335328 * @deprecated use {@link #listCheckoutCredentials(Item, String)}
336329 */
330+ @ Deprecated
337331 @ NonNull
338332 public static ListBoxModel listCheckoutCredentials (@ CheckForNull SCMSourceOwner context , String apiUri ) {
339333 return listCheckoutCredentials ((Item ) context , apiUri );
@@ -354,7 +348,7 @@ public static ListBoxModel listCheckoutCredentials(@CheckForNull Item context, S
354348 result .add ("- same as scan credentials -" , GitHubSCMSource .DescriptorImpl .SAME );
355349 result .add ("- anonymous -" , GitHubSCMSource .DescriptorImpl .ANONYMOUS );
356350 return result .includeMatchingAs (
357- context instanceof Queue .Task ? (( Queue . Task ) context ). getDefaultAuthentication () : ACL .SYSTEM ,
351+ context instanceof Queue .Task t ? t . getDefaultAuthentication2 () : ACL .SYSTEM2 ,
358352 context ,
359353 StandardUsernameCredentials .class ,
360354 githubDomainRequirements (apiUri ),
@@ -521,11 +515,6 @@ public static void release(@CheckForNull GitHub hub) {
521515 }
522516 }
523517
524- private static CredentialsMatcher githubScanCredentialsMatcher () {
525- // TODO OAuth credentials
526- return CredentialsMatchers .anyOf (CredentialsMatchers .instanceOf (StandardUsernamePasswordCredentials .class ));
527- }
528-
529518 static List <DomainRequirement > githubDomainRequirements (String apiUri ) {
530519 return URIRequirementBuilder .fromUri (StringUtils .defaultIfEmpty (apiUri , GitHubServerConfig .GITHUB_URL ))
531520 .build ();
0 commit comments