|
|
@@ -16,7 +16,6 @@ import java.util.logging.Logger;
|
|
|
|
|
|
public class SettingsManager {
|
|
|
private static final Logger log = Logger.getLogger(SettingsManager.class.getName());
|
|
|
- public static final String GPG_GENERATED = "BouncyCastle gpg key";
|
|
|
|
|
|
public static class EncryptionType {
|
|
|
public static final EncryptionType TYPE_RAW = new EncryptionType(0);
|
|
|
@@ -222,15 +221,15 @@ public class SettingsManager {
|
|
|
prefs.remove(VCS.class.getSimpleName()).commit();
|
|
|
}
|
|
|
|
|
|
- private static void doSetGpgKeyContent(Context ctx, String filename, String content) {
|
|
|
- GetPrefManager(ctx).edit().putString("GPGKeyFile", filename + '@' + content).commit();
|
|
|
+ private static void doSetGpgKeyContent(Context ctx, String content) {
|
|
|
+ GetPrefManager(ctx).edit().putString("GPGKeyFile", content).commit();
|
|
|
}
|
|
|
|
|
|
public static void RemoveGpgKey(Context ctx) {
|
|
|
GetPrefManager(ctx).edit().remove("GPGKeyFile").commit();
|
|
|
}
|
|
|
|
|
|
- public static boolean SetGPGKeyContent(Context ctx, String filename, InputStream stream) {
|
|
|
+ public static boolean SetGPGKeyContent(Context ctx, InputStream stream) {
|
|
|
if (stream == null) {
|
|
|
GetPrefManager(ctx).edit().remove("GPGKeyFile").commit();
|
|
|
return false;
|
|
|
@@ -244,7 +243,7 @@ public class SettingsManager {
|
|
|
len = stream.read(buffer);
|
|
|
bytes.write(buffer, 0, len);
|
|
|
} while (len == bufLen);
|
|
|
- doSetGpgKeyContent(ctx, filename, Base64.encodeToString(bytes.toByteArray(), 0));
|
|
|
+ doSetGpgKeyContent(ctx, Base64.encodeToString(bytes.toByteArray(), 0));
|
|
|
} catch (IOException e) {
|
|
|
log.log(Level.SEVERE, "Cannot read file", e);
|
|
|
RemoveGpgKey(ctx);
|
|
|
@@ -256,14 +255,7 @@ public class SettingsManager {
|
|
|
public static InputStream GetGPGKeyContent(Context ctx) {
|
|
|
String content = GetPrefManager(ctx).getString("GPGKeyFile", null);
|
|
|
if (content != null)
|
|
|
- return new ByteArrayInputStream(Base64.decode(content.substring(content.indexOf('@') + 1), 0));
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- public static String GetGPGKeyName(Context ctx) {
|
|
|
- String content = GetPrefManager(ctx).getString("GPGKeyFile", null);
|
|
|
- if (content != null)
|
|
|
- return content.substring(0, content.indexOf('@'));
|
|
|
+ return new ByteArrayInputStream(Base64.decode(content, 0));
|
|
|
return null;
|
|
|
}
|
|
|
|