Class CredentialsManagerImpl
- All Implemented Interfaces:
CredentialsAccessor,CredentialsManager
-
Constructor Summary
ConstructorsConstructorDescriptionCredentialsManagerImpl(AuditLogService auditLogService, CredentialsDao credentialsDao, FeatureManager featureManager, com.atlassian.event.api.EventPublisher eventPublisher, com.atlassian.plugin.PluginAccessor pluginAccessor, org.apache.struts2.text.TextProvider textProvider) -
Method Summary
Modifier and TypeMethodDescription@NotNull LongCount all global credentials.@NotNull LongCount all project credentials.@NotNull CredentialsDatacreateCredentials(@NotNull CredentialTypeModuleDescriptor credentialDescriptor, @NotNull String credentialsName, @NotNull Map<String, String> credentialsConfig) Creates Credentials from the configuration map and stores them in the database.@NotNull CredentialsDatacreateOrUpdateCredentials(@NotNull CredentialsData credentials) Creates credentials based on the object representation.@NotNull CredentialsDatacreateProjectCredentials(@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.voiddeleteCredentials(long id) Deletes credentials based on Id@NotNull CredentialsDataeditCredentials(long credentialsId, @NotNull String credentialsName, @NotNull Map<String, String> credentialsConfig) Updates Credentials with values in the configuration map.@NotNull CredentialsDataeditProjectCredentials(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 CredentialTypeModuleDescriptorgetCredentialTypeDescriptor(@Nullable String pluginKey) @NotNull List<CredentialTypeModuleDescriptor> @NotNull Iterable<CredentialsData> @NotNull Iterable<CredentialsData> getGlobalCredentials(@NotNull String pluginKey) @NotNull PaginatedProjectSharedCredentialsgetPaginatedSharedCredentials(@Nullable Long projectId, int start, int limit, @Nullable String filter) Get paginated shared credentials for a project.@Nullable CredentialsDatagetProjectCredentials(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) booleanhasAnyCredentials(@NotNull String pluginKey) @NotNull CredentialsDatamergeImportedEntity(@NotNull CredentialsData importedEntity) Merges the state of the given imported entity into the database.@NotNull CredentialTypeExporterretrieveCredentialTypeExporter(@Nullable String pluginKey) Find credential type exporter for given plugin key.@NotNull CredentialsDataupdateCredentialsName(long id, @NotNull String name) Updates shared credentials namevoidvalidate(@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, org.apache.struts2.text.TextProvider textProvider)
-
-
Method Details
-
getCredentialTypeDescriptors
- Specified by:
getCredentialTypeDescriptorsin interfaceCredentialsManager- Returns:
- Provides a list of available shared credential types
-
getCredentialTypeDescriptor
@Nullable public @Nullable CredentialTypeModuleDescriptor getCredentialTypeDescriptor(@Nullable @Nullable String pluginKey) - Specified by:
getCredentialTypeDescriptorin 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:CredentialsManagerUpdates shared credentials name- Specified by:
updateCredentialsNamein 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:CredentialsManagerCreates 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:
createOrUpdateCredentialsin 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:CredentialsManagerCreates 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:
createCredentialsin 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:CredentialsManagerCreates 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:
createProjectCredentialsin 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:CredentialsManagerUpdates 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:
editCredentialsin 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:CredentialsManagerUpdates 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:
editProjectCredentialsin 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:CredentialsAccessorGets the Shared Credentials by id- Specified by:
getCredentialsin interfaceCredentialsAccessor- Parameters:
id-- Returns:
- Returns the object representation of the credentials
-
getCredentialsByOid
Description copied from interface:CredentialsAccessorFind shared credentials byBambooEntityOid- Specified by:
getCredentialsByOidin interfaceCredentialsAccessor- Parameters:
oid-- Returns:
-
getCredentialsByName
Description copied from interface:CredentialsAccessorFind global shared credentials by name- Specified by:
getCredentialsByNamein interfaceCredentialsAccessor- Parameters:
name-- Returns:
-
getCredentialsByNameAndProjectId
Description copied from interface:CredentialsAccessorFind shared credentials by name and project id- Specified by:
getCredentialsByNameAndProjectIdin interfaceCredentialsAccessor- Parameters:
name-projectId-- Returns:
-
getAllCredentials
- Specified by:
getAllCredentialsin interfaceCredentialsAccessor- Returns:
- A list of all global credentials
-
getGlobalCredentials
- Specified by:
getGlobalCredentialsin interfaceCredentialsAccessor- Returns:
- A list of all global credentials
-
countAllGlobalCredentials
Description copied from interface:CredentialsManagerCount all global credentials.- Specified by:
countAllGlobalCredentialsin interfaceCredentialsManager- Returns:
- Long count of global credentials.
-
countAllProjectsCredentials
Description copied from interface:CredentialsManagerCount all project credentials.- Specified by:
countAllProjectsCredentialsin interfaceCredentialsManager- Returns:
- Long count of project credentials.
-
getAllCredentials
@NotNull public @NotNull Iterable<CredentialsData> getAllCredentials(@NotNull @NotNull String pluginKey) - Specified by:
getAllCredentialsin 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:
getGlobalCredentialsin 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:
getAllCredentialsByPluginKeyin interfaceCredentialsAccessor- Returns:
- A list of all (global and project) credentials that match the given plugin key
-
hasAnyCredentials
- Specified by:
hasAnyCredentialsin interfaceCredentialsAccessor- Returns:
- True if there are global credentials that match the given plugin key
-
deleteCredentials
public void deleteCredentials(long id) Description copied from interface:CredentialsManagerDeletes credentials based on Id- Specified by:
deleteCredentialsin 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:CredentialsManagerValidate entity before saving it in database.- Specified by:
validatein 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:CredentialsManagerFind credential type exporter for given plugin key. Returns null if couldn't find it.- Specified by:
retrieveCredentialTypeExporterin interfaceCredentialsManager
-
mergeImportedEntity
@NotNull public @NotNull CredentialsData mergeImportedEntity(@NotNull @NotNull CredentialsData importedEntity) Description copied from interface:CredentialsManagerMerges 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:
mergeImportedEntityin 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:
getProjectCredentialsin interfaceCredentialsAccessor- Parameters:
projectId-- 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:
getProjectCredentialsByPluginKeyin interfaceCredentialsAccessor- Parameters:
projectId-pluginKey-- Returns:
- a collection of project credentials that match the given plugin key
-
getProjectCredentials
Description copied from interface:CredentialsAccessorGets the Shared Credentials by id and projectId- Specified by:
getProjectCredentialsin interfaceCredentialsAccessor- Parameters:
id-- Returns:
- Returns the object representation of the credentials
-