This commit is contained in:
Dominik Schürmann 2014-02-14 17:19:54 +01:00
parent d695374581
commit 581e6edb4c
13 changed files with 4 additions and 306 deletions

View File

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.sufficientlysecure.keychain.demo"
android:versionCode="2"
android:versionName="1.1" >
android:versionName="1.1">
<uses-sdk
android:minSdkVersion="9"
@ -11,10 +11,10 @@
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="OpenPGP Keychain API Demo" >
android:label="OpenPGP Keychain API Demo">
<activity
android:name=".BaseActivity"
android:label="OpenPGP Keychain API Demo" >
android:label="OpenPGP Keychain API Demo">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -25,10 +25,6 @@
android:name=".OpenPgpProviderActivity"
android:label="OpenPGP Provider"
android:windowSoftInputMode="stateHidden" />
<activity
android:name=".AidlDemoActivity2"
android:label="Aidl Demo (ACCESS_KEYS permission)"
android:windowSoftInputMode="stateHidden" />
</application>
</manifest>

View File

@ -1,168 +0,0 @@
///*
// * Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package org.sufficientlysecure.keychain.demo;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import org.sufficientlysecure.keychain.demo.R;
//import org.sufficientlysecure.keychain.integration.KeychainData;
//import org.sufficientlysecure.keychain.integration.KeychainIntentHelper;
//import org.sufficientlysecure.keychain.service.IKeychainKeyService;
//import org.sufficientlysecure.keychain.service.handler.IKeychainGetKeyringsHandler;
//
//import android.annotation.SuppressLint;
//import android.app.Activity;
//import android.app.AlertDialog;
//import android.content.ComponentName;
//import android.content.Context;
//import android.content.Intent;
//import android.content.ServiceConnection;
//import android.os.Bundle;
//import android.os.IBinder;
//import android.os.RemoteException;
//import android.util.Base64;
//import android.view.View;
//import android.widget.TextView;
//
//public class AidlDemoActivity2 extends Activity {
// Activity mActivity;
//
// TextView mKeyringsTextView;
//
// KeychainIntentHelper mKeychainIntentHelper;
// KeychainData mKeychainData;
//
// byte[] keysBytes;
// ArrayList<String> keysStrings;
//
// private IKeychainKeyService service = null;
// private ServiceConnection svcConn = new ServiceConnection() {
// public void onServiceConnected(ComponentName className, IBinder binder) {
// service = IKeychainKeyService.Stub.asInterface(binder);
// }
//
// public void onServiceDisconnected(ComponentName className) {
// service = null;
// }
// };
//
// @Override
// public void onCreate(Bundle icicle) {
// super.onCreate(icicle);
// setContentView(R.layout.aidl_demo2);
//
// mActivity = this;
//
// mKeyringsTextView = (TextView) findViewById(R.id.aidl_demo_keyrings);
//
// mKeychainIntentHelper = new KeychainIntentHelper(mActivity);
// mKeychainData = new KeychainData();
//
// bindService(new Intent(IKeychainKeyService.class.getName()), svcConn,
// Context.BIND_AUTO_CREATE);
// }
//
// public void getKeyringsStringsOnClick(View view) {
// try {
// service.getPublicKeyRings(mKeychainData.getPublicKeys(), true, getKeyringsHandler);
// } catch (RemoteException e) {
// exceptionImplementation(-1, e.toString());
// }
// }
//
// public void getKeyringsBytesOnClick(View view) {
// try {
// service.getPublicKeyRings(mKeychainData.getPublicKeys(), false, getKeyringsHandler);
// } catch (RemoteException e) {
// exceptionImplementation(-1, e.toString());
// }
// }
//
// @SuppressLint("NewApi")
// private void updateView() {
// if (keysBytes != null) {
// mKeyringsTextView.setText(Base64.encodeToString(keysBytes, Base64.DEFAULT));
// } else if (keysStrings != null) {
// mKeyringsTextView.setText("");
// for (String output : keysStrings) {
// mKeyringsTextView.append(output);
// }
// }
// }
//
// @Override
// public void onDestroy() {
// super.onDestroy();
//
// unbindService(svcConn);
// }
//
// private void exceptionImplementation(int exceptionId, String error) {
// AlertDialog.Builder builder = new AlertDialog.Builder(this);
// builder.setTitle("Exception!").setMessage(error).setPositiveButton("OK", null).show();
// }
//
// private final IKeychainGetKeyringsHandler.Stub getKeyringsHandler = new IKeychainGetKeyringsHandler.Stub() {
//
// @Override
// public void onException(final int exceptionId, final String message) throws RemoteException {
// runOnUiThread(new Runnable() {
// public void run() {
// exceptionImplementation(exceptionId, message);
// }
// });
// }
//
// @Override
// public void onSuccess(final byte[] outputBytes, final List<String> outputStrings)
// throws RemoteException {
// runOnUiThread(new Runnable() {
// public void run() {
// if (outputBytes != null) {
// keysBytes = outputBytes;
// keysStrings = null;
// } else if (outputStrings != null) {
// keysBytes = null;
// keysStrings = (ArrayList<String>) outputStrings;
// }
// updateView();
// }
// });
//
// }
//
// };
//
// public void selectEncryptionKeysOnClick(View view) {
// mKeychainIntentHelper.selectPublicKeys("user@example.com");
// }
//
// @Override
// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// // this updates the mKeychainData object to the result of the methods
// boolean result = mKeychainIntentHelper.onActivityResult(requestCode, resultCode, data,
// mKeychainData);
// if (result) {
// updateView();
// }
//
// // continue with other activity results
// super.onActivityResult(requestCode, resultCode, data);
// }
//
//}

