mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 03:25:05 -05:00
Merge branch 'canonicalize'
This commit is contained in:
commit
9d77790729
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -25,3 +25,9 @@
|
||||
[submodule "extern/openkeychain-api-lib"]
|
||||
path = extern/openkeychain-api-lib
|
||||
url = https://github.com/open-keychain/openkeychain-api-lib.git
|
||||
[submodule "extern/SuperToasts"]
|
||||
path = extern/SuperToasts
|
||||
url = https://github.com/open-keychain/SuperToasts.git
|
||||
[submodule "extern/dnsjava"]
|
||||
path = extern/dnsjava
|
||||
url = https://github.com/open-keychain/dnsjava.git
|
||||
|
@ -4,13 +4,13 @@ before_install:
|
||||
# Install base Android SDK
|
||||
- sudo apt-get update -qq
|
||||
- if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm lib32z1 lib32stdc++6; fi
|
||||
- wget http://dl.google.com/android/android-sdk_r22.3-linux.tgz
|
||||
- tar xzf android-sdk_r22.3-linux.tgz
|
||||
- wget http://dl.google.com/android/android-sdk_r22.6.2-linux.tgz
|
||||
- tar xzf android-sdk_r22.6.2-linux.tgz
|
||||
- export ANDROID_HOME=$PWD/android-sdk-linux
|
||||
- export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
|
||||
|
||||
# Install required Android components.
|
||||
- echo "y" | android update sdk -a --filter build-tools-19.0.3,android-19,platform-tools,extra-android-support,extra-android-m2repository --no-ui --force
|
||||
- echo "y" | android update sdk -a --filter build-tools-19.1.0,android-19,platform-tools,extra-android-support,extra-android-m2repository --no-ui --force
|
||||
install: echo "Installation done"
|
||||
script: gradle assemble -S -q
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
apply plugin: 'android'
|
||||
apply plugin: 'android-test'
|
||||
//apply plugin: 'android-test'
|
||||
|
||||
sourceSets {
|
||||
androidTest {
|
||||
java.srcDir file('src/test/java')
|
||||
//androidTest {
|
||||
//java.srcDir file('src/test/java')
|
||||
// configure the set of classes for JUnit tests
|
||||
// include '**/*Test.class'
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -26,6 +26,8 @@ dependencies {
|
||||
compile project(':extern:spongycastle:pkix')
|
||||
compile project(':extern:spongycastle:prov')
|
||||
compile project(':extern:AppMsg:library')
|
||||
compile project(':extern:SuperToasts:supertoasts')
|
||||
compile project(':extern:dnsjava')
|
||||
|
||||
// Dependencies for the `instrumentTest` task, make sure to list all your global dependencies here as well
|
||||
androidTestCompile 'junit:junit:4.10'
|
||||
@ -46,11 +48,13 @@ dependencies {
|
||||
androidTestCompile project(':extern:spongycastle:pkix')
|
||||
androidTestCompile project(':extern:spongycastle:prov')
|
||||
androidTestCompile project(':extern:AppMsg:library')
|
||||
androidTestCompile project(':extern:SuperToasts:supertoasts')
|
||||
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "19.0.3"
|
||||
buildToolsVersion "19.1"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 9
|
||||
|
@ -53,6 +53,12 @@
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.NFC" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
|
||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/>
|
||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/>
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||
|
||||
<!-- android:allowBackup="false": Don't allow backup over adb backup or other apps! -->
|
||||
<application
|
||||
@ -86,6 +92,11 @@
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".ui.KeyListActivity" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.key" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.ViewCertActivity"
|
||||
@ -434,6 +445,34 @@
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".ui.LogDisplayActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:label="@string/title_log_display"
|
||||
android:exported="false" />
|
||||
|
||||
<service android:name=".service.DummyAccountService">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.AccountAuthenticator"/>
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.accounts.AccountAuthenticator"
|
||||
android:resource="@xml/account_desc"/>
|
||||
</service>
|
||||
|
||||
<service android:name=".service.ContactSyncAdapterService">
|
||||
<intent-filter>
|
||||
<action android:name="android.content.SyncAdapter"/>
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.content.SyncAdapter"
|
||||
android:resource="@xml/sync_adapter_desc"/>
|
||||
<meta-data
|
||||
android:name="android.provider.CONTACTS_STRUCTURE"
|
||||
android:resource="@xml/custom_pgp_contacts_structure"/>
|
||||
</service>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@ -46,6 +46,8 @@ public final class Constants {
|
||||
|
||||
public static final String INTENT_PREFIX = PACKAGE_NAME + ".action.";
|
||||
|
||||
public static final String CUSTOM_CONTACT_DATA_MIME_TYPE = "vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.key";
|
||||
|
||||
public static final class Path {
|
||||
public static final String APP_DIR = Environment.getExternalStorageDirectory()
|
||||
+ "/OpenKeychain";
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
package org.sufficientlysecure.keychain;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
@ -24,6 +26,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Environment;
|
||||
|
||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.sufficientlysecure.keychain.helper.ContactHelper;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.PRNGFixes;
|
||||
|
||||
@ -76,6 +79,17 @@ public class KeychainApplication extends Application {
|
||||
|
||||
brandGlowEffect(getApplicationContext(),
|
||||
getApplicationContext().getResources().getColor(R.color.emphasis));
|
||||
|
||||
setupAccountAsNeeded(this);
|
||||
}
|
||||
|
||||
public static void setupAccountAsNeeded(Context context) {
|
||||
AccountManager manager = AccountManager.get(context);
|
||||
Account[] accounts = manager.getAccountsByType(Constants.PACKAGE_NAME);
|
||||
if (accounts == null || accounts.length == 0) {
|
||||
Account dummy = new Account(context.getString(R.string.app_name), Constants.PACKAGE_NAME);
|
||||
manager.addAccountExplicitly(dummy, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
static void brandGlowEffect(Context context, int brandColor) {
|
||||
|
@ -19,8 +19,18 @@ package org.sufficientlysecure.keychain.helper;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.Context;
|
||||
import android.content.*;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.ContactsContract;
|
||||
import android.util.Patterns;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@ -29,6 +39,15 @@ import java.util.Set;
|
||||
|
||||
public class ContactHelper {
|
||||
|
||||
public static final String[] KEYS_TO_CONTACT_PROJECTION = new String[]{
|
||||
KeychainContract.KeyRings.USER_ID,
|
||||
KeychainContract.KeyRings.FINGERPRINT,
|
||||
KeychainContract.KeyRings.KEY_ID,
|
||||
KeychainContract.KeyRings.MASTER_KEY_ID};
|
||||
public static final String[] RAW_CONTACT_ID_PROJECTION = new String[]{ContactsContract.RawContacts._ID};
|
||||
public static final String FIND_RAW_CONTACT_SELECTION =
|
||||
ContactsContract.RawContacts.ACCOUNT_TYPE + "=? AND " + ContactsContract.RawContacts.SOURCE_ID + "=?";
|
||||
|
||||
public static final List<String> getMailAccounts(Context context) {
|
||||
final Account[] accounts = AccountManager.get(context).getAccounts();
|
||||
final Set<String> emailSet = new HashSet<String>();
|
||||
@ -39,4 +58,92 @@ public class ContactHelper {
|
||||
}
|
||||
return new ArrayList<String>(emailSet);
|
||||
}
|
||||
|
||||
public static List<String> getContactMails(Context context) {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
Cursor mailCursor = resolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,
|
||||
new String[]{ContactsContract.CommonDataKinds.Email.DATA},
|
||||
null, null, null);
|
||||
if (mailCursor == null) return null;
|
||||
|
||||
Set<String> mails = new HashSet<String>();
|
||||
while (mailCursor.moveToNext()) {
|
||||
String email = mailCursor.getString(0);
|
||||
if (email != null) {
|
||||
mails.add(email);
|
||||
}
|
||||
}
|
||||
mailCursor.close();
|
||||
return new ArrayList<String>(mails);
|
||||
}
|
||||
|
||||
public static Uri dataUriFromContactUri(Context context, Uri contactUri) {
|
||||
Cursor contactMasterKey = context.getContentResolver().query(contactUri, new String[]{ContactsContract.Data.DATA2}, null, null, null, null);
|
||||
if (contactMasterKey != null) {
|
||||
if (contactMasterKey.moveToNext()) {
|
||||
return KeychainContract.KeyRings.buildGenericKeyRingUri(contactMasterKey.getLong(0));
|
||||
}
|
||||
contactMasterKey.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void writeKeysToContacts(Context context) {
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
Cursor cursor = resolver.query(KeychainContract.KeyRings.buildUnifiedKeyRingsUri(), KEYS_TO_CONTACT_PROJECTION,
|
||||
null, null, null);
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String[] userId = KeyRing.splitUserId(cursor.getString(0));
|
||||
String fingerprint = PgpKeyHelper.convertFingerprintToHex(cursor.getBlob(1));
|
||||
String keyIdShort = PgpKeyHelper.convertKeyIdToHexShort(cursor.getLong(2));
|
||||
long masterKeyId = cursor.getLong(3);
|
||||
int rawContactId = -1;
|
||||
Cursor raw = resolver.query(ContactsContract.RawContacts.CONTENT_URI, RAW_CONTACT_ID_PROJECTION,
|
||||
FIND_RAW_CONTACT_SELECTION, new String[]{Constants.PACKAGE_NAME, fingerprint}, null, null);
|
||||
if (raw != null) {
|
||||
if (raw.moveToNext()) {
|
||||
rawContactId = raw.getInt(0);
|
||||
}
|
||||
raw.close();
|
||||
}
|
||||
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
|
||||
if (rawContactId == -1) {
|
||||
ops.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI)
|
||||
.withValue(ContactsContract.RawContacts.ACCOUNT_NAME, context.getString(R.string.app_name))
|
||||
.withValue(ContactsContract.RawContacts.ACCOUNT_TYPE, Constants.PACKAGE_NAME)
|
||||
.withValue(ContactsContract.RawContacts.SOURCE_ID, fingerprint)
|
||||
.build());
|
||||
if (userId[0] != null) {
|
||||
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
||||
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
|
||||
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
|
||||
.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, userId[0])
|
||||
.build());
|
||||
}
|
||||
if (userId[1] != null) {
|
||||
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
||||
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
|
||||
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE)
|
||||
.withValue(ContactsContract.CommonDataKinds.Email.DATA, userId[1])
|
||||
.build());
|
||||
}
|
||||
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
||||
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
|
||||
.withValue(ContactsContract.Data.MIMETYPE, Constants.CUSTOM_CONTACT_DATA_MIME_TYPE)
|
||||
.withValue(ContactsContract.Data.DATA1, String.format(context.getString(R.string.contact_show_key), keyIdShort))
|
||||
.withValue(ContactsContract.Data.DATA2, masterKeyId)
|
||||
.build());
|
||||
}
|
||||
try {
|
||||
resolver.applyBatch(ContactsContract.AUTHORITY, ops);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
} catch (OperationApplicationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.helper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Messenger;
|
||||
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||
import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class EmailKeyHelper {
|
||||
|
||||
public static void importContacts(Context context, Messenger messenger) {
|
||||
importAll(context, messenger, ContactHelper.getContactMails(context));
|
||||
}
|
||||
|
||||
public static void importAll(Context context, Messenger messenger, List<String> mails) {
|
||||
Set<ImportKeysListEntry> keys = new HashSet<ImportKeysListEntry>();
|
||||
for (String mail : mails) {
|
||||
keys.addAll(getEmailKeys(context, mail));
|
||||
}
|
||||
importKeys(context, messenger, new ArrayList<ImportKeysListEntry>(keys));
|
||||
}
|
||||
|
||||
public static List<ImportKeysListEntry> getEmailKeys(Context context, String mail) {
|
||||
Set<ImportKeysListEntry> keys = new HashSet<ImportKeysListEntry>();
|
||||
|
||||
// Try _hkp._tcp SRV record first
|
||||
String[] mailparts = mail.split("@");
|
||||
if (mailparts.length == 2) {
|
||||
HkpKeyserver hkp = HkpKeyserver.resolve(mailparts[1]);
|
||||
if (hkp != null) {
|
||||
keys.addAll(getEmailKeys(mail, hkp));
|
||||
}
|
||||
}
|
||||
|
||||
// Most users don't have the SRV record, so ask a default server as well
|
||||
String[] servers = Preferences.getPreferences(context).getKeyServers();
|
||||
if (servers != null && servers.length != 0) {
|
||||
HkpKeyserver hkp = new HkpKeyserver(servers[0]);
|
||||
keys.addAll(getEmailKeys(mail, hkp));
|
||||
}
|
||||
return new ArrayList<ImportKeysListEntry>(keys);
|
||||
}
|
||||
|
||||
private static void importKeys(Context context, Messenger messenger, List<ImportKeysListEntry> keys) {
|
||||
Intent importIntent = new Intent(context, KeychainIntentService.class);
|
||||
importIntent.setAction(KeychainIntentService.ACTION_DOWNLOAD_AND_IMPORT_KEYS);
|
||||
Bundle importData = new Bundle();
|
||||
importData.putParcelableArrayList(KeychainIntentService.DOWNLOAD_KEY_LIST,
|
||||
new ArrayList<ImportKeysListEntry>(keys));
|
||||
importIntent.putExtra(KeychainIntentService.EXTRA_DATA, importData);
|
||||
importIntent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
context.startService(importIntent);
|
||||
}
|
||||
|
||||
public static List<ImportKeysListEntry> getEmailKeys(String mail, Keyserver keyServer) {
|
||||
Set<ImportKeysListEntry> keys = new HashSet<ImportKeysListEntry>();
|
||||
try {
|
||||
for (ImportKeysListEntry key : keyServer.search(mail)) {
|
||||
if (key.isRevoked() || key.isExpired()) continue;
|
||||
for (String userId : key.getUserIds()) {
|
||||
if (userId.toLowerCase().contains(mail.toLowerCase())) {
|
||||
keys.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Keyserver.QueryFailedException ignored) {
|
||||
} catch (Keyserver.QueryNeedsRepairException ignored) {
|
||||
}
|
||||
return new ArrayList<ImportKeysListEntry>(keys);
|
||||
}
|
||||
}
|
@ -33,6 +33,10 @@ import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.xbill.DNS.Lookup;
|
||||
import org.xbill.DNS.Record;
|
||||
import org.xbill.DNS.SRVRecord;
|
||||
import org.xbill.DNS.Type;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -45,6 +49,8 @@ import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -75,6 +81,7 @@ public class HkpKeyserver extends Keyserver {
|
||||
|
||||
private String mHost;
|
||||
private short mPort;
|
||||
private boolean mSecure;
|
||||
|
||||
/**
|
||||
* pub:%keyid%:%algo%:%keylen%:%creationdate%:%expirationdate%:%flags%
|
||||
@ -109,7 +116,7 @@ public class HkpKeyserver extends Keyserver {
|
||||
*/
|
||||
public static final Pattern PUB_KEY_LINE = Pattern
|
||||
.compile("pub:([0-9a-fA-F]+):([0-9]+):([0-9]+):([0-9]+):([0-9]*):([rde]*)[ \n\r]*" // pub line
|
||||
+ "(uid:(.*):([0-9]+):([0-9]*):([rde]*))+", // one or more uid lines
|
||||
+ "((uid:([^:]*):([0-9]+):([0-9]*):([rde]*)[ \n\r]*)+)", // one or more uid lines
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
|
||||
/**
|
||||
@ -137,10 +144,11 @@ public class HkpKeyserver extends Keyserver {
|
||||
* </ul>
|
||||
*/
|
||||
public static final Pattern UID_LINE = Pattern
|
||||
.compile("uid:(.*):([0-9]+):([0-9]*):([rde]*)",
|
||||
.compile("uid:([^:]*):([0-9]+):([0-9]*):([rde]*)",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
|
||||
private static final short PORT_DEFAULT = 11371;
|
||||
private static final short PORT_DEFAULT_HKPS = 443;
|
||||
|
||||
/**
|
||||
* @param hostAndPort may be just
|
||||
@ -151,31 +159,68 @@ public class HkpKeyserver extends Keyserver {
|
||||
public HkpKeyserver(String hostAndPort) {
|
||||
String host = hostAndPort;
|
||||
short port = PORT_DEFAULT;
|
||||
final int colonPosition = hostAndPort.lastIndexOf(':');
|
||||
if (colonPosition > 0) {
|
||||
host = hostAndPort.substring(0, colonPosition);
|
||||
final String portStr = hostAndPort.substring(colonPosition + 1);
|
||||
port = Short.decode(portStr);
|
||||
boolean secure = false;
|
||||
String[] parts = hostAndPort.split(":");
|
||||
if (parts.length > 1) {
|
||||
if (!parts[0].contains(".")) { // This is not a domain or ip, so it must be a protocol name
|
||||
if (parts[0].equalsIgnoreCase("hkps") || parts[0].equalsIgnoreCase("https")) {
|
||||
secure = true;
|
||||
port = PORT_DEFAULT_HKPS;
|
||||
} else if (!parts[0].equalsIgnoreCase("hkp") && !parts[0].equalsIgnoreCase("http")) {
|
||||
throw new IllegalArgumentException("Protocol " + parts[0] + " is unknown");
|
||||
}
|
||||
host = parts[1];
|
||||
if (host.startsWith("//")) { // People tend to type https:// and hkps://, so we'll support that as well
|
||||
host = host.substring(2);
|
||||
}
|
||||
if (parts.length > 2) {
|
||||
port = Short.decode(parts[2]);
|
||||
}
|
||||
} else {
|
||||
host = parts[0];
|
||||
port = Short.decode(parts[1]);
|
||||
}
|
||||
}
|
||||
mHost = host;
|
||||
mPort = port;
|
||||
mSecure = secure;
|
||||
}
|
||||
|
||||
public HkpKeyserver(String host, short port) {
|
||||
this(host, port, false);
|
||||
}
|
||||
|
||||
public HkpKeyserver(String host, short port, boolean secure) {
|
||||
mHost = host;
|
||||
mPort = port;
|
||||
mSecure = secure;
|
||||
}
|
||||
|
||||
private String getUrlPrefix() {
|
||||
return mSecure ? "https://" : "http://";
|
||||
}
|
||||
|
||||
private String query(String request) throws QueryFailedException, HttpError {
|
||||
InetAddress ips[];
|
||||
try {
|
||||
ips = InetAddress.getAllByName(mHost);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new QueryFailedException(e.toString());
|
||||
}
|
||||
for (int i = 0; i < ips.length; ++i) {
|
||||
List<String> urls = new ArrayList<String>();
|
||||
if (mSecure) {
|
||||
urls.add(getUrlPrefix() + mHost + ":" + mPort + request);
|
||||
} else {
|
||||
InetAddress ips[];
|
||||
try {
|
||||
ips = InetAddress.getAllByName(mHost);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new QueryFailedException(e.toString());
|
||||
}
|
||||
for (InetAddress ip : ips) {
|
||||
// Note: This is actually not HTTP 1.1 compliant, as we hide the real "Host" value,
|
||||
// but Android's HTTPUrlConnection does not support any other way to set
|
||||
// Socket's remote IP address...
|
||||
urls.add(getUrlPrefix() + ip.getHostAddress() + ":" + mPort + request);
|
||||
}
|
||||
}
|
||||
|
||||
for (String url : urls) {
|
||||
try {
|
||||
String url = "http://" + ips[i].getHostAddress() + ":" + mPort + request;
|
||||
Log.d(Constants.TAG, "hkp keyserver query: " + url);
|
||||
URL realUrl = new URL(url);
|
||||
HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection();
|
||||
@ -238,6 +283,7 @@ public class HkpKeyserver extends Keyserver {
|
||||
while (matcher.find()) {
|
||||
final ImportKeysListEntry entry = new ImportKeysListEntry();
|
||||
entry.setQuery(query);
|
||||
entry.setOrigin(getUrlPrefix() + mHost + ":" + mPort);
|
||||
|
||||
entry.setBitStrength(Integer.parseInt(matcher.group(3)));
|
||||
|
||||
@ -262,6 +308,7 @@ public class HkpKeyserver extends Keyserver {
|
||||
entry.setDate(tmpGreg.getTime());
|
||||
|
||||
entry.setRevoked(matcher.group(6).contains("r"));
|
||||
entry.setExpired(matcher.group(6).contains("e"));
|
||||
|
||||
ArrayList<String> userIds = new ArrayList<String>();
|
||||
final String uidLines = matcher.group(7);
|
||||
@ -290,7 +337,7 @@ public class HkpKeyserver extends Keyserver {
|
||||
public String get(String keyIdHex) throws QueryFailedException {
|
||||
HttpClient client = new DefaultHttpClient();
|
||||
try {
|
||||
String query = "http://" + mHost + ":" + mPort +
|
||||
String query = getUrlPrefix() + mHost + ":" + mPort +
|
||||
"/pks/lookup?op=get&options=mr&search=" + keyIdHex;
|
||||
Log.d(Constants.TAG, "hkp keyserver get: " + query);
|
||||
HttpGet get = new HttpGet(query);
|
||||
@ -319,7 +366,7 @@ public class HkpKeyserver extends Keyserver {
|
||||
public void add(String armoredKey) throws AddKeyException {
|
||||
HttpClient client = new DefaultHttpClient();
|
||||
try {
|
||||
String query = "http://" + mHost + ":" + mPort + "/pks/add";
|
||||
String query = getUrlPrefix() + mHost + ":" + mPort + "/pks/add";
|
||||
HttpPost post = new HttpPost(query);
|
||||
Log.d(Constants.TAG, "hkp keyserver add: " + query);
|
||||
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
|
||||
@ -336,4 +383,36 @@ public class HkpKeyserver extends Keyserver {
|
||||
client.getConnectionManager().shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return mHost + ":" + mPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to find a server responsible for a given domain
|
||||
*
|
||||
* @return A responsible Keyserver or null if not found.
|
||||
*/
|
||||
public static HkpKeyserver resolve(String domain) {
|
||||
try {
|
||||
Record[] records = new Lookup("_hkp._tcp." + domain, Type.SRV).run();
|
||||
if (records.length > 0) {
|
||||
Arrays.sort(records, new Comparator<Record>() {
|
||||
@Override
|
||||
public int compare(Record lhs, Record rhs) {
|
||||
if (!(lhs instanceof SRVRecord)) return 1;
|
||||
if (!(rhs instanceof SRVRecord)) return -1;
|
||||
return ((SRVRecord) lhs).getPriority() - ((SRVRecord) rhs).getPriority();
|
||||
}
|
||||
});
|
||||
Record record = records[0]; // This is our best choice
|
||||
if (record instanceof SRVRecord) {
|
||||
return new HkpKeyserver(((SRVRecord) record).getTarget().toString(), (short) ((SRVRecord) record).getPort());
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -32,18 +32,20 @@ import java.util.Date;
|
||||
public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
private static final long serialVersionUID = -7797972103284992662L;
|
||||
|
||||
public ArrayList<String> userIds;
|
||||
public long keyId;
|
||||
public String keyIdHex;
|
||||
public boolean revoked;
|
||||
public Date date; // TODO: not displayed
|
||||
public String fingerprintHex;
|
||||
public int bitStrength;
|
||||
public String algorithm;
|
||||
public boolean secretKey;
|
||||
public String mPrimaryUserId;
|
||||
private ArrayList<String> mUserIds;
|
||||
private long mKeyId;
|
||||
private String mKeyIdHex;
|
||||
private boolean mRevoked;
|
||||
private boolean mExpired;
|
||||
private Date mDate; // TODO: not displayed
|
||||
private String mFingerprintHex;
|
||||
private int mBitStrength;
|
||||
private String mAlgorithm;
|
||||
private boolean mSecretKey;
|
||||
private String mPrimaryUserId;
|
||||
private String mExtraData;
|
||||
private String mQuery;
|
||||
private String mOrigin;
|
||||
|
||||
private boolean mSelected;
|
||||
|
||||
@ -54,35 +56,39 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(mPrimaryUserId);
|
||||
dest.writeStringList(userIds);
|
||||
dest.writeLong(keyId);
|
||||
dest.writeByte((byte) (revoked ? 1 : 0));
|
||||
dest.writeSerializable(date);
|
||||
dest.writeString(fingerprintHex);
|
||||
dest.writeString(keyIdHex);
|
||||
dest.writeInt(bitStrength);
|
||||
dest.writeString(algorithm);
|
||||
dest.writeByte((byte) (secretKey ? 1 : 0));
|
||||
dest.writeStringList(mUserIds);
|
||||
dest.writeLong(mKeyId);
|
||||
dest.writeByte((byte) (mRevoked ? 1 : 0));
|
||||
dest.writeByte((byte) (mExpired ? 1 : 0));
|
||||
dest.writeSerializable(mDate);
|
||||
dest.writeString(mFingerprintHex);
|
||||
dest.writeString(mKeyIdHex);
|
||||
dest.writeInt(mBitStrength);
|
||||
dest.writeString(mAlgorithm);
|
||||
dest.writeByte((byte) (mSecretKey ? 1 : 0));
|
||||
dest.writeByte((byte) (mSelected ? 1 : 0));
|
||||
dest.writeString(mExtraData);
|
||||
dest.writeString(mOrigin);
|
||||
}
|
||||
|
||||
public static final Creator<ImportKeysListEntry> CREATOR = new Creator<ImportKeysListEntry>() {
|
||||
public ImportKeysListEntry createFromParcel(final Parcel source) {
|
||||
ImportKeysListEntry vr = new ImportKeysListEntry();
|
||||
vr.mPrimaryUserId = source.readString();
|
||||
vr.userIds = new ArrayList<String>();
|
||||
source.readStringList(vr.userIds);
|
||||
vr.keyId = source.readLong();
|
||||
vr.revoked = source.readByte() == 1;
|
||||
vr.date = (Date) source.readSerializable();
|
||||
vr.fingerprintHex = source.readString();
|
||||
vr.keyIdHex = source.readString();
|
||||
vr.bitStrength = source.readInt();
|
||||
vr.algorithm = source.readString();
|
||||
vr.secretKey = source.readByte() == 1;
|
||||
vr.mUserIds = new ArrayList<String>();
|
||||
source.readStringList(vr.mUserIds);
|
||||
vr.mKeyId = source.readLong();
|
||||
vr.mRevoked = source.readByte() == 1;
|
||||
vr.mExpired = source.readByte() == 1;
|
||||
vr.mDate = (Date) source.readSerializable();
|
||||
vr.mFingerprintHex = source.readString();
|
||||
vr.mKeyIdHex = source.readString();
|
||||
vr.mBitStrength = source.readInt();
|
||||
vr.mAlgorithm = source.readString();
|
||||
vr.mSecretKey = source.readByte() == 1;
|
||||
vr.mSelected = source.readByte() == 1;
|
||||
vr.mExtraData = source.readString();
|
||||
vr.mOrigin = source.readString();
|
||||
|
||||
return vr;
|
||||
}
|
||||
@ -93,7 +99,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
};
|
||||
|
||||
public String getKeyIdHex() {
|
||||
return keyIdHex;
|
||||
return mKeyIdHex;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
@ -104,72 +110,80 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
this.mSelected = selected;
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
return mExpired;
|
||||
}
|
||||
|
||||
public void setExpired(boolean expired) {
|
||||
this.mExpired = expired;
|
||||
}
|
||||
|
||||
public long getKeyId() {
|
||||
return keyId;
|
||||
return mKeyId;
|
||||
}
|
||||
|
||||
public void setKeyId(long keyId) {
|
||||
this.keyId = keyId;
|
||||
this.mKeyId = keyId;
|
||||
}
|
||||
|
||||
public void setKeyIdHex(String keyIdHex) {
|
||||
this.keyIdHex = keyIdHex;
|
||||
this.mKeyIdHex = keyIdHex;
|
||||
}
|
||||
|
||||
public boolean isRevoked() {
|
||||
return revoked;
|
||||
return mRevoked;
|
||||
}
|
||||
|
||||
public void setRevoked(boolean revoked) {
|
||||
this.revoked = revoked;
|
||||
this.mRevoked = revoked;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
return mDate;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
this.mDate = date;
|
||||
}
|
||||
|
||||
public String getFingerprintHex() {
|
||||
return fingerprintHex;
|
||||
return mFingerprintHex;
|
||||
}
|
||||
|
||||
public void setFingerprintHex(String fingerprintHex) {
|
||||
this.fingerprintHex = fingerprintHex;
|
||||
this.mFingerprintHex = fingerprintHex;
|
||||
}
|
||||
|
||||
public int getBitStrength() {
|
||||
return bitStrength;
|
||||
return mBitStrength;
|
||||
}
|
||||
|
||||
public void setBitStrength(int bitStrength) {
|
||||
this.bitStrength = bitStrength;
|
||||
this.mBitStrength = bitStrength;
|
||||
}
|
||||
|
||||
public String getAlgorithm() {
|
||||
return algorithm;
|
||||
return mAlgorithm;
|
||||
}
|
||||
|
||||
public void setAlgorithm(String algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
this.mAlgorithm = algorithm;
|
||||
}
|
||||
|
||||
public boolean isSecretKey() {
|
||||
return secretKey;
|
||||
return mSecretKey;
|
||||
}
|
||||
|
||||
public void setSecretKey(boolean secretKey) {
|
||||
this.secretKey = secretKey;
|
||||
this.mSecretKey = secretKey;
|
||||
}
|
||||
|
||||
public ArrayList<String> getUserIds() {
|
||||
return userIds;
|
||||
return mUserIds;
|
||||
}
|
||||
|
||||
public void setUserIds(ArrayList<String> userIds) {
|
||||
this.userIds = userIds;
|
||||
this.mUserIds = userIds;
|
||||
}
|
||||
|
||||
public String getPrimaryUserId() {
|
||||
@ -196,15 +210,23 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
mQuery = query;
|
||||
}
|
||||
|
||||
public String getOrigin() {
|
||||
return mOrigin;
|
||||
}
|
||||
|
||||
public void setOrigin(String origin) {
|
||||
mOrigin = origin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for later querying from keyserver
|
||||
*/
|
||||
public ImportKeysListEntry() {
|
||||
// keys from keyserver are always public keys; from keybase too
|
||||
secretKey = false;
|
||||
mSecretKey = false;
|
||||
// do not select by default
|
||||
mSelected = false;
|
||||
userIds = new ArrayList<String>();
|
||||
mUserIds = new ArrayList<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,24 +237,24 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
|
||||
// selected is default
|
||||
this.mSelected = true;
|
||||
|
||||
secretKey = ring.isSecret();
|
||||
mSecretKey = ring.isSecret();
|
||||
UncachedPublicKey key = ring.getPublicKey();
|
||||
|
||||
mPrimaryUserId = key.getPrimaryUserId();
|
||||
userIds = key.getUnorderedUserIds();
|
||||
mUserIds = key.getUnorderedUserIds();
|
||||
|
||||
// if there was no user id flagged as primary, use the first one
|
||||
if (mPrimaryUserId == null) {
|
||||
mPrimaryUserId = userIds.get(0);
|
||||
mPrimaryUserId = mUserIds.get(0);
|
||||
}
|
||||
|
||||
this.keyId = key.getKeyId();
|
||||
this.keyIdHex = PgpKeyHelper.convertKeyIdToHex(keyId);
|
||||
this.mKeyId = key.getKeyId();
|
||||
this.mKeyIdHex = PgpKeyHelper.convertKeyIdToHex(mKeyId);
|
||||
|
||||
this.revoked = key.maybeRevoked();
|
||||
this.fingerprintHex = PgpKeyHelper.convertFingerprintToHex(key.getFingerprint());
|
||||
this.bitStrength = key.getBitStrength();
|
||||
this.mRevoked = key.isRevoked();
|
||||
this.mFingerprintHex = PgpKeyHelper.convertFingerprintToHex(key.getFingerprint());
|
||||
this.mBitStrength = key.getBitStrength();
|
||||
final int algorithm = key.getAlgorithm();
|
||||
this.algorithm = PgpKeyHelper.getAlgorithmInfo(context, algorithm);
|
||||
this.mAlgorithm = PgpKeyHelper.getAlgorithmInfo(context, algorithm);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class KeybaseKeyserver extends Keyserver {
|
||||
public static final String ORIGIN = "keybase:keybase.io";
|
||||
private String mQuery;
|
||||
|
||||
@Override
|
||||
@ -87,6 +88,7 @@ public class KeybaseKeyserver extends Keyserver {
|
||||
|
||||
final ImportKeysListEntry entry = new ImportKeysListEntry();
|
||||
entry.setQuery(mQuery);
|
||||
entry.setOrigin(ORIGIN);
|
||||
|
||||
String keybaseId = JWalk.getString(match, "components", "username", "val");
|
||||
String fullName = JWalk.getString(match, "components", "full_name", "val");
|
||||
@ -144,7 +146,8 @@ public class KeybaseKeyserver extends Keyserver {
|
||||
try {
|
||||
JSONObject json = new JSONObject(text);
|
||||
if (JWalk.getInt(json, "status", "code") != 0) {
|
||||
throw new QueryFailedException("Keybase autocomplete search failed");
|
||||
throw new QueryFailedException("Keybase.io query failed: " + path + "?" +
|
||||
query);
|
||||
}
|
||||
return json;
|
||||
} catch (JSONException e) {
|
||||
|
@ -48,12 +48,12 @@ public abstract class Keyserver {
|
||||
private static final long serialVersionUID = -507574859137295530L;
|
||||
}
|
||||
|
||||
abstract List<ImportKeysListEntry> search(String query) throws QueryFailedException,
|
||||
public abstract List<ImportKeysListEntry> search(String query) throws QueryFailedException,
|
||||
QueryNeedsRepairException;
|
||||
|
||||
abstract String get(String keyIdHex) throws QueryFailedException;
|
||||
public abstract String get(String keyIdHex) throws QueryFailedException;
|
||||
|
||||
abstract void add(String armoredKey) throws AddKeyException;
|
||||
public abstract void add(String armoredKey) throws AddKeyException;
|
||||
|
||||
public static String readAll(InputStream in, String encoding) throws IOException {
|
||||
ByteArrayOutputStream raw = new ByteArrayOutputStream();
|
||||
|
@ -3,7 +3,7 @@ package org.sufficientlysecure.keychain.keyimport;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/** This is a trivial wrapper around UncachedKeyRing which implements Parcelable. It exists
|
||||
/** This is a trivial wrapper around keyring bytes which implements Parcelable. It exists
|
||||
* for the sole purpose of keeping spongycastle and android imports in separate packages.
|
||||
*/
|
||||
public class ParcelableKeyRing implements Parcelable {
|
||||
|
@ -33,6 +33,9 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||
import org.sufficientlysecure.keychain.service.OperationResultParcel.OperationLog;
|
||||
import org.sufficientlysecure.keychain.service.OperationResults.ImportResult;
|
||||
import org.sufficientlysecure.keychain.service.OperationResults.SaveKeyringResult;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -55,10 +58,6 @@ public class PgpImportExport {
|
||||
|
||||
private ProviderHelper mProviderHelper;
|
||||
|
||||
public static final int RETURN_OK = 0;
|
||||
public static final int RETURN_BAD = -2;
|
||||
public static final int RETURN_UPDATED = 1;
|
||||
|
||||
public PgpImportExport(Context context, Progressable progressable) {
|
||||
super();
|
||||
this.mContext = context;
|
||||
@ -115,26 +114,20 @@ public class PgpImportExport {
|
||||
if (aos != null) {
|
||||
aos.close();
|
||||
}
|
||||
if (bos != null) {
|
||||
bos.close();
|
||||
}
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
// this is just a finally thing, no matter if it doesn't work out.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports keys from given data. If keyIds is given only those are imported
|
||||
*/
|
||||
public Bundle importKeyRings(List<ParcelableKeyRing> entries)
|
||||
/** Imports keys from given data. If keyIds is given only those are imported */
|
||||
public ImportResult importKeyRings(List<ParcelableKeyRing> entries)
|
||||
throws PgpGeneralException, PGPException, IOException {
|
||||
Bundle returnData = new Bundle();
|
||||
|
||||
updateProgress(R.string.progress_importing, 0, 100);
|
||||
|
||||
int newKeys = 0;
|
||||
int oldKeys = 0;
|
||||
int badKeys = 0;
|
||||
int newKeys = 0, oldKeys = 0, badKeys = 0;
|
||||
|
||||
int position = 0;
|
||||
for (ParcelableKeyRing entry : entries) {
|
||||
@ -152,14 +145,19 @@ public class PgpImportExport {
|
||||
}
|
||||
}
|
||||
|
||||
mProviderHelper.savePublicKeyRing(key);
|
||||
/*switch(status) {
|
||||
case RETURN_UPDATED: oldKeys++; break;
|
||||
case RETURN_OK: newKeys++; break;
|
||||
case RETURN_BAD: badKeys++; break;
|
||||
}*/
|
||||
// TODO proper import feedback
|
||||
newKeys += 1;
|
||||
SaveKeyringResult result;
|
||||
if (key.isSecret()) {
|
||||
result = mProviderHelper.saveSecretKeyRing(key);
|
||||
} else {
|
||||
result = mProviderHelper.savePublicKeyRing(key);
|
||||
}
|
||||
if (!result.success()) {
|
||||
badKeys += 1;
|
||||
} else if (result.updated()) {
|
||||
oldKeys += 1;
|
||||
} else {
|
||||
newKeys += 1;
|
||||
}
|
||||
|
||||
} catch (PgpGeneralException e) {
|
||||
Log.e(Constants.TAG, "Encountered bad key on import!", e);
|
||||
@ -170,11 +168,31 @@ public class PgpImportExport {
|
||||
updateProgress(position / entries.size() * 100, 100);
|
||||
}
|
||||
|
||||
returnData.putInt(KeychainIntentService.RESULT_IMPORT_ADDED, newKeys);
|
||||
returnData.putInt(KeychainIntentService.RESULT_IMPORT_UPDATED, oldKeys);
|
||||
returnData.putInt(KeychainIntentService.RESULT_IMPORT_BAD, badKeys);
|
||||
OperationLog log = mProviderHelper.getLog();
|
||||
int resultType = 0;
|
||||
// special return case: no new keys at all
|
||||
if (badKeys == 0 && newKeys == 0 && oldKeys == 0) {
|
||||
resultType = ImportResult.RESULT_FAIL_NOTHING;
|
||||
} else {
|
||||
if (newKeys > 0) {
|
||||
resultType |= ImportResult.RESULT_OK_NEWKEYS;
|
||||
}
|
||||
if (oldKeys > 0) {
|
||||
resultType |= ImportResult.RESULT_OK_UPDATED;
|
||||
}
|
||||
if (badKeys > 0) {
|
||||
resultType |= ImportResult.RESULT_WITH_ERRORS;
|
||||
if (newKeys == 0 && oldKeys == 0) {
|
||||
resultType |= ImportResult.RESULT_ERROR;
|
||||
}
|
||||
}
|
||||
if (log.containsWarnings()) {
|
||||
resultType |= ImportResult.RESULT_WITH_WARNINGS;
|
||||
}
|
||||
}
|
||||
|
||||
return new ImportResult(resultType, log, newKeys, oldKeys, badKeys);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
public Bundle exportKeyRings(ArrayList<Long> publicKeyRingMasterIds,
|
||||
|
@ -2,14 +2,23 @@ package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
import org.spongycastle.bcpg.ArmoredOutputStream;
|
||||
import org.spongycastle.bcpg.S2K;
|
||||
import org.spongycastle.bcpg.SignatureSubpacketTags;
|
||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||
import org.spongycastle.openpgp.PGPKeyFlags;
|
||||
import org.spongycastle.openpgp.PGPKeyRing;
|
||||
import org.spongycastle.openpgp.PGPObjectFactory;
|
||||
import org.spongycastle.openpgp.PGPPublicKey;
|
||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.spongycastle.openpgp.PGPSignature;
|
||||
import org.spongycastle.openpgp.PGPSignatureList;
|
||||
import org.spongycastle.openpgp.PGPUtil;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||
import org.sufficientlysecure.keychain.service.OperationResultParcel.OperationLog;
|
||||
import org.sufficientlysecure.keychain.service.OperationResultParcel.LogLevel;
|
||||
import org.sufficientlysecure.keychain.service.OperationResultParcel.LogType;
|
||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
@ -18,7 +27,8 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
@ -149,13 +159,13 @@ public class UncachedKeyRing {
|
||||
aos.close();
|
||||
}
|
||||
|
||||
public ArrayList<Long> getAvailableSubkeys() {
|
||||
public HashSet<Long> getAvailableSubkeys() {
|
||||
if(!isSecret()) {
|
||||
throw new RuntimeException("Tried to find available subkeys from non-secret keys. " +
|
||||
"This is a programming error and should never happen!");
|
||||
}
|
||||
|
||||
ArrayList<Long> result = new ArrayList<Long>();
|
||||
HashSet<Long> result = new HashSet<Long>();
|
||||
// then, mark exactly the keys we have available
|
||||
for (PGPSecretKey sub : new IterableIterator<PGPSecretKey>(
|
||||
((PGPSecretKeyRing) mRing).getSecretKeys())) {
|
||||
@ -168,4 +178,411 @@ public class UncachedKeyRing {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** "Canonicalizes" a key, removing inconsistencies in the process. This operation can be
|
||||
* applied to public keyrings only.
|
||||
*
|
||||
* More specifically:
|
||||
* - Remove all non-verifying self-certificates
|
||||
* - Remove all "future" self-certificates
|
||||
* - Remove all certificates flagged as "local"
|
||||
* - Remove all certificates which are superseded by a newer one on the same target
|
||||
*
|
||||
* After this cleaning, a number of checks are done: TODO implement
|
||||
* - See if each subkey retains a valid self certificate
|
||||
* - See if each user id retains a valid self certificate
|
||||
*
|
||||
* This operation writes an OperationLog which can be used as part of a OperationResultParcel.
|
||||
*
|
||||
* @return A canonicalized key
|
||||
*
|
||||
*/
|
||||
public UncachedKeyRing canonicalize(OperationLog log, int indent) {
|
||||
if (isSecret()) {
|
||||
throw new RuntimeException("Tried to canonicalize non-secret keyring. " +
|
||||
"This is a programming error and should never happen!");
|
||||
}
|
||||
|
||||
log.add(LogLevel.START, LogType.MSG_KC,
|
||||
new String[]{PgpKeyHelper.convertKeyIdToHex(getMasterKeyId())}, indent);
|
||||
indent += 1;
|
||||
|
||||
final Date now = new Date();
|
||||
|
||||
int removedCerts = 0;
|
||||
|
||||
PGPPublicKeyRing ring = (PGPPublicKeyRing) mRing;
|
||||
PGPPublicKey masterKey = mRing.getPublicKey();
|
||||
final long masterKeyId = masterKey.getKeyID();
|
||||
|
||||
{
|
||||
log.add(LogLevel.DEBUG, LogType.MSG_KC_MASTER,
|
||||
new String[]{PgpKeyHelper.convertKeyIdToHex(masterKey.getKeyID())}, indent);
|
||||
indent += 1;
|
||||
|
||||
PGPPublicKey modified = masterKey;
|
||||
PGPSignature revocation = null;
|
||||
for (PGPSignature zert : new IterableIterator<PGPSignature>(masterKey.getSignatures())) {
|
||||
int type = zert.getSignatureType();
|
||||
|
||||
// Disregard certifications on user ids, we will deal with those later
|
||||
if (type == PGPSignature.NO_CERTIFICATION
|
||||
|| type == PGPSignature.DEFAULT_CERTIFICATION
|
||||
|| type == PGPSignature.CASUAL_CERTIFICATION
|
||||
|| type == PGPSignature.POSITIVE_CERTIFICATION
|
||||
|| type == PGPSignature.CERTIFICATION_REVOCATION) {
|
||||
continue;
|
||||
}
|
||||
WrappedSignature cert = new WrappedSignature(zert);
|
||||
|
||||
if (type != PGPSignature.KEY_REVOCATION) {
|
||||
// Unknown type, just remove
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_REVOKE_BAD_TYPE, new String[]{
|
||||
"0x" + Integer.toString(type, 16)
|
||||
}, indent);
|
||||
modified = PGPPublicKey.removeCertification(modified, zert);
|
||||
removedCerts += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cert.getCreationTime().after(now)) {
|
||||
// Creation date in the future? No way!
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_REVOKE_BAD_TIME, null, indent);
|
||||
modified = PGPPublicKey.removeCertification(modified, zert);
|
||||
removedCerts += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cert.isLocal()) {
|
||||
// Creation date in the future? No way!
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_REVOKE_BAD_LOCAL, null, indent);
|
||||
modified = PGPPublicKey.removeCertification(modified, zert);
|
||||
removedCerts += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
cert.init(masterKey);
|
||||
if (!cert.verifySignature(masterKey)) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_REVOKE_BAD, null, indent);
|
||||
modified = PGPPublicKey.removeCertification(modified, zert);
|
||||
removedCerts += 1;
|
||||
continue;
|
||||
}
|
||||
} catch (PgpGeneralException e) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_REVOKE_BAD_ERR, null, indent);
|
||||
modified = PGPPublicKey.removeCertification(modified, zert);
|
||||
removedCerts += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// first revocation? fine then.
|
||||
if (revocation == null) {
|
||||
revocation = zert;
|
||||
// more revocations? at least one is superfluous, then.
|
||||
} else if (revocation.getCreationTime().before(zert.getCreationTime())) {
|
||||
modified = PGPPublicKey.removeCertification(modified, revocation);
|
||||
removedCerts += 1;
|
||||
log.add(LogLevel.INFO, LogType.MSG_KC_REVOKE_DUP, null, indent);
|
||||
revocation = zert;
|
||||
} else {
|
||||
modified = PGPPublicKey.removeCertification(modified, zert);
|
||||
removedCerts += 1;
|
||||
log.add(LogLevel.INFO, LogType.MSG_KC_REVOKE_DUP, null, indent);
|
||||
}
|
||||
}
|
||||
|
||||
for (String userId : new IterableIterator<String>(masterKey.getUserIDs())) {
|
||||
PGPSignature selfCert = null;
|
||||
revocation = null;
|
||||
|
||||
// look through signatures for this specific key
|
||||
for (PGPSignature zert : new IterableIterator<PGPSignature>(
|
||||
masterKey.getSignaturesForID(userId))) {
|
||||
WrappedSignature cert = new WrappedSignature(zert);
|
||||
long certId = cert.getKeyId();
|
||||
|
||||
int type = zert.getSignatureType();
|
||||
if (type != PGPSignature.DEFAULT_CERTIFICATION
|
||||
&& type != PGPSignature.NO_CERTIFICATION
|
||||
&& type != PGPSignature.CASUAL_CERTIFICATION
|
||||
&& type != PGPSignature.POSITIVE_CERTIFICATION
|
||||
&& type != PGPSignature.CERTIFICATION_REVOCATION) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_TYPE,
|
||||
new String[] {
|
||||
"0x" + Integer.toString(zert.getSignatureType(), 16)
|
||||
}, indent);
|
||||
modified = PGPPublicKey.removeCertification(modified, userId, zert);
|
||||
removedCerts += 1;
|
||||
}
|
||||
|
||||
if (cert.getCreationTime().after(now)) {
|
||||
// Creation date in the future? No way!
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_REVOKE_BAD_TIME, null, indent);
|
||||
modified = PGPPublicKey.removeCertification(modified, zert);
|
||||
removedCerts += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cert.isLocal()) {
|
||||
// Creation date in the future? No way!
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_REVOKE_BAD_LOCAL, null, indent);
|
||||
modified = PGPPublicKey.removeCertification(modified, zert);
|
||||
removedCerts += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this is a foreign signature, never mind any further
|
||||
if (certId != masterKeyId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise, first make sure it checks out
|
||||
try {
|
||||
cert.init(masterKey);
|
||||
if (!cert.verifySignature(masterKey, userId)) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD,
|
||||
new String[] { userId }, indent);
|
||||
modified = PGPPublicKey.removeCertification(modified, userId, zert);
|
||||
removedCerts += 1;
|
||||
continue;
|
||||
}
|
||||
} catch (PgpGeneralException e) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_UID_BAD_ERR,
|
||||
new String[] { userId }, indent);
|
||||
modified = PGPPublicKey.removeCertification(modified, userId, zert);
|
||||
removedCerts += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case PGPSignature.DEFAULT_CERTIFICATION:
|
||||
case PGPSignature.NO_CERTIFICATION:
|
||||
case PGPSignature.CASUAL_CERTIFICATION:
|
||||
case PGPSignature.POSITIVE_CERTIFICATION:
|
||||
if (selfCert == null) {
|
||||
selfCert = zert;
|
||||
} else if (selfCert.getCreationTime().before(cert.getCreationTime())) {
|
||||
modified = PGPPublicKey.removeCertification(modified, userId, selfCert);
|
||||
removedCerts += 1;
|
||||
log.add(LogLevel.INFO, LogType.MSG_KC_UID_DUP,
|
||||
new String[] { userId }, indent);
|
||||
selfCert = zert;
|
||||
} else {
|
||||
modified = PGPPublicKey.removeCertification(modified, userId, zert);
|
||||
removedCerts += 1;
|
||||
log.add(LogLevel.INFO, LogType.MSG_KC_UID_DUP,
|
||||
new String[] { userId }, indent);
|
||||
}
|
||||
// If there is a revocation certificate, and it's older than this, drop it
|
||||
if (revocation != null
|
||||
&& revocation.getCreationTime().before(selfCert.getCreationTime())) {
|
||||
modified = PGPPublicKey.removeCertification(modified, userId, revocation);
|
||||
revocation = null;
|
||||
removedCerts += 1;
|
||||
log.add(LogLevel.INFO, LogType.MSG_KC_UID_REVOKE_OLD,
|
||||
new String[] { userId }, indent);
|
||||
}
|
||||
break;
|
||||
|
||||
case PGPSignature.CERTIFICATION_REVOCATION:
|
||||
// If this is older than the (latest) self cert, drop it
|
||||
if (selfCert != null && selfCert.getCreationTime().after(zert.getCreationTime())) {
|
||||
modified = PGPPublicKey.removeCertification(modified, userId, zert);
|
||||
removedCerts += 1;
|
||||
log.add(LogLevel.INFO, LogType.MSG_KC_UID_REVOKE_OLD,
|
||||
new String[] { userId }, indent);
|
||||
continue;
|
||||
}
|
||||
// first revocation? remember it.
|
||||
if (revocation == null) {
|
||||
revocation = zert;
|
||||
// more revocations? at least one is superfluous, then.
|
||||
} else if (revocation.getCreationTime().before(cert.getCreationTime())) {
|
||||
modified = PGPPublicKey.removeCertification(modified, userId, revocation);
|
||||
removedCerts += 1;
|
||||
log.add(LogLevel.INFO, LogType.MSG_KC_UID_REVOKE_DUP,
|
||||
new String[] { userId }, indent);
|
||||
revocation = zert;
|
||||
} else {
|
||||
modified = PGPPublicKey.removeCertification(modified, userId, zert);
|
||||
removedCerts += 1;
|
||||
log.add(LogLevel.INFO, LogType.MSG_KC_UID_REVOKE_DUP,
|
||||
new String[] { userId }, indent);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Replace modified key in the keyring
|
||||
ring = PGPPublicKeyRing.insertPublicKey(ring, modified);
|
||||
|
||||
log.add(LogLevel.DEBUG, LogType.MSG_KC_MASTER_SUCCESS, null, indent);
|
||||
indent -= 1;
|
||||
|
||||
}
|
||||
|
||||
// Process all keys
|
||||
for (PGPPublicKey key : new IterableIterator<PGPPublicKey>(ring.getPublicKeys())) {
|
||||
// Don't care about the master key here, that one gets special treatment above
|
||||
if (key.isMasterKey()) {
|
||||
continue;
|
||||
}
|
||||
log.add(LogLevel.DEBUG, LogType.MSG_KC_SUB,
|
||||
new String[]{PgpKeyHelper.convertKeyIdToHex(key.getKeyID())}, indent);
|
||||
indent += 1;
|
||||
// A subkey needs exactly one subkey binding certificate, and optionally one revocation
|
||||
// certificate.
|
||||
PGPPublicKey modified = key;
|
||||
PGPSignature selfCert = null, revocation = null;
|
||||
uids: for (PGPSignature zig : new IterableIterator<PGPSignature>(key.getSignatures())) {
|
||||
// remove from keyring (for now)
|
||||
modified = PGPPublicKey.removeCertification(modified, zig);
|
||||
// add this too, easier than adding it for every single "continue" case
|
||||
removedCerts += 1;
|
||||
|
||||
WrappedSignature cert = new WrappedSignature(zig);
|
||||
int type = cert.getSignatureType();
|
||||
|
||||
// filter out bad key types...
|
||||
if (cert.getKeyId() != masterKey.getKeyID()) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_SUB_BAD_KEYID, null, indent);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type != PGPSignature.SUBKEY_BINDING && type != PGPSignature.SUBKEY_REVOCATION) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_SUB_BAD_TYPE, new String[]{
|
||||
"0x" + Integer.toString(type, 16)
|
||||
}, indent);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cert.getCreationTime().after(now)) {
|
||||
// Creation date in the future? No way!
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_SUB_BAD_TIME, null, indent);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cert.isLocal()) {
|
||||
// Creation date in the future? No way!
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_SUB_BAD_LOCAL, null, indent);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type == PGPSignature.SUBKEY_BINDING) {
|
||||
|
||||
// make sure the certificate checks out
|
||||
try {
|
||||
cert.init(masterKey);
|
||||
if (!cert.verifySignature(masterKey, key)) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_SUB_BAD, null, indent);
|
||||
continue;
|
||||
}
|
||||
} catch (PgpGeneralException e) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_SUB_BAD_ERR, null, indent);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (zig.getHashedSubPackets().hasSubpacket(SignatureSubpacketTags.KEY_FLAGS)) {
|
||||
int flags = ((KeyFlags) zig.getHashedSubPackets()
|
||||
.getSubpacket(SignatureSubpacketTags.KEY_FLAGS)).getFlags();
|
||||
// If this subkey is allowed to sign data,
|
||||
if ((flags & PGPKeyFlags.CAN_SIGN) == PGPKeyFlags.CAN_SIGN) {
|
||||
try {
|
||||
PGPSignatureList list = zig.getUnhashedSubPackets().getEmbeddedSignatures();
|
||||
boolean ok = false;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
WrappedSignature subsig = new WrappedSignature(list.get(i));
|
||||
if (subsig.getSignatureType() == PGPSignature.PRIMARYKEY_BINDING) {
|
||||
subsig.init(key);
|
||||
if (subsig.verifySignature(masterKey, key)) {
|
||||
ok = true;
|
||||
} else {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_SUB_PRIMARY_BAD, null, indent);
|
||||
continue uids;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ok) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_SUB_PRIMARY_NONE, null, indent);
|
||||
continue;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_SUB_PRIMARY_BAD_ERR, null, indent);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we already have a cert, and this one is not newer: skip it
|
||||
if (selfCert != null && selfCert.getCreationTime().before(cert.getCreationTime())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
selfCert = zig;
|
||||
// if this is newer than a possibly existing revocation, drop that one
|
||||
if (revocation != null && selfCert.getCreationTime().after(revocation.getCreationTime())) {
|
||||
revocation = null;
|
||||
}
|
||||
|
||||
// it must be a revocation, then (we made sure above)
|
||||
} else {
|
||||
|
||||
// make sure the certificate checks out
|
||||
try {
|
||||
cert.init(masterKey);
|
||||
if (!cert.verifySignature(key)) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_SUB_REVOKE_BAD, null, indent);
|
||||
continue;
|
||||
}
|
||||
} catch (PgpGeneralException e) {
|
||||
log.add(LogLevel.WARN, LogType.MSG_KC_SUB_REVOKE_BAD_ERR, null, indent);
|
||||
continue;
|
||||
}
|
||||
|
||||
// if there is no binding (yet), or the revocation is newer than the binding: keep it
|
||||
if (selfCert == null || selfCert.getCreationTime().before(cert.getCreationTime())) {
|
||||
revocation = zig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// it is not properly bound? error!
|
||||
if (selfCert == null) {
|
||||
ring = PGPPublicKeyRing.removePublicKey(ring, modified);
|
||||
|
||||
log.add(LogLevel.ERROR, LogType.MSG_KC_SUB_NO_CERT,
|
||||
new String[]{PgpKeyHelper.convertKeyIdToHex(key.getKeyID())}, indent);
|
||||
indent -= 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// re-add certification
|
||||
modified = PGPPublicKey.addCertification(modified, selfCert);
|
||||
removedCerts -= 1;
|
||||
// add revocation, if any
|
||||
if (revocation != null) {
|
||||
modified = PGPPublicKey.addCertification(modified, revocation);
|
||||
removedCerts -= 1;
|
||||
}
|
||||
// replace pubkey in keyring
|
||||
ring = PGPPublicKeyRing.insertPublicKey(ring, modified);
|
||||
|
||||
log.add(LogLevel.DEBUG, LogType.MSG_KC_SUB_SUCCESS, null, indent);
|
||||
indent -= 1;
|
||||
}
|
||||
|
||||
if (removedCerts > 0) {
|
||||
log.add(LogLevel.OK, LogType.MSG_KC_SUCCESS_REMOVED,
|
||||
new String[] { Integer.toString(removedCerts) }, indent);
|
||||
} else {
|
||||
log.add(LogLevel.OK, LogType.MSG_KC_SUCCESS, null, indent);
|
||||
}
|
||||
|
||||
return new UncachedKeyRing(ring);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package org.sufficientlysecure.keychain.pgp;
|
||||
|
||||
import org.spongycastle.bcpg.SignatureSubpacketTags;
|
||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||
import org.spongycastle.openpgp.PGPException;
|
||||
import org.spongycastle.openpgp.PGPPublicKey;
|
||||
import org.spongycastle.openpgp.PGPSignature;
|
||||
import org.spongycastle.openpgp.PGPSignatureSubpacketVector;
|
||||
@ -9,6 +10,7 @@ import org.spongycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProv
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
|
||||
import java.security.SignatureException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@ -28,8 +30,13 @@ public class UncachedPublicKey {
|
||||
}
|
||||
|
||||
/** The revocation signature is NOT checked here, so this may be false! */
|
||||
public boolean maybeRevoked() {
|
||||
return mPublicKey.isRevoked();
|
||||
public boolean isRevoked() {
|
||||
for (PGPSignature sig : new IterableIterator<PGPSignature>(
|
||||
mPublicKey.getSignaturesOfType(isMasterKey() ? PGPSignature.KEY_REVOCATION
|
||||
: PGPSignature.SUBKEY_REVOCATION))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Date getCreationTime() {
|
||||
@ -193,4 +200,5 @@ public class UncachedPublicKey {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class WrappedSignature {
|
||||
|
||||
final PGPSignature mSig;
|
||||
|
||||
protected WrappedSignature(PGPSignature sig) {
|
||||
WrappedSignature(PGPSignature sig) {
|
||||
mSig = sig;
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ public class WrappedSignature {
|
||||
init(key.getPublicKey());
|
||||
}
|
||||
|
||||
protected void init(PGPPublicKey key) throws PgpGeneralException {
|
||||
void init(PGPPublicKey key) throws PgpGeneralException {
|
||||
try {
|
||||
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider =
|
||||
new JcaPGPContentVerifierBuilderProvider()
|
||||
@ -125,7 +125,27 @@ public class WrappedSignature {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean verifySignature(PGPPublicKey key, String uid) throws PgpGeneralException {
|
||||
boolean verifySignature(PGPPublicKey key) throws PgpGeneralException {
|
||||
try {
|
||||
return mSig.verifyCertification(key);
|
||||
} catch (SignatureException e) {
|
||||
throw new PgpGeneralException("Sign!", e);
|
||||
} catch (PGPException e) {
|
||||
throw new PgpGeneralException("Error!", e);
|
||||
}
|
||||
}
|
||||
|
||||
boolean verifySignature(PGPPublicKey masterKey, PGPPublicKey subKey) throws PgpGeneralException {
|
||||
try {
|
||||
return mSig.verifyCertification(masterKey, subKey);
|
||||
} catch (SignatureException e) {
|
||||
throw new PgpGeneralException("Sign!", e);
|
||||
} catch (PGPException e) {
|
||||
throw new PgpGeneralException("Error!", e);
|
||||
}
|
||||
}
|
||||
|
||||
boolean verifySignature(PGPPublicKey key, String uid) throws PgpGeneralException {
|
||||
try {
|
||||
return mSig.verifyCertification(uid, key);
|
||||
} catch (SignatureException e) {
|
||||
@ -158,4 +178,11 @@ public class WrappedSignature {
|
||||
return new WrappedSignature(signatures.get(0));
|
||||
}
|
||||
|
||||
public boolean isLocal() {
|
||||
if (!mSig.getHashedSubPackets().hasSubpacket(SignatureSubpacketTags.EXPORTABLE)) {
|
||||
return false;
|
||||
}
|
||||
SignatureSubpacket p = mSig.getHashedSubPackets().getSubpacket(SignatureSubpacketTags.EXPORTABLE);
|
||||
return p.getData()[0] == 0;
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,10 @@ import android.support.v4.util.LongSparseArray;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.WrappedPublicKey;
|
||||
import org.sufficientlysecure.keychain.service.OperationResultParcel.LogType;
|
||||
import org.sufficientlysecure.keychain.service.OperationResultParcel.LogLevel;
|
||||
import org.sufficientlysecure.keychain.service.OperationResultParcel.OperationLog;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
@ -45,6 +49,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||
import org.sufficientlysecure.keychain.remote.AccountSettings;
|
||||
import org.sufficientlysecure.keychain.remote.AppSettings;
|
||||
import org.sufficientlysecure.keychain.service.OperationResults.SaveKeyringResult;
|
||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
@ -58,13 +63,43 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/** This class contains high level methods for database access. Despite its
|
||||
* name, it is not only a helper but actually the main interface for all
|
||||
* synchronous database operations.
|
||||
*
|
||||
* Operations in this class write logs (TODO). These can be obtained from the
|
||||
* OperationResultParcel return values directly, but are also accumulated over
|
||||
* the lifetime of the executing ProviderHelper object unless the resetLog()
|
||||
* method is called to start a new one specifically.
|
||||
*
|
||||
*/
|
||||
public class ProviderHelper {
|
||||
private Context mContext;
|
||||
private ContentResolver mContentResolver;
|
||||
private final Context mContext;
|
||||
private final ContentResolver mContentResolver;
|
||||
private OperationLog mLog;
|
||||
private int mIndent;
|
||||
|
||||
public ProviderHelper(Context context) {
|
||||
this.mContext = context;
|
||||
this.mContentResolver = context.getContentResolver();
|
||||
this(context, new OperationLog(), 0);
|
||||
}
|
||||
|
||||
public ProviderHelper(Context context, OperationLog log, int indent) {
|
||||
mContext = context;
|
||||
mContentResolver = context.getContentResolver();
|
||||
mLog = log;
|
||||
mIndent = indent;
|
||||
}
|
||||
|
||||
public void resetLog() {
|
||||
if(mLog != null) {
|
||||
// Start a new log (leaving the old one intact)
|
||||
mLog = new OperationLog();
|
||||
mIndent = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public OperationLog getLog() {
|
||||
return mLog;
|
||||
}
|
||||
|
||||
public static class NotFoundException extends Exception {
|
||||
@ -76,6 +111,17 @@ public class ProviderHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void log(LogLevel level, LogType type) {
|
||||
if(mLog != null) {
|
||||
mLog.add(level, type, null, mIndent);
|
||||
}
|
||||
}
|
||||
public void log(LogLevel level, LogType type, String[] parameters) {
|
||||
if(mLog != null) {
|
||||
mLog.add(level, type, parameters, mIndent);
|
||||
}
|
||||
}
|
||||
|
||||
// If we ever switch to api level 11, we can ditch this whole mess!
|
||||
public static final int FIELD_TYPE_NULL = 1;
|
||||
// this is called integer to stay coherent with the constants in Cursor (api level 11)
|
||||
@ -126,36 +172,31 @@ public class ProviderHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public Object getUnifiedData(long masterKeyId, String column, int type)
|
||||
throws NotFoundException {
|
||||
return getUnifiedData(masterKeyId, new String[]{column}, new int[]{type}).get(column);
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getUnifiedData(long masterKeyId, String[] proj, int[] types)
|
||||
throws NotFoundException {
|
||||
return getGenericData(KeyRings.buildUnifiedKeyRingUri(masterKeyId), proj, types);
|
||||
}
|
||||
|
||||
private LongSparseArray<UncachedPublicKey> getUncachedMasterKeys(Uri queryUri) {
|
||||
Cursor cursor = mContentResolver.query(queryUri,
|
||||
new String[]{KeyRingData.MASTER_KEY_ID, KeyRingData.KEY_RING_DATA},
|
||||
null, null, null);
|
||||
private LongSparseArray<WrappedPublicKey> getTrustedMasterKeys() {
|
||||
Cursor cursor = mContentResolver.query(KeyRings.buildUnifiedKeyRingsUri(), new String[] {
|
||||
KeyRings.MASTER_KEY_ID,
|
||||
// we pick from cache only information that is not easily available from keyrings
|
||||
KeyRings.HAS_ANY_SECRET, KeyRings.VERIFIED,
|
||||
// and of course, ring data
|
||||
KeyRings.PUBKEY_DATA
|
||||
}, KeyRings.HAS_ANY_SECRET + " = 1", null, null);
|
||||
|
||||
LongSparseArray<UncachedPublicKey> result =
|
||||
new LongSparseArray<UncachedPublicKey>(cursor.getCount());
|
||||
LongSparseArray<WrappedPublicKey> result =
|
||||
new LongSparseArray<WrappedPublicKey>(cursor.getCount());
|
||||
try {
|
||||
if (cursor != null && cursor.moveToFirst()) do {
|
||||
long masterKeyId = cursor.getLong(0);
|
||||
byte[] data = cursor.getBlob(1);
|
||||
if (data != null) {
|
||||
try {
|
||||
result.put(masterKeyId,
|
||||
UncachedKeyRing.decodeFromData(data).getPublicKey());
|
||||
} catch(PgpGeneralException e) {
|
||||
Log.e(Constants.TAG, "Error parsing keyring, skipping " + masterKeyId, e);
|
||||
} catch(IOException e) {
|
||||
Log.e(Constants.TAG, "IO error, skipping keyring" + masterKeyId, e);
|
||||
}
|
||||
boolean hasAnySecret = cursor.getInt(1) > 0;
|
||||
int verified = cursor.getInt(2);
|
||||
byte[] blob = cursor.getBlob(3);
|
||||
if (blob != null) {
|
||||
result.put(masterKeyId,
|
||||
new WrappedPublicKeyRing(blob, hasAnySecret, verified).getSubkey());
|
||||
}
|
||||
} while (cursor.moveToNext());
|
||||
} finally {
|
||||
@ -206,7 +247,7 @@ public class ProviderHelper {
|
||||
throw new NotFoundException("Secret key not available!");
|
||||
}
|
||||
return secret
|
||||
? new WrappedSecretKeyRing(blob, hasAnySecret, verified)
|
||||
? new WrappedSecretKeyRing(blob, true, verified)
|
||||
: new WrappedPublicKeyRing(blob, hasAnySecret, verified);
|
||||
} else {
|
||||
throw new NotFoundException("Key not found!");
|
||||
@ -222,134 +263,269 @@ public class ProviderHelper {
|
||||
* Saves PGPPublicKeyRing with its keys and userIds in DB
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void savePublicKeyRing(UncachedKeyRing keyRing) throws IOException {
|
||||
public SaveKeyringResult savePublicKeyRing(UncachedKeyRing keyRing) {
|
||||
if (keyRing.isSecret()) {
|
||||
throw new RuntimeException("Tried to save secret keyring as public! " +
|
||||
"This is a bug, please file a bug report.");
|
||||
log(LogLevel.ERROR, LogType.MSG_IP_BAD_TYPE_SECRET);
|
||||
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog);
|
||||
}
|
||||
|
||||
// start with ok result
|
||||
int result = SaveKeyringResult.SAVED_PUBLIC;
|
||||
|
||||
long masterKeyId = keyRing.getMasterKeyId();
|
||||
log(LogLevel.START, LogType.MSG_IP,
|
||||
new String[]{ PgpKeyHelper.convertKeyIdToHex(masterKeyId) });
|
||||
mIndent += 1;
|
||||
|
||||
// Canonicalize this key, to assert a number of assumptions made about it.
|
||||
keyRing = keyRing.canonicalize(mLog, mIndent);
|
||||
|
||||
UncachedPublicKey masterKey = keyRing.getPublicKey();
|
||||
long masterKeyId = masterKey.getKeyId();
|
||||
|
||||
// IF there is a secret key, preserve it!
|
||||
UncachedKeyRing secretRing = null;
|
||||
UncachedKeyRing secretRing;
|
||||
try {
|
||||
secretRing = getWrappedSecretKeyRing(masterKeyId).getUncached();
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_PRESERVING_SECRET);
|
||||
} catch (NotFoundException e) {
|
||||
Log.e(Constants.TAG, "key not found!");
|
||||
secretRing = null;
|
||||
}
|
||||
|
||||
// delete old version of this keyRing, which also deletes all keys and userIds on cascade
|
||||
ArrayList<ContentProviderOperation> operations;
|
||||
try {
|
||||
mContentResolver.delete(KeyRingData.buildPublicKeyRingUri(Long.toString(masterKeyId)), null, null);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
Log.e(Constants.TAG, "Key could not be deleted! Maybe we are creating a new one!", e);
|
||||
}
|
||||
|
||||
// insert new version of this keyRing
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KeyRingData.MASTER_KEY_ID, masterKeyId);
|
||||
values.put(KeyRingData.KEY_RING_DATA, keyRing.getEncoded());
|
||||
Uri uri = KeyRingData.buildPublicKeyRingUri(Long.toString(masterKeyId));
|
||||
mContentResolver.insert(uri, values);
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_PREPARE);
|
||||
mIndent += 1;
|
||||
|
||||
// save all keys and userIds included in keyRing object in database
|
||||
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
|
||||
// save all keys and userIds included in keyRing object in database
|
||||
operations = new ArrayList<ContentProviderOperation>();
|
||||
|
||||
int rank = 0;
|
||||
for (UncachedPublicKey key : new IterableIterator<UncachedPublicKey>(keyRing.getPublicKeys())) {
|
||||
operations.add(buildPublicKeyOperations(masterKeyId, key, rank));
|
||||
++rank;
|
||||
}
|
||||
|
||||
// get a list of owned secret keys, for verification filtering
|
||||
LongSparseArray<UncachedPublicKey> allKeyRings =
|
||||
getUncachedMasterKeys(KeyRingData.buildSecretKeyRingUri());
|
||||
// special case: available secret keys verify themselves!
|
||||
if (secretRing != null) {
|
||||
allKeyRings.put(secretRing.getMasterKeyId(), secretRing.getPublicKey());
|
||||
}
|
||||
|
||||
// classify and order user ids. primary are moved to the front, revoked to the back,
|
||||
// otherwise the order in the keyfile is preserved.
|
||||
List<UserIdItem> uids = new ArrayList<UserIdItem>();
|
||||
|
||||
for (String userId : new IterableIterator<String>(
|
||||
masterKey.getUnorderedUserIds().iterator())) {
|
||||
UserIdItem item = new UserIdItem();
|
||||
uids.add(item);
|
||||
item.userId = userId;
|
||||
|
||||
// look through signatures for this specific key
|
||||
for (WrappedSignature cert : new IterableIterator<WrappedSignature>(
|
||||
masterKey.getSignaturesForId(userId))) {
|
||||
long certId = cert.getKeyId();
|
||||
log(LogLevel.INFO, LogType.MSG_IP_INSERT_KEYRING);
|
||||
{ // insert keyring
|
||||
// insert new version of this keyRing
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KeyRingData.MASTER_KEY_ID, masterKeyId);
|
||||
try {
|
||||
// self signature
|
||||
if (certId == masterKeyId) {
|
||||
cert.init(masterKey);
|
||||
if (!cert.verifySignature(masterKey, userId)) {
|
||||
// not verified?! dang! TODO notify user? this is kinda serious...
|
||||
Log.e(Constants.TAG, "Could not verify self signature for " + userId + "!");
|
||||
continue;
|
||||
values.put(KeyRingData.KEY_RING_DATA, keyRing.getEncoded());
|
||||
} catch (IOException e) {
|
||||
log(LogLevel.ERROR, LogType.MSG_IP_ENCODE_FAIL);
|
||||
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog);
|
||||
}
|
||||
|
||||
Uri uri = KeyRingData.buildPublicKeyRingUri(Long.toString(masterKeyId));
|
||||
operations.add(ContentProviderOperation.newInsert(uri).withValues(values).build());
|
||||
}
|
||||
|
||||
log(LogLevel.INFO, LogType.MSG_IP_INSERT_SUBKEYS);
|
||||
mIndent += 1;
|
||||
{ // insert subkeys
|
||||
Uri uri = Keys.buildKeysUri(Long.toString(masterKeyId));
|
||||
int rank = 0;
|
||||
for (UncachedPublicKey key : new IterableIterator<UncachedPublicKey>(keyRing.getPublicKeys())) {
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_SUBKEY, new String[]{
|
||||
PgpKeyHelper.convertKeyIdToHex(key.getKeyId())
|
||||
});
|
||||
mIndent += 1;
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Keys.MASTER_KEY_ID, masterKeyId);
|
||||
values.put(Keys.RANK, rank);
|
||||
|
||||
values.put(Keys.KEY_ID, key.getKeyId());
|
||||
values.put(Keys.KEY_SIZE, key.getBitStrength());
|
||||
values.put(Keys.ALGORITHM, key.getAlgorithm());
|
||||
values.put(Keys.FINGERPRINT, key.getFingerprint());
|
||||
|
||||
boolean c = key.canCertify(), e = key.canEncrypt(), s = key.canSign();
|
||||
values.put(Keys.CAN_CERTIFY, c);
|
||||
values.put(Keys.CAN_ENCRYPT, e);
|
||||
values.put(Keys.CAN_SIGN, s);
|
||||
values.put(Keys.IS_REVOKED, key.isRevoked());
|
||||
if (c) {
|
||||
if (e) {
|
||||
log(LogLevel.DEBUG, s ? LogType.MSG_IP_SUBKEY_FLAGS_CES
|
||||
: LogType.MSG_IP_SUBKEY_FLAGS_CEX, null);
|
||||
} else {
|
||||
log(LogLevel.DEBUG, s ? LogType.MSG_IP_SUBKEY_FLAGS_CXS
|
||||
: LogType.MSG_IP_SUBKEY_FLAGS_CXX, null);
|
||||
}
|
||||
// is this the first, or a more recent certificate?
|
||||
if (item.selfCert == null ||
|
||||
item.selfCert.getCreationTime().before(cert.getCreationTime())) {
|
||||
item.selfCert = cert;
|
||||
item.isPrimary = cert.isPrimaryUserId();
|
||||
item.isRevoked = cert.isRevocation();
|
||||
} else {
|
||||
if (e) {
|
||||
log(LogLevel.DEBUG, s ? LogType.MSG_IP_SUBKEY_FLAGS_XES
|
||||
: LogType.MSG_IP_SUBKEY_FLAGS_XEX, null);
|
||||
} else {
|
||||
log(LogLevel.DEBUG, s ? LogType.MSG_IP_SUBKEY_FLAGS_XXS
|
||||
: LogType.MSG_IP_SUBKEY_FLAGS_XXX, null);
|
||||
}
|
||||
}
|
||||
// verify signatures from known private keys
|
||||
if (allKeyRings.indexOfKey(certId) >= 0) {
|
||||
cert.init(allKeyRings.get(certId));
|
||||
if (cert.verifySignature(masterKey, userId)) {
|
||||
item.trustedCerts.add(cert);
|
||||
|
||||
Date creation = key.getCreationTime();
|
||||
values.put(Keys.CREATION, creation.getTime() / 1000);
|
||||
Date expiryDate = key.getExpiryTime();
|
||||
if (expiryDate != null) {
|
||||
values.put(Keys.EXPIRY, expiryDate.getTime() / 1000);
|
||||
if (key.isExpired()) {
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_SUBKEY_EXPIRED, new String[]{
|
||||
expiryDate.toString()
|
||||
});
|
||||
} else {
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_SUBKEY_EXPIRES, new String[]{
|
||||
expiryDate.toString()
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (PgpGeneralException e) {
|
||||
Log.e(Constants.TAG, "Signature verification failed! "
|
||||
+ PgpKeyHelper.convertKeyIdToHex(masterKey.getKeyId())
|
||||
+ " from "
|
||||
+ PgpKeyHelper.convertKeyIdToHex(cert.getKeyId()), e);
|
||||
|
||||
operations.add(ContentProviderOperation.newInsert(uri).withValues(values).build());
|
||||
++rank;
|
||||
mIndent -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
mIndent -= 1;
|
||||
|
||||
// get a list of owned secret keys, for verification filtering
|
||||
LongSparseArray<WrappedPublicKey> trustedKeys = getTrustedMasterKeys();
|
||||
|
||||
// classify and order user ids. primary are moved to the front, revoked to the back,
|
||||
// otherwise the order in the keyfile is preserved.
|
||||
log(LogLevel.INFO, LogType.MSG_IP_UID_CLASSIFYING, new String[]{
|
||||
Integer.toString(trustedKeys.size())
|
||||
});
|
||||
mIndent += 1;
|
||||
List<UserIdItem> uids = new ArrayList<UserIdItem>();
|
||||
for (String userId : new IterableIterator<String>(
|
||||
masterKey.getUnorderedUserIds().iterator())) {
|
||||
UserIdItem item = new UserIdItem();
|
||||
uids.add(item);
|
||||
item.userId = userId;
|
||||
|
||||
int unknownCerts = 0;
|
||||
|
||||
log(LogLevel.INFO, LogType.MSG_IP_UID_PROCESSING, new String[]{ userId });
|
||||
mIndent += 1;
|
||||
// look through signatures for this specific key
|
||||
for (WrappedSignature cert : new IterableIterator<WrappedSignature>(
|
||||
masterKey.getSignaturesForId(userId))) {
|
||||
long certId = cert.getKeyId();
|
||||
try {
|
||||
// self signature
|
||||
if (certId == masterKeyId) {
|
||||
|
||||
// NOTE self-certificates are already verified during canonicalization,
|
||||
// AND we know there is at most one cert plus at most one revocation
|
||||
if (!cert.isRevocation()) {
|
||||
item.selfCert = cert;
|
||||
item.isPrimary = cert.isPrimaryUserId();
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_UID_SELF_GOOD);
|
||||
} else {
|
||||
item.isRevoked = true;
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_UID_REVOKED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// verify signatures from known private keys
|
||||
if (trustedKeys.indexOfKey(certId) >= 0) {
|
||||
WrappedPublicKey trustedKey = trustedKeys.get(certId);
|
||||
cert.init(trustedKey);
|
||||
if (cert.verifySignature(masterKey, userId)) {
|
||||
item.trustedCerts.add(cert);
|
||||
log(LogLevel.INFO, LogType.MSG_IP_UID_CERT_GOOD, new String[] {
|
||||
PgpKeyHelper.convertKeyIdToHexShort(trustedKey.getKeyId()),
|
||||
trustedKey.getPrimaryUserId()
|
||||
});
|
||||
} else {
|
||||
log(LogLevel.WARN, LogType.MSG_IP_UID_CERT_BAD);
|
||||
}
|
||||
}
|
||||
|
||||
unknownCerts += 1;
|
||||
|
||||
} catch (PgpGeneralException e) {
|
||||
log(LogLevel.WARN, LogType.MSG_IP_UID_CERT_ERROR, new String[]{
|
||||
PgpKeyHelper.convertKeyIdToHex(cert.getKeyId())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (unknownCerts > 0) {
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_UID_CERTS_UNKNOWN, new String[]{
|
||||
Integer.toString(unknownCerts)
|
||||
});
|
||||
}
|
||||
mIndent -= 1;
|
||||
|
||||
// primary before regular before revoked (see UserIdItem.compareTo)
|
||||
// this is a stable sort, so the order of keys is otherwise preserved.
|
||||
Collections.sort(uids);
|
||||
// iterate and put into db
|
||||
for (int userIdRank = 0; userIdRank < uids.size(); userIdRank++) {
|
||||
UserIdItem item = uids.get(userIdRank);
|
||||
operations.add(buildUserIdOperations(masterKeyId, item, userIdRank));
|
||||
// no self cert is bad, but allowed by the rfc...
|
||||
if (item.selfCert != null) {
|
||||
operations.add(buildCertOperations(
|
||||
masterKeyId, userIdRank, item.selfCert, Certs.VERIFIED_SELF));
|
||||
}
|
||||
// don't bother with trusted certs if the uid is revoked, anyways
|
||||
if (item.isRevoked) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < item.trustedCerts.size(); i++) {
|
||||
operations.add(buildCertOperations(
|
||||
masterKeyId, userIdRank, item.trustedCerts.get(i), Certs.VERIFIED_SECRET));
|
||||
mIndent -= 1;
|
||||
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_UID_REORDER);
|
||||
// primary before regular before revoked (see UserIdItem.compareTo)
|
||||
// this is a stable sort, so the order of keys is otherwise preserved.
|
||||
Collections.sort(uids);
|
||||
// iterate and put into db
|
||||
for (int userIdRank = 0; userIdRank < uids.size(); userIdRank++) {
|
||||
UserIdItem item = uids.get(userIdRank);
|
||||
operations.add(buildUserIdOperations(masterKeyId, item, userIdRank));
|
||||
if (item.selfCert != null) {
|
||||
operations.add(buildCertOperations(masterKeyId, userIdRank, item.selfCert,
|
||||
secretRing != null ? Certs.VERIFIED_SECRET : Certs.VERIFIED_SELF));
|
||||
}
|
||||
// don't bother with trusted certs if the uid is revoked, anyways
|
||||
if (item.isRevoked) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < item.trustedCerts.size(); i++) {
|
||||
operations.add(buildCertOperations(
|
||||
masterKeyId, userIdRank, item.trustedCerts.get(i), Certs.VERIFIED_SECRET));
|
||||
}
|
||||
}
|
||||
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_PREPARE_SUCCESS);
|
||||
mIndent -= 1;
|
||||
|
||||
} catch (IOException e) {
|
||||
log(LogLevel.ERROR, LogType.MSG_IP_FAIL_IO_EXC);
|
||||
Log.e(Constants.TAG, "IOException during import", e);
|
||||
mIndent -= 1;
|
||||
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog);
|
||||
}
|
||||
|
||||
try {
|
||||
mContentResolver.applyBatch(KeychainContract.CONTENT_AUTHORITY, operations);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(Constants.TAG, "applyBatch failed!", e);
|
||||
} catch (OperationApplicationException e) {
|
||||
Log.e(Constants.TAG, "applyBatch failed!", e);
|
||||
}
|
||||
// delete old version of this keyRing, which also deletes all keys and userIds on cascade
|
||||
int deleted = mContentResolver.delete(
|
||||
KeyRingData.buildPublicKeyRingUri(Long.toString(masterKeyId)), null, null);
|
||||
if (deleted > 0) {
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_DELETE_OLD_OK);
|
||||
result |= SaveKeyringResult.UPDATED;
|
||||
} else {
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_DELETE_OLD_FAIL);
|
||||
}
|
||||
|
||||
// Save the saved keyring (if any)
|
||||
if (secretRing != null) {
|
||||
saveSecretKeyRing(secretRing);
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_APPLY_BATCH);
|
||||
mContentResolver.applyBatch(KeychainContract.CONTENT_AUTHORITY, operations);
|
||||
|
||||
// Save the saved keyring (if any)
|
||||
if (secretRing != null) {
|
||||
log(LogLevel.DEBUG, LogType.MSG_IP_REINSERT_SECRET);
|
||||
mIndent += 1;
|
||||
saveSecretKeyRing(secretRing);
|
||||
result |= SaveKeyringResult.SAVED_SECRET;
|
||||
mIndent -= 1;
|
||||
}
|
||||
|
||||
mIndent -= 1;
|
||||
log(LogLevel.OK, LogType.MSG_IP_SUCCESS);
|
||||
return new SaveKeyringResult(result, mLog);
|
||||
|
||||
} catch (RemoteException e) {
|
||||
log(LogLevel.ERROR, LogType.MSG_IP_FAIL_REMOTE_EX);
|
||||
Log.e(Constants.TAG, "RemoteException during import", e);
|
||||
mIndent -= 1;
|
||||
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog);
|
||||
} catch (OperationApplicationException e) {
|
||||
log(LogLevel.ERROR, LogType.MSG_IP_FAIL_OP_EX);
|
||||
Log.e(Constants.TAG, "OperationApplicationException during import", e);
|
||||
mIndent -= 1;
|
||||
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog);
|
||||
}
|
||||
|
||||
}
|
||||
@ -378,14 +554,37 @@ public class ProviderHelper {
|
||||
/**
|
||||
* Saves a PGPSecretKeyRing in the DB. This will only work if a corresponding public keyring
|
||||
* is already in the database!
|
||||
*
|
||||
* TODO allow adding secret keys where no public key exists (ie, consolidate keys)
|
||||
*/
|
||||
public void saveSecretKeyRing(UncachedKeyRing keyRing) throws IOException {
|
||||
public SaveKeyringResult saveSecretKeyRing(UncachedKeyRing keyRing) {
|
||||
|
||||
if (!keyRing.isSecret()) {
|
||||
throw new RuntimeException("Tried to save publkc keyring as secret! " +
|
||||
"This is a bug, please file a bug report.");
|
||||
log(LogLevel.ERROR, LogType.MSG_IS_BAD_TYPE_PUBLIC);
|
||||
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog);
|
||||
}
|
||||
|
||||
long masterKeyId = keyRing.getMasterKeyId();
|
||||
log(LogLevel.START, LogType.MSG_IS,
|
||||
new String[]{ PgpKeyHelper.convertKeyIdToHex(masterKeyId) });
|
||||
mIndent += 1;
|
||||
|
||||
// IF this is successful, it's a secret key
|
||||
int result = SaveKeyringResult.SAVED_SECRET;
|
||||
|
||||
// save secret keyring
|
||||
try {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KeyRingData.MASTER_KEY_ID, masterKeyId);
|
||||
values.put(KeyRingData.KEY_RING_DATA, keyRing.getEncoded());
|
||||
// insert new version of this keyRing
|
||||
Uri uri = KeyRingData.buildSecretKeyRingUri(Long.toString(masterKeyId));
|
||||
mContentResolver.insert(uri, values);
|
||||
} catch (IOException e) {
|
||||
Log.e(Constants.TAG, "Failed to encode key!", e);
|
||||
log(LogLevel.ERROR, LogType.MSG_IS_IO_EXCPTION);
|
||||
return new SaveKeyringResult(SaveKeyringResult.RESULT_ERROR, mLog);
|
||||
}
|
||||
|
||||
{
|
||||
Uri uri = Keys.buildKeysUri(Long.toString(masterKeyId));
|
||||
@ -397,24 +596,38 @@ public class ProviderHelper {
|
||||
|
||||
values.put(Keys.HAS_SECRET, 1);
|
||||
// then, mark exactly the keys we have available
|
||||
for (Long sub : new IterableIterator<Long>(keyRing.getAvailableSubkeys().iterator())) {
|
||||
mContentResolver.update(uri, values, Keys.KEY_ID + " = ?", new String[] {
|
||||
Long.toString(sub)
|
||||
});
|
||||
log(LogLevel.INFO, LogType.MSG_IS_IMPORTING_SUBKEYS);
|
||||
mIndent += 1;
|
||||
Set<Long> available = keyRing.getAvailableSubkeys();
|
||||
for (UncachedPublicKey sub :
|
||||
new IterableIterator<UncachedPublicKey>(keyRing.getPublicKeys())) {
|
||||
long id = sub.getKeyId();
|
||||
if(available.contains(id)) {
|
||||
int upd = mContentResolver.update(uri, values, Keys.KEY_ID + " = ?",
|
||||
new String[] { Long.toString(id) });
|
||||
if (upd == 1) {
|
||||
log(LogLevel.DEBUG, LogType.MSG_IS_SUBKEY_OK, new String[]{
|
||||
PgpKeyHelper.convertKeyIdToHex(id)
|
||||
});
|
||||
} else {
|
||||
log(LogLevel.WARN, LogType.MSG_IS_SUBKEY_NONEXISTENT, new String[]{
|
||||
PgpKeyHelper.convertKeyIdToHex(id)
|
||||
});
|
||||
}
|
||||
} else {
|
||||
log(LogLevel.INFO, LogType.MSG_IS_SUBKEY_STRIPPED, new String[]{
|
||||
PgpKeyHelper.convertKeyIdToHex(id)
|
||||
});
|
||||
}
|
||||
}
|
||||
mIndent -= 1;
|
||||
|
||||
// this implicitly leaves all keys which were not in the secret key ring
|
||||
// with has_secret = 0
|
||||
}
|
||||
|
||||
// save secret keyring
|
||||
{
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(KeyRingData.MASTER_KEY_ID, masterKeyId);
|
||||
values.put(KeyRingData.KEY_RING_DATA, keyRing.getEncoded());
|
||||
// insert new version of this keyRing
|
||||
Uri uri = KeyRingData.buildSecretKeyRingUri(Long.toString(masterKeyId));
|
||||
mContentResolver.insert(uri, values);
|
||||
}
|
||||
log(LogLevel.OK, LogType.MSG_IS_SUCCESS);
|
||||
return new SaveKeyringResult(result, mLog);
|
||||
|
||||
}
|
||||
|
||||
@ -432,37 +645,6 @@ public class ProviderHelper {
|
||||
saveSecretKeyRing(secRing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing
|
||||
*/
|
||||
private ContentProviderOperation
|
||||
buildPublicKeyOperations(long masterKeyId, UncachedPublicKey key, int rank) throws IOException {
|
||||
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Keys.MASTER_KEY_ID, masterKeyId);
|
||||
values.put(Keys.RANK, rank);
|
||||
|
||||
values.put(Keys.KEY_ID, key.getKeyId());
|
||||
values.put(Keys.KEY_SIZE, key.getBitStrength());
|
||||
values.put(Keys.ALGORITHM, key.getAlgorithm());
|
||||
values.put(Keys.FINGERPRINT, key.getFingerprint());
|
||||
|
||||
values.put(Keys.CAN_CERTIFY, key.canCertify());
|
||||
values.put(Keys.CAN_SIGN, key.canSign());
|
||||
values.put(Keys.CAN_ENCRYPT, key.canEncrypt());
|
||||
values.put(Keys.IS_REVOKED, key.maybeRevoked());
|
||||
|
||||
values.put(Keys.CREATION, key.getCreationTime().getTime() / 1000);
|
||||
Date expiryDate = key.getExpiryTime();
|
||||
if (expiryDate != null) {
|
||||
values.put(Keys.EXPIRY, expiryDate.getTime() / 1000);
|
||||
}
|
||||
|
||||
Uri uri = Keys.buildKeysUri(Long.toString(masterKeyId));
|
||||
|
||||
return ContentProviderOperation.newInsert(uri).withValues(values).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing
|
||||
*/
|
||||
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.service;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.app.Service;
|
||||
import android.content.AbstractThreadedSyncAdapter;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.Intent;
|
||||
import android.content.SyncResult;
|
||||
import android.os.*;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.KeychainApplication;
|
||||
import org.sufficientlysecure.keychain.helper.ContactHelper;
|
||||
import org.sufficientlysecure.keychain.helper.EmailKeyHelper;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
public class ContactSyncAdapterService extends Service {
|
||||
|
||||
private class ContactSyncAdapter extends AbstractThreadedSyncAdapter {
|
||||
|
||||
public ContactSyncAdapter() {
|
||||
super(ContactSyncAdapterService.this, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
|
||||
final SyncResult syncResult) {
|
||||
EmailKeyHelper.importContacts(getContext(), new Messenger(new Handler(Looper.getMainLooper(),
|
||||
new Handler.Callback() {
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
Bundle data = msg.getData();
|
||||
switch (msg.arg1) {
|
||||
case KeychainIntentServiceHandler.MESSAGE_OKAY:
|
||||
return true;
|
||||
case KeychainIntentServiceHandler.MESSAGE_UPDATE_PROGRESS:
|
||||
if (data.containsKey(KeychainIntentServiceHandler.DATA_PROGRESS) &&
|
||||
data.containsKey(KeychainIntentServiceHandler.DATA_PROGRESS_MAX)) {
|
||||
Log.d(Constants.TAG, "Progress: " +
|
||||
data.getInt(KeychainIntentServiceHandler.DATA_PROGRESS) + "/" +
|
||||
data.getInt(KeychainIntentServiceHandler.DATA_PROGRESS_MAX));
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
Log.d(Constants.TAG, "Syncing... " + msg.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})));
|
||||
KeychainApplication.setupAccountAsNeeded(ContactSyncAdapterService.this);
|
||||
ContactHelper.writeKeysToContacts(ContactSyncAdapterService.this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return new ContactSyncAdapter().getSyncAdapterBinder();
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.service;
|
||||
|
||||
import android.accounts.AbstractAccountAuthenticator;
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountAuthenticatorResponse;
|
||||
import android.accounts.NetworkErrorException;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.widget.Toast;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
/**
|
||||
* This service actually does nothing, it's sole task is to show a Toast if the use tries to create an account.
|
||||
*/
|
||||
public class DummyAccountService extends Service {
|
||||
|
||||
private class Toaster {
|
||||
private static final String TOAST_MESSAGE = "toast_message";
|
||||
private Context context;
|
||||
private Handler handler = new Handler(new Handler.Callback() {
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
Toast.makeText(context, msg.getData().getString(TOAST_MESSAGE), Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
private Toaster(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void toast(int resourceId) {
|
||||
toast(context.getString(resourceId));
|
||||
}
|
||||
|
||||
public void toast(String message) {
|
||||
Message msg = new Message();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(TOAST_MESSAGE, message);
|
||||
msg.setData(bundle);
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private class Authenticator extends AbstractAccountAuthenticator {
|
||||
|
||||
public Authenticator() {
|
||||
super(DummyAccountService.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
|
||||
Log.d(Constants.TAG, "DummyAccountService.editProperties");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
|
||||
String[] requiredFeatures, Bundle options) throws NetworkErrorException {
|
||||
response.onResult(new Bundle());
|
||||
toaster.toast(R.string.info_no_manual_account_creation);
|
||||
Log.d(Constants.TAG, "DummyAccountService.addAccount");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)
|
||||
throws NetworkErrorException {
|
||||
Log.d(Constants.TAG, "DummyAccountService.confirmCredentials");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType,
|
||||
Bundle options) throws NetworkErrorException {
|
||||
Log.d(Constants.TAG, "DummyAccountService.getAuthToken");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthTokenLabel(String authTokenType) {
|
||||
Log.d(Constants.TAG, "DummyAccountService.getAuthTokenLabel");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType,
|
||||
Bundle options) throws NetworkErrorException {
|
||||
Log.d(Constants.TAG, "DummyAccountService.updateCredentials");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features)
|
||||
throws NetworkErrorException {
|
||||
Log.d(Constants.TAG, "DummyAccountService.hasFeatures");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Toaster toaster;
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
toaster = new Toaster(this);
|
||||
return new Authenticator().getIBinder();
|
||||
}
|
||||
}
|
@ -32,6 +32,7 @@ import org.sufficientlysecure.keychain.helper.FileHelper;
|
||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
||||
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
||||
import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||
import org.sufficientlysecure.keychain.keyimport.KeybaseKeyserver;
|
||||
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
@ -174,14 +175,11 @@ public class KeychainIntentService extends IntentService
|
||||
public static final String RESULT_DECRYPTED_BYTES = "decrypted_data";
|
||||
public static final String RESULT_DECRYPT_VERIFY_RESULT = "signature";
|
||||
|
||||
// import
|
||||
public static final String RESULT_IMPORT_ADDED = "added";
|
||||
public static final String RESULT_IMPORT_UPDATED = "updated";
|
||||
public static final String RESULT_IMPORT_BAD = "bad";
|
||||
|
||||
// export
|
||||
public static final String RESULT_EXPORT = "exported";
|
||||
|
||||
public static final String RESULT = "result";
|
||||
|
||||
Messenger mMessenger;
|
||||
|
||||
private boolean mIsCanceled;
|
||||
@ -648,7 +646,10 @@ public class KeychainIntentService extends IntentService
|
||||
List<ParcelableKeyRing> entries = data.getParcelableArrayList(IMPORT_KEY_LIST);
|
||||
|
||||
PgpImportExport pgpImportExport = new PgpImportExport(this, this);
|
||||
Bundle resultData = pgpImportExport.importKeyRings(entries);
|
||||
OperationResults.ImportResult result = pgpImportExport.importKeyRings(entries);
|
||||
|
||||
Bundle resultData = new Bundle();
|
||||
resultData.putParcelable(RESULT, result);
|
||||
|
||||
sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY, resultData);
|
||||
} catch (Exception e) {
|
||||
@ -734,49 +735,30 @@ public class KeychainIntentService extends IntentService
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
} else if (ACTION_IMPORT_KEYBASE_KEYS.equals(action)) {
|
||||
ArrayList<ImportKeysListEntry> entries = data.getParcelableArrayList(DOWNLOAD_KEY_LIST);
|
||||
|
||||
try {
|
||||
KeybaseKeyserver server = new KeybaseKeyserver();
|
||||
ArrayList<ParcelableKeyRing> keyRings = new ArrayList<ParcelableKeyRing>(entries.size());
|
||||
for (ImportKeysListEntry entry : entries) {
|
||||
// the keybase handle is in userId(1)
|
||||
String keybaseId = entry.getExtraData();
|
||||
byte[] downloadedKeyBytes = server.get(keybaseId).getBytes();
|
||||
|
||||
// save key bytes in entry object for doing the
|
||||
// actual import afterwards
|
||||
keyRings.add(new ParcelableKeyRing(downloadedKeyBytes));
|
||||
}
|
||||
|
||||
Intent importIntent = new Intent(this, KeychainIntentService.class);
|
||||
importIntent.setAction(ACTION_IMPORT_KEYRING);
|
||||
Bundle importData = new Bundle();
|
||||
importData.putParcelableArrayList(IMPORT_KEY_LIST, keyRings);
|
||||
importIntent.putExtra(EXTRA_DATA, importData);
|
||||
importIntent.putExtra(EXTRA_MESSENGER, mMessenger);
|
||||
|
||||
// now import it with this service
|
||||
onHandleIntent(importIntent);
|
||||
|
||||
// result is handled in ACTION_IMPORT_KEYRING
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
} else if (ACTION_DOWNLOAD_AND_IMPORT_KEYS.equals(action)) {
|
||||
} else if (ACTION_DOWNLOAD_AND_IMPORT_KEYS.equals(action) || ACTION_IMPORT_KEYBASE_KEYS.equals(action)) {
|
||||
try {
|
||||
ArrayList<ImportKeysListEntry> entries = data.getParcelableArrayList(DOWNLOAD_KEY_LIST);
|
||||
|
||||
// this downloads the keys and places them into the ImportKeysListEntry entries
|
||||
String keyServer = data.getString(DOWNLOAD_KEY_SERVER);
|
||||
HkpKeyserver server = new HkpKeyserver(keyServer);
|
||||
|
||||
ArrayList<ParcelableKeyRing> keyRings = new ArrayList<ParcelableKeyRing>(entries.size());
|
||||
for (ImportKeysListEntry entry : entries) {
|
||||
|
||||
Keyserver server;
|
||||
if (entry.getOrigin() == null) {
|
||||
server = new HkpKeyserver(keyServer);
|
||||
} else if (KeybaseKeyserver.ORIGIN.equals(entry.getOrigin())) {
|
||||
server = new KeybaseKeyserver();
|
||||
} else {
|
||||
server = new HkpKeyserver(entry.getOrigin());
|
||||
}
|
||||
|
||||
// if available use complete fingerprint for get request
|
||||
byte[] downloadedKeyBytes;
|
||||
if (entry.getFingerprintHex() != null) {
|
||||
if (KeybaseKeyserver.ORIGIN.equals(entry.getOrigin())) {
|
||||
downloadedKeyBytes = server.get(entry.getExtraData()).getBytes();
|
||||
} else if (entry.getFingerprintHex() != null) {
|
||||
downloadedKeyBytes = server.get("0x" + entry.getFingerprintHex()).getBytes();
|
||||
} else {
|
||||
downloadedKeyBytes = server.get(entry.getKeyIdHex()).getBytes();
|
||||
|
@ -0,0 +1,250 @@
|
||||
package org.sufficientlysecure.keychain.service;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/** Represent the result of an operation.
|
||||
*
|
||||
* This class holds a result and the log of an operation. It can be subclassed
|
||||
* to include typed additional information specific to the operation. To keep
|
||||
* the class structure (somewhat) simple, this class contains an exhaustive
|
||||
* list (ie, enum) of all possible log types, which should in all cases be tied
|
||||
* to string resource ids.
|
||||
*
|
||||
*/
|
||||
public class OperationResultParcel implements Parcelable {
|
||||
/** Holds the overall result, the number specifying varying degrees of success. The first bit
|
||||
* is 0 on overall success, 1 on overall failure. All other bits may be used for more specific
|
||||
* conditions. */
|
||||
final int mResult;
|
||||
|
||||
public static final int RESULT_OK = 0;
|
||||
public static final int RESULT_ERROR = 1;
|
||||
|
||||
/// A list of log entries tied to the operation result.
|
||||
final OperationLog mLog;
|
||||
|
||||
public OperationResultParcel(int result, OperationLog log) {
|
||||
mResult = result;
|
||||
mLog = log;
|
||||
}
|
||||
|
||||
public OperationResultParcel(Parcel source) {
|
||||
mResult = source.readInt();
|
||||
mLog = new OperationLog();
|
||||
mLog.addAll(source.createTypedArrayList(LogEntryParcel.CREATOR));
|
||||
}
|
||||
|
||||
public int getResult() {
|
||||
return mResult;
|
||||
}
|
||||
|
||||
public boolean success() {
|
||||
return (mResult & 1) == 0;
|
||||
}
|
||||
|
||||
public OperationLog getLog() {
|
||||
return mLog;
|
||||
}
|
||||
|
||||
/** One entry in the log. */
|
||||
public static class LogEntryParcel implements Parcelable {
|
||||
public final LogLevel mLevel;
|
||||
public final LogType mType;
|
||||
public final String[] mParameters;
|
||||
public final int mIndent;
|
||||
|
||||
public LogEntryParcel(LogLevel level, LogType type, String[] parameters, int indent) {
|
||||
mLevel = level;
|
||||
mType = type;
|
||||
mParameters = parameters;
|
||||
mIndent = indent;
|
||||
}
|
||||
public LogEntryParcel(LogLevel level, LogType type, String[] parameters) {
|
||||
this(level, type, parameters, 0);
|
||||
}
|
||||
|
||||
public LogEntryParcel(Parcel source) {
|
||||
mLevel = LogLevel.values()[source.readInt()];
|
||||
mType = LogType.values()[source.readInt()];
|
||||
mParameters = source.createStringArray();
|
||||
mIndent = source.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(mLevel.ordinal());
|
||||
dest.writeInt(mType.ordinal());
|
||||
dest.writeStringArray(mParameters);
|
||||
dest.writeInt(mIndent);
|
||||
}
|
||||
|
||||
public static final Creator<LogEntryParcel> CREATOR = new Creator<LogEntryParcel>() {
|
||||
public LogEntryParcel createFromParcel(final Parcel source) {
|
||||
return new LogEntryParcel(source);
|
||||
}
|
||||
|
||||
public LogEntryParcel[] newArray(final int size) {
|
||||
return new LogEntryParcel[size];
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static enum LogType {
|
||||
|
||||
// import public
|
||||
MSG_IP(R.string.msg_ip),
|
||||
MSG_IP_APPLY_BATCH (R.string.msg_ip_apply_batch),
|
||||
MSG_IP_BAD_TYPE_SECRET (R.string.msg_ip_bad_type_secret),
|
||||
MSG_IP_DELETE_OLD_FAIL (R.string.msg_ip_delete_old_fail),
|
||||
MSG_IP_DELETE_OLD_OK (R.string.msg_ip_delete_old_ok),
|
||||
MSG_IP_ENCODE_FAIL (R.string.msg_ip_encode_fail),
|
||||
MSG_IP_FAIL_IO_EXC (R.string.msg_ip_fail_io_exc),
|
||||
MSG_IP_FAIL_OP_EX (R.string.msg_ip_fail_op_ex),
|
||||
MSG_IP_FAIL_REMOTE_EX (R.string.msg_ip_fail_remote_ex),
|
||||
MSG_IP_INSERT_KEYRING (R.string.msg_ip_insert_keyring),
|
||||
MSG_IP_INSERT_SUBKEYS (R.string.msg_ip_insert_subkeys),
|
||||
MSG_IP_PREPARE (R.string.msg_ip_prepare),
|
||||
MSG_IP_PREPARE_SUCCESS(R.string.msg_ip_prepare_success),
|
||||
MSG_IP_PRESERVING_SECRET (R.string.msg_ip_preserving_secret),
|
||||
MSG_IP_REINSERT_SECRET (R.string.msg_ip_reinsert_secret),
|
||||
MSG_IP_SUBKEY (R.string.msg_ip_subkey),
|
||||
MSG_IP_SUBKEY_EXPIRED (R.string.msg_ip_subkey_expired),
|
||||
MSG_IP_SUBKEY_EXPIRES (R.string.msg_ip_subkey_expires),
|
||||
MSG_IP_SUBKEY_FLAGS (R.string.msg_ip_subkey_flags),
|
||||
MSG_IP_SUBKEY_FLAGS_CES (R.string.msg_ip_subkey_flags_ces),
|
||||
MSG_IP_SUBKEY_FLAGS_CEX (R.string.msg_ip_subkey_flags_cex),
|
||||
MSG_IP_SUBKEY_FLAGS_CXS (R.string.msg_ip_subkey_flags_cxs),
|
||||
MSG_IP_SUBKEY_FLAGS_XES (R.string.msg_ip_subkey_flags_xes),
|
||||
MSG_IP_SUBKEY_FLAGS_CXX (R.string.msg_ip_subkey_flags_cxx),
|
||||
MSG_IP_SUBKEY_FLAGS_XEX (R.string.msg_ip_subkey_flags_xex),
|
||||
MSG_IP_SUBKEY_FLAGS_XXS (R.string.msg_ip_subkey_flags_xxs),
|
||||
MSG_IP_SUBKEY_FLAGS_XXX (R.string.msg_ip_subkey_flags_xxx),
|
||||
MSG_IP_SUCCESS (R.string.msg_ip_success),
|
||||
MSG_IP_UID_CERT_BAD (R.string.msg_ip_uid_cert_bad),
|
||||
MSG_IP_UID_CERT_ERROR (R.string.msg_ip_uid_cert_error),
|
||||
MSG_IP_UID_CERT_GOOD (R.string.msg_ip_uid_cert_good),
|
||||
MSG_IP_UID_CERTS_UNKNOWN (R.string.msg_ip_uid_certs_unknown),
|
||||
MSG_IP_UID_CLASSIFYING (R.string.msg_ip_uid_classifying),
|
||||
MSG_IP_UID_REORDER(R.string.msg_ip_uid_reorder),
|
||||
MSG_IP_UID_PROCESSING (R.string.msg_ip_uid_processing),
|
||||
MSG_IP_UID_REVOKED (R.string.msg_ip_uid_revoked),
|
||||
MSG_IP_UID_SELF_GOOD (R.string.msg_ip_uid_self_good),
|
||||
|
||||
// import secret
|
||||
MSG_IS(R.string.msg_is),
|
||||
MSG_IS_BAD_TYPE_PUBLIC (R.string.msg_is_bad_type_public),
|
||||
MSG_IS_IMPORTING_SUBKEYS (R.string.msg_is_importing_subkeys),
|
||||
MSG_IS_IO_EXCPTION (R.string.msg_is_io_excption),
|
||||
MSG_IS_SUBKEY_NONEXISTENT (R.string.msg_is_subkey_nonexistent),
|
||||
MSG_IS_SUBKEY_OK (R.string.msg_is_subkey_ok),
|
||||
MSG_IS_SUBKEY_STRIPPED (R.string.msg_is_subkey_stripped),
|
||||
MSG_IS_SUCCESS (R.string.msg_is_success),
|
||||
|
||||
// keyring canonicalization
|
||||
MSG_KC (R.string.msg_kc),
|
||||
MSG_KC_MASTER (R.string.msg_kc_master),
|
||||
MSG_KC_MASTER_SUCCESS (R.string.msg_kc_master_success),
|
||||
MSG_KC_REVOKE_BAD_ERR (R.string.msg_kc_revoke_bad_err),
|
||||
MSG_KC_REVOKE_BAD_LOCAL (R.string.msg_kc_revoke_bad_local),
|
||||
MSG_KC_REVOKE_BAD_TIME (R.string.msg_kc_revoke_bad_time),
|
||||
MSG_KC_REVOKE_BAD_TYPE (R.string.msg_kc_revoke_bad_type),
|
||||
MSG_KC_REVOKE_BAD (R.string.msg_kc_revoke_bad),
|
||||
MSG_KC_REVOKE_DUP (R.string.msg_kc_revoke_dup),
|
||||
MSG_KC_SUB (R.string.msg_kc_sub),
|
||||
MSG_KC_SUB_BAD(R.string.msg_kc_sub_bad),
|
||||
MSG_KC_SUB_BAD_ERR(R.string.msg_kc_sub_bad_err),
|
||||
MSG_KC_SUB_BAD_LOCAL(R.string.msg_kc_sub_bad_local),
|
||||
MSG_KC_SUB_BAD_KEYID(R.string.msg_kc_sub_bad_keyid),
|
||||
MSG_KC_SUB_BAD_TIME(R.string.msg_kc_sub_bad_time),
|
||||
MSG_KC_SUB_BAD_TYPE(R.string.msg_kc_sub_bad_type),
|
||||
MSG_KC_SUB_PRIMARY_BAD(R.string.msg_kc_sub_primary_bad),
|
||||
MSG_KC_SUB_PRIMARY_BAD_ERR(R.string.msg_kc_sub_primary_bad_err),
|
||||
MSG_KC_SUB_PRIMARY_NONE(R.string.msg_kc_sub_primary_none),
|
||||
MSG_KC_SUB_NO_CERT(R.string.msg_kc_sub_no_cert),
|
||||
MSG_KC_SUB_REVOKE_BAD_ERR (R.string.msg_kc_sub_revoke_bad_err),
|
||||
MSG_KC_SUB_REVOKE_BAD (R.string.msg_kc_sub_revoke_bad),
|
||||
MSG_KC_SUB_REVOKE_DUP (R.string.msg_kc_sub_revoke_dup),
|
||||
MSG_KC_SUB_SUCCESS (R.string.msg_kc_sub_success),
|
||||
MSG_KC_SUCCESS_REMOVED (R.string.msg_kc_success_removed),
|
||||
MSG_KC_SUCCESS (R.string.msg_kc_success),
|
||||
MSG_KC_UID_BAD_ERR (R.string.msg_kc_uid_bad_err),
|
||||
MSG_KC_UID_BAD_LOCAL (R.string.msg_kc_uid_bad_local),
|
||||
MSG_KC_UID_BAD_TIME (R.string.msg_kc_uid_bad_time),
|
||||
MSG_KC_UID_BAD_TYPE (R.string.msg_kc_uid_bad_type),
|
||||
MSG_KC_UID_BAD (R.string.msg_kc_uid_bad),
|
||||
MSG_KC_UID_DUP (R.string.msg_kc_uid_dup),
|
||||
MSG_KC_UID_REVOKE_DUP (R.string.msg_kc_uid_revoke_dup),
|
||||
MSG_KC_UID_REVOKE_OLD (R.string.msg_kc_uid_revoke_old),
|
||||
;
|
||||
|
||||
private final int mMsgId;
|
||||
LogType(int msgId) {
|
||||
mMsgId = msgId;
|
||||
}
|
||||
public int getMsgId() {
|
||||
return mMsgId;
|
||||
}
|
||||
}
|
||||
|
||||
/** Enumeration of possible log levels. */
|
||||
public static enum LogLevel {
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARN,
|
||||
ERROR, // should occur once at the end of a failed operation
|
||||
START, // should occur once at the start of each independent operation
|
||||
OK, // should occur once at the end of a successful operation
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(mResult);
|
||||
dest.writeTypedList(mLog);
|
||||
}
|
||||
|
||||
public static final Creator<OperationResultParcel> CREATOR = new Creator<OperationResultParcel>() {
|
||||
public OperationResultParcel createFromParcel(final Parcel source) {
|
||||
return new OperationResultParcel(source);
|
||||
}
|
||||
|
||||
public OperationResultParcel[] newArray(final int size) {
|
||||
return new OperationResultParcel[size];
|
||||
}
|
||||
};
|
||||
|
||||
public static class OperationLog extends ArrayList<LogEntryParcel> {
|
||||
|
||||
/// Simple convenience method
|
||||
public void add(LogLevel level, LogType type, String[] parameters, int indent) {
|
||||
add(new OperationResultParcel.LogEntryParcel(level, type, parameters, indent));
|
||||
}
|
||||
|
||||
public boolean containsWarnings() {
|
||||
for(LogEntryParcel entry : new IterableIterator<LogEntryParcel>(iterator())) {
|
||||
if (entry.mLevel == LogLevel.WARN || entry.mLevel == LogLevel.ERROR) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package org.sufficientlysecure.keychain.service;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
public abstract class OperationResults {
|
||||
|
||||
public static class ImportResult extends OperationResultParcel {
|
||||
|
||||
public final int mNewKeys, mUpdatedKeys, mBadKeys;
|
||||
|
||||
// At least one new key
|
||||
public static final int RESULT_OK_NEWKEYS = 2;
|
||||
// At least one updated key
|
||||
public static final int RESULT_OK_UPDATED = 4;
|
||||
// At least one key failed (might still be an overall success)
|
||||
public static final int RESULT_WITH_ERRORS = 8;
|
||||
// There are warnings in the log
|
||||
public static final int RESULT_WITH_WARNINGS = 16;
|
||||
|
||||
// No keys to import...
|
||||
public static final int RESULT_FAIL_NOTHING = 32 +1;
|
||||
|
||||
public boolean isOkBoth() {
|
||||
return (mResult & (RESULT_OK_NEWKEYS | RESULT_OK_UPDATED))
|
||||
== (RESULT_OK_NEWKEYS | RESULT_OK_UPDATED);
|
||||
}
|
||||
public boolean isOkNew() {
|
||||
return (mResult & RESULT_OK_NEWKEYS) == RESULT_OK_NEWKEYS;
|
||||
}
|
||||
public boolean isOkUpdated() {
|
||||
return (mResult & RESULT_OK_UPDATED) == RESULT_OK_UPDATED;
|
||||
}
|
||||
public boolean isFailNothing() {
|
||||
return (mResult & RESULT_FAIL_NOTHING) == RESULT_FAIL_NOTHING;
|
||||
}
|
||||
|
||||
public ImportResult(Parcel source) {
|
||||
super(source);
|
||||
mNewKeys = source.readInt();
|
||||
mUpdatedKeys = source.readInt();
|
||||
mBadKeys = source.readInt();
|
||||
}
|
||||
|
||||
public ImportResult(int result, OperationLog log,
|
||||
int newKeys, int updatedKeys, int badKeys) {
|
||||
super(result, log);
|
||||
mNewKeys = newKeys;
|
||||
mUpdatedKeys = updatedKeys;
|
||||
mBadKeys = badKeys;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(mNewKeys);
|
||||
dest.writeInt(mUpdatedKeys);
|
||||
dest.writeInt(mBadKeys);
|
||||
}
|
||||
|
||||
public static Creator<ImportResult> CREATOR = new Creator<ImportResult>() {
|
||||
public ImportResult createFromParcel(final Parcel source) {
|
||||
return new ImportResult(source);
|
||||
}
|
||||
|
||||
public ImportResult[] newArray(final int size) {
|
||||
return new ImportResult[size];
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static class SaveKeyringResult extends OperationResultParcel {
|
||||
|
||||
public SaveKeyringResult(int result, OperationLog log) {
|
||||
super(result, log);
|
||||
}
|
||||
|
||||
// Some old key was updated
|
||||
public static final int UPDATED = 2;
|
||||
|
||||
// Public key was saved
|
||||
public static final int SAVED_PUBLIC = 8;
|
||||
// Secret key was saved (not exclusive with public!)
|
||||
public static final int SAVED_SECRET = 16;
|
||||
|
||||
public boolean updated() {
|
||||
return (mResult & UPDATED) == UPDATED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -25,7 +25,7 @@ import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
||||
import org.sufficientlysecure.keychain.util.SlidingTabLayout;
|
||||
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
|
||||
|
||||
public class HelpActivity extends ActionBarActivity {
|
||||
public static final String EXTRA_SELECTED_TAB = "selected_tab";
|
||||
|
@ -38,7 +38,10 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import com.devspark.appmsg.AppMsg;
|
||||
import com.github.johnpersano.supertoasts.SuperCardToast;
|
||||
import com.github.johnpersano.supertoasts.SuperToast;
|
||||
import com.github.johnpersano.supertoasts.util.OnClickWrapper;
|
||||
import com.github.johnpersano.supertoasts.util.Style;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
@ -47,7 +50,7 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.BadImportKeyDialogFragment;
|
||||
import org.sufficientlysecure.keychain.service.OperationResults.ImportResult;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -135,6 +138,7 @@ public class ImportKeysActivity extends ActionBarActivity implements ActionBar.O
|
||||
}
|
||||
|
||||
handleActions(savedInstanceState, getIntent());
|
||||
|
||||
}
|
||||
|
||||
protected void handleActions(Bundle savedInstanceState, Intent intent) {
|
||||
@ -331,8 +335,11 @@ public class ImportKeysActivity extends ActionBarActivity implements ActionBar.O
|
||||
|
||||
public void loadFromFingerprint(Bundle savedInstanceState, String fingerprint) {
|
||||
if (fingerprint == null || fingerprint.length() < 40) {
|
||||
AppMsg.makeText(this, R.string.import_qr_code_too_short_fingerprint,
|
||||
AppMsg.STYLE_ALERT).show();
|
||||
SuperCardToast toast = SuperCardToast.create(this,
|
||||
getString(R.string.import_qr_code_too_short_fingerprint),
|
||||
SuperToast.Duration.LONG);
|
||||
toast.setBackground(SuperToast.Background.RED);
|
||||
toast.show();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -368,39 +375,93 @@ public class ImportKeysActivity extends ActionBarActivity implements ActionBar.O
|
||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
||||
// get returned data bundle
|
||||
Bundle returnData = message.getData();
|
||||
final ImportResult result =
|
||||
returnData.<ImportResult>getParcelable(KeychainIntentService.RESULT);
|
||||
|
||||
int resultType = result.getResult();
|
||||
|
||||
String str;
|
||||
int duration, color;
|
||||
|
||||
// Not an overall failure
|
||||
if ((resultType & ImportResult.RESULT_ERROR) == 0) {
|
||||
String withWarnings;
|
||||
|
||||
// Any warnings?
|
||||
if ((resultType & ImportResult.RESULT_WITH_WARNINGS) > 0) {
|
||||
duration = 0;
|
||||
color = Style.ORANGE;
|
||||
withWarnings = getResources().getString(R.string.import_with_warnings);
|
||||
} else {
|
||||
duration = SuperToast.Duration.LONG;
|
||||
color = Style.GREEN;
|
||||
withWarnings = "";
|
||||
}
|
||||
|
||||
// New and updated keys
|
||||
if (result.isOkBoth()) {
|
||||
str = getResources().getQuantityString(
|
||||
R.plurals.import_keys_added_and_updated_1, result.mNewKeys, result.mNewKeys);
|
||||
str += getResources().getQuantityString(
|
||||
R.plurals.import_keys_added_and_updated_2, result.mUpdatedKeys, result.mUpdatedKeys, withWarnings);
|
||||
} else if (result.isOkUpdated()) {
|
||||
str = getResources().getQuantityString(
|
||||
R.plurals.import_keys_updated, result.mUpdatedKeys, result.mUpdatedKeys, withWarnings);
|
||||
} else if (result.isOkNew()) {
|
||||
str = getResources().getQuantityString(
|
||||
R.plurals.import_keys_added, result.mNewKeys, result.mNewKeys, withWarnings);
|
||||
} else {
|
||||
duration = 0;
|
||||
color = Style.RED;
|
||||
str = "internal error";
|
||||
}
|
||||
|
||||
int added = returnData.getInt(KeychainIntentService.RESULT_IMPORT_ADDED);
|
||||
int updated = returnData
|
||||
.getInt(KeychainIntentService.RESULT_IMPORT_UPDATED);
|
||||
int bad = returnData.getInt(KeychainIntentService.RESULT_IMPORT_BAD);
|
||||
String toastMessage;
|
||||
if (added > 0 && updated > 0) {
|
||||
String addedStr = getResources().getQuantityString(
|
||||
R.plurals.keys_added_and_updated_1, added, added);
|
||||
String updatedStr = getResources().getQuantityString(
|
||||
R.plurals.keys_added_and_updated_2, updated, updated);
|
||||
toastMessage = addedStr + updatedStr;
|
||||
} else if (added > 0) {
|
||||
toastMessage = getResources().getQuantityString(R.plurals.keys_added,
|
||||
added, added);
|
||||
} else if (updated > 0) {
|
||||
toastMessage = getResources().getQuantityString(R.plurals.keys_updated,
|
||||
updated, updated);
|
||||
} else {
|
||||
toastMessage = getString(R.string.no_keys_added_or_updated);
|
||||
duration = 0;
|
||||
color = Style.RED;
|
||||
if (result.isFailNothing()) {
|
||||
str = getString(R.string.import_error_nothing);
|
||||
} else {
|
||||
str = getString(R.string.import_error);
|
||||
}
|
||||
}
|
||||
AppMsg.makeText(ImportKeysActivity.this, toastMessage, AppMsg.STYLE_INFO)
|
||||
.show();
|
||||
|
||||
SuperCardToast toast = new SuperCardToast(ImportKeysActivity.this,
|
||||
SuperToast.Type.BUTTON, Style.getStyle(color, SuperToast.Animations.POPUP));
|
||||
toast.setText(str);
|
||||
toast.setDuration(duration);
|
||||
toast.setIndeterminate(duration == 0);
|
||||
toast.setSwipeToDismiss(true);
|
||||
toast.setButtonIcon(R.drawable.ic_action_view_as_list,
|
||||
getResources().getString(R.string.import_view_log));
|
||||
toast.setButtonTextColor(getResources().getColor(R.color.black));
|
||||
toast.setTextColor(getResources().getColor(R.color.black));
|
||||
toast.setOnClickWrapper(new OnClickWrapper("supercardtoast",
|
||||
new SuperToast.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view, Parcelable token) {
|
||||
Intent intent = new Intent(
|
||||
ImportKeysActivity.this, LogDisplayActivity.class);
|
||||
intent.putExtra(LogDisplayFragment.EXTRA_RESULT, result);
|
||||
startActivity(intent);
|
||||
}
|
||||
}));
|
||||
toast.show();
|
||||
|
||||
/*
|
||||
if (bad > 0) {
|
||||
BadImportKeyDialogFragment badImportKeyDialogFragment =
|
||||
BadImportKeyDialogFragment.newInstance(bad);
|
||||
badImportKeyDialogFragment.show(getSupportFragmentManager(), "badKeyDialog");
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(getIntent().getAction())) {
|
||||
ImportKeysActivity.this.setResult(Activity.RESULT_OK, mPendingIntentData);
|
||||
finish();
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -483,7 +544,11 @@ public class ImportKeysActivity extends ActionBarActivity implements ActionBar.O
|
||||
startService(intent);
|
||||
|
||||
} else {
|
||||
AppMsg.makeText(this, R.string.error_nothing_import, AppMsg.STYLE_ALERT).show();
|
||||
SuperCardToast toast = SuperCardToast.create(this,
|
||||
getString(R.string.error_nothing_import),
|
||||
SuperToast.Duration.LONG);
|
||||
toast.setBackground(SuperToast.Background.RED);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ public class KeyListFragment extends LoaderFragment
|
||||
static final int INDEX_HAS_ANY_SECRET = 6;
|
||||
|
||||
static final String ORDER =
|
||||
KeyRings.HAS_ANY_SECRET + " DESC, " + KeyRings.USER_ID + " ASC";
|
||||
KeyRings.HAS_ANY_SECRET + " DESC, UPPER(" + KeyRings.USER_ID + ") ASC";
|
||||
|
||||
|
||||
@Override
|
||||
@ -592,7 +592,7 @@ public class KeyListFragment extends LoaderFragment
|
||||
String userId = mCursor.getString(KeyListFragment.INDEX_USER_ID);
|
||||
String headerText = convertView.getResources().getString(R.string.user_id_no_name);
|
||||
if (userId != null && userId.length() > 0) {
|
||||
headerText = "" + userId.subSequence(0, 1).charAt(0);
|
||||
headerText = "" + userId.charAt(0);
|
||||
}
|
||||
holder.mText.setText(headerText);
|
||||
holder.mCount.setVisibility(View.GONE);
|
||||
@ -621,7 +621,7 @@ public class KeyListFragment extends LoaderFragment
|
||||
// otherwise, return the first character of the name as ID
|
||||
String userId = mCursor.getString(KeyListFragment.INDEX_USER_ID);
|
||||
if (userId != null && userId.length() > 0) {
|
||||
return userId.charAt(0);
|
||||
return Character.toUpperCase(userId.charAt(0));
|
||||
} else {
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.view.GestureDetectorCompat;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
public class LogDisplayActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.log_display_activity);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.util.TypedValue;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.service.OperationResultParcel;
|
||||
import org.sufficientlysecure.keychain.service.OperationResultParcel.LogEntryParcel;
|
||||
import org.sufficientlysecure.keychain.service.OperationResultParcel.LogLevel;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class LogDisplayFragment extends ListFragment implements OnTouchListener {
|
||||
|
||||
HashMap<LogLevel,LogAdapter> mAdapters = new HashMap<LogLevel, LogAdapter>();
|
||||
LogAdapter mAdapter;
|
||||
LogLevel mLevel = LogLevel.DEBUG;
|
||||
|
||||
OperationResultParcel mResult;
|
||||
|
||||
GestureDetector mDetector;
|
||||
|
||||
public static final String EXTRA_RESULT = "log";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
Intent intent = getActivity().getIntent();
|
||||
if (intent.getExtras() == null || !intent.getExtras().containsKey(EXTRA_RESULT)) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
||||
mResult = intent.<OperationResultParcel>getParcelableExtra(EXTRA_RESULT);
|
||||
if (mResult == null) {
|
||||
getActivity().finish();
|
||||
return;
|
||||
}
|
||||
|
||||
mAdapter = new LogAdapter(getActivity(), mResult.getLog(), LogLevel.DEBUG);
|
||||
mAdapters.put(LogLevel.DEBUG, mAdapter);
|
||||
setListAdapter(mAdapter);
|
||||
|
||||
mDetector = new GestureDetector(getActivity(), new SimpleOnGestureListener() {
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float vx, float vy) {
|
||||
Log.d(Constants.TAG, "x: " + vx + ", y: " + vy);
|
||||
if (vx < -2000) {
|
||||
decreaseLogLevel();
|
||||
} else if (vx > 2000) {
|
||||
increaseLogLevel();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void decreaseLogLevel() {
|
||||
switch (mLevel) {
|
||||
case DEBUG: mLevel = LogLevel.INFO; break;
|
||||
case INFO: mLevel = LogLevel.WARN; break;
|
||||
}
|
||||
refreshLevel();
|
||||
}
|
||||
|
||||
public void increaseLogLevel() {
|
||||
switch (mLevel) {
|
||||
case INFO: mLevel = LogLevel.DEBUG; break;
|
||||
case WARN: mLevel = LogLevel.INFO; break;
|
||||
}
|
||||
refreshLevel();
|
||||
}
|
||||
|
||||
private void refreshLevel() {
|
||||
/* TODO not sure if this is a good idea
|
||||
if (!mAdapters.containsKey(mLevel)) {
|
||||
mAdapters.put(mLevel, new LogAdapter(getActivity(), mResult.getLog(), mLevel));
|
||||
}
|
||||
mAdapter = mAdapters.get(mLevel);
|
||||
setListAdapter(mAdapter);
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getListView().setDividerHeight(0);
|
||||
getListView().setOnTouchListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
mDetector.onTouchEvent(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
private class LogAdapter extends ArrayAdapter<LogEntryParcel> {
|
||||
|
||||
private LayoutInflater mInflater;
|
||||
private int dipFactor;
|
||||
|
||||
public LogAdapter(Context context, ArrayList<LogEntryParcel> log, LogLevel level) {
|
||||
super(context, R.layout.log_display_item);
|
||||
mInflater = LayoutInflater.from(getContext());
|
||||
dipFactor = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
||||
(float) 8, getResources().getDisplayMetrics());
|
||||
// we can't use addAll for a LogLevel.DEBUG shortcut here, unfortunately :(
|
||||
for (LogEntryParcel e : log) {
|
||||
if (e.mLevel.ordinal() >= level.ordinal()) {
|
||||
add(e);
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private class ItemHolder {
|
||||
final TextView mText;
|
||||
final ImageView mImg;
|
||||
public ItemHolder(TextView text, ImageView image) {
|
||||
mText = text;
|
||||
mImg = image;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
LogEntryParcel entry = getItem(position);
|
||||
ItemHolder ih;
|
||||
if (convertView == null) {
|
||||
convertView = mInflater.inflate(R.layout.log_display_item, parent, false);
|
||||
ih = new ItemHolder(
|
||||
(TextView) convertView.findViewById(R.id.log_text),
|
||||
(ImageView) convertView.findViewById(R.id.log_img)
|
||||
);
|
||||
convertView.setTag(ih);
|
||||
} else {
|
||||
ih = (ItemHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
ih.mText.setText(getResources().getString(entry.mType.getMsgId(), (Object[]) entry.mParameters));
|
||||
ih.mText.setTextColor(entry.mLevel == LogLevel.DEBUG ? Color.GRAY : Color.BLACK);
|
||||
convertView.setPadding((entry.mIndent) * dipFactor, 0, 0, 0);
|
||||
switch (entry.mLevel) {
|
||||
case DEBUG: ih.mImg.setBackgroundColor(Color.GRAY); break;
|
||||
case INFO: ih.mImg.setBackgroundColor(Color.BLACK); break;
|
||||
case WARN: ih.mImg.setBackgroundColor(Color.YELLOW); break;
|
||||
case ERROR: ih.mImg.setBackgroundColor(Color.RED); break;
|
||||
case START: ih.mImg.setBackgroundColor(Color.GREEN); break;
|
||||
case OK: ih.mImg.setBackgroundColor(Color.GREEN); break;
|
||||
}
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
@ -32,6 +33,7 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
@ -47,6 +49,7 @@ import com.devspark.appmsg.AppMsg;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.ContactHelper;
|
||||
import org.sufficientlysecure.keychain.helper.ExportHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
@ -54,7 +57,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.SlidingTabLayout;
|
||||
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@ -92,6 +95,8 @@ public class ViewKeyActivity extends ActionBarActivity implements
|
||||
|
||||
private static final int LOADER_ID_UNIFIED = 0;
|
||||
|
||||
private boolean mShowAdvancedTabs;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -116,16 +121,13 @@ public class ViewKeyActivity extends ActionBarActivity implements
|
||||
mViewPager = (ViewPager) findViewById(R.id.view_key_pager);
|
||||
mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.view_key_sliding_tab_layout);
|
||||
|
||||
mTabsAdapter = new PagerTabStripAdapter(this);
|
||||
mViewPager.setAdapter(mTabsAdapter);
|
||||
|
||||
int switchToTab = TAB_MAIN;
|
||||
Intent intent = getIntent();
|
||||
if (intent.getExtras() != null && intent.getExtras().containsKey(EXTRA_SELECTED_TAB)) {
|
||||
switchToTab = intent.getExtras().getInt(EXTRA_SELECTED_TAB);
|
||||
}
|
||||
|
||||
Uri dataUri = getIntent().getData();
|
||||
Uri dataUri = getDataUri();
|
||||
if (dataUri == null) {
|
||||
Log.e(Constants.TAG, "Data missing. Should be Uri of key!");
|
||||
finish();
|
||||
@ -136,6 +138,18 @@ public class ViewKeyActivity extends ActionBarActivity implements
|
||||
|
||||
initNfc(dataUri);
|
||||
|
||||
mShowAdvancedTabs = false;
|
||||
|
||||
initTabs(dataUri);
|
||||
|
||||
// switch to tab selected by extra
|
||||
mViewPager.setCurrentItem(switchToTab);
|
||||
}
|
||||
|
||||
private void initTabs(Uri dataUri) {
|
||||
mTabsAdapter = new PagerTabStripAdapter(this);
|
||||
mViewPager.setAdapter(mTabsAdapter);
|
||||
|
||||
Bundle mainBundle = new Bundle();
|
||||
mainBundle.putParcelable(ViewKeyMainFragment.ARG_DATA_URI, dataUri);
|
||||
mTabsAdapter.addTab(ViewKeyMainFragment.class,
|
||||
@ -146,6 +160,11 @@ public class ViewKeyActivity extends ActionBarActivity implements
|
||||
mTabsAdapter.addTab(ViewKeyShareFragment.class,
|
||||
mainBundle, getString(R.string.key_view_tab_share));
|
||||
|
||||
// update layout after operations
|
||||
mSlidingTabLayout.setViewPager(mViewPager);
|
||||
}
|
||||
|
||||
private void addAdvancedTabs(Uri dataUri) {
|
||||
Bundle keyDetailsBundle = new Bundle();
|
||||
keyDetailsBundle.putParcelable(ViewKeyKeysFragment.ARG_DATA_URI, dataUri);
|
||||
mTabsAdapter.addTab(ViewKeyKeysFragment.class,
|
||||
@ -156,11 +175,54 @@ public class ViewKeyActivity extends ActionBarActivity implements
|
||||
mTabsAdapter.addTab(ViewKeyCertsFragment.class,
|
||||
certBundle, getString(R.string.key_view_tab_certs));
|
||||
|
||||
// NOTE: must be after adding the tabs!
|
||||
// update layout after operations
|
||||
mSlidingTabLayout.setViewPager(mViewPager);
|
||||
}
|
||||
|
||||
// switch to tab selected by extra
|
||||
mViewPager.setCurrentItem(switchToTab);
|
||||
private void removeAdvancedTabs() {
|
||||
// before removing, switch to the first tab if necessary
|
||||
if (mViewPager.getCurrentItem() >= TAB_KEYS) {
|
||||
// remove _after_ switching to the main tab
|
||||
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
if (ViewPager.SCROLL_STATE_SETTLING == state) {
|
||||
mTabsAdapter.removeTab(TAB_CERTS);
|
||||
mTabsAdapter.removeTab(TAB_KEYS);
|
||||
|
||||
// update layout after operations
|
||||
mSlidingTabLayout.setViewPager(mViewPager);
|
||||
|
||||
// remove this listener again
|
||||
// mViewPager.setOnPageChangeListener(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mViewPager.setCurrentItem(TAB_MAIN);
|
||||
} else {
|
||||
mTabsAdapter.removeTab(TAB_CERTS);
|
||||
mTabsAdapter.removeTab(TAB_KEYS);
|
||||
}
|
||||
|
||||
// update layout after operations
|
||||
mSlidingTabLayout.setViewPager(mViewPager);
|
||||
}
|
||||
|
||||
private Uri getDataUri() {
|
||||
Uri dataUri = getIntent().getData();
|
||||
if (dataUri != null && dataUri.getHost().equals(ContactsContract.AUTHORITY)) {
|
||||
dataUri = ContactHelper.dataUriFromContactUri(this, dataUri);
|
||||
}
|
||||
return dataUri;
|
||||
}
|
||||
|
||||
private void loadData(Uri dataUri) {
|
||||
@ -177,6 +239,9 @@ public class ViewKeyActivity extends ActionBarActivity implements
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
getMenuInflater().inflate(R.menu.key_view, menu);
|
||||
|
||||
MenuItem showAdvancedInfoItem = menu.findItem(R.id.menu_key_view_advanced);
|
||||
showAdvancedInfoItem.setChecked(mShowAdvancedTabs);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -184,24 +249,37 @@ public class ViewKeyActivity extends ActionBarActivity implements
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
try {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
case android.R.id.home: {
|
||||
Intent homeIntent = new Intent(this, KeyListActivity.class);
|
||||
homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(homeIntent);
|
||||
return true;
|
||||
case R.id.menu_key_view_update:
|
||||
}
|
||||
case R.id.menu_key_view_update: {
|
||||
updateFromKeyserver(mDataUri, mProviderHelper);
|
||||
return true;
|
||||
case R.id.menu_key_view_export_keyserver:
|
||||
}
|
||||
case R.id.menu_key_view_export_keyserver: {
|
||||
uploadToKeyserver(mDataUri);
|
||||
return true;
|
||||
case R.id.menu_key_view_export_file:
|
||||
}
|
||||
case R.id.menu_key_view_export_file: {
|
||||
exportToFile(mDataUri, mExportHelper, mProviderHelper);
|
||||
return true;
|
||||
}
|
||||
case R.id.menu_key_view_delete: {
|
||||
deleteKey(mDataUri, mExportHelper);
|
||||
return true;
|
||||
}
|
||||
case R.id.menu_key_view_advanced: {
|
||||
mShowAdvancedTabs = !mShowAdvancedTabs;
|
||||
item.setChecked(mShowAdvancedTabs);
|
||||
if (mShowAdvancedTabs) {
|
||||
addAdvancedTabs(mDataUri);
|
||||
} else {
|
||||
removeAdvancedTabs();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ProviderHelper.NotFoundException e) {
|
||||
AppMsg.makeText(this, R.string.error_key_not_found, AppMsg.STYLE_ALERT).show();
|
||||
|
@ -33,7 +33,6 @@ import android.widget.TextView;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.util.Highlighter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -120,13 +119,13 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
}
|
||||
|
||||
// main user id
|
||||
String userId = entry.userIds.get(0);
|
||||
String userId = entry.getUserIds().get(0);
|
||||
String[] userIdSplit = KeyRing.splitUserId(userId);
|
||||
|
||||
// name
|
||||
if (userIdSplit[0] != null) {
|
||||
// show red user id if it is a secret key
|
||||
if (entry.secretKey) {
|
||||
if (entry.isSecretKey()) {
|
||||
holder.mainUserId.setText(mActivity.getString(R.string.secret_key)
|
||||
+ " " + userIdSplit[0]);
|
||||
holder.mainUserId.setTextColor(Color.RED);
|
||||
@ -147,30 +146,26 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
holder.mainUserIdRest.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
holder.keyId.setText(entry.keyIdHex);
|
||||
holder.keyId.setText(entry.getKeyIdHex());
|
||||
|
||||
if (entry.fingerprintHex != null) {
|
||||
holder.fingerprint.setVisibility(View.VISIBLE);
|
||||
holder.fingerprint.setText(PgpKeyHelper.colorizeFingerprint(entry.fingerprintHex));
|
||||
} else {
|
||||
holder.fingerprint.setVisibility(View.GONE);
|
||||
}
|
||||
// don't show full fingerprint on key import
|
||||
holder.fingerprint.setVisibility(View.GONE);
|
||||
|
||||
if (entry.bitStrength != 0 && entry.algorithm != null) {
|
||||
holder.algorithm.setText("" + entry.bitStrength + "/" + entry.algorithm);
|
||||
if (entry.getBitStrength() != 0 && entry.getAlgorithm() != null) {
|
||||
holder.algorithm.setText("" + entry.getBitStrength() + "/" + entry.getAlgorithm());
|
||||
holder.algorithm.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.algorithm.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
if (entry.revoked) {
|
||||
if (entry.isRevoked()) {
|
||||
holder.status.setVisibility(View.VISIBLE);
|
||||
holder.status.setText(R.string.revoked);
|
||||
} else {
|
||||
holder.status.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (entry.userIds.size() == 1) {
|
||||
if (entry.getUserIds().size() == 1) {
|
||||
holder.userIdsList.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.userIdsList.setVisibility(View.VISIBLE);
|
||||
@ -178,7 +173,7 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
||||
// clear view from holder
|
||||
holder.userIdsList.removeAllViews();
|
||||
|
||||
Iterator<String> it = entry.userIds.iterator();
|
||||
Iterator<String> it = entry.getUserIds().iterator();
|
||||
// skip primary user id
|
||||
it.next();
|
||||
while (it.hasNext()) {
|
||||
|
@ -20,8 +20,13 @@ package org.sufficientlysecure.keychain.ui.adapter;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -52,6 +57,11 @@ public class PagerTabStripAdapter extends FragmentPagerAdapter {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void removeTab(int index) {
|
||||
mTabs.remove(index);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mTabs.size();
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.util;
|
||||
package org.sufficientlysecure.keychain.ui.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.util;
|
||||
package org.sufficientlysecure.keychain.ui.widget;
|
||||
|
||||
import android.R;
|
||||
import android.content.Context;
|
Binary file not shown.
After Width: | Height: | Size: 308 B |
Binary file not shown.
After Width: | Height: | Size: 246 B |
Binary file not shown.
After Width: | Height: | Size: 337 B |
Binary file not shown.
After Width: | Height: | Size: 431 B |
@ -4,7 +4,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<org.sufficientlysecure.keychain.util.SlidingTabLayout
|
||||
<org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout
|
||||
android:id="@+id/sliding_tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
@ -1,22 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/content_frame"
|
||||
android:layout_marginLeft="@dimen/drawer_content_padding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/card_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/import_navigation_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/import_keys_list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:layout_weight="0.9" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/import_footer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
@ -43,16 +58,4 @@
|
||||
style="@style/SelectableItem" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/import_keys_list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/import_footer"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@+id/import_navigation_fragment"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
46
OpenKeychain/src/main/res/layout/log_display_activity.xml
Normal file
46
OpenKeychain/src/main/res/layout/log_display_activity.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/list"
|
||||
android:name="org.sufficientlysecure.keychain.ui.LogDisplayFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.9"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginLeft="8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/import_footer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/import_import"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Close"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
style="@style/SelectableItem" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
11
OpenKeychain/src/main/res/layout/log_display_fragment.xml
Normal file
11
OpenKeychain/src/main/res/layout/log_display_fragment.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ListView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/log_text" />
|
||||
</LinearLayout>
|
22
OpenKeychain/src/main/res/layout/log_display_item.xml
Normal file
22
OpenKeychain/src/main/res/layout/log_display_item.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/log_img"
|
||||
android:minWidth="10dp"
|
||||
android:background="@color/bg_gray" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Log Entry Text"
|
||||
android:id="@+id/log_text"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginLeft="8dp" />
|
||||
</LinearLayout>
|
@ -35,7 +35,7 @@
|
||||
android:visibility="gone"
|
||||
android:id="@+id/status_divider" />
|
||||
|
||||
<org.sufficientlysecure.keychain.util.SlidingTabLayout
|
||||
<org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout
|
||||
android:id="@+id/view_key_sliding_tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
@ -31,4 +31,10 @@
|
||||
app:showAsAction="never"
|
||||
android:title="@string/menu_delete_key" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_key_view_advanced"
|
||||
app:showAsAction="never"
|
||||
android:checkable="true"
|
||||
android:title="@string/menu_advanced" />
|
||||
|
||||
</menu>
|
@ -206,23 +206,23 @@
|
||||
<string name="ask_empty_id_ok">Es wurde eine leere Identität hinzugefügt. Wirklich fortfahren?</string>
|
||||
<string name="public_key_deletetion_confirmation">Soll der öffentliche Schlüssel \'%s\' wirklich gelöscht werden?\nDies kann nicht rückgängig gemacht werden! </string>
|
||||
<string name="also_export_secret_keys">Private Schlüssel auch exportieren</string>
|
||||
<plurals name="keys_added_and_updated_1">
|
||||
<plurals name="import_keys_added_and_updated_1">
|
||||
<item quantity="one">%d Schlüssel erfolgreich hinzugefügt</item>
|
||||
<item quantity="other">%d Schlüssel erfolgreich hinzugefügt</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added_and_updated_2">
|
||||
<plurals name="import_keys_added_and_updated_2">
|
||||
<item quantity="one">und %d Schlüssel erfolgreich aktualisiert.</item>
|
||||
<item quantity="other">und %d Schlüssel erfolgreich aktualisiert.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added">
|
||||
<plurals name="import_keys_added">
|
||||
<item quantity="one">%d Schlüssel erfolgreich hinzugefügt.</item>
|
||||
<item quantity="other">%d Schlüssel erfolgreich hinzugefügt.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_updated">
|
||||
<plurals name="import_keys_updated">
|
||||
<item quantity="one">%d Schlüssel erfolgreich aktualisiert.</item>
|
||||
<item quantity="other">%d Schlüssel erfolgreich aktualisiert.</item>
|
||||
</plurals>
|
||||
<string name="no_keys_added_or_updated">Keine Schlüssel hinzugefügt oder aktualisiert.</string>
|
||||
<string name="import_error_nothing">Keine Schlüssel hinzugefügt oder aktualisiert.</string>
|
||||
<string name="key_exported">1 Schlüssel erfolgreich exportiert.</string>
|
||||
<string name="keys_exported">%d Schlüssel erfolgreich exportiert.</string>
|
||||
<string name="no_keys_exported">Keine Schlüssel exportiert.</string>
|
||||
|
@ -206,23 +206,23 @@
|
||||
<string name="ask_empty_id_ok">Ha añadido una identidad vacía, ¿está seguro de que quiere continuar?</string>
|
||||
<string name="public_key_deletetion_confirmation">¿De veras quiere borrar la clave pública \'%s\'?\n¡No puede deshacer esto!</string>
|
||||
<string name="also_export_secret_keys">¿Exportar también las claves secretas?</string>
|
||||
<plurals name="keys_added_and_updated_1">
|
||||
<plurals name="import_keys_added_and_updated_1">
|
||||
<item quantity="one">%d clave añadida satisfactoriamente</item>
|
||||
<item quantity="other">%d claves añadidas satisfactoriamente</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added_and_updated_2">
|
||||
<plurals name="import_keys_added_and_updated_2">
|
||||
<item quantity="one">y actualizada %d clave.</item>
|
||||
<item quantity="other">y actualizadas %d claves.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added">
|
||||
<plurals name="import_keys_added">
|
||||
<item quantity="one">%d clave añadida satisfactoriamente.</item>
|
||||
<item quantity="other">%d claves añadidas satisfactoriamente.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_updated">
|
||||
<plurals name="import_keys_updated">
|
||||
<item quantity="one">%d clave actualizada satisfactoriamente.</item>
|
||||
<item quantity="other">%d claves actualizadas satisfactoriamente.</item>
|
||||
</plurals>
|
||||
<string name="no_keys_added_or_updated">No se han añadido o actualizado claves.</string>
|
||||
<string name="import_error_nothing">No se han añadido o actualizado claves.</string>
|
||||
<string name="key_exported">Se ha exportado 1 clave satisfactoriamente.</string>
|
||||
<string name="keys_exported">%d claves exportadas satisfactoriamente.</string>
|
||||
<string name="no_keys_exported">No se han exportado claves.</string>
|
||||
|
@ -206,23 +206,23 @@
|
||||
<string name="ask_empty_id_ok">Vous avez ajouté une identité vide, êtes-vous certain de vouloir continuer ?</string>
|
||||
<string name="public_key_deletetion_confirmation">Voulez-vous vraiment supprimer la clef publique %s ?\nCeci est irréversible !</string>
|
||||
<string name="also_export_secret_keys">Exporter aussi les clefs secrètes ?</string>
|
||||
<plurals name="keys_added_and_updated_1">
|
||||
<plurals name="import_keys_added_and_updated_1">
|
||||
<item quantity="one">%d clef ajoutée avec succès</item>
|
||||
<item quantity="other">%d clefs ajoutées avec succès</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added_and_updated_2">
|
||||
<plurals name="import_keys_added_and_updated_2">
|
||||
<item quantity="one">et %d clef mise à jour.</item>
|
||||
<item quantity="other">et %d clefs mises à jour.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added">
|
||||
<plurals name="import_keys_added">
|
||||
<item quantity="one">%d clef ajoutée avec succès.</item>
|
||||
<item quantity="other">%d clefs ajoutées avec succès.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_updated">
|
||||
<plurals name="import_keys_updated">
|
||||
<item quantity="one">%d clef mise à jour avec succès.</item>
|
||||
<item quantity="other">%d clefs mises à jour avec succès.</item>
|
||||
</plurals>
|
||||
<string name="no_keys_added_or_updated">Aucune clef ajoutée ou mise à jour.</string>
|
||||
<string name="import_error_nothing">Aucune clef ajoutée ou mise à jour.</string>
|
||||
<string name="key_exported">1 clef exportée avec succès.</string>
|
||||
<string name="keys_exported">%d clefs exportées avec succès.</string>
|
||||
<string name="no_keys_exported">Aucune clef exportée.</string>
|
||||
|
@ -206,23 +206,23 @@
|
||||
<string name="ask_empty_id_ok">Hai aggiunto una identità vuota, sei sicuro di voler continuare?</string>
|
||||
<string name="public_key_deletetion_confirmation">Vuoi veramente eliminare la chiave pubblica \'%s\'?\nNon potrai annullare!</string>
|
||||
<string name="also_export_secret_keys">Esportare anche le chiavi segrete?</string>
|
||||
<plurals name="keys_added_and_updated_1">
|
||||
<plurals name="import_keys_added_and_updated_1">
|
||||
<item quantity="one">%d chiave aggiunta correttamente</item>
|
||||
<item quantity="other">%d chiavi aggiunte correttamente</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added_and_updated_2">
|
||||
<plurals name="import_keys_added_and_updated_2">
|
||||
<item quantity="one">e %d chiave aggiornata.</item>
|
||||
<item quantity="other">e %d chiavi aggiornate.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added">
|
||||
<plurals name="import_keys_added">
|
||||
<item quantity="one">%d chiave aggiunta correttamente.</item>
|
||||
<item quantity="other">%d chiavi aggiunte correttamente.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_updated">
|
||||
<plurals name="import_keys_updated">
|
||||
<item quantity="one">%d chiave aggiornata correttamente.</item>
|
||||
<item quantity="other">%d chiavi aggiornate correttamente.</item>
|
||||
</plurals>
|
||||
<string name="no_keys_added_or_updated">Nessuna chiave aggiunta o aggiornata.</string>
|
||||
<string name="import_error_nothing">Nessuna chiave aggiunta o aggiornata.</string>
|
||||
<string name="key_exported">1 chiave esportata correttamente.</string>
|
||||
<string name="keys_exported">%d chiavi esportate correttamente.</string>
|
||||
<string name="no_keys_exported">Nessuna chiave esportata.</string>
|
||||
|
@ -203,19 +203,19 @@
|
||||
<string name="ask_empty_id_ok">あなたは空のユーザIDを追加しました、このまま続けますか?</string>
|
||||
<string name="public_key_deletetion_confirmation">公開鍵\'%s\'を本当に削除してもよいですか?\nこれは元に戻せません!</string>
|
||||
<string name="also_export_secret_keys">秘密鍵もエクスポートしますか?</string>
|
||||
<plurals name="keys_added_and_updated_1">
|
||||
<plurals name="import_keys_added_and_updated_1">
|
||||
<item quantity="other">%d の鍵を追加しました</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added_and_updated_2">
|
||||
<plurals name="import_keys_added_and_updated_2">
|
||||
<item quantity="other">そして %d の鍵をアップロードしました。</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added">
|
||||
<plurals name="import_keys_added">
|
||||
<item quantity="other">%d の鍵を追加しました。</item>
|
||||
</plurals>
|
||||
<plurals name="keys_updated">
|
||||
<plurals name="import_keys_updated">
|
||||
<item quantity="other">%d の鍵をアップロードしました。</item>
|
||||
</plurals>
|
||||
<string name="no_keys_added_or_updated">鍵の追加もしくは更新はありませんでした。</string>
|
||||
<string name="import_error_nothing">鍵の追加もしくは更新はありませんでした。</string>
|
||||
<string name="key_exported">1つの鍵をエクスポートしました。</string>
|
||||
<string name="keys_exported">%d の鍵をエクスポートしました。</string>
|
||||
<string name="no_keys_exported">鍵をエクスポートしていません。</string>
|
||||
|
@ -206,23 +206,23 @@
|
||||
<string name="ask_empty_id_ok">U heeft een lege identiteit toegevoegd, weet u zeker dat u wilt doorgaan?</string>
|
||||
<string name="public_key_deletetion_confirmation">Wilt u echt de publieke sleutel \'%s\' verwijderen?\nDit kunt u niet ongedaan maken!</string>
|
||||
<string name="also_export_secret_keys">Ook geheime sleutels exporteren?</string>
|
||||
<plurals name="keys_added_and_updated_1">
|
||||
<plurals name="import_keys_added_and_updated_1">
|
||||
<item quantity="one">Succesvol %d sleutel toegevoegd</item>
|
||||
<item quantity="other">Succesvol %d sleutels toegevoegd</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added_and_updated_2">
|
||||
<plurals name="import_keys_added_and_updated_2">
|
||||
<item quantity="one">en %d sleutel bijgewerkt.</item>
|
||||
<item quantity="other">en %d sleutels bijgewerkt.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added">
|
||||
<plurals name="import_keys_added">
|
||||
<item quantity="one">Succesvol %d sleutel toegevoegd.</item>
|
||||
<item quantity="other">Succesvol %d sleutels toegevoegd.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_updated">
|
||||
<plurals name="import_keys_updated">
|
||||
<item quantity="one">Succesvol %d sleutel bijgewerkt.</item>
|
||||
<item quantity="other">Succesvol %d sleutels bijgewerkt.</item>
|
||||
</plurals>
|
||||
<string name="no_keys_added_or_updated">Geen sleutels toegevoegd of bijgewerkt.</string>
|
||||
<string name="import_error_nothing">Geen sleutels toegevoegd of bijgewerkt.</string>
|
||||
<string name="key_exported">1 sleutel succesvol geëxporteerd.</string>
|
||||
<string name="keys_exported">Succesvol %d sleutels geëxporteerd.</string>
|
||||
<string name="no_keys_exported">Geen sleutels geëxporteerd.</string>
|
||||
|
@ -191,27 +191,27 @@
|
||||
<string name="ask_save_changed_key">Zostały dokonane zmiany w pęku kluczy, czy chcesz je zachować?</string>
|
||||
<string name="public_key_deletetion_confirmation">Czy na pewno chcesz usunąć klucz publiczny \'%s\'?\nNie można cofnąć tej operacji!</string>
|
||||
<string name="also_export_secret_keys">Czy wyeksportować również klucze prywatne?</string>
|
||||
<plurals name="keys_added_and_updated_1">
|
||||
<plurals name="import_keys_added_and_updated_1">
|
||||
<item quantity="one">Pomyślnie dodano %d klucz</item>
|
||||
<item quantity="few">Pomyślnie dodano %d kluczy</item>
|
||||
<item quantity="other">Pomyślnie dodano %d kluczy</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added_and_updated_2">
|
||||
<plurals name="import_keys_added_and_updated_2">
|
||||
<item quantity="one">i zaktualizowano %d klucz.</item>
|
||||
<item quantity="few">i zaktualizowano %d kluczy.</item>
|
||||
<item quantity="other">i zaktualizowano %d kluczy.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added">
|
||||
<plurals name="import_keys_added">
|
||||
<item quantity="one">Pomyślnie dodano %d klucz.</item>
|
||||
<item quantity="few">Pomyślnie dodano %d kluczy.</item>
|
||||
<item quantity="other">Pomyślnie dodano %d kluczy.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_updated">
|
||||
<plurals name="import_keys_updated">
|
||||
<item quantity="one">Pomyślnie zaktualizowano %d klucz.</item>
|
||||
<item quantity="few">Pomyślnie zaktualizowano %d kluczy.</item>
|
||||
<item quantity="other">Pomyślnie zaktualizowano %d kluczy.</item>
|
||||
</plurals>
|
||||
<string name="no_keys_added_or_updated">Nie dodano ani zaktualizowano żadnych kluczy.</string>
|
||||
<string name="import_error_nothing">Nie dodano ani zaktualizowano żadnych kluczy.</string>
|
||||
<string name="key_exported">Pomyślnie wyeksportowano 1 klucz.</string>
|
||||
<string name="keys_exported">Pomyślnie wyeksportowano %d kluczy.</string>
|
||||
<string name="no_keys_exported">Nie wyeksportowano żadnych kluczy.</string>
|
||||
|
@ -206,27 +206,27 @@
|
||||
<string name="ask_empty_id_ok">Вы добавили пустой идентификатор. Вы уверены, что хотите продолжить?</string>
|
||||
<string name="public_key_deletetion_confirmation">Вы правда хотите удалить публичный ключ \'%s\'?\nЭто действие нельзя отменить!</string>
|
||||
<string name="also_export_secret_keys">Экспортировать секретные ключи?</string>
|
||||
<plurals name="keys_added_and_updated_1">
|
||||
<plurals name="import_keys_added_and_updated_1">
|
||||
<item quantity="one">Успешно добавлено %d ключ</item>
|
||||
<item quantity="few">Успешно добавлено %d ключей</item>
|
||||
<item quantity="other">Успешно добавлено %d ключей</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added_and_updated_2">
|
||||
<plurals name="import_keys_added_and_updated_2">
|
||||
<item quantity="one">и обновлен %d ключ.</item>
|
||||
<item quantity="few">и обновлено %d ключей.</item>
|
||||
<item quantity="other">и обновлено %d ключей.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added">
|
||||
<plurals name="import_keys_added">
|
||||
<item quantity="one">Добавлен %d ключ</item>
|
||||
<item quantity="few">Добавлено %d ключей</item>
|
||||
<item quantity="other">Добавлено %d ключей</item>
|
||||
</plurals>
|
||||
<plurals name="keys_updated">
|
||||
<plurals name="import_keys_updated">
|
||||
<item quantity="one">Обновлен %d ключ.</item>
|
||||
<item quantity="few">Обновлено %d ключей.</item>
|
||||
<item quantity="other">Обновлено %d ключей.</item>
|
||||
</plurals>
|
||||
<string name="no_keys_added_or_updated">Нет обновленных или добавленных ключей</string>
|
||||
<string name="import_error_nothing">Нет обновленных или добавленных ключей</string>
|
||||
<string name="key_exported">Успешный экспорт 1 ключа.</string>
|
||||
<string name="keys_exported">Экспортировано %d ключей.</string>
|
||||
<string name="no_keys_exported">Ключи не были экспортированы.</string>
|
||||
|
@ -212,31 +212,31 @@
|
||||
<string name="ask_empty_id_ok">Dodali ste prazno identiteto, ali res želite nadaljevati?</string>
|
||||
<string name="public_key_deletetion_confirmation">Ali res želite izbrisati javni ključ \'%s\'?\nTega koraka ne boste mogli preklicati!</string>
|
||||
<string name="also_export_secret_keys">Želite izvoziti tudi zasebne ključe?</string>
|
||||
<plurals name="keys_added_and_updated_1">
|
||||
<plurals name="import_keys_added_and_updated_1">
|
||||
<item quantity="one">Uspešno dodan %d ključ</item>
|
||||
<item quantity="two">Uspešno dodana %d ključa</item>
|
||||
<item quantity="few">Uspešno dodani %d ključi</item>
|
||||
<item quantity="other">Uspešno dodanih %d ključev</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added_and_updated_2">
|
||||
<plurals name="import_keys_added_and_updated_2">
|
||||
<item quantity="one">in posodbljen %d.</item>
|
||||
<item quantity="two">in posodobljena %d.</item>
|
||||
<item quantity="few">in posodobljeni %d.</item>
|
||||
<item quantity="other">in posodobljenih %d.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added">
|
||||
<plurals name="import_keys_added">
|
||||
<item quantity="one">Uspešno dodan %d ključ.</item>
|
||||
<item quantity="two">Uspešno dodana %d ključa.</item>
|
||||
<item quantity="few">Uspešno dodani %d ključi.</item>
|
||||
<item quantity="other">Uspešno dodanih %d ključev.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_updated">
|
||||
<plurals name="import_keys_updated">
|
||||
<item quantity="one">Uspešno posodobljen %d ključ.</item>
|
||||
<item quantity="two">Uspešno posodobljena %d ključa.</item>
|
||||
<item quantity="few">Uspešno posodobljeni %d ključi.</item>
|
||||
<item quantity="other">Uspešno posodobljenih %d ključev.</item>
|
||||
</plurals>
|
||||
<string name="no_keys_added_or_updated">Noben ključ ni bil dodan ali posodobljen.</string>
|
||||
<string name="import_error_nothing">Noben ključ ni bil dodan ali posodobljen.</string>
|
||||
<string name="key_exported">Uspešno izvožen 1 ključ.</string>
|
||||
<string name="keys_exported">Uspešno izvoženih ključev: %d</string>
|
||||
<string name="no_keys_exported">Noben ključ ni bil izvožen.</string>
|
||||
|
@ -209,27 +209,27 @@
|
||||
<string name="ask_empty_id_ok">Ви вже додали порожню сутність. Ви справді хочете продовжити?</string>
|
||||
<string name="public_key_deletetion_confirmation">Ви справді хочете вилучити відкритий ключ \'%s\'?\nВи не зможете це відмінити!</string>
|
||||
<string name="also_export_secret_keys">Також експортувати секретні ключі?</string>
|
||||
<plurals name="keys_added_and_updated_1">
|
||||
<plurals name="import_keys_added_and_updated_1">
|
||||
<item quantity="one">Успішно додано %d ключ</item>
|
||||
<item quantity="few">Успішно додано %d ключі</item>
|
||||
<item quantity="other">Успішно додано %d ключів</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added_and_updated_2">
|
||||
<plurals name="import_keys_added_and_updated_2">
|
||||
<item quantity="one">і оновлено %d ключ.</item>
|
||||
<item quantity="few">і оновлено %d ключі.</item>
|
||||
<item quantity="other">і оновлено %d ключів.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added">
|
||||
<plurals name="import_keys_added">
|
||||
<item quantity="one">Успішно додано %d ключ.</item>
|
||||
<item quantity="few">Успішно додано %d ключі.</item>
|
||||
<item quantity="other">Успішно додано %d ключів.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_updated">
|
||||
<plurals name="import_keys_updated">
|
||||
<item quantity="one">Успішно оновлено %d ключ.</item>
|
||||
<item quantity="few">Успішно оновлено %d ключі.</item>
|
||||
<item quantity="other">Успішно оновлено %d ключів.</item>
|
||||
</plurals>
|
||||
<string name="no_keys_added_or_updated">Жодного ключа не додано та не оновлено.</string>
|
||||
<string name="import_error_nothing">Жодного ключа не додано та не оновлено.</string>
|
||||
<string name="key_exported">Успішно експортовано 1 ключ.</string>
|
||||
<string name="keys_exported">Успішно експортовано %d ключів.</string>
|
||||
<string name="no_keys_exported">Жодного ключа не експортовано.</string>
|
||||
|
@ -28,6 +28,7 @@
|
||||
<string name="title_certify_key">Certify Identities</string>
|
||||
<string name="title_key_details">Key Details</string>
|
||||
<string name="title_help">Help</string>
|
||||
<string name="title_log_display">Log</string>
|
||||
|
||||
<!-- section -->
|
||||
<string name="section_user_ids">Identities</string>
|
||||
@ -102,6 +103,7 @@
|
||||
<string name="menu_select_all">Select all</string>
|
||||
<string name="menu_add_keys">Add keys</string>
|
||||
<string name="menu_export_all_keys">Export all keys</string>
|
||||
<string name="menu_advanced">Show advanced info</string>
|
||||
|
||||
<!-- label -->
|
||||
<string name="label_sign">Sign</string>
|
||||
@ -220,24 +222,6 @@
|
||||
<string name="public_key_deletetion_confirmation">Do you really want to delete the public key \'%s\'?\nYou can\'t undo this!</string>
|
||||
<string name="also_export_secret_keys">Also export secret keys?</string>
|
||||
|
||||
<plurals name="keys_added_and_updated_1">
|
||||
<item quantity="one">Successfully added %d key</item>
|
||||
<item quantity="other">Successfully added %d keys</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added_and_updated_2">
|
||||
<item quantity="one"> and updated %d key.</item>
|
||||
<item quantity="other"> and updated %d keys.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_added">
|
||||
<item quantity="one">Successfully added %d key.</item>
|
||||
<item quantity="other">Successfully added %d keys.</item>
|
||||
</plurals>
|
||||
<plurals name="keys_updated">
|
||||
<item quantity="one">Successfully updated %d key.</item>
|
||||
<item quantity="other">Successfully updated %d keys.</item>
|
||||
</plurals>
|
||||
|
||||
<string name="no_keys_added_or_updated">No keys added or updated.</string>
|
||||
<string name="key_exported">Successfully exported 1 key.</string>
|
||||
<string name="keys_exported">Successfully exported %d keys.</string>
|
||||
<string name="no_keys_exported">No keys exported.</string>
|
||||
@ -406,6 +390,28 @@
|
||||
<string name="import_clipboard_button">Get key from clipboard</string>
|
||||
<string name="import_keybase_button">Get key from Keybase.io</string>
|
||||
|
||||
<!-- Import result toast -->
|
||||
<plurals name="import_keys_added_and_updated_1">
|
||||
<item quantity="one">Successfully added %1$d key</item>
|
||||
<item quantity="other">Successfully added %1$d keys</item>
|
||||
</plurals>
|
||||
<plurals name="import_keys_added_and_updated_2">
|
||||
<item quantity="one"> and updated %1$d key%2$s.</item>
|
||||
<item quantity="other"> and updated %1$d keys%2$s.</item>
|
||||
</plurals>
|
||||
<plurals name="import_keys_added">
|
||||
<item quantity="one">Successfully added %1$d key%2$s.</item>
|
||||
<item quantity="other">Successfully added %1$d keys%2$s.</item>
|
||||
</plurals>
|
||||
<plurals name="import_keys_updated">
|
||||
<item quantity="one">Successfully updated %1$d key%2$s.</item>
|
||||
<item quantity="other">Successfully updated %1$d keys%2$s.</item>
|
||||
</plurals>
|
||||
<string name="import_view_log">View Log</string>
|
||||
<string name="import_error_nothing">Nothing to import.</string>
|
||||
<string name="import_error">Error importing keys!</string>
|
||||
<string name="import_with_warnings">, with warnings</string>
|
||||
|
||||
<!-- Intent labels -->
|
||||
<string name="intent_decrypt_file">Decrypt File with OpenKeychain</string>
|
||||
<string name="intent_import_key">Import Key with OpenKeychain</string>
|
||||
@ -499,6 +505,91 @@
|
||||
<string name="cert_verify_error">error!</string>
|
||||
<string name="cert_verify_unavailable">key unavailable</string>
|
||||
|
||||
<!-- Import Public log entries -->
|
||||
<string name="msg_ip_apply_batch">Applying insert batch operation.</string>
|
||||
<string name="msg_ip_bad_type_secret">Tried to import secret keyring as public. This is a bug, please file a report!</string>
|
||||
<string name="msg_ip_delete_old_fail">No old key deleted (creating a new one?)</string>
|
||||
<string name="msg_ip_delete_old_ok">Deleted old key from database</string>
|
||||
<string name="msg_ip_encode_fail">Operation failed due to encoding error</string>
|
||||
<string name="msg_ip_fail_io_exc">Operation failed due to i/o error</string>
|
||||
<string name="msg_ip_fail_op_ex">Operation failed due to database error</string>
|
||||
<string name="msg_ip_fail_remote_ex">Operation failed due to internal error</string>
|
||||
<string name="msg_ip">Importing public keyring %s</string>
|
||||
<string name="msg_ip_insert_keyring">Encoding keyring data</string>
|
||||
<string name="msg_ip_insert_subkeys">Evaluating subkeys</string>
|
||||
<string name="msg_ip_prepare">Preparing database operations</string>
|
||||
<string name="msg_ip_prepare_success">OK</string>
|
||||
<string name="msg_ip_preserving_secret">Preserving available secret key</string>
|
||||
<string name="msg_ip_subkey">Processing subkey %s</string>
|
||||
<string name="msg_ip_subkey_expired">Subkey expired on %s</string>
|
||||
<string name="msg_ip_subkey_expires">Subkey expires on %s</string>
|
||||
<string name="msg_ip_subkey_flags">Subkey flags: %s</string>
|
||||
<string name="msg_ip_subkey_flags_ces">Subkey flags: certify, encrypt, sign</string>
|
||||
<string name="msg_ip_subkey_flags_cex">Subkey flags: certify, encrypt</string>
|
||||
<string name="msg_ip_subkey_flags_cxs">Subkey flags: certify, sign</string>
|
||||
<string name="msg_ip_subkey_flags_xes">Subkey flags: encrypt, sign</string>
|
||||
<string name="msg_ip_subkey_flags_cxx">Subkey flags: certify</string>
|
||||
<string name="msg_ip_subkey_flags_xex">Subkey flags: encrypt</string>
|
||||
<string name="msg_ip_subkey_flags_xxs">Subkey flags: sign</string>
|
||||
<string name="msg_ip_subkey_flags_xxx">Subkey flags: none</string>
|
||||
<string name="msg_ip_success">Successfully imported public keyring</string>
|
||||
<string name="msg_ip_reinsert_secret">Re-inserting secret key</string>
|
||||
<string name="msg_ip_uid_cert_bad">Encountered bad certificate!</string>
|
||||
<string name="msg_ip_uid_cert_error">Error processing certificate!</string>
|
||||
<string name="msg_ip_uid_cert_good">Found good certificate from %1$s (%2$s)</string>
|
||||
<string name="msg_ip_uid_certs_unknown">Ignoring %s certificates from unknown pubkeys</string>
|
||||
<string name="msg_ip_uid_classifying">Classifying user ids, using %s trusted signatures</string>
|
||||
<string name="msg_ip_uid_reorder">Re-ordering user ids</string>
|
||||
<string name="msg_ip_uid_processing">Processing user id %s</string>
|
||||
<string name="msg_ip_uid_revoked">Found uid revocation certificate</string>
|
||||
<string name="msg_ip_uid_self_good">Found good self certificate</string>
|
||||
<string name="msg_is_bad_type_public">Tried to import public keyring as secret. This is a bug, please file a report!</string>
|
||||
|
||||
<!-- Import Secret log entries -->
|
||||
<string name="msg_is">Importing secret key %s</string>
|
||||
<string name="msg_is_importing_subkeys">Processing secret subkeys</string>
|
||||
<string name="msg_is_io_excption">Error encoding keyring</string>
|
||||
<string name="msg_is_subkey_nonexistent">Subkey %s unavailable in public key</string>
|
||||
<string name="msg_is_subkey_ok">Marked %s as available</string>
|
||||
<string name="msg_is_subkey_stripped">Marked %s as stripped</string>
|
||||
<string name="msg_is_success">Successfully imported secret keyring</string>
|
||||
|
||||
<!-- Keyring Canonicalization log entries -->
|
||||
<string name="msg_kc">Canonicalizing keyring %s</string>
|
||||
<string name="msg_kc_master">Processing master key</string>
|
||||
<string name="msg_kc_master_success">OK</string>
|
||||
<string name="msg_kc_revoke_bad_err">Removing bad keyring revocation certificate</string>
|
||||
<string name="msg_kc_revoke_bad_local">Removing keyring revocation certificate with "local" flag</string>
|
||||
<string name="msg_kc_revoke_bad_time">Removing keyring revocation certificate with future timestamp</string>
|
||||
<string name="msg_kc_revoke_bad_type">Removing master key certificate of unknown type (%s)</string>
|
||||
<string name="msg_kc_revoke_bad">Removing bad keyring revocation certificate</string>
|
||||
<string name="msg_kc_revoke_dup">Removing redundant keyring revocation certificate</string>
|
||||
<string name="msg_kc_sub">Processing subkey %s</string>
|
||||
<string name="msg_kc_sub_bad">Removing invalid subkey binding certificate</string>
|
||||
<string name="msg_kc_sub_bad_err">Removing bad subkey binding certificate</string>
|
||||
<string name="msg_kc_sub_bad_local">Removing subkey binding certificate with "local" flag</string>
|
||||
<string name="msg_kc_sub_bad_keyid">Subkey binding issuer id mismatch</string>
|
||||
<string name="msg_kc_sub_bad_time">Removing subkey binding certificate with future timestamp</string>
|
||||
<string name="msg_kc_sub_bad_type">Unknown subkey certificate type: %s</string>
|
||||
<string name="msg_kc_sub_primary_bad">Removing subkey binding certificate due to invalid primary binding certificate</string>
|
||||
<string name="msg_kc_sub_primary_bad_err">Removing subkey binding certificate due to bad primary binding certificate</string>
|
||||
<string name="msg_kc_sub_primary_none">Removing subkey binding certificate due to missing primary binding certificate</string>
|
||||
<string name="msg_kc_sub_no_cert">No valid certificate found for %s, removing from ring</string>
|
||||
<string name="msg_kc_sub_revoke_bad_err">Removing bad subkey revocation key</string>
|
||||
<string name="msg_kc_sub_revoke_bad">Removing bad subkey revocation key</string>
|
||||
<string name="msg_kc_sub_revoke_dup">Removing redundant keyring revocation key</string>
|
||||
<string name="msg_kc_sub_success">Subkey binding OK</string>
|
||||
<string name="msg_kc_success">Keyring canonicalization successful</string>
|
||||
<string name="msg_kc_success_removed">Keyring canonicalization successful, removed %s certificates</string>
|
||||
<string name="msg_kc_uid_bad_err">Removing bad self certificate for user id %s</string>
|
||||
<string name="msg_kc_uid_bad_local">Removing user id certificate with "local" flag</string>
|
||||
<string name="msg_kc_uid_bad_time">Removing user id with future timestamp</string>
|
||||
<string name="msg_kc_uid_bad_type">Removing user id certificate of unknown type (%s)</string>
|
||||
<string name="msg_kc_uid_bad">Removing bad self certificate for user id "%s"</string>
|
||||
<string name="msg_kc_uid_dup">Removing outdated self certificate for user id "%s"</string>
|
||||
<string name="msg_kc_uid_revoke_dup">Removing redundant revocation certificate for user id "%s"</string>
|
||||
<string name="msg_kc_uid_revoke_old">Removing outdated revocation certificate for user id "%s"</string>
|
||||
|
||||
<!-- unsorted -->
|
||||
<string name="section_certifier_id">Certifier</string>
|
||||
<string name="section_cert">Certificate Details</string>
|
||||
@ -519,5 +610,7 @@
|
||||
<string name="can_sign_not">cannot sign</string>
|
||||
<string name="error_encoding">Encoding error</string>
|
||||
<string name="error_no_encrypt_subkey">No encryption subkey available!</string>
|
||||
<string name="info_no_manual_account_creation">Do not create OpenKeychain-Accounts manually.\nFor more information, see Help.</string>
|
||||
<string name="contact_show_key">Show key (%s)</string>
|
||||
|
||||
</resources>
|
||||
|
6
OpenKeychain/src/main/res/xml/account_desc.xml
Normal file
6
OpenKeychain/src/main/res/xml/account_desc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:accountType="org.sufficientlysecure.keychain"
|
||||
android:icon="@drawable/icon"
|
||||
android:label="@string/app_name"/>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ContactsSource xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ContactsDataKind android:mimeType="vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.key"
|
||||
android:detailColumn="data1"/>
|
||||
</ContactsSource>
|
6
OpenKeychain/src/main/res/xml/sync_adapter_desc.xml
Normal file
6
OpenKeychain/src/main/res/xml/sync_adapter_desc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:contentAuthority="com.android.contacts"
|
||||
android:accountType="org.sufficientlysecure.keychain"
|
||||
android:supportsUploading="false"
|
||||
android:userVisible="true"/>
|
@ -33,7 +33,7 @@ Development mailinglist at http://groups.google.com/d/forum/openpgp-keychain-dev
|
||||
1. Get all external submodules with ``git submodule update --init --recursive``
|
||||
2. Have Android SDK "tools", "platform-tools", and "build-tools" directories in your PATH (http://developer.android.com/sdk/index.html)
|
||||
3. Open the Android SDK Manager (shell command: ``android``).
|
||||
Expand the Tools directory and select "Android SDK Build-tools (Version 19.0.3)".
|
||||
Expand the Tools directory and select "Android SDK Build-tools (Version 19.1)".
|
||||
Expand the Extras directory and install "Android Support Repository"
|
||||
Select everything for the newest SDK Platform (API-Level 19)
|
||||
4. Export ANDROID_HOME pointing to your Android SDK
|
||||
@ -42,8 +42,8 @@ Select everything for the newest SDK Platform (API-Level 19)
|
||||
|
||||
### Build API Demo with Gradle
|
||||
|
||||
1. Follow 1-3 from above
|
||||
2. Change to API Demo directory ``cd OpenKeychain-API``
|
||||
1. Follow 1-4 from above
|
||||
2. The example code is available at https://github.com/open-keychain/api-example
|
||||
3. Execute ``./gradlew build``
|
||||
|
||||
### Development with Android Studio
|
||||
|
@ -5,8 +5,8 @@ buildscript {
|
||||
|
||||
dependencies {
|
||||
// NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information
|
||||
classpath 'com.android.tools.build:gradle:0.10.0'
|
||||
classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.10.0'
|
||||
classpath 'com.android.tools.build:gradle:0.11.1'
|
||||
//classpath 'org.robolectric.gradle:gradle-android-test-plugin:0.10.0'
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,5 +17,5 @@ allprojects {
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '1.10'
|
||||
gradleVersion = '1.12'
|
||||
}
|
||||
|
2
extern/AndroidBootstrap
vendored
2
extern/AndroidBootstrap
vendored
@ -1 +1 @@
|
||||
Subproject commit bfa160c4ef3a1a53aebd68aca9c05b8e546219e0
|
||||
Subproject commit 02f02391e3eee9331e07d7690d3b533a8b0f69e2
|
2
extern/AppMsg
vendored
2
extern/AppMsg
vendored
@ -1 +1 @@
|
||||
Subproject commit ca714df97bfce67a7a9a1efefd2c49645b6f22e4
|
||||
Subproject commit 61e74741909a712db2e0d31ddffa5b7cf37c21f2
|
2
extern/StickyListHeaders
vendored
2
extern/StickyListHeaders
vendored
@ -1 +1 @@
|
||||
Subproject commit efe46c21143cc54a2394303a67822f14580d1d20
|
||||
Subproject commit 706c0e447229226b6edc82ab10630d39fd0f6c38
|
1
extern/SuperToasts
vendored
Submodule
1
extern/SuperToasts
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 8578cfe6917cf16a9f123c1964e4bbff2a15be59
|
1
extern/dnsjava
vendored
Submodule
1
extern/dnsjava
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 71c8a9e56b19b34907e7e2e810ca15b57e3edc2b
|
2
extern/html-textview
vendored
2
extern/html-textview
vendored
@ -1 +1 @@
|
||||
Subproject commit c31ef2aff4282ad00af98e879e3e0a6000885b55
|
||||
Subproject commit eedaa334e761273efbfc49ded2124df58c8a4d88
|
2
extern/openkeychain-api-lib
vendored
2
extern/openkeychain-api-lib
vendored
@ -1 +1 @@
|
||||
Subproject commit 26497acb27e9f6349c0557b15cd24a5b0b735e74
|
||||
Subproject commit 175a3cb772c88c9b50985abc98f81c9ea69c3659
|
2
extern/openpgp-api-lib
vendored
2
extern/openpgp-api-lib
vendored
@ -1 +1 @@
|
||||
Subproject commit 650e1ebda82596cd4fbfaae406e6eccf189f4f63
|
||||
Subproject commit a77887d32fae68171fcd0d2989bf537c0c11f0b9
|
2
extern/zxing-android-integration
vendored
2
extern/zxing-android-integration
vendored
@ -1 +1 @@
|
||||
Subproject commit 34029d4dcac81ec06137a046a189dac608e76efe
|
||||
Subproject commit 1d787845663fd232f98f5e8e0923733c1a188f2a
|
2
extern/zxing-qr-code
vendored
2
extern/zxing-qr-code
vendored
@ -1 +1 @@
|
||||
Subproject commit 50193905fd8cef92140ea242f77b04bb31391c9e
|
||||
Subproject commit 9ef2f3b66ea7cc283e865ec39434d023a18d17f3
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Thu Mar 06 22:23:44 CET 2014
|
||||
#Mon Jun 09 22:04:23 CEST 2014
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-bin.zip
|
||||
|
@ -11,3 +11,5 @@ include ':extern:spongycastle:pg'
|
||||
include ':extern:spongycastle:pkix'
|
||||
include ':extern:spongycastle:prov'
|
||||
include ':extern:AppMsg:library'
|
||||
include ':extern:SuperToasts:supertoasts'
|
||||
include ':extern:dnsjava'
|
||||
|
Loading…
Reference in New Issue
Block a user