@@ -409,53 +409,4 @@ public GithubOAuthUserDetails getUserDetails(String username) throws IOException
409
409
}
410
410
return null ;
411
411
}
412
-
413
- public GrantedAuthority [] getGrantedAuthorities (GHUser user ) {
414
- List <GrantedAuthority > groups = new ArrayList <GrantedAuthority >();
415
- groups .add (SecurityRealm .AUTHENTICATED_AUTHORITY );
416
-
417
- try {
418
- GHPersonSet <GHOrganization > orgs ;
419
- if (myRealm == null ) {
420
- Jenkins jenkins = Jenkins .getInstance ();
421
- if (jenkins == null ) {
422
- throw new IllegalStateException ("Jenkins not started" );
423
- }
424
- myRealm = (GithubSecurityRealm ) jenkins .getSecurityRealm ();
425
- }
426
- //Search for scopes that allow fetching team membership. This is documented online.
427
- //https://developer.github.com/v3/orgs/#list-your-organizations
428
- //https://developer.github.com/v3/orgs/teams/#list-user-teams
429
- if (this .userName .equals (user .getLogin ()) && (myRealm .hasScope ("read:org" ) || myRealm .hasScope ("admin:org" ) || myRealm .hasScope ("user" ) || myRealm .hasScope ("repo" ))) {
430
- //This allows us to search for private organization membership.
431
- orgs = getMyself ().getAllOrganizations ();
432
- } else {
433
- //This searches for public organization membership.
434
- orgs = user .getOrganizations ();
435
- }
436
- for (GHOrganization ghOrganization : orgs ) {
437
- String orgLogin = ghOrganization .getLogin ();
438
- LOGGER .log (Level .FINE , "Fetch teams for user " + user .getLogin () + " in organization " + orgLogin );
439
- groups .add (new GrantedAuthorityImpl (orgLogin ));
440
- try {
441
- if (!getMyself ().isMemberOf (ghOrganization )) {
442
- continue ;
443
- }
444
- Map <String , GHTeam > teams = ghOrganization .getTeams ();
445
- for (Map .Entry <String , GHTeam > entry : teams .entrySet ()) {
446
- GHTeam team = entry .getValue ();
447
- if (team .hasMember (user )) {
448
- groups .add (new GrantedAuthorityImpl (orgLogin + GithubOAuthGroupDetails .ORG_TEAM_SEPARATOR
449
- + team .getName ()));
450
- }
451
- }
452
- } catch (IOException | Error ignore ) {
453
- LOGGER .log (Level .FINEST , "not enough rights to list teams from " + orgLogin , ignore );
454
- }
455
- }
456
- } catch (IOException e ) {
457
- LOGGER .log (Level .FINE , e .getMessage (), e );
458
- }
459
- return groups .toArray (new GrantedAuthority [groups .size ()]);
460
- }
461
412
}
0 commit comments