package com.cloudbees.plugins.credentials;

import hudson.ExtensionPoint;
import hudson.model.Item;
import hudson.model.ModelObject;
import hudson.model.Node;
import hudson.model.Run;
import jenkins.util.Listeners;

import java.util.List;


/**
 * A Listener to track {@link Credentials} usage.
 * @see CredentialsProvider#trackAll(Item, List) 
 * @see CredentialsProvider#trackAll(Run, List) 
 * @see CredentialsProvider#trackAll(Node, List) 
 */
public interface CredentialsUseListener extends ExtensionPoint {

    /**
     * Called when {@link Credentials} is read by an object.
     *
     * @param c   The used Credentials.
     * @param obj The object using the credentials.
     */
    void onUse(Credentials c, ModelObject obj);

    /**
     * Fires the {@link #onUse} event to track the object that uses credentials.
     *  @see CredentialsProvider#trackAll(Item, List)
     *  @see CredentialsProvider#trackAll(Run, List)
     *  @see CredentialsProvider#trackAll(Node, List)
     */
    static void fireUse(Credentials c, ModelObject obj) {
        Listeners.notify(CredentialsUseListener.class, true, listener -> listener.onUse(c, obj));
    }
}

@@ -570,16 +570,12 @@
 by a
-n object
+ run
 .%0A  
@@ -637,22 +637,232 @@
 ram 
-obj
+run
  The 
-object
+run using the credentials.%0A     */%0A    void onUse(Credentials c, Run run);%0A%0A    /**%0A     * Called when %7B@link Credentials%7D is read by a node.%0A     *%0A     * @param c   The used Credentials.%0A     * @param node The node
  usi
@@ -919,31 +919,241 @@
 ials c, 
-ModelObject obj
+Node node);%0A%0A    /**%0A     * Called when %7B@link Credentials%7D is read by an item.%0A     *%0A     * @param c   The used Credentials.%0A     * @param item The item using the credentials.%0A     */%0A    void onUse(Credentials c, Item item
 );%0A%0A    
@@ -1211,14 +1211,11 @@
 the 
-object
+run
  tha
@@ -1280,72 +1280,575 @@
 All(
-Item, List)%0A     *  @see CredentialsProvider#trackAll(Run, List)
+Run, List)%0A     */%0A    static void fireUse(Credentials c, Run run) %7B%0A        Listeners.notify(CredentialsUseListener.class, true, listener -%3E listener.onUse(c, run));%0A    %7D%0A%0A    /**%0A     * Fires the %7B@link #onUse%7D event to track the node that uses credentials.%0A     *  @see CredentialsProvider#trackAll(Node, List)%0A     */%0A    static void fireUse(Credentials c, Node node) %7B%0A        Listeners.notify(CredentialsUseListener.class, true, listener -%3E listener.onUse(c, node));%0A    %7D%0A%0A    /**%0A     * Fires the %7B@link #onUse%7D event to track the item that uses credentials.
 %0A   
@@ -1878,36 +1878,36 @@
 ovider#trackAll(
-Node
+Item
 , List)%0A     */%0A
@@ -1949,23 +1949,17 @@
  c, 
-ModelObject obj
+Item item
 ) %7B%0A
@@ -2053,11 +2053,12 @@
 (c, 
-obj
+item
 ));%0A

Make listener more type-specific