package info.knacki.pass.io.pgp;

import android.content.Context;
import android.support.annotation.NonNull;

import org.bouncycastle.openpgp.PGPSecretKey;
import org.bouncycastle.openpgp.PGPSecretKeyRing;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class GPGStorageEngine {
    private static IGPGStorage fDefaultEngine = null;

    public static IGPGStorage GetDefaultEngine(Context ctx) {
        if (fDefaultEngine == null) {
            synchronized (GPGStorageEngine.class) {
                return fDefaultEngine = new UberGPGStorage(ctx);
            }
        }
        return fDefaultEngine;
    }

    public interface IGPGStorage {
        boolean HasGPGKey();
        boolean SetGPGKeyContent(InputStream content);
        void ExportGPGKeyContent(OutputStream out) throws IOException;
        @NonNull PGPSecretKeyRing GetGPGKeyRing() throws IOException;
        @NonNull PGPSecretKey GetGPGSecretKey() throws IOException;
        @NonNull PGPSecretKey GetGPGSecretKey(long keyId) throws IOException;
        void RemoveGpgKey();
    }
}
