Class GitLabAuthenticationToken

java.lang.Object
org.springframework.security.authentication.AbstractAuthenticationToken
org.jenkinsci.plugins.GitLabAuthenticationToken
All Implemented Interfaces:
Serializable, Principal, org.springframework.security.core.Authentication, org.springframework.security.core.CredentialsContainer

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

    • GitLabAuthenticationToken Link icon

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

    • clearCaches Link icon

      public static void clearCaches()
      Necessary for testing
    • getAccessToken Link icon

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

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

      public Collection<org.springframework.security.core.GrantedAuthority> getAuthorities()
      Specified by:
      getAuthorities in interface org.springframework.security.core.Authentication
      Overrides:
      getAuthorities in class org.springframework.security.authentication.AbstractAuthenticationToken
    • getCredentials Link icon

      public Object getCredentials()
    • getPrincipal Link icon

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

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

      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 Link icon

      public boolean hasRepositoryPermission(String repositoryName)
    • myRepositories Link icon

      public Set<String> myRepositories()
    • listToNames Link icon

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

      public boolean isPublicRepository(String repositoryName)
    • loadUser Link icon

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

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

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

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

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