package com.nirima.jenkins.plugins.docker.utils;

import com.cloudbees.plugins.credentials.Credentials;
import com.cloudbees.plugins.credentials.CredentialsDescriptor;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials;
import com.cloudbees.plugins.credentials.impl.Messages;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.Util;
import hudson.util.Secret;
import org.kohsuke.stapler.DataBoundConstructor;

/**
 * Created by magnayn on 17/11/2015.
 */
public class DockerDirectoryCredentials extends BaseStandardCredentials {

    String path;

    @DataBoundConstructor
    public DockerDirectoryCredentials(@CheckForNull CredentialsScope scope, @CheckForNull String id, @CheckForNull String description, @CheckForNull String path) {
        super(scope, id, description);
        this.path = Util.fixNull(path);
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    @Extension
    public static class DescriptorImpl extends CredentialsDescriptor {
        public DescriptorImpl() {
        }

        public String getDisplayName() {
            return "Docker Certificates Directory";
        }
    }
}

@@ -161,16 +161,78 @@
 riptor;%0A
+import com.cloudbees.plugins.credentials.CredentialsProvider;%0A
 import c
@@ -597,91 +597,375 @@
 org.
-kohsuke.stapler.DataBoundConstructor;%0A%0A/**%0A * Created by magnayn on 17/11/2015.%0A */
+apache.commons.io.FileUtils;%0Aimport org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials;%0Aimport org.kohsuke.stapler.DataBoundConstructor;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0A%0A/**%0A * Created by magnayn on 17/11/2015.%0A * @deprecated  use %7B@link org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials%7D%0A */%0A@Deprecated
 %0Apub
@@ -1062,40 +1062,15 @@
     
-@DataBoundConstructor%0A    public
+private
  Doc
@@ -1093,30 +1093,16 @@
 entials(
-@CheckForNull 
 Credenti
@@ -1121,172 +1121,77 @@
 pe, 
-@CheckForNull String id, @CheckForNull String description, @CheckForNull String path) %7B%0A        super(scope, id, description);%0A        this.path = Util.fixNull(path
+String id, String description) %7B%0A        super(scope, id, description
 );%0A 
@@ -1188,32 +1188,33 @@
 iption);%0A    %7D%0A%0A
+%0A
     public Strin
@@ -1323,24 +1323,412 @@
 ath;%0A    %7D%0A%0A
+    private Object readResolve() throws IOException %7B%0A        final File f = new File(path);%0A%0A        return new DockerServerCredentials(getScope(), getId(), getDescription(),%0A                FileUtils.readFileToString(new File(f, %22key.pem%22)),%0A                FileUtils.readFileToString(new File(f, %22cert.pem%22)),%0A                FileUtils.readFileToString(new File(f, %22ca.pem%22)));%0A    %7D%0A%0A
     @Extensi
@@ -1936,17 +1936,153 @@
 irectory
-%22
+ (Deprecated)%22;%0A        %7D%0A%0A        @Override%0A        public boolean isApplicable(CredentialsProvider provider) %7B%0A            return false
 ;%0A      

migrate legacy DockerDirectoryCredentials to docker-commons’ DockerServerCredentials (#520)