Class CredentialsManagerImpl
- All Implemented Interfaces:
CredentialsAccessor
,CredentialsManager
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.bamboo.credentials.CredentialsAccessor
CredentialsAccessor.IsCredentialsOfType
-
Constructor Summary
ConstructorDescriptionCredentialsManagerImpl
(AuditLogService auditLogService, CredentialsDao credentialsDao, FeatureManager featureManager, com.atlassian.event.api.EventPublisher eventPublisher, com.atlassian.plugin.PluginAccessor pluginAccessor, com.opensymphony.xwork2.TextProvider textProvider) -
Method Summary
Modifier and TypeMethodDescription@NotNull Long
Count all global credentials.@NotNull Long
Count all project credentials.@NotNull CredentialsData
createCredentials
(@NotNull CredentialTypeModuleDescriptor credentialDescriptor, @NotNull String credentialsName, @NotNull Map<String, String> credentialsConfig) Creates Credentials from the configuration map and stores them in the database.@NotNull CredentialsData
createOrUpdateCredentials
(@NotNull CredentialsData credentials) Creates credentials based on the object representation.@NotNull CredentialsData
createProjectCredentials
(@NotNull CredentialTypeModuleDescriptor credentialDescriptor, @NotNull String credentialsName, @NotNull Map<String, String> credentialsConfig, @NotNull Long projectId) Creates Credentials from the configuration map and stores them in the database.void
deleteCredentials
(long id) Deletes credentials based on Id@NotNull CredentialsData
editCredentials
(long credentialsId, @NotNull String credentialsName, @NotNull Map<String, String> credentialsConfig) Updates Credentials with values in the configuration map.@NotNull CredentialsData
editProjectCredentials
(long credentialsId, @NotNull String credentialsName, @NotNull Map<String, String> credentialsConfig, long projectId) Updates Credentials with values in the configuration map.@NotNull Iterable<CredentialsData>
@NotNull Iterable<CredentialsData>
getAllCredentials
(@NotNull String pluginKey) @NotNull Iterable<CredentialsData>
getAllCredentialsByPluginKey
(@NotNull String pluginKey) getCredentials
(long id) Gets the Shared Credentials by idgetCredentialsByName
(String name) Find global shared credentials by namegetCredentialsByNameAndProjectId
(String name, long projectId) Find shared credentials by name and project idFind shared credentials byBambooEntityOid
@Nullable CredentialTypeModuleDescriptor
getCredentialTypeDescriptor
(@Nullable String pluginKey) @NotNull List<CredentialTypeModuleDescriptor>
@NotNull Iterable<CredentialsData>
@NotNull Iterable<CredentialsData>
getGlobalCredentials
(@NotNull String pluginKey) @NotNull PaginatedProjectSharedCredentials
getPaginatedSharedCredentials
(@Nullable Long projectId, int start, int limit, @Nullable String filter) Get paginated shared credentials for a project.@Nullable CredentialsData
getProjectCredentials
(long id, long projectId) Gets the Shared Credentials by id and projectId@NotNull Iterable<CredentialsData>
getProjectCredentials
(@NotNull Long projectId) @NotNull Iterable<CredentialsData>
getProjectCredentialsByPluginKey
(@NotNull Long projectId, String pluginKey) boolean
hasAnyCredentials
(@NotNull String pluginKey) @NotNull CredentialsData
mergeImportedEntity
(@NotNull CredentialsData importedEntity) Merges the state of the given imported entity into the database.@NotNull CredentialTypeExporter
retrieveCredentialTypeExporter
(@Nullable String pluginKey) Find credential type exporter for given plugin key.@NotNull CredentialsData
updateCredentialsName
(long id, @NotNull String name) Updates shared credentials namevoid
validate
(@NotNull CredentialsData importedEntity) Validate entity before saving it in database.
-
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
- Specified by:
getCredentialTypeDescriptors
in interfaceCredentialsManager
- Returns:
- Provides a list of available shared credential types
-
getCredentialTypeDescriptor
@Nullable public @Nullable CredentialTypeModuleDescriptor getCredentialTypeDescriptor(@Nullable @Nullable String pluginKey) - Specified by:
getCredentialTypeDescriptor
in interfaceCredentialsManager
- 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 interfaceCredentialsManager
- Parameters:
id
- The id of the object to updatename
- 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 interfaceCredentialsManager
- 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 interfaceCredentialsManager
- 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 interfaceCredentialsManager
- 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 interfaceCredentialsManager
- 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 interfaceCredentialsManager
- 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
Description copied from interface:CredentialsAccessor
Gets the Shared Credentials by id- Specified by:
getCredentials
in interfaceCredentialsAccessor
- Returns:
- Returns the object representation of the credentials
-
getCredentialsByOid
Description copied from interface:CredentialsAccessor
Find shared credentials byBambooEntityOid
- Specified by:
getCredentialsByOid
in interfaceCredentialsAccessor
- Returns:
-
getCredentialsByName
Description copied from interface:CredentialsAccessor
Find global shared credentials by name- Specified by:
getCredentialsByName
in interfaceCredentialsAccessor
- Returns:
-
getCredentialsByNameAndProjectId
Description copied from interface:CredentialsAccessor
Find shared credentials by name and project id- Specified by:
getCredentialsByNameAndProjectId
in interfaceCredentialsAccessor
- Returns:
-
getAllCredentials
- Specified by:
getAllCredentials
in interfaceCredentialsAccessor
- Returns:
- A list of all global credentials
-
getGlobalCredentials
- Specified by:
getGlobalCredentials
in interfaceCredentialsAccessor
- Returns:
- A list of all global credentials
-
countAllGlobalCredentials
Description copied from interface:CredentialsManager
Count all global credentials.- Specified by:
countAllGlobalCredentials
in interfaceCredentialsManager
- Returns:
- Long count of global credentials.
-
countAllProjectsCredentials
Description copied from interface:CredentialsManager
Count all project credentials.- Specified by:
countAllProjectsCredentials
in interfaceCredentialsManager
- Returns:
- Long count of project credentials.
-
getAllCredentials
@NotNull public @NotNull Iterable<CredentialsData> getAllCredentials(@NotNull @NotNull String pluginKey) - Specified by:
getAllCredentials
in interfaceCredentialsAccessor
- 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 interfaceCredentialsAccessor
- 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 interfaceCredentialsAccessor
- Returns:
- A list of all (global and project) credentials that match the given plugin key
-
hasAnyCredentials
- Specified by:
hasAnyCredentials
in interfaceCredentialsAccessor
- 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 interfaceCredentialsManager
- 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 interfaceCredentialsManager
- 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 interfaceCredentialsManager
-
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 onCredentialsData.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 interfaceCredentialsManager
- 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 interfaceCredentialsAccessor
- 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 interfaceCredentialsAccessor
- Returns:
- a collection of project credentials that match the given plugin key
-
getProjectCredentials
Description copied from interface:CredentialsAccessor
Gets the Shared Credentials by id and projectId- Specified by:
getProjectCredentials
in interfaceCredentialsAccessor
- Returns:
- Returns the object representation of the credentials
-