package com.github.dreamhead.moco.internal;

import com.github.dreamhead.moco.resource.ContentResource;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

public class HttpsCertificate {

    private final InputStream keyStore;
    private final String keyStorePassword;
    private final String certPassword;

    public HttpsCertificate(InputStream keyStore, String keyStorePassword, String certPassword) {
        this.keyStore = keyStore;
        this.keyStorePassword = keyStorePassword;
        this.certPassword = certPassword;
    }

    public InputStream getKeyStore() {
        return keyStore;
    }

    public char[] getKeyStorePassword() {
        return keyStorePassword.toCharArray();
    }

    public char[] getCertPassword() {
        return certPassword.toCharArray();
    }

    public static HttpsCertificate certificate(ContentResource resource, String keyStorePassword, String certPassword) {
        return new HttpsCertificate(new ByteArrayInputStream(resource.readFor(null)), keyStorePassword, certPassword);
    }
}

@@ -215,35 +215,39 @@
 e final 
-InputStream keyStor
+ContentResource resourc
 e;%0A    p
@@ -356,27 +356,31 @@
 ate(
-InputStream keyStor
+ContentResource resourc
 e, S
@@ -443,26 +443,26 @@
 his.
-keyStore = keyStor
+resource = resourc
 e;%0A 
@@ -613,24 +613,64 @@
  return 
-keyStore
+new ByteArrayInputStream(resource.readFor(null))
 ;%0A    %7D%0A
@@ -1015,56 +1015,16 @@
 ate(
-new ByteArrayInputStream(resource.readFor(null))
+resource
 , ke

load keystore dynamically