// Path: src/main/java/org/jenkinsci/plugins/credentialsbinding/BindingDescriptor.java
// public abstract class BindingDescriptor<C extends StandardCredentials> extends Descriptor<MultiBinding<C>> {
// 
//     protected abstract Class<C> type();
// 
//     /**
//      * Determines whether this {@link MultiBinding} needs a workspace to evaluate.
//      */
//     public boolean requiresWorkspace() {
//         return true;
//     }
// 
//     public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item owner) {
//         if (owner == null || !owner.hasPermission(Item.CONFIGURE)) {
//             return new ListBoxModel();
//         }
//         // when configuring the job, you only want those credentials that are available to ACL.SYSTEM selectable
//         // as we cannot select from a user's credentials unless they are the only user submitting the build
//         // (which we cannot assume) thus ACL.SYSTEM is correct here.
//         return new Model().withAll(CredentialsProvider.lookupCredentials(type(), owner, ACL.SYSTEM, Collections.emptyList()));
//     }
// 
//     private final class Model extends AbstractIdCredentialsListBoxModel<Model,C> {
// 
//         @NonNull
//         @Override
//         protected String describe(@NonNull C c) {
//             return CredentialsNameProvider.name(c);
//         }
// 
//     }
// 
// }
// 
// Path: src/main/java/org/jenkinsci/plugins/credentialsbinding/MultiBinding.java
// public interface Unbinder extends Serializable {
//     /**
//      * Performs any needed cleanup.
//      * @param build The build. Cannot be null
//      * @param workspace The workspace - can be null if {@link BindingDescriptor#requiresWorkspace()} is false.
//      * @param launcher The launcher - can be null if {@link BindingDescriptor#requiresWorkspace()} is false.
//      * @param listener The task listener. Cannot be null.
//      */
//     void unbind(@NonNull Run<?,?> build,
//                 @Nullable FilePath workspace,
//                 @Nullable Launcher launcher,
//                 @NonNull TaskListener listener) throws IOException, InterruptedException;
// }


import java.io.IOException;
import java.util.UUID;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.jenkinsci.plugins.credentialsbinding.BindingDescriptor;
import org.jenkinsci.plugins.credentialsbinding.MultiBinding.Unbinder;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.slaves.WorkspaceList;
package org.jenkinsci.plugins.credentialsbinding.impl;




/**
 * Convenience class for creating a secure temporary directory dedicated to writing credentials file(s), and getting a
 * corresponding {@link Unbinder} instance.
 */
public class UnbindableDir {

    private final FilePath dirPath;
// Path: src/main/java/org/jenkinsci/plugins/credentialsbinding/BindingDescriptor.java
// public abstract class BindingDescriptor<C extends StandardCredentials> extends Descriptor<MultiBinding<C>> {
// 
//     protected abstract Class<C> type();
// 
//     /**
//      * Determines whether this {@link MultiBinding} needs a workspace to evaluate.
//      */
//     public boolean requiresWorkspace() {
//         return true;
//     }
// 
//     public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item owner) {
//         if (owner == null || !owner.hasPermission(Item.CONFIGURE)) {
//             return new ListBoxModel();
//         }
//         // when configuring the job, you only want those credentials that are available to ACL.SYSTEM selectable
//         // as we cannot select from a user's credentials unless they are the only user submitting the build
//         // (which we cannot assume) thus ACL.SYSTEM is correct here.
//         return new Model().withAll(CredentialsProvider.lookupCredentials(type(), owner, ACL.SYSTEM, Collections.emptyList()));
//     }
// 
//     private final class Model extends AbstractIdCredentialsListBoxModel<Model,C> {
// 
//         @NonNull
//         @Override
//         protected String describe(@NonNull C c) {
//             return CredentialsNameProvider.name(c);
//         }
// 
//     }
// 
// }
// 
// Path: src/main/java/org/jenkinsci/plugins/credentialsbinding/MultiBinding.java
// public interface Unbinder extends Serializable {
//     /**
//      * Performs any needed cleanup.
//      * @param build The build. Cannot be null
//      * @param workspace The workspace - can be null if {@link BindingDescriptor#requiresWorkspace()} is false.
//      * @param launcher The launcher - can be null if {@link BindingDescriptor#requiresWorkspace()} is false.
//      * @param listener The task listener. Cannot be null.
//      */
//     void unbind(@NonNull Run<?,?> build,
//                 @Nullable FilePath workspace,
//                 @Nullable Launcher launcher,
//                 @NonNull TaskListener listener) throws IOException, InterruptedException;
// }


// Path: src/main/java/org/jenkinsci/plugins/credentialsbinding/impl/UnbindableDir.java
import java.io.IOException;
import java.util.UUID;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.jenkinsci.plugins.credentialsbinding.BindingDescriptor;
import org.jenkinsci.plugins.credentialsbinding.MultiBinding.Unbinder;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.slaves.WorkspaceList;

package org.jenkinsci.plugins.credentialsbinding.impl;




/**
 * Convenience class for creating a secure temporary directory dedicated to writing credentials file(s), and getting a
 * corresponding {@link Unbinder} instance.
 */
public class UnbindableDir {

    private final FilePath dirPath;
    private final Unbinder unbinder;