org.jenkinsci.plugins
Class GithubAuthenticationToken

java.lang.Object
  extended by org.acegisecurity.providers.AbstractAuthenticationToken
      extended by org.jenkinsci.plugins.GithubAuthenticationToken
All Implemented Interfaces:
Serializable, Principal, org.acegisecurity.Authentication

public class GithubAuthenticationToken
extends org.acegisecurity.providers.AbstractAuthenticationToken

Author:
mocleiri to hold the authentication token from the github oauth process.
See Also:
Serialized Form

Constructor Summary
GithubAuthenticationToken(String accessToken, String githubServer)
           
 
Method Summary
static void clearCaches()
          Necessary for testing
 String getAccessToken()
          Gets the OAuth access token, so that it can be persisted and used elsewhere.
 org.acegisecurity.GrantedAuthority[] getAuthorities()
           
 Object getCredentials()
           
 org.kohsuke.github.GitHub getGitHub()
           
 String getPrincipal()
          Returns the login name in GitHub.
 GithubOAuthUserDetails getUserDetails(String username)
           
 boolean hasOrganizationPermission(String candidateName, String organization)
          For some reason I can't get the github api to tell me for the current user the groups to which he belongs.
 boolean hasRepositoryPermission(String repositoryName)
           
 boolean isPublicRepository(String repositoryName)
           
 Set<String> listToNames(Collection<org.kohsuke.github.GHRepository> respositories)
           
 org.kohsuke.github.GHOrganization loadOrganization(String organization)
           
 org.kohsuke.github.GHRepository loadRepository(String repositoryName)
           
 org.kohsuke.github.GHTeam loadTeam(String organization, String team)
           
 org.kohsuke.github.GHUser loadUser(String username)
           
 Set<String> myRepositories()
           
 
Methods inherited from class org.acegisecurity.providers.AbstractAuthenticationToken
equals, getDetails, getName, hashCode, isAuthenticated, setAuthenticated, setDetails, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GithubAuthenticationToken

public GithubAuthenticationToken(String accessToken,
                                 String githubServer)
                          throws IOException
Throws:
IOException
Method Detail

clearCaches

public static void clearCaches()
Necessary for testing


getAccessToken

public String getAccessToken()
Gets the OAuth access token, so that it can be persisted and used elsewhere.


getGitHub

public org.kohsuke.github.GitHub getGitHub()

getAuthorities

public org.acegisecurity.GrantedAuthority[] getAuthorities()
Specified by:
getAuthorities in interface org.acegisecurity.Authentication
Overrides:
getAuthorities in class org.acegisecurity.providers.AbstractAuthenticationToken

getCredentials

public Object getCredentials()

getPrincipal

public String getPrincipal()
Returns the login name in GitHub.


hasOrganizationPermission

public boolean hasOrganizationPermission(String candidateName,
                                         String organization)
For some reason I can't get the github api to tell me for the current user the groups to which he belongs. So this is a slightly larger consideration. If the authenticated user is part of any team within the organization then they have permission. It caches user organizations for 24 hours for faster web navigation.

Parameters:
candidateName -
organization -
Returns:

hasRepositoryPermission

public boolean hasRepositoryPermission(String repositoryName)

myRepositories

public Set<String> myRepositories()

listToNames

public Set<String> listToNames(Collection<org.kohsuke.github.GHRepository> respositories)
                        throws IOException
Throws:
IOException

isPublicRepository

public boolean isPublicRepository(String repositoryName)

loadUser

public org.kohsuke.github.GHUser loadUser(String username)

loadOrganization

public org.kohsuke.github.GHOrganization loadOrganization(String organization)

loadRepository

public org.kohsuke.github.GHRepository loadRepository(String repositoryName)

loadTeam

public org.kohsuke.github.GHTeam loadTeam(String organization,
                                          String team)

getUserDetails

public GithubOAuthUserDetails getUserDetails(String username)
Since:
0.21


Copyright © 2004-2015. All Rights Reserved.