View File

@ -32,8 +32,6 @@ public class BaseActivity extends PreferenceActivity {
private Preference mIntentDemo;
private Preference mContentProviderDemo;
private Preference mCryptoProvider;
private Preference mAidlDemo;
private Preference mAidlDemo2;
/**
* Called when the activity is first created.
@ -51,8 +49,6 @@ public class BaseActivity extends PreferenceActivity {
mIntentDemo = (Preference) findPreference("intent_demo");
mContentProviderDemo = (Preference) findPreference("content_provider_demo");
mCryptoProvider = (Preference) findPreference("openpgp_provider_demo");
mAidlDemo = (Preference) findPreference("aidl_demo");
mAidlDemo2 = (Preference) findPreference("aidl_demo2");
mIntentDemo.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
@ -73,15 +69,6 @@ public class BaseActivity extends PreferenceActivity {
}
});
// mAidlDemo2.setOnPreferenceClickListener(new OnPreferenceClickListener() {
// @Override
// public boolean onPreferenceClick(Preference preference) {
// startActivity(new Intent(mActivity, AidlDemoActivity2.class));
//
// return false;
// }
// });
}
}

View File

@ -69,7 +69,7 @@ public class OpenPgpProviderActivity extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.crypto_provider_demo);
setContentView(R.layout.openpgp_provider);
mActivity = this;

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="@+id/aidl_demo_select_encryption_key"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="selectEncryptionKeysOnClick"
android:text="Select encryption key(s)" />
<EditText
android:id="@+id/aidl_demo_keyrings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="keyrings output"
android:textAppearance="@android:style/TextAppearance.Small" />
<Button
android:id="@+id/aidl_demo_get_keyrings_strings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="getKeyringsStringsOnClick"
android:text="getKeyrings as Strings" />
<Button
android:id="@+id/aidl_demo_get_keyrings_bytes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="getKeyringsBytesOnClick"
android:text="getKeyringsBytes" />
</LinearLayout>
</ScrollView>

View File

@ -6,11 +6,6 @@
android:key="intent_demo"
android:title="Intent Demo" />
</PreferenceCategory>
<!-- <PreferenceCategory android:title="AIDL" > -->
<!-- <Preference -->
<!-- android:key="aidl_demo2" -->
<!-- android:title="AIDL Demo (ACCESS_KEYS permission)" /> -->
<!-- </PreferenceCategory> -->
<PreferenceCategory android:title="OpenPGP Provider" >
<org.openintents.openpgp.util.OpenPgpListPreference
android:key="openpgp_provider_list"

View File

@ -1,24 +0,0 @@
/*
* Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sufficientlysecure.keychain.service.remote;
interface IExtendedApiCallback {
oneway void onSuccess(in byte[] outputBytes);
oneway void onError(in String error);
}

View File

@ -1,48 +0,0 @@
/*
* Copyright (C) 2013 Dominik Schürmann <dominik@dominikschuermann.de>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sufficientlysecure.keychain.service.remote;
import org.sufficientlysecure.keychain.service.remote.IExtendedApiCallback;
/**
* All methods are oneway, which means they are asynchronous and non-blocking.
* Results are returned to the callback, which has to be implemented on client side.
*/
interface IExtendedApiService {
/**
* Symmetric Encrypt
*
* @param inputBytes
* Byte array you want to encrypt
* @param passphrase
* symmetric passhprase
* @param callback
* Callback where to return results
*/
oneway void encrypt(in byte[] inputBytes, in String passphrase, in IExtendedApiCallback callback);
/**
* Generates self signed X509 certificate signed by OpenPGP private key (from app settings)
*
* @param subjAltNameURI
* @param callback
* Callback where to return results
*/
oneway void selfSignedX509Cert(in String subjAltNameURI, in IExtendedApiCallback callback);
}