ditch safeslinger

This commit is contained in:
Vincent Breitmoser 2019-11-15 11:23:21 +01:00
parent 46a25451ba
commit 573ea47a40
9 changed files with 3 additions and 289 deletions

4
.gitmodules vendored
View File

@ -10,10 +10,6 @@
path = extern/minidns
url = https://github.com/open-keychain/minidns.git
ignore = dirty
[submodule "extern/safeslinger-exchange"]
path = extern/safeslinger-exchange
url = https://github.com/open-keychain/exchange-android
ignore = dirty
[submodule "OpenKeychain/src/test/resources/openpgp-interop"]
path = OpenKeychain/src/test/resources/openpgp-interop
url = https://github.com/google/openpgp-interop

View File

@ -62,7 +62,6 @@ dependencies {
implementation project(':extern:bouncycastle:prov')
implementation project(':extern:minidns')
implementation project(':KeybaseLib')
implementation project(':safeslinger-exchange')
implementation project(':extern:MaterialChipsInput')
implementation "android.arch.work:work-runtime:1.0.0-alpha02"

View File

@ -166,16 +166,6 @@
<data android:mimeType="vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.key" />
</intent-filter>
</activity>
<activity
android:name=".ui.SafeSlingerActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:label="@string/title_exchange_keys"
android:parentActivityName=".ui.MainActivity"
android:windowSoftInputMode="stateHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.MainActivity" />
</activity>
<activity
android:name=".ui.EncryptFilesActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"

View File

@ -188,12 +188,6 @@ public class KeyListFragment extends RecyclerFragment<FlexibleAdapter<FlexibleKe
return false;
}
public void startSafeSlingerForKey(long masterKeyId) {
Intent safeSlingerIntent = new Intent(getActivity(), SafeSlingerActivity.class);
safeSlingerIntent.putExtra(SafeSlingerActivity.EXTRA_MASTER_KEY_ID, masterKeyId);
startActivityForResult(safeSlingerIntent, REQUEST_ACTION);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.key_list_fragment, container, false);

View File

