Package com.mwdle.bitwarden.converters
Class CredentialProxy
java.lang.Object
com.mwdle.bitwarden.converters.CredentialProxy
- All Implemented Interfaces:
Serializable
,InvocationHandler
A stateless, lazy-loading proxy handler for Bitwarden-backed credentials.
This is the core of the plugin's lazy-loading mechanism. It acts as an intermediary for all credential method calls. For non-secret data (like ID or description), it returns values instantly from memory. For secret data (passwords, keys), it performs a one-time, live call to the Bitwarden CLI to fetch the fresh secret at the moment it is needed.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCredentialProxy
(String credentialId, String itemId, String itemName, Descriptor<?> itemDescriptor) Constructs a new proxy handler for a Bitwarden credential. -
Method Summary
-
Constructor Details
-
CredentialProxy
public CredentialProxy(String credentialId, String itemId, String itemName, Descriptor<?> itemDescriptor) Constructs a new proxy handler for a Bitwarden credential.This constructor also builds the user-facing description string, intelligently formatting it to provide extra context for file-based credentials and items with non-unique names.
- Parameters:
credentialId
- The ID this credential will be known by in Jenkins (either the name or UUID).itemId
- The unique, persistent UUID of the item in Bitwarden.itemName
- The user-provided name of the item in Bitwarden.itemDescriptor
- The JenkinsDescriptor
for the credential type this proxy represents.
-
-
Method Details
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws IOException, InterruptedException Intercepts all method calls made to the proxied credential object.This is the main entry point for the proxy. It handles non-secret methods instantly and triggers the one-time, thread-safe resolution of the full secret when required.
- Specified by:
invoke
in interfaceInvocationHandler
- Parameters:
proxy
- The proxy instance that the method was invoked on.method
- TheMethod
instance corresponding to the interface method invoked on the proxy instance.args
- An array of objects containing the values of the arguments passed in the method invocation.- Returns:
- The value to return from the method invocation on the proxy instance.
- Throws:
IOException
- if the underlying secret resolution fails.InterruptedException
- if the thread is interrupted during secret resolution.
-