Class CredentialsManagerImpl

    • Constructor Detail

      • 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 Detail

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