Class GitLabAuthenticationToken

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

public class GitLabAuthenticationToken extends AbstractAuthenticationToken
Author:
mocleiri to hold the authentication token from the gitlab oauth process.
See Also:
  • Constructor Details

    • GitLabAuthenticationToken

      public GitLabAuthenticationToken(String accessToken, String gitlabServer, org.gitlab4j.api.Constants.TokenType tokenType) throws org.gitlab4j.api.GitLabApiException
      Throws:
      org.gitlab4j.api.GitLabApiException
  • Method Details

    • 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.
    • getGitLabAPI

      public org.gitlab4j.api.GitLabApi getGitLabAPI()
    • getAuthorities

      public GrantedAuthority[] getAuthorities()
      Specified by:
      getAuthorities in interface Authentication
      Overrides:
      getAuthorities in class AbstractAuthenticationToken
    • getCredentials

      public Object getCredentials()
    • getPrincipal

      public String getPrincipal()
      Returns the login name in GitLab.
    • getMyself

      public org.gitlab4j.api.models.User getMyself()
      Returns the GHMyself object from this instance.
    • hasOrganizationPermission

      public boolean hasOrganizationPermission(String candidateName, String organization)
      For some reason I can't get the gitlab 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:
      whether given candidate belongs to a given organization
    • hasRepositoryPermission

      public boolean hasRepositoryPermission(String repositoryName)
    • myRepositories

      public Set<String> myRepositories()
    • listToNames

      public Set<String> listToNames(Collection<org.gitlab4j.api.models.Project> repositories)
    • isPublicRepository

      public boolean isPublicRepository(String repositoryName)
    • loadUser

      public org.gitlab4j.api.models.User loadUser(String username)
    • loadOrganization

      public org.gitlab4j.api.models.Group loadOrganization(String organization)
    • loadRepository

      public org.gitlab4j.api.models.Project loadRepository(String repositoryName)
    • getUserDetails

      public GitLabOAuthUserDetails getUserDetails(String username)
      Since:
      0.21
    • getGroupProjects

      public List<org.gitlab4j.api.models.Project> getGroupProjects(org.gitlab4j.api.models.Group group)