Dont write version header by default
This commit is contained in:
@@ -67,7 +67,7 @@ public final class Constants {
|
||||
public static final String FORCE_V3_SIGNATURES = "forceV3Signatures";
|
||||
public static final String KEY_SERVERS = "keyServers";
|
||||
public static final String KEY_SERVERS_DEFAULT_VERSION = "keyServersDefaultVersion";
|
||||
public static final String CONCEAL_PGP_APPLICATION = "concealPgpApplication";
|
||||
public static final String WRITE_VERSION_HEADER = "writeVersionHeader";
|
||||
public static final String FIRST_TIME = "firstTime";
|
||||
}
|
||||
|
||||
|
||||
@@ -205,13 +205,13 @@ public class Preferences {
|
||||
}
|
||||
}
|
||||
|
||||
public void setConcealPgpApplication(boolean conceal) {
|
||||
public void setWriteVersionHeader(boolean conceal) {
|
||||
SharedPreferences.Editor editor = mSharedPreferences.edit();
|
||||
editor.putBoolean(Constants.Pref.CONCEAL_PGP_APPLICATION, conceal);
|
||||
editor.putBoolean(Constants.Pref.WRITE_VERSION_HEADER, conceal);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public boolean getConcealPgpApplication() {
|
||||
return mSharedPreferences.getBoolean(Constants.Pref.CONCEAL_PGP_APPLICATION, false);
|
||||
public boolean getWriteVersionHeader() {
|
||||
return mSharedPreferences.getBoolean(Constants.Pref.WRITE_VERSION_HEADER, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ public class PgpHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFullVersion(Context context) {
|
||||
if(Preferences.getPreferences(context).getConcealPgpApplication()){
|
||||
return "";
|
||||
} else {
|
||||
public static String getVersionForHeader(Context context) {
|
||||
if(Preferences.getPreferences(context).getWriteVersionHeader()){
|
||||
return "OpenKeychain v" + getVersion(context);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,10 @@ public class PgpImportExport {
|
||||
progress++;
|
||||
// Create an output stream
|
||||
ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream);
|
||||
arOutStream.setHeader("Version", PgpHelper.getFullVersion(mContext));
|
||||
String version = PgpHelper.getVersionForHeader(mContext);
|
||||
if (version != null) {
|
||||
arOutStream.setHeader("Version", version);
|
||||
}
|
||||
|
||||
updateProgress(progress * 100 / masterKeyIdsSize, 100);
|
||||
|
||||
@@ -258,7 +261,10 @@ public class PgpImportExport {
|
||||
progress++;
|
||||
// Create an output stream
|
||||
ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream);
|
||||
arOutStream.setHeader("Version", PgpHelper.getFullVersion(mContext));
|
||||
String version = PgpHelper.getVersionForHeader(mContext);
|
||||
if (version != null) {
|
||||
arOutStream.setHeader("Version", version);
|
||||
}
|
||||
|
||||
updateProgress(progress * 100 / masterKeyIdsSize, 100);
|
||||
|
||||
|
||||
@@ -109,11 +109,11 @@ public class PgpSignEncrypt {
|
||||
public static class Builder {
|
||||
// mandatory parameter
|
||||
private ProviderHelper mProviderHelper;
|
||||
private String mVersionHeader;
|
||||
private InputData mData;
|
||||
private OutputStream mOutStream;
|
||||
|
||||
// optional
|
||||
private String mVersionHeader = null;
|
||||
private Progressable mProgressable = null;
|
||||
private boolean mEnableAsciiArmorOutput = false;
|
||||
private int mCompressionId = CompressionAlgorithmTags.UNCOMPRESSED;
|
||||
@@ -128,13 +128,17 @@ public class PgpSignEncrypt {
|
||||
private boolean mCleartextInput = false;
|
||||
private String mOriginalFilename = "";
|
||||
|
||||
public Builder(ProviderHelper providerHelper, String versionHeader, InputData data, OutputStream outStream) {
|
||||
public Builder(ProviderHelper providerHelper, InputData data, OutputStream outStream) {
|
||||
mProviderHelper = providerHelper;
|
||||
mVersionHeader = versionHeader;
|
||||
mData = data;
|
||||
mOutStream = outStream;
|
||||
}
|
||||
|
||||
public Builder setVersionHeader(String versionHeader) {
|
||||
mVersionHeader = versionHeader;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setProgressable(Progressable progressable) {
|
||||
mProgressable = progressable;
|
||||
return this;
|
||||
@@ -271,7 +275,9 @@ public class PgpSignEncrypt {
|
||||
OutputStream out;
|
||||
if (mEnableAsciiArmorOutput) {
|
||||
armorOut = new ArmoredOutputStream(mOutStream);
|
||||
armorOut.setHeader("Version", mVersionHeader);
|
||||
if (mVersionHeader != null) {
|
||||
armorOut.setHeader("Version", mVersionHeader);
|
||||
}
|
||||
out = armorOut;
|
||||
} else {
|
||||
out = mOutStream;
|
||||
|
||||
@@ -204,7 +204,9 @@ public class UncachedKeyRing {
|
||||
|
||||
public void encodeArmored(OutputStream out, String version) throws IOException {
|
||||
ArmoredOutputStream aos = new ArmoredOutputStream(out);
|
||||
aos.setHeader("Version", version);
|
||||
if (version != null) {
|
||||
aos.setHeader("Version", version);
|
||||
}
|
||||
aos.write(mRing.getEncoded());
|
||||
aos.close();
|
||||
}
|
||||
|
||||
@@ -862,7 +862,10 @@ public class ProviderHelper {
|
||||
UncachedKeyRing keyRing = UncachedKeyRing.decodeFromData(data);
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
keyRing.encodeArmored(bos, PgpHelper.getFullVersion(mContext));
|
||||
String version = PgpHelper.getVersionForHeader(mContext);
|
||||
if (version != null) {
|
||||
keyRing.encodeArmored(bos, version);
|
||||
}
|
||||
String armoredKey = bos.toString("UTF-8");
|
||||
|
||||
Log.d(Constants.TAG, "armoredKey:" + armoredKey);
|
||||
|
||||
@@ -187,9 +187,9 @@ public class OpenPgpService extends RemoteService {
|
||||
// sign-only
|
||||
PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(
|
||||
new ProviderHelper(getContext()),
|
||||
PgpHelper.getFullVersion(getContext()),
|
||||
inputData, os);
|
||||
builder.setEnableAsciiArmorOutput(asciiArmor)
|
||||
.setVersionHeader(PgpHelper.getVersionForHeader(this))
|
||||
.setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
|
||||
.setSignatureForceV3(false)
|
||||
.setSignatureMasterKeyId(accSettings.getKeyId())
|
||||
@@ -276,9 +276,9 @@ public class OpenPgpService extends RemoteService {
|
||||
|
||||
PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(
|
||||
new ProviderHelper(getContext()),
|
||||
PgpHelper.getFullVersion(getContext()),
|
||||
inputData, os);
|
||||
builder.setEnableAsciiArmorOutput(asciiArmor)
|
||||
.setVersionHeader(PgpHelper.getVersionForHeader(this))
|
||||
.setCompressionId(accSettings.getCompression())
|
||||
.setSymmetricEncryptionAlgorithm(accSettings.getEncryptionAlgorithm())
|
||||
.setEncryptionMasterKeyIds(keyIds)
|
||||
|
||||
@@ -249,11 +249,11 @@ public class KeychainIntentService extends IntentService
|
||||
PgpSignEncrypt.Builder builder =
|
||||
new PgpSignEncrypt.Builder(
|
||||
new ProviderHelper(this),
|
||||
PgpHelper.getFullVersion(this),
|
||||
inputData, outStream);
|
||||
builder.setProgressable(this);
|
||||
|
||||
builder.setEnableAsciiArmorOutput(useAsciiArmor)
|
||||
.setVersionHeader(PgpHelper.getVersionForHeader(this))
|
||||
.setCompressionId(compressionId)
|
||||
.setSymmetricEncryptionAlgorithm(
|
||||
Preferences.getPreferences(this).getDefaultEncryptionAlgorithm())
|
||||
|
||||
@@ -122,8 +122,8 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
initializeForceV3Signatures(
|
||||
(CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES));
|
||||
|
||||
initializeConcealPgpApplication(
|
||||
(CheckBoxPreference) findPreference(Constants.Pref.CONCEAL_PGP_APPLICATION));
|
||||
initializeWriteVersionHeader(
|
||||
(CheckBoxPreference) findPreference(Constants.Pref.WRITE_VERSION_HEADER));
|
||||
|
||||
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||
// Load the legacy preferences headers
|
||||
@@ -269,8 +269,8 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
initializeForceV3Signatures(
|
||||
(CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES));
|
||||
|
||||
initializeConcealPgpApplication(
|
||||
(CheckBoxPreference) findPreference(Constants.Pref.CONCEAL_PGP_APPLICATION));
|
||||
initializeWriteVersionHeader(
|
||||
(CheckBoxPreference) findPreference(Constants.Pref.WRITE_VERSION_HEADER));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,12 +404,12 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private static void initializeConcealPgpApplication(final CheckBoxPreference mConcealPgpApplication) {
|
||||
mConcealPgpApplication.setChecked(sPreferences.getConcealPgpApplication());
|
||||
mConcealPgpApplication.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
private static void initializeWriteVersionHeader(final CheckBoxPreference mWriteVersionHeader) {
|
||||
mWriteVersionHeader.setChecked(sPreferences.getWriteVersionHeader());
|
||||
mWriteVersionHeader.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
mConcealPgpApplication.setChecked((Boolean) newValue);
|
||||
sPreferences.setConcealPgpApplication((Boolean) newValue);
|
||||
mWriteVersionHeader.setChecked((Boolean) newValue);
|
||||
sPreferences.setWriteVersionHeader((Boolean) newValue);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user