Class CredentialConverter
- All Implemented Interfaces:
ExtensionPoint
- Direct Known Subclasses:
LoginConverter
,SecureNoteConverter
,SshKeyConverter
This abstract class is a Jenkins ExtensionPoint
, allowing different implementations
to be discovered at runtime. Each implementation is responsible for a specific
Bitwarden item type (e.g., Login, Secure Note) and provides the logic for creating both
a lightweight proxy and a fully resolved credential object.
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
canConvert
(BitwardenItem item) Checks if this converter can handle the fully resolved item.abstract boolean
canConvert
(BitwardenItemMetadata metadata) Checks if this converter can handle the item type specified in the metadata.abstract com.cloudbees.plugins.credentials.common.StandardCredentials
convert
(com.cloudbees.plugins.credentials.CredentialsScope scope, String id, String description, BitwardenItem item) Creates a real, fully-formed Jenkins credential from a complete Bitwarden item.abstract com.cloudbees.plugins.credentials.common.StandardCredentials
createProxy
(com.cloudbees.plugins.credentials.CredentialsScope scope, String id, BitwardenItemMetadata metadata) Creates a lightweight, lazy-loading proxy for a Jenkins credential.static CredentialConverter
findConverter
(BitwardenItem item) Finds the first available and registered converter that can handle the given item.static CredentialConverter
findConverter
(BitwardenItemMetadata metadata) Finds the first available and registered converter that can handle the given item metadata.
-
Constructor Details
-
CredentialConverter
public CredentialConverter()
-
-
Method Details
-
findConverter
Finds the first available and registered converter that can handle the given item metadata.This static factory method iterates through all registered
CredentialConverter
implementations and returns the first one that reports it can handle the item's type.- Parameters:
metadata
- The lightweight, non-secret metadata of the Bitwarden item.- Returns:
- A suitable
CredentialConverter
instance, ornull
if none are found.
-
findConverter
Finds the first available and registered converter that can handle the given item.This static factory method is used during the lazy-loading process to ensure the correct converter is used to create the final, concrete credential object.
- Parameters:
item
- The fully resolved Bitwarden item with all metadata and secret fields.- Returns:
- A suitable
CredentialConverter
instance, ornull
if none are found.
-
canConvert
Checks if this converter can handle the item type specified in the metadata.This is a fast check based only on the item's type, without accessing any secret data.
- Parameters:
metadata
- The lightweight, non-secret metadata of the Bitwarden item.- Returns:
true
if this converter is designed for the item's type.
-
canConvert
Checks if this converter can handle the fully resolved item.This check is performed after the secret has been fetched and can be used to verify that the necessary fields (e.g.,
login
,notes
) are present.- Parameters:
item
- The fully resolved Bitwarden item with all metadata and secret fields.- Returns:
true
if this converter can handle the item's data.
-
createProxy
public abstract com.cloudbees.plugins.credentials.common.StandardCredentials createProxy(com.cloudbees.plugins.credentials.CredentialsScope scope, String id, BitwardenItemMetadata metadata) Creates a lightweight, lazy-loading proxy for a Jenkins credential.This method should not perform any expensive operations. It creates a dynamic proxy that will defer the actual fetching of the secret until a method like
getPassword()
orgetContent()
is called.- Parameters:
scope
- The scope for the new credential (always GLOBAL for this provider).id
- The ID the credential will be known by in Jenkins (either the name or UUID).metadata
- The lightweight metadata of the Bitwarden item.- Returns:
- A
StandardCredentials
proxy object.
-
convert
public abstract com.cloudbees.plugins.credentials.common.StandardCredentials convert(com.cloudbees.plugins.credentials.CredentialsScope scope, String id, String description, BitwardenItem item) Creates a real, fully-formed Jenkins credential from a complete Bitwarden item.This method is called by the
CredentialProxy
during the lazy-loading process after the full item has been fetched from the Bitwarden CLI.- Parameters:
scope
- The scope for the new credential.id
- The ID for the new credential.description
- The user-facing description for the new credential.item
- The fully resolved Bitwarden item.- Returns:
- The final, concrete Jenkins credential object.
-