// 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);
//         }
// 
//     }
// 
// }


import hudson.model.TaskListener;
import java.io.IOException;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.credentialsbinding.BindingDescriptor;
import org.jenkinsci.plugins.plaincredentials.FileCredentials;
import org.kohsuke.stapler.DataBoundConstructor;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.Run;
        FilePath secret = dir.child(credentials.getFileName());
        secret.copyFrom(credentials.getContent());
        secret.chmod(0400);
        return secret;
    }

    @SuppressWarnings("unused")
    @Deprecated
    private static class UnbinderImpl implements Unbinder {
        private static final long serialVersionUID = 1;
        private final String dirName;

        private UnbinderImpl(String dirName) {
            this.dirName = dirName;
        }

        protected Object readResolve() {
            return new UnbindableDir.UnbinderImpl(dirName);
        }

        @Override
        public void unbind(@NonNull Run<?, ?> build,
                           @Nullable FilePath workspace,
                           @Nullable Launcher launcher,
                           @NonNull TaskListener listener) {
            // replaced by the UnbindableDir.UnbinderImpl implementation
        }
    }

    @Symbol("file")
// 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/impl/FileBinding.java
import hudson.model.TaskListener;
import java.io.IOException;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.credentialsbinding.BindingDescriptor;
import org.jenkinsci.plugins.plaincredentials.FileCredentials;
import org.kohsuke.stapler.DataBoundConstructor;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.Run;

        FilePath secret = dir.child(credentials.getFileName());
        secret.copyFrom(credentials.getContent());
        secret.chmod(0400);
        return secret;
    }

    @SuppressWarnings("unused")
    @Deprecated
    private static class UnbinderImpl implements Unbinder {
        private static final long serialVersionUID = 1;
        private final String dirName;

        private UnbinderImpl(String dirName) {
            this.dirName = dirName;
        }

        protected Object readResolve() {
            return new UnbindableDir.UnbinderImpl(dirName);
        }

        @Override
        public void unbind(@NonNull Run<?, ?> build,
                           @Nullable FilePath workspace,
                           @Nullable Launcher launcher,
                           @NonNull TaskListener listener) {
            // replaced by the UnbindableDir.UnbinderImpl implementation
        }
    }

    @Symbol("file")
    @Extension public static class DescriptorImpl extends BindingDescriptor<FileCredentials> {