-
Notifications
You must be signed in to change notification settings - Fork 249
Add CredentialsUseListener to improve tracking of Credentials usage #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jglick
merged 7 commits into
jenkinsci:master
from
meiswjn:feature/credential-usage-event
Apr 19, 2022
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
70141de
Add CredentialsUseListener
meiswjn d43b53b
Simplify CredentialsUseListener by using latest LTS feature
meiswjn 735747f
Add @see links
meiswjn b91f8e9
Change CredentialsUseListener to Interface
meiswjn 5066407
Merge branch 'master' into feature/credential-usage-event
meiswjn 342e742
Make listener more type-specific
meiswjn d8c2e77
Merge branch 'feature/credential-usage-event' of https://github.com/m…
meiswjn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/com/cloudbees/plugins/credentials/CredentialsUseListener.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.cloudbees.plugins.credentials; | ||
|
|
||
| import hudson.ExtensionPoint; | ||
| import hudson.model.ModelObject; | ||
| import jenkins.util.Listeners; | ||
|
|
||
|
|
||
| /** | ||
| * A Listener to track {@link Credentials } usage. | ||
| */ | ||
| public abstract class CredentialsUseListener implements ExtensionPoint { | ||
meiswjn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Called when {@link Credentials} is read by an object. | ||
| * | ||
| * @param c The used Credentials. | ||
| * @param obj The object using the credentials. | ||
| */ | ||
| public abstract void onUse(Credentials c, ModelObject obj); | ||
|
|
||
| /** | ||
| * Fires the {@link #onUse} event to track the object that uses credentials. | ||
| */ | ||
| public static void fireUse(Credentials c, ModelObject obj) { | ||
| Listeners.notify(CredentialsUseListener.class, true, listener -> { | ||
| listener.onUse(c, obj); | ||
| }); | ||
meiswjn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.