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
 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.
 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)
           
 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)
           
 
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

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)

isPublicRepository

public boolean isPublicRepository(String repositoryName)

loadUser

public org.kohsuke.github.GHUser loadUser(String username)
                                   throws IOException
Throws:
IOException

loadOrganization

public org.kohsuke.github.GHOrganization loadOrganization(String organization)
                                                   throws IOException
Throws:
IOException

loadRepository

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

loadTeam

public org.kohsuke.github.GHTeam loadTeam(String organization,
                                          String team)
                                   throws IOException
Throws:
IOException


Copyright © 2004-2014. All Rights Reserved.