Class CredentialsManagerImpl

java.lang.Object
com.atlassian.bamboo.credentials.CredentialsManagerImpl
All Implemented Interfaces:
CredentialsAccessor, CredentialsManager

public class CredentialsManagerImpl extends Object implements CredentialsManager
Make sure all mutative operations are logging changes with AuditLogService
  • Constructor Details

    • CredentialsManagerImpl

      @Inject public CredentialsManagerImpl(AuditLogService auditLogService, CredentialsDao credentialsDao, FeatureManager featureManager, com.atlassian.event.api.EventPublisher eventPublisher, com.atlassian.plugin.PluginAccessor pluginAccessor, com.opensymphony.xwork2.TextProvider textProvider)
  • Method Details

    • getCredentialTypeDescriptors

      @NotNull public @NotNull List<CredentialTypeModuleDescriptor> getCredentialTypeDescriptors()
      Specified by:
      getCredentialTypeDescriptors in interface CredentialsManager
      Returns:
      Provides a list of available shared credential types
    • getCredentialTypeDescriptor

      @Nullable public @Nullable CredentialTypeModuleDescriptor getCredentialTypeDescriptor(@Nullable @Nullable String pluginKey)
      Specified by:
      getCredentialTypeDescriptor in interface CredentialsManager
      Returns:
      The shared credential type for the given key
    • updateCredentialsName

      @NotNull public @NotNull CredentialsData updateCredentialsName(long id, @NotNull @NotNull String name) throws WebValidationException
      Description copied from interface: CredentialsManager
      Updates shared credentials name
      Specified by:
      updateCredentialsName in interface CredentialsManager
      Parameters:
      id - The id of the object to update
      name - The new name to identify the credentials
      Returns:
      Returns the object updated
      Throws:
      WebValidationException
    • createOrUpdateCredentials

      @NotNull public @NotNull CredentialsData createOrUpdateCredentials(@NotNull @NotNull CredentialsData credentials)
      Description copied from interface: CredentialsManager
      Creates credentials based on the object representation. If the object has ID set, then an update will be executed.

      This method encrypts the values of the credentials, for example for ssh encrypts the ssh key and ssh passphrase.

      Specified by:
      createOrUpdateCredentials in interface CredentialsManager
      Parameters:
      credentials - The object representation with the data to save.
      Returns:
      Returns the persisted object for the credentials
    • createCredentials

      @NotNull public @NotNull CredentialsData createCredentials(@NotNull @NotNull CredentialTypeModuleDescriptor credentialDescriptor, @NotNull @NotNull String credentialsName, @NotNull @NotNull Map<String,String> credentialsConfig)
      Description copied from interface: CredentialsManager
      Creates Credentials from the configuration map and stores them in the database.

      This method encrypts the values of the credentials, for example for ssh encrypts the ssh key and ssh passphrase.

      Specified by:
      createCredentials in interface CredentialsManager
      Parameters:
      credentialDescriptor - The plugin module descriptor for the credential type being created.
      credentialsName - The name for the credentials.
      credentialsConfig - The configuration map containing the credential values as defined by the plugin for this credential type.
      Returns:
      Returns the CredentialsData object representation of the credentials after creation.
    • createProjectCredentials

      @NotNull public @NotNull CredentialsData createProjectCredentials(@NotNull @NotNull CredentialTypeModuleDescriptor credentialDescriptor, @NotNull @NotNull String credentialsName, @NotNull @NotNull Map<String,String> credentialsConfig, @NotNull @NotNull Long projectId)
      Description copied from interface: CredentialsManager
      Creates Credentials from the configuration map and stores them in the database.

      This method encrypts the values of the credentials, for example for ssh encrypts the ssh key and ssh passphrase.

      Specified by:
      createProjectCredentials in interface CredentialsManager
      Parameters:
      credentialDescriptor - The plugin module descriptor for the credential type being created.
      credentialsName - The name for the credentials.
      credentialsConfig - The configuration map containing the credential values as defined by the plugin for this credential type.
      projectId - Project id
      Returns:
      Returns the CredentialsData object representation of the credentials after creation.
    • editCredentials

      @NotNull public @NotNull CredentialsData editCredentials(long credentialsId, @NotNull @NotNull String credentialsName, @NotNull @NotNull Map<String,String> credentialsConfig)
      Description copied from interface: CredentialsManager
      Updates Credentials with values in the configuration map.

      This method encrypts the values of the credentials, for example for ssh encrypts the ssh key and ssh passphrase.

      Specified by:
      editCredentials in interface CredentialsManager
      Parameters:
      credentialsId - The ID of the credentials to update.
      credentialsName - The name for the credentials.
      credentialsConfig - The configuration map containing the credential values as defined by the plugin for this credential type.
      Returns:
      Returns the CredentialsData object representation of the credentials.
    • editProjectCredentials

      @NotNull public @NotNull CredentialsData editProjectCredentials(long credentialsId, @NotNull @NotNull String credentialsName, @NotNull @NotNull Map<String,String> credentialsConfig, long projectId)
      Description copied from interface: CredentialsManager
      Updates Credentials with values in the configuration map.

      This method encrypts the values of the credentials, for example for ssh encrypts the ssh key and ssh passphrase.

      Specified by:
      editProjectCredentials in interface CredentialsManager
      Parameters:
      credentialsId - The ID of the credentials to update.
      credentialsName - The name for the credentials.
      credentialsConfig - The configuration map containing the credential values as defined by the plugin for this credential type.
      projectId - The ID of the Project
      Returns:
      Returns the CredentialsData object representation of the credentials.
    • getCredentials

      public CredentialsData getCredentials(long id)
      Description copied from interface: CredentialsAccessor
      Gets the Shared Credentials by id
      Specified by:
      getCredentials in interface CredentialsAccessor
      Returns:
      Returns the object representation of the credentials
    • getCredentialsByOid

      public CredentialsData getCredentialsByOid(BambooEntityOid oid)
      Description copied from interface: CredentialsAccessor
      Find shared credentials by BambooEntityOid
      Specified by:
      getCredentialsByOid in interface CredentialsAccessor
      Returns:
    • getCredentialsByName

      public CredentialsData getCredentialsByName(String name)
      Description copied from interface: CredentialsAccessor
      Find global shared credentials by name
      Specified by:
      getCredentialsByName in interface CredentialsAccessor
      Returns:
    • getCredentialsByNameAndProjectId

      public CredentialsData getCredentialsByNameAndProjectId(String name, long projectId)
      Description copied from interface: CredentialsAccessor
      Find shared credentials by name and project id
      Specified by:
      getCredentialsByNameAndProjectId in interface CredentialsAccessor
      Returns:
    • getAllCredentials

      @NotNull public @NotNull Iterable<CredentialsData> getAllCredentials()
      Specified by:
      getAllCredentials in interface CredentialsAccessor
      Returns:
      A list of all global credentials
    • getGlobalCredentials

      @NotNull public @NotNull Iterable<CredentialsData> getGlobalCredentials()
      Specified by:
      getGlobalCredentials in interface CredentialsAccessor
      Returns:
      A list of all global credentials
    • countAllGlobalCredentials

      @NotNull public @NotNull Long countAllGlobalCredentials()
      Description copied from interface: CredentialsManager
      Count all global credentials.
      Specified by:
      countAllGlobalCredentials in interface CredentialsManager
      Returns:
      Long count of global credentials.
    • countAllProjectsCredentials

      @NotNull public @NotNull Long countAllProjectsCredentials()
      Description copied from interface: CredentialsManager
      Count all project credentials.
      Specified by:
      countAllProjectsCredentials in interface CredentialsManager
      Returns:
      Long count of project credentials.
    • findAllProjectsIdsUsingProjectSharedCredentials

      @NotNull public @NotNull List<Long> findAllProjectsIdsUsingProjectSharedCredentials()
      Specified by:
      findAllProjectsIdsUsingProjectSharedCredentials in interface CredentialsManager
      Returns:
      a list which contains IDs of all project which are using project shared credentials.
    • getAllCredentials

      @NotNull public @NotNull Iterable<CredentialsData> getAllCredentials(@NotNull @NotNull String pluginKey)
      Specified by:
      getAllCredentials in interface CredentialsAccessor
      Returns:
      A list of global credentials that match the given plugin key
    • getGlobalCredentials

      @NotNull public @NotNull Iterable<CredentialsData> getGlobalCredentials(@NotNull @NotNull String pluginKey)
      Specified by:
      getGlobalCredentials in interface CredentialsAccessor
      Returns:
      A list of global credentials that match the given plugin key
    • getAllCredentialsByPluginKey

      @NotNull public @NotNull Iterable<CredentialsData> getAllCredentialsByPluginKey(@NotNull @NotNull String pluginKey)
      Specified by:
      getAllCredentialsByPluginKey in interface CredentialsAccessor
      Returns:
      A list of all (global and project) credentials that match the given plugin key
    • getPaginatedSharedCredentials

      @NotNull public @NotNull PaginatedProjectSharedCredentials getPaginatedSharedCredentials(@Nullable @Nullable Long projectId, int start, int limit, @Nullable @Nullable String filter)
      Description copied from interface: CredentialsManager
      Get paginated shared credentials for a project. Filtering requires at least one character. If filter is null or empty then no filtering.
      Specified by:
      getPaginatedSharedCredentials in interface CredentialsManager
      Parameters:
      projectId - of the project to get shared credentials for
      start - start by index
      limit - return no more entries than limit
      filter - filter
      Returns:
      Paginated shared credentials for a project.
    • hasAnyCredentials

      public boolean hasAnyCredentials(@NotNull @NotNull String pluginKey)
      Specified by:
      hasAnyCredentials in interface CredentialsAccessor
      Returns:
      True if there are global credentials that match the given plugin key
    • deleteCredentials

      public void deleteCredentials(long id)
      Description copied from interface: CredentialsManager
      Deletes credentials based on Id
      Specified by:
      deleteCredentials in interface CredentialsManager
      Parameters:
      id - id of the object to delete
    • validate

      public void validate(@NotNull @NotNull CredentialsData importedEntity) throws com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
      Description copied from interface: CredentialsManager
      Validate entity before saving it in database.
      Specified by:
      validate in interface CredentialsManager
      Parameters:
      importedEntity - imported entity
      Throws:
      com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException
    • retrieveCredentialTypeExporter

      @NotNull public @NotNull CredentialTypeExporter retrieveCredentialTypeExporter(@Nullable @Nullable String pluginKey)
      Description copied from interface: CredentialsManager
      Find credential type exporter for given plugin key. Returns null if couldn't find it.
      Specified by:
      retrieveCredentialTypeExporter in interface CredentialsManager
    • mergeImportedEntity

      @NotNull public @NotNull CredentialsData mergeImportedEntity(@NotNull @NotNull CredentialsData importedEntity)
      Description copied from interface: CredentialsManager
      Merges the state of the given imported entity into the database.

      This service will attempt to merge the entity based on ImmutableEntityWithOid.getOid(), and if there's no match, based on CredentialsData.getName(). If an existing entity is found, then it will be updated. Otherwise, a new database entity will be created. It's assumed that this method is used in specs import only as it's sending analytic event.

      Specified by:
      mergeImportedEntity in interface CredentialsManager
      Parameters:
      importedEntity - imported entity
      Returns:
      an object after persisting to the database - either the newly created or updated database object
    • getProjectCredentials

      @NotNull public @NotNull Iterable<CredentialsData> getProjectCredentials(@NotNull @NotNull Long projectId)
      Specified by:
      getProjectCredentials in interface CredentialsAccessor
      Returns:
      A list of all project credentials in project associated with given projectId
    • getProjectCredentialsByPluginKey

      @NotNull public @NotNull Iterable<CredentialsData> getProjectCredentialsByPluginKey(@NotNull @NotNull Long projectId, String pluginKey)
      Specified by:
      getProjectCredentialsByPluginKey in interface CredentialsAccessor
      Returns:
      a collection of project credentials that match the given plugin key
    • getProjectCredentials

      @Nullable public @Nullable CredentialsData getProjectCredentials(long id, long projectId)
      Description copied from interface: CredentialsAccessor
      Gets the Shared Credentials by id and projectId
      Specified by:
      getProjectCredentials in interface CredentialsAccessor
      Returns:
      Returns the object representation of the credentials