@ -1,218 +0,0 @@
/*
* Copyright (C) 2017 Schürmann & Breitmoser GbR
*
* 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.ui;
import java.io.IOException;
import java.util.ArrayList;
import android.annotation.TargetApi;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.NumberPicker;
import edu.cmu.cylab.starslinger.exchange.ExchangeActivity;
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.keyimport.HkpKeyserverAddress;
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
import org.sufficientlysecure.keychain.operations.ImportOperation;
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
import org.sufficientlysecure.keychain.operations.results.OperationResult;
import org.sufficientlysecure.keychain.daos.KeyRepository;
import org.sufficientlysecure.keychain.daos.KeyRepository.NotFoundException;
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
import timber.log.Timber;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class SafeSlingerActivity extends BaseActivity
implements CryptoOperationHelper.Callback<ImportKeyringParcel, ImportKeyResult> {
private static final int REQUEST_CODE_SAFE_SLINGER = 211;
public static final String EXTRA_MASTER_KEY_ID = "master_key_id";
private long mMasterKeyId;
private int mSelectedNumber = 2;
// for CryptoOperationHelper
private ArrayList<ParcelableKeyRing> mKeyList;
private HkpKeyserverAddress mKeyserver;
private CryptoOperationHelper<ImportKeyringParcel, ImportKeyResult> mOperationHelper;
private KeyRepository keyRepository;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
keyRepository = KeyRepository.create(this);
mMasterKeyId = getIntent().getLongExtra(EXTRA_MASTER_KEY_ID, 0);
NumberPicker picker = findViewById(R.id.safe_slinger_picker);
picker.setMinValue(2);
picker.setMaxValue(10);
picker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
mSelectedNumber = newVal;
}
});
ImageView buttonIcon = findViewById(R.id.safe_slinger_button_image);
buttonIcon.setColorFilter(FormattingUtils.getColorFromAttr(this, R.attr.colorTertiaryText),
PorterDuff.Mode.SRC_IN);
View button = findViewById(R.id.safe_slinger_button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startExchange(mMasterKeyId, mSelectedNumber);
}
});
}
@Override
protected void initLayout() {
setContentView(R.layout.safe_slinger_activity);
}
private void startExchange(long masterKeyId, int number) {
try {
byte[] keyBlob = keyRepository.loadPublicKeyRingData(masterKeyId);
Intent slingerIntent = new Intent(this, ExchangeActivity.class);
slingerIntent.putExtra(ExchangeConfig.extra.NUM_USERS, number);
slingerIntent.putExtra(ExchangeConfig.extra.USER_DATA, keyBlob);
slingerIntent.putExtra(ExchangeConfig.extra.HOST_NAME, Constants.SAFESLINGER_SERVER);
startActivityForResult(slingerIntent, REQUEST_CODE_SAFE_SLINGER);
} catch (NotFoundException e) {
Timber.e(e, "key for transfer not found");
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (mOperationHelper != null) {
mOperationHelper.handleActivityResult(requestCode, resultCode, data);
}
if (requestCode == REQUEST_CODE_SAFE_SLINGER) {
if (resultCode == ExchangeActivity.RESULT_EXCHANGE_CANCELED) {
return;
}
Timber.d("importKeys started");
// instead of giving the entries by Intent extra, cache them into a
// file to prevent Java Binder problems on heavy imports
// read FileImportCache for more info.
try {
// import exchanged keys
ArrayList<ParcelableKeyRing> it = getSlingedKeys(data.getExtras());
// We parcel this iteratively into a file - anything we can
// display here, we should be able to import.
ParcelableFileCache<ParcelableKeyRing> cache =
new ParcelableFileCache<>(this, ImportOperation.CACHE_FILE_NAME);
cache.writeCache(it.size(), it.iterator());
mOperationHelper =
new CryptoOperationHelper(1, this, this, R.string.progress_importing);
mKeyList = null;
mKeyserver = null;
mOperationHelper.cryptoOperation();
} catch (IOException e) {
Timber.e(e, "Problem writing cache file");
Notify.create(this, "Problem writing cache file!", Notify.Style.ERROR).show();
}
} else {
// give everything else down to KeyListActivity!
setResult(resultCode, data);
finish();
}
}
private static ArrayList<ParcelableKeyRing> getSlingedKeys(Bundle extras) {
ArrayList<ParcelableKeyRing> list = new ArrayList<>();
if (extras != null) {
byte[] d;
int i = 0;
do {
d = extras.getByteArray(ExchangeConfig.extra.MEMBER_DATA + i);
if (d != null) {
list.add(ParcelableKeyRing.createFromEncodedBytes(d));
i++;
}
} while (d != null);
}
return list;
}
// CryptoOperationHelper.Callback functions
@Override
public ImportKeyringParcel createOperationInput() {
return ImportKeyringParcel.createImportKeyringParcel(mKeyList, mKeyserver);
}
@Override
public void onCryptoOperationSuccess(ImportKeyResult result) {
Intent certifyIntent = new Intent(this, CertifyKeyActivity.class);
certifyIntent.putExtra(CertifyKeyActivity.EXTRA_RESULT, result);
certifyIntent.putExtra(CertifyKeyActivity.EXTRA_KEY_IDS, result.getImportedMasterKeyIds());
certifyIntent.putExtra(CertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, mMasterKeyId);
startActivityForResult(certifyIntent, 0);
}
@Override
public void onCryptoOperationCancelled() {
}
@Override
public void onCryptoOperationError(ImportKeyResult result) {
Bundle returnData = new Bundle();
returnData.putParcelable(OperationResult.EXTRA_RESULT, result);
Intent data = new Intent();
data.putExtras(returnData);
setResult(RESULT_OK, data);
finish();
}
@Override
public boolean onCryptoSetProgress(String msg, int progress, int max) {
return false;
}
}

View File

@ -28,7 +28,6 @@ import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -40,15 +39,14 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.livedata.GenericLiveData;
import org.sufficientlysecure.keychain.model.SubKey.UnifiedKeyInfo;
import org.sufficientlysecure.keychain.ui.ViewKeyAdvActivity.ViewKeyAdvViewModel;
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
@ -99,12 +97,9 @@ public class ViewKeyAdvShareFragment extends Fragment {
View vFingerprintClipboardButton = view.findViewById(R.id.view_key_action_fingerprint_clipboard);
View vKeyShareButton = view.findViewById(R.id.view_key_action_key_share);
View vKeyClipboardButton = view.findViewById(R.id.view_key_action_key_clipboard);
ImageButton vKeySafeSlingerButton = view.findViewById(R.id.view_key_action_key_safeslinger);
View vKeySshShareButton = view.findViewById(R.id.view_key_action_key_ssh_share);
View vKeySshClipboardButton = view.findViewById(R.id.view_key_action_key_ssh_clipboard);
View vKeyUploadButton = view.findViewById(R.id.view_key_action_upload);
vKeySafeSlingerButton.setColorFilter(FormattingUtils.getColorFromAttr(requireContext(), R.attr.colorTertiaryText),
PorterDuff.Mode.SRC_IN);
vFingerprintShareButton.setOnClickListener(v -> shareFingerprint(false));
vFingerprintClipboardButton.setOnClickListener(v -> shareFingerprint(true));
@ -113,7 +108,6 @@ public class ViewKeyAdvShareFragment extends Fragment {
vKeyClipboardButton.setOnClickListener(v -> ShareKeyHelper.shareKeyToClipboard(getActivity(), unifiedKeyInfo.master_key_id()));
vKeySafeSlingerButton.setOnClickListener(v -> startSafeSlinger());
vKeySshShareButton.setOnClickListener(v -> ShareKeyHelper.shareSshKey(getActivity(), unifiedKeyInfo.master_key_id()));
vKeySshClipboardButton.setOnClickListener(v -> ShareKeyHelper.shareSshKeyToClipboard(getActivity(), unifiedKeyInfo.master_key_id()));
@ -122,12 +116,6 @@ public class ViewKeyAdvShareFragment extends Fragment {
return view;
}
private void startSafeSlinger() {
Intent safeSlingerIntent = new Intent(getActivity(), SafeSlingerActivity.class);
safeSlingerIntent.putExtra(SafeSlingerActivity.EXTRA_MASTER_KEY_ID, unifiedKeyInfo.master_key_id());
startActivityForResult(safeSlingerIntent, 0);
}
private void shareFingerprint(boolean toClipboard) {
Activity activity = getActivity();
if (activity == null || unifiedKeyInfo == null) {

View File

@ -91,7 +91,6 @@ import org.sufficientlysecure.keychain.ui.ImportKeysProxyActivity;
import org.sufficientlysecure.keychain.ui.MainActivity;
import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
import org.sufficientlysecure.keychain.ui.QrCodeViewActivity;
import org.sufficientlysecure.keychain.ui.SafeSlingerActivity;
import org.sufficientlysecure.keychain.ui.ViewKeyAdvActivity;
import org.sufficientlysecure.keychain.ui.ViewKeyKeybaseFragment;
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity;
@ -267,11 +266,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity {
actionShareClipboard.setOnClickListener(v -> ShareKeyHelper.shareKeyToClipboard(this, masterKeyId));
floatingActionButton.setOnClickListener(v -> {
if (unifiedKeyInfo.has_any_secret()) {
startSafeSlinger();
} else {
scanQrCode();
}
scanQrCode();
});
qrCodeLayout.setOnClickListener(v -> showQrCodeDialog());
@ -592,12 +587,6 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity {
startActivityForResult(intent, 0);
}
private void startSafeSlinger() {
Intent safeSlingerIntent = new Intent(this, SafeSlingerActivity.class);
safeSlingerIntent.putExtra(SafeSlingerActivity.EXTRA_MASTER_KEY_ID, unifiedKeyInfo.master_key_id());
startActivityForResult(safeSlingerIntent, 0);
}
/**
* Load QR Code asynchronously and with a fade in animation
*/
@ -778,8 +767,7 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity {
actionShare.setVisibility(View.VISIBLE);
actionShareClipboard.setVisibility(View.VISIBLE);
showFab();
floatingActionButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_repeat_white_24dp));
hideFab();
} else {
actionEncryptFile.setVisibility(View.VISIBLE);
actionEncryptText.setVisibility(View.VISIBLE);

View File

@ -134,23 +134,6 @@
android:layout_gravity="center_vertical"
android:background="?android:selectableItemBackground" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:gravity="right"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/listDivider" />
<ImageButton
android:id="@+id/view_key_action_key_safeslinger"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
android:src="@drawable/ic_repeat_grey_24dp"
android:layout_gravity="center_vertical"
android:background="?android:selectableItemBackground" />
</LinearLayout>
<View

View File

@ -8,12 +8,6 @@ include ':extern:minidns'
include ':extern:MaterialChipsInput:library'
// Workaround for Android Gradle Plugin 2.0, as described in http://stackoverflow.com/a/36544850
//include ':libkeychain'
include ':libkeychain'
project(':libkeychain').projectDir = new File('libkeychain')
//include ':extern:safeslinger-exchange:safeslinger-exchange'
include ':safeslinger-exchange'
project(':safeslinger-exchange').projectDir = new File('extern/safeslinger-exchange/safeslinger-exchange')
//include ':extern:openpgp-api-lib:openpgp-api'
include ':openpgp-api-lib'
project(':openpgp-api-lib').projectDir = new File('extern/openpgp-api-lib/openpgp-api')