org.jenkinsci.plugins
Class GithubAuthenticationToken
java.lang.Object
org.acegisecurity.providers.AbstractAuthenticationToken
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
| Methods inherited from class org.acegisecurity.providers.AbstractAuthenticationToken |
equals, getDetails, getName, hashCode, isAuthenticated, setAuthenticated, setDetails, toString |
GithubAuthenticationToken
public GithubAuthenticationToken(String accessToken,
String githubServer)
throws IOException
- Throws:
IOException
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.