Class LoginConverter
- All Implemented Interfaces:
ExtensionPoint
StandardUsernamePasswordCredentials.-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanConvert(BitwardenItem item) Checks if this converter can handle the fully resolved item.booleancanConvert(BitwardenItemMetadata metadata) Checks if this converter can handle the item type specified in the metadata.com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentialsconvert(com.cloudbees.plugins.credentials.CredentialsScope scope, String id, String description, BitwardenItem item) Creates a real, fully-formed Jenkins credential from a complete Bitwarden item.com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentialscreateProxy(com.cloudbees.plugins.credentials.CredentialsScope scope, String id, BitwardenItemMetadata metadata) Creates a lightweight, lazy-loading proxy for a Jenkins credential.Methods inherited from class com.mwdle.bitwarden.converters.CredentialConverter
findConverter, findConverter
-
Constructor Details
-
LoginConverter
public LoginConverter()
-
-
Method Details
-
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.
This implementation returns
trueif the item's type isBitwardenItemType.LOGIN.- Specified by:
canConvertin classCredentialConverter- Parameters:
metadata- The lightweight, non-secret metadata of the Bitwarden item.- Returns:
trueif 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.This implementation returns
trueif the Bitwarden item contains a non-nullloginobject with either a username or a password, or both.- Specified by:
canConvertin classCredentialConverter- Parameters:
item- The fully resolved Bitwarden item with all metadata and secret fields.- Returns:
trueif this converter can handle the item's data.
-
createProxy
public com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials 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.- Specified by:
createProxyin classCredentialConverter- 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
StandardCredentialsproxy object.
-
convert
public com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials 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
CredentialProxyduring the lazy-loading process after the full item has been fetched from the Bitwarden CLI.This implementation constructs a
UsernamePasswordCredentialsImplusing the username and password from the Bitwarden item. It safely handles null values by substituting empty strings.- Specified by:
convertin classCredentialConverter- 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.
-