Remove old API demos

This commit is contained in:
Dominik Schürmann 2013-09-09 14:25:08 +02:00
parent b6a1bc770c
commit 35b74f47d1
34 changed files with 193 additions and 2344 deletions

View File

@ -1,72 +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="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/aidl_demo_create_new_key"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="createNewKeyOnClick"
android:text="Create new key" />
<Button
android:id="@+id/aidl_demo_select_secret_key"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="selectSecretKeyOnClick"
android:text="Select secret key" />
<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_message"
android:layout_width="match_parent"
android:layout_height="150dip"
android:text="message"
android:textAppearance="@android:style/TextAppearance.Small" />
<EditText
android:id="@+id/aidl_demo_ciphertext"
android:layout_width="match_parent"
android:layout_height="150dip"
android:text="ciphertext"
android:textAppearance="@android:style/TextAppearance.Small" />
<Button
android:id="@+id/aidl_demo_encrypt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="encryptOnClick"
android:text="Encrypt" />
<Button
android:id="@+id/aidl_demo_decrypt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="decryptOnClick"
android:text="Decrypt" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="APG Data:" />
<TextView
android:id="@+id/aidl_demo_data"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minLines="10" />
</LinearLayout>
</ScrollView>

View File

@ -1,33 +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/content_provider_test1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="test1OnClick"
android:text="Test 1" />
<Button
android:id="@+id/content_provider_test2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="test2OnClick"
android:text="Test 2" />
<EditText
android:id="@+id/content_provider_output"
android:layout_width="match_parent"
android:layout_height="150dip"
android:text="output"
android:textAppearance="@android:style/TextAppearance.Small" />
</LinearLayout>
</ScrollView>

View File

@ -6,19 +6,11 @@
android:key="intent_demo"
android:title="Intent Demo" />
</PreferenceCategory>
<PreferenceCategory android:title="Content Provider" >
<Preference
android:key="content_provider_demo"
android:title="Content Provider Demo" />
</PreferenceCategory>
<PreferenceCategory android:title="AIDL" >
<Preference
android:key="aidl_demo"
android:title="AIDL Demo (ACCESS_API permission)" />
<Preference
android:key="aidl_demo2"
android:title="AIDL Demo (ACCESS_KEYS permission)" />
</PreferenceCategory>
<!-- <PreferenceCategory android:title="AIDL" > -->
<!-- <Preference -->
<!-- android:key="aidl_demo2" -->
<!-- android:title="AIDL Demo (ACCESS_KEYS permission)" /> -->
<!-- </PreferenceCategory> -->
<PreferenceCategory android:title="Crypto Provider" >
<Preference
android:key="crypto_provider_demo"

View File

@ -1,216 +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 org.sufficientlysecure.keychain.demo.R;
import org.sufficientlysecure.keychain.integration.KeychainData;
import org.sufficientlysecure.keychain.integration.KeychainIntentHelper;
import org.sufficientlysecure.keychain.service.IKeychainApiService;
import org.sufficientlysecure.keychain.service.IKeychainKeyService;
import org.sufficientlysecure.keychain.service.handler.IKeychainDecryptHandler;
import org.sufficientlysecure.keychain.service.handler.IKeychainEncryptHandler;
import org.sufficientlysecure.keychain.service.handler.IKeychainGetDecryptionKeyIdHandler;
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.view.View;
import android.widget.TextView;
public class AidlDemoActivity extends Activity {
Activity mActivity;
TextView mMessageTextView;
TextView mCiphertextTextView;
TextView mDataTextView;
KeychainIntentHelper mKeychainIntentHelper;
KeychainData mKeychainData;
private IKeychainApiService service = null;
private ServiceConnection svcConn = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder binder) {
service = IKeychainApiService.Stub.asInterface(binder);
}
public void onServiceDisconnected(ComponentName className) {
service = null;
}
};
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.aidl_demo);
mActivity = this;
mMessageTextView = (TextView) findViewById(R.id.aidl_demo_message);
mCiphertextTextView = (TextView) findViewById(R.id.aidl_demo_ciphertext);
mDataTextView = (TextView) findViewById(R.id.aidl_demo_data);
mKeychainIntentHelper = new KeychainIntentHelper(mActivity);
mKeychainData = new KeychainData();
bindService(new Intent(IKeychainApiService.class.getName()), svcConn,
Context.BIND_AUTO_CREATE);
}
public void encryptOnClick(View view) {
byte[] inputBytes = mMessageTextView.getText().toString().getBytes();
try {
service.encryptAsymmetric(inputBytes, null, true, 0, mKeychainData.getPublicKeys(), 7,
encryptHandler);
} catch (RemoteException e) {
exceptionImplementation(-1, e.toString());
}
}
public void decryptOnClick(View view) {
byte[] inputBytes = mCiphertextTextView.getText().toString().getBytes();
try {
service.decryptAndVerifyAsymmetric(inputBytes, null, null, decryptHandler);
} catch (RemoteException e) {
exceptionImplementation(-1, e.toString());
}
}
private void updateView() {
if (mKeychainData.getDecryptedData() != null) {
mMessageTextView.setText(mKeychainData.getDecryptedData());
}
if (mKeychainData.getEncryptedData() != null) {
mCiphertextTextView.setText(mKeychainData.getEncryptedData());
}
mDataTextView.setText(mKeychainData.toString());
}
@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 IKeychainEncryptHandler.Stub encryptHandler = new IKeychainEncryptHandler.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, String outputUri) throws RemoteException {
runOnUiThread(new Runnable() {
public void run() {
mKeychainData.setEncryptedData(new String(outputBytes));
updateView();
}
});
}
};
private final IKeychainDecryptHandler.Stub decryptHandler = new IKeychainDecryptHandler.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, String outputUri, boolean signature,
long signatureKeyId, String signatureUserId, boolean signatureSuccess,
boolean signatureUnknown) throws RemoteException {
runOnUiThread(new Runnable() {
public void run() {
mKeychainData.setDecryptedData(new String(outputBytes));
updateView();
}
});
}
};
private final IKeychainGetDecryptionKeyIdHandler.Stub helperHandler = new IKeychainGetDecryptionKeyIdHandler.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(long arg0, boolean arg1) throws RemoteException {
// TODO Auto-generated method stub
}
};
/**
* Selection is done with Intents, not AIDL!
*
* @param view
*/
public void selectSecretKeyOnClick(View view) {
mKeychainIntentHelper.selectSecretKey();
}
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

@ -1,168 +1,168 @@
/*
* 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);
}
}
///*
// * 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

@ -24,6 +24,7 @@ import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.widget.Toast;
public class BaseActivity extends PreferenceActivity {
private Activity mActivity;
@ -56,16 +57,8 @@ public class BaseActivity extends PreferenceActivity {
mIntentDemo.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(mActivity, IntentDemoActivity.class));
return false;
}
});
mContentProviderDemo.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(mActivity, ContentProviderDemoActivity.class));
// startActivity(new Intent(mActivity, IntentDemoActivity.class));
Toast.makeText(BaseActivity.this, "Not implemented!", Toast.LENGTH_LONG).show();
return false;
}
@ -80,23 +73,14 @@ public class BaseActivity extends PreferenceActivity {
}
});
mAidlDemo.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(mActivity, AidlDemoActivity.class));
return false;
}
});
mAidlDemo2.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startActivity(new Intent(mActivity, AidlDemoActivity2.class));
return false;
}
});
// mAidlDemo2.setOnPreferenceClickListener(new OnPreferenceClickListener() {
// @Override
// public boolean onPreferenceClick(Preference preference) {
// startActivity(new Intent(mActivity, AidlDemoActivity2.class));
//
// return false;
// }
// });
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
* 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.
@ -14,12 +14,12 @@
* limitations under the License.
*/
package org.sufficientlysecure.keychain.service.handler;
package org.sufficientlysecure.keychain.demo;
interface IKeychainGetDecryptionKeyIdHandler {
public final class Constants {
oneway void onSuccess(in long secretKeyId, in boolean symmetric);
public static final boolean DEBUG = BuildConfig.DEBUG;
public static final String TAG = "Keychain API";
oneway void onException(in int exceptionNumber, in String message);
}

View File

@ -1,68 +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.Arrays;
import org.sufficientlysecure.keychain.demo.R;
import org.sufficientlysecure.keychain.integration.KeychainContentProviderHelper;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class ContentProviderDemoActivity extends Activity {
Activity mActivity;
TextView mOutputTextView;
TextView mCiphertextTextView;
TextView mDataTextView;
KeychainContentProviderHelper mKeychainContentProviderHelper;
/**
* Instantiate View for this Activity
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_provider_demo);
mActivity = this;
mOutputTextView = (TextView) findViewById(R.id.content_provider_output);
mKeychainContentProviderHelper = new KeychainContentProviderHelper(mActivity);
}
public void test1OnClick(View view) {
long[] test = mKeychainContentProviderHelper.getPublicKeyringIdsByEmail("user@example.com");
mOutputTextView.setText(Arrays.toString(test));
}
public void test2OnClick(View view) {
boolean test = mKeychainContentProviderHelper.hasPublicKeyringByEmail("user@example.com");
if (test) {
mOutputTextView.setText("true");
} else {
mOutputTextView.setText("false");
}
}
}

View File

@ -24,7 +24,6 @@ import org.openintents.crypto.CryptoServiceConnection;
import org.openintents.crypto.CryptoSignatureResult;
import org.openintents.crypto.ICryptoCallback;
import org.openintents.crypto.ICryptoService;
import org.sufficientlysecure.keychain.integration.Constants;
import android.app.Activity;
import android.app.AlertDialog;

View File

@ -1,111 +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 org.sufficientlysecure.keychain.demo.R;
import org.sufficientlysecure.keychain.integration.KeychainData;
import org.sufficientlysecure.keychain.integration.KeychainIntentHelper;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class IntentDemoActivity extends Activity {
Activity mActivity;
TextView mMessageTextView;
TextView mCiphertextTextView;
TextView mDataTextView;
KeychainIntentHelper mKeychainIntentHelper;
KeychainData mKeychainData;
/**
* Instantiate View for this Activity
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.intent_demo);
mActivity = this;
mMessageTextView = (TextView) findViewById(R.id.intent_demo_message);
mCiphertextTextView = (TextView) findViewById(R.id.intent_demo_ciphertext);
mDataTextView = (TextView) findViewById(R.id.intent_demo_data);
mKeychainIntentHelper = new KeychainIntentHelper(mActivity);
mKeychainData = new KeychainData();
}
public void createNewKeyOnClick(View view) {
// mKeychainIntentHelper.createNewKey();
mKeychainIntentHelper.createNewKey("test <user@example.com>", true, true);
}
public void selectSecretKeyOnClick(View view) {
mKeychainIntentHelper.selectSecretKey();
}
public void selectEncryptionKeysOnClick(View view) {
mKeychainIntentHelper.selectPublicKeys("user@example.com");
}
public void encryptOnClick(View view) {
mKeychainIntentHelper.encrypt(mMessageTextView.getText().toString(),
mKeychainData.getPublicKeys(), mKeychainData.getSecretKeyId(), false);
}
public void encryptAndReturnOnClick(View view) {
mKeychainIntentHelper.encrypt(mMessageTextView.getText().toString(),
mKeychainData.getPublicKeys(), mKeychainData.getSecretKeyId(), true);
}
public void decryptOnClick(View view) {
mKeychainIntentHelper.decrypt(mCiphertextTextView.getText().toString(), false);
}
public void decryptAndReturnOnClick(View view) {
mKeychainIntentHelper.decrypt(mCiphertextTextView.getText().toString(), true);
}
@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);
}
private void updateView() {
if (mKeychainData.getDecryptedData() != null) {
mMessageTextView.setText(mKeychainData.getDecryptedData());
}
if (mKeychainData.getEncryptedData() != null) {
mCiphertextTextView.setText(mKeychainData.getEncryptedData());
}
mDataTextView.setText(mKeychainData.toString());
}
}

View File

@ -1,33 +0,0 @@
#Android specific
bin
gen
obj
libs/armeabi
lint.xml
local.properties
release.properties
ant.properties
*.class
*.apk
#Gradle
.gradle
build
gradle.properties
gradlew
gradlew.bat
gradle
#Maven
target
pom.xml.*
#Eclipse
.project
.classpath
.settings
.metadata
#IntelliJ IDEA
.idea
*.iml

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.sufficientlysecure.keychain.integration"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="14" />
</manifest>

View File

@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="apg_integration_lib" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@ -1,20 +0,0 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

View File

@ -1,15 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-15
android.library=true

View File

@ -1 +0,0 @@
Directory must be empty. Then Android will build a jar instead of an apk!

View File

@ -1,24 +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.integration;
public class Constants {
public static final String TAG = "Keychain Integration Lib";
public static final String KEYCHAIN_PACKAGE_NAME = "org.sufficientlysecure.keychain";
public static final int MIN_REQUIRED_VERSION = 50;
}

View File

@ -1,273 +0,0 @@
/*
* Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
* Copyright (C) 2010-2011 K-9 Mail Contributors
*
* 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.integration;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.widget.Toast;
public class KeychainContentProviderHelper {
public static final String AUTHORITY = Constants.KEYCHAIN_PACKAGE_NAME;
public static final Uri CONTENT_URI_PUBLIC_KEY_RING_BY_KEY_ID = Uri.parse("content://"
+ AUTHORITY + "/key_rings/public/key_id/");
public static final Uri CONTENT_URI_PUBLIC_KEY_RING_BY_EMAILS = Uri.parse("content://"
+ AUTHORITY + "/key_rings/public/emails/");
public static final Uri CONTENT_URI_PUBLIC_KEY_RING_BY_LIKE_EMAIL = Uri.parse("content://"
+ AUTHORITY + "/key_rings/public/like_email/");
public static final Uri CONTENT_URI_SECRET_KEY_RING_BY_KEY_ID = Uri.parse("content://"
+ AUTHORITY + "/key_rings/secret/key_id/");
public static final Uri CONTENT_URI_SECRET_KEY_RING_BY_EMAILS = Uri.parse("content://"
+ AUTHORITY + "/key_rings/secret/emails/");
public static final Uri CONTENT_URI_SECRET_KEY_RING_BY_LIKE_EMAIL = Uri.parse("content://"
+ AUTHORITY + "/key_rings/secret/like_email/");
private Context mContext;
public KeychainContentProviderHelper(Context context) {
this.mContext = context;
}
/**
* Get secret key ids based on a given email.
*
* @param context
* @param email
* The email in question.
* @return key ids
*/
public long[] getSecretKeyringIdsByEmail(String email) {
long ids[] = null;
try {
Uri contentUri = Uri.withAppendedPath(CONTENT_URI_SECRET_KEY_RING_BY_EMAILS, email);
Cursor c = mContext.getContentResolver().query(contentUri,
new String[] { "master_key_id" }, null, null, null);
if (c != null && c.getCount() > 0) {
ids = new long[c.getCount()];
while (c.moveToNext()) {
ids[c.getPosition()] = c.getLong(0);
}
}
if (c != null) {
c.close();
}
} catch (SecurityException e) {
insufficientPermissions();
}
return ids;
}
/**
* Get secret key ids based on a given String that is part of the email.
*
* Example: String: example, then emails: test@example.com, example@google.com are returned
*
* @param context
* @param email
* The email in question.
* @return key ids
*/
public long[] getSecretKeyringIdsByLikeEmail(String likeEmail) {
long ids[] = null;
try {
Uri contentUri = Uri.withAppendedPath(CONTENT_URI_SECRET_KEY_RING_BY_LIKE_EMAIL,
likeEmail);
Cursor c = mContext.getContentResolver().query(contentUri,
new String[] { "master_key_id" }, null, null, null);
if (c != null && c.getCount() > 0) {
ids = new long[c.getCount()];
while (c.moveToNext()) {
ids[c.getPosition()] = c.getLong(0);
}
}
if (c != null) {
c.close();
}
} catch (SecurityException e) {
insufficientPermissions();
}
return ids;
}
/**
* Get public key ids based on a given email.
*
* @param context
* @param email
* The email in question.
* @return key ids
*/
public long[] getPublicKeyringIdsByEmail(String email) {
long ids[] = null;
try {
Uri contentUri = Uri.withAppendedPath(CONTENT_URI_PUBLIC_KEY_RING_BY_EMAILS, email);
Cursor c = mContext.getContentResolver().query(contentUri,
new String[] { "master_key_id" }, null, null, null);
if (c != null && c.getCount() > 0) {
ids = new long[c.getCount()];
while (c.moveToNext()) {
ids[c.getPosition()] = c.getLong(0);
}
}
if (c != null) {
c.close();
}
} catch (SecurityException e) {
insufficientPermissions();
}
return ids;
}
/**
* Get public key ids based on a given String that is part of the email.
*
* Example: String: example, then emails: test@example.com, example@google.com are returned
*
* @param context
* @param email
* The email in question.
* @return key ids
*/
public long[] getPublicKeyringIdsByLikeEmail(String likeEmail) {
long ids[] = null;
try {
Uri contentUri = Uri.withAppendedPath(CONTENT_URI_PUBLIC_KEY_RING_BY_LIKE_EMAIL,
likeEmail);
Cursor c = mContext.getContentResolver().query(contentUri,
new String[] { "master_key_id" }, null, null, null);
if (c != null && c.getCount() > 0) {
ids = new long[c.getCount()];
while (c.moveToNext()) {
ids[c.getPosition()] = c.getLong(0);
}
}
if (c != null) {
c.close();
}
} catch (SecurityException e) {
insufficientPermissions();
}
return ids;
}
/**
* Find out if a given email has a secret key.
*
* @param context
* @param email
* The email in question.
* @return true if there is a secret key for this email.
*/
public boolean hasSecretKeyringByEmail(String email) {
try {
Uri contentUri = Uri.withAppendedPath(CONTENT_URI_SECRET_KEY_RING_BY_EMAILS, email);
Cursor c = mContext.getContentResolver().query(contentUri,
new String[] { "master_key_id" }, null, null, null);
if (c != null && c.getCount() > 0) {
c.close();
return true;
}
if (c != null) {
c.close();
}
} catch (SecurityException e) {
insufficientPermissions();
}
return false;
}
/**
* Find out if a given email has a public key.
*
* @param context
* @param email
* The email in question.
* @return true if there is a public key for this email.
*/
public boolean hasPublicKeyringByEmail(String email) {
try {
Uri contentUri = Uri.withAppendedPath(CONTENT_URI_PUBLIC_KEY_RING_BY_EMAILS, email);
Cursor c = mContext.getContentResolver().query(contentUri,
new String[] { "master_key_id" }, null, null, null);
if (c != null && c.getCount() > 0) {
c.close();
return true;
}
if (c != null) {
c.close();
}
} catch (SecurityException e) {
insufficientPermissions();
}
return false;
}
/**
* Get the user id based on the key id.
*
* @param context
* @param keyId
* @return user id
*/
public String getUserId(long keyId, boolean secretKeyrings) {
String userId = null;
try {
Uri contentUri = null;
if (secretKeyrings) {
contentUri = ContentUris.withAppendedId(CONTENT_URI_SECRET_KEY_RING_BY_KEY_ID,
keyId);
} else {
contentUri = ContentUris.withAppendedId(CONTENT_URI_PUBLIC_KEY_RING_BY_KEY_ID,
keyId);
}
Cursor c = mContext.getContentResolver().query(contentUri, new String[] { "user_id" },
null, null, null);
if (c != null && c.moveToFirst()) {
userId = c.getString(0);
}
if (c != null) {
c.close();
}
} catch (SecurityException e) {
insufficientPermissions();
}
if (userId == null) {
userId = "unknown";
}
return userId;
}
private void insufficientPermissions() {
Toast.makeText(mContext, "Permission to access APG Provider is missing!", Toast.LENGTH_LONG)
.show();
}
}

View File

@ -1,116 +0,0 @@
/*
* Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
* Copyright (C) 2010-2011 K-9 Mail Contributors
*
* 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.integration;
import java.io.Serializable;
import java.util.Arrays;
public class KeychainData implements Serializable {
private static final long serialVersionUID = 6314045536270848410L;
protected long[] mPublicKeyIds = null;
protected String[] mPublicUserIds = null;
protected long mSecretKeyId = 0;
protected String mSecretKeyUserId = null;
protected boolean mSignatureSuccess = false;
protected boolean mSignatureUnknown = false;
protected String mDecryptedData = null;
protected String mEncryptedData = null;
public void setSecretKeyId(long keyId) {
mSecretKeyId = keyId;
}
public long getSecretKeyId() {
return mSecretKeyId;
}
public void setPublicKeyIds(long[] keyIds) {
mPublicKeyIds = keyIds;
}
public long[] getPublicKeys() {
return mPublicKeyIds;
}
public void setPublicUserIds(String[] userIds) {
mPublicUserIds = userIds;
}
public String[] getPublicUserIds() {
return mPublicUserIds;
}
public boolean hasSecretKey() {
return mSecretKeyId != 0;
}
public boolean hasPublicKeys() {
return (mPublicKeyIds != null) && (mPublicKeyIds.length > 0);
}
public String getEncryptedData() {
return mEncryptedData;
}
public void setEncryptedData(String data) {
mEncryptedData = data;
}
public String getDecryptedData() {
return mDecryptedData;
}
public void setDecryptedData(String data) {
mDecryptedData = data;
}
public void setSecretKeyUserId(String userId) {
mSecretKeyUserId = userId;
}
public String getSecretKeyUserId() {
return mSecretKeyUserId;
}
public boolean getSignatureSuccess() {
return mSignatureSuccess;
}
public void setSignatureSuccess(boolean success) {
mSignatureSuccess = success;
}
public boolean getSignatureUnknown() {
return mSignatureUnknown;
}
public void setSignatureUnknown(boolean unknown) {
mSignatureUnknown = unknown;
}
@Override
public String toString() {
String output = "mPublicKeyIds: " + Arrays.toString(mPublicKeyIds) + "\nmSecretKeyId: "
+ mSecretKeyId + "\nmSecretKeyUserId: " + mSecretKeyUserId
+ "\nmSignatureSuccess: " + mSignatureSuccess + "\nmSignatureUnknown: "
+ mSignatureUnknown + "\nmDecryptedData: " + mDecryptedData + "\nmEncryptedData: "
+ mEncryptedData;
return output;
}
}

View File

@ -1,471 +0,0 @@
/*
* Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
* Copyright (C) 2010-2011 K-9 Mail Contributors
*
* 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.integration;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.widget.Toast;
public class KeychainIntentHelper {
public static final String APG_INTENT_PREFIX = Constants.KEYCHAIN_PACKAGE_NAME + ".action.";
// Intents
/**
* Encrypt
*/
// without permission
public static final String ACTION_ENCRYPT = APG_INTENT_PREFIX + "ENCRYPT";
public static final String ACTION_ENCRYPT_FILE = APG_INTENT_PREFIX + "ENCRYPT_FILE";
// with permission
public static final String ACTION_ENCRYPT_AND_RETURN = APG_INTENT_PREFIX + "ENCRYPT_AND_RETURN";
public static final String ACTION_GENERATE_SIGNATURE_AND_RETURN = APG_INTENT_PREFIX
+ "GENERATE_SIGNATURE_AND_RETURN";
public static final String ACTION_ENCRYPT_STREAM_AND_RETURN = APG_INTENT_PREFIX
+ "ENCRYPT_STREAM_AND_RETURN";
/**
* Decrypt
*/
// without permission
public static final String ACTION_DECRYPT = APG_INTENT_PREFIX + "DECRYPT";
public static final String ACTION_DECRYPT_FILE = APG_INTENT_PREFIX + "DECRYPT_FILE";
// with permission
public static final String ACTION_DECRYPT_AND_RETURN = APG_INTENT_PREFIX + "DECRYPT_AND_RETURN";
public static final String ACTION_DECRYPT_STREAM_AND_RETURN = APG_INTENT_PREFIX
+ "DECRYPT_STREAM_AND_RETURN";
/**
* Select keys, without permission
*/
public static final String ACTION_SELECT_PUBLIC_KEYS = APG_INTENT_PREFIX
+ "SELECT_PUBLIC_KEYRINGS";
public static final String ACTION_SELECT_SECRET_KEY = APG_INTENT_PREFIX
+ "SELECT_SECRET_KEYRING";
/**
* Create key/edit key, without permission
*/
public static final String ACTION_CREATE_KEY = APG_INTENT_PREFIX + "CREATE_KEYRING";
public static final String ACTION_EDIT_KEY = APG_INTENT_PREFIX + "EDIT_KEYRING";
/**
* Import actions
*/
public static final String ACTION_IMPORT = APG_INTENT_PREFIX + "IMPORT";
// only used by IMPORT
public static final String EXTRA_IMPORT_TEXT = "text";
public static final String EXTRA_IMPORT_KEYRING_BYTES = "keyringBytes";
public static final String ACTION_IMPORT_FROM_FILE = APG_INTENT_PREFIX + "IMPORT_FROM_FILE";
public static final String ACTION_IMPORT_FROM_QR_CODE = APG_INTENT_PREFIX
+ "IMPORT_FROM_QR_CODE";
/**
* Share actions
*/
public static final String ACTION_SHARE_KEYRING = APG_INTENT_PREFIX + "SHARE_KEYRING";
public static final String ACTION_SHARE_KEYRING_WITH_QR_CODE = APG_INTENT_PREFIX
+ "SHARE_KEYRING_WITH_QR_CODE";
public static final String ACTION_SHARE_KEYRING_WITH_NFC = APG_INTENT_PREFIX
+ "SHARE_KEYRING_WITH_NFC";
// used by SHARE_WITH_QR_CODE and SHARE_WITH_NFC
public static final String EXTRA_MASTER_KEY_ID = "masterKeyId";
public static final String EXTRA_TEXT = "text";
public static final String EXTRA_DATA = "data";
public static final String EXTRA_ERROR = "error";
public static final String EXTRA_DECRYPTED_MESSAGE = "decryptedMessage";
public static final String EXTRA_ENCRYPTED_MESSAGE = "encryptedMessage";
public static final String EXTRA_SIGNATURE = "signature";
public static final String EXTRA_SIGNATURE_KEY_ID = "signatureKeyId";
public static final String EXTRA_SIGNATURE_USER_ID = "signatureUserId";
public static final String EXTRA_SIGNATURE_SUCCESS = "signatureSuccess";
public static final String EXTRA_SIGNATURE_UNKNOWN = "signatureUnknown";
public static final String EXTRA_USER_ID = "userId";
public static final String EXTRA_USER_IDS = "userIds";
public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryptionKeyIds";
public static final String EXTRA_SELECTION = "selection";
public static final String EXTRA_MESSAGE = "message";
public static final String EXTRA_NO_PASSPHRASE = "noPassphrase";
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys";
public static final String EXTRA_INTENT_VERSION = "intentVersion";
public static final String RESULT_EXTRA_MASTER_KEY_IDS = "masterKeyIds";
public static final String RESULT_EXTRA_USER_IDS = "userIds";
// result from EditKey
public static final String RESULT_EXTRA_MASTER_KEY_ID = "masterKeyId";
public static final String RESULT_EXTRA_USER_ID = "userId";
public static final String INTENT_VERSION = "1";
public static final int DECRYPT_MESSAGE = 0x00007121;
public static final int ENCRYPT_MESSAGE = 0x00007122;
public static final int SELECT_PUBLIC_KEYRINGS = 0x00007123;
public static final int SELECT_SECRET_KEYRING = 0x00007124;
public static final int CREATE_KEYRING = 0x00007125;
public static final int EDIT_KEYRING = 0x00007126;
private Activity activity;
public KeychainIntentHelper(Activity activity) {
this.activity = activity;
}
/**
* Start an activity.<br>
* This method is defined to allow different methods of activity starting for newer versions of
* Android and for compatibility library.
*
* @param intent
* Intent to start.
* @param code
* Request code for the activity
* @see android.app.Activity#startActivityForResult(Intent, int)
* @see android.app.Fragment#startActivityForResult(Intent, int)
*/
protected void startActivityForResult(Intent intent, int code) {
activity.startActivityForResult(intent, code);
}
/**
* Open activity to scan qr code and import key in it
*
* @return true when activity was found and executed successfully
*/
public boolean importFromQrCode() {
Intent intent = new Intent(ACTION_IMPORT_FROM_QR_CODE);
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
try {
startActivityForResult(intent, -1);
return true;
} catch (ActivityNotFoundException e) {
activityNotFound();
return false;
}
}
/**
* Opens activity to share keyring with
*
* @return true when activity was found and executed successfully
*/
public boolean share(long masterKeyId) {
Intent intent = new Intent(ACTION_SHARE_KEYRING);
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
intent.putExtra(EXTRA_MASTER_KEY_ID, masterKeyId);
try {
startActivityForResult(intent, -1);
return true;
} catch (ActivityNotFoundException e) {
activityNotFound();
return false;
}
}
/**
* Opens activity with qr code for masterKeyId
*
* @return true when activity was found and executed successfully
*/
public boolean shareWithQrCode(long masterKeyId) {
Intent intent = new Intent(ACTION_SHARE_KEYRING_WITH_QR_CODE);
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
intent.putExtra(EXTRA_MASTER_KEY_ID, masterKeyId);
try {
startActivityForResult(intent, -1);
return true;
} catch (ActivityNotFoundException e) {
activityNotFound();
return false;
}
}
/**
* Opens activity to share keyring withnc based on given masterKeyId
*
* @return true when activity was found and executed successfully
*/
public boolean shareWithNfc(long masterKeyId) {
Intent intent = new Intent(ACTION_SHARE_KEYRING_WITH_NFC);
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
intent.putExtra(EXTRA_MASTER_KEY_ID, masterKeyId);
try {
startActivityForResult(intent, -1);
return true;
} catch (ActivityNotFoundException e) {
activityNotFound();
return false;
}
}
/**
* Opens APG activity to create new key
*
* @param userIds
* value to specify prefilled values for user that should be created
* @return true when activity was found and executed successfully
*/
public boolean createNewKey(String userIds, boolean noPassphrase, boolean generateDefaultKeys) {
Intent intent = new Intent(ACTION_CREATE_KEY);
if (userIds != null) {
intent.putExtra(EXTRA_USER_IDS, userIds);
}
intent.putExtra(EXTRA_NO_PASSPHRASE, noPassphrase);
intent.putExtra(EXTRA_GENERATE_DEFAULT_KEYS, generateDefaultKeys);
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
try {
startActivityForResult(intent, CREATE_KEYRING);
return true;
} catch (ActivityNotFoundException e) {
activityNotFound();
return false;
}
}
/**
* Opens APG activity to create new key
*
* @return true when activity was found and executed successfully
*/
public boolean createNewKey() {
return createNewKey(null, false, false);
}
/**
* Opens APG activity to edit already existing key based on keyId
*
* @param keyId
* @return true when activity was found and executed successfully
*/
public boolean editKey(long keyId) {
Intent intent = new Intent(ACTION_EDIT_KEY);
intent.putExtra(EXTRA_MASTER_KEY_ID, keyId);
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
try {
startActivityForResult(intent, EDIT_KEYRING);
return true;
} catch (ActivityNotFoundException e) {
activityNotFound();
return false;
}
}
/**
* Opens APG activity to select the signature key.
*
* @return true when activity was found and executed successfully
*/
public boolean selectSecretKey() {
Intent intent = new Intent(ACTION_SELECT_SECRET_KEY);
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
try {
startActivityForResult(intent, SELECT_SECRET_KEYRING);
return true;
} catch (ActivityNotFoundException e) {
activityNotFound();
return false;
}
}
/**
* Encrypts the given data by opening APGs encrypt activity. If encryptionKeys are given it
* encrypts immediately and goes back to your program after that
*
* @param data
* String that contains the message to be encrypted
* @param encryptionKeyIds
* long[] that holds the ids of the encryption keys
* @param signatureKeyId
* id of the signature key
* @return true when activity was found and executed successfully
*/
public boolean encrypt(String data, long[] encryptionKeyIds, long signatureKeyId,
boolean returnResult) {
Intent intent = new Intent();
if (returnResult) {
intent.setAction(ACTION_ENCRYPT_AND_RETURN);
} else {
intent.setAction(ACTION_ENCRYPT);
}
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
intent.setType("text/plain");
intent.putExtra(EXTRA_TEXT, data);
intent.putExtra(EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds);
intent.putExtra(EXTRA_SIGNATURE_KEY_ID, signatureKeyId);
try {
startActivityForResult(intent, ENCRYPT_MESSAGE);
return true;
} catch (ActivityNotFoundException e) {
activityNotFound();
return false;
}
}
/**
* Start the decrypt activity.
*
* @param activity
* @param data
* @param pgpData
* @return true when activity was found and executed successfully
*/
public boolean decrypt(String data, boolean returnResult) {
Intent intent = new Intent();
if (returnResult) {
intent.setAction(ACTION_DECRYPT_AND_RETURN);
} else {
intent.setAction(ACTION_DECRYPT);
}
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
intent.setType("text/plain");
if (data == null) {
return false;
}
try {
intent.putExtra(EXTRA_TEXT, data);
startActivityForResult(intent, DECRYPT_MESSAGE);
return true;
} catch (ActivityNotFoundException e) {
activityNotFound();
return false;
}
}
/**
* Handle the activity results that concern us.
*
* @param requestCode
* @param resultCode
* @param data
* @return handled or not
*/
public boolean onActivityResult(int requestCode, int resultCode, Intent data,
KeychainData apgData) {
switch (requestCode) {
case CREATE_KEYRING:
if (resultCode != Activity.RESULT_OK || data == null) {
// user canceled!
break;
}
apgData.setSecretKeyId(data.getLongExtra(RESULT_EXTRA_MASTER_KEY_ID, 0));
apgData.setSecretKeyUserId(data.getStringExtra(RESULT_EXTRA_USER_ID));
break;
case SELECT_SECRET_KEYRING:
if (resultCode != Activity.RESULT_OK || data == null) {
// user canceled!
break;
}
apgData.setSecretKeyId(data.getLongExtra(EXTRA_MASTER_KEY_ID, 0));
apgData.setSecretKeyUserId(data.getStringExtra(EXTRA_USER_ID));
break;
case SELECT_PUBLIC_KEYRINGS:
if (resultCode != Activity.RESULT_OK || data == null) {
apgData.setPublicKeyIds(null);
break;
}
apgData.setPublicKeyIds(data.getLongArrayExtra(RESULT_EXTRA_MASTER_KEY_IDS));
apgData.setPublicUserIds(data.getStringArrayExtra(RESULT_EXTRA_USER_IDS));
break;
case ENCRYPT_MESSAGE:
if (resultCode != Activity.RESULT_OK || data == null) {
apgData.setPublicKeyIds(null);
break;
}
apgData.setEncryptedData(data.getStringExtra(EXTRA_ENCRYPTED_MESSAGE));
break;
case DECRYPT_MESSAGE:
if (resultCode != Activity.RESULT_OK || data == null) {
break;
}
apgData.setSecretKeyUserId(data.getStringExtra(EXTRA_SIGNATURE_USER_ID));
apgData.setSecretKeyId(data.getLongExtra(EXTRA_SIGNATURE_KEY_ID, 0));
apgData.setSignatureSuccess(data.getBooleanExtra(EXTRA_SIGNATURE_SUCCESS, false));
apgData.setSignatureUnknown(data.getBooleanExtra(EXTRA_SIGNATURE_UNKNOWN, false));
apgData.setDecryptedData(data.getStringExtra(EXTRA_DECRYPTED_MESSAGE));
break;
default:
return false;
}
return true;
}
/**
* Select encryption keys.
*
* @param emails
* The emails that should be used for preselection.
* @return true when activity was found and executed successfully
*/
public boolean selectPublicKeys(String emails) {
return selectPublicKeys(emails, null);
}
/**
* Select encryption keys.
*
* @param emails
* The emails that should be used for preselection.
* @param apgData
* ApgData with encryption keys and signature keys preselected
* @return true when activity was found and executed successfully
*/
public boolean selectPublicKeys(String emails, KeychainData apgData) {
Intent intent = new Intent(ACTION_SELECT_PUBLIC_KEYS);
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
long[] initialKeyIds = null;
if (apgData == null || !apgData.hasPublicKeys()) {
KeychainContentProviderHelper cPHelper = new KeychainContentProviderHelper(activity);
initialKeyIds = cPHelper.getPublicKeyringIdsByEmail(emails);
} else {
initialKeyIds = apgData.getPublicKeys();
}
intent.putExtra(EXTRA_SELECTION, initialKeyIds);
try {
startActivityForResult(intent, SELECT_PUBLIC_KEYRINGS);
return true;
} catch (ActivityNotFoundException e) {
activityNotFound();
return false;
}
}
private void activityNotFound() {
Toast.makeText(activity, "APG Activity not found! Is APG installed correctly?",
Toast.LENGTH_LONG).show();
}
}

View File

@ -1,43 +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.integration;
import android.content.Intent;
import android.support.v4.app.Fragment;
/**
* ApgIntentHelper for the V4 Android compatibility package.
*/
public final class KeychainIntentHelperSupportV4 extends KeychainIntentHelper {
private final Fragment fragment;
/**
* @param fragment
* Fragment to handle activity response.
*/
public KeychainIntentHelperSupportV4(Fragment fragment) {
super(fragment.getActivity());
this.fragment = fragment;
}
@Override
protected void startActivityForResult(Intent intent, int code) {
fragment.startActivityForResult(intent, code);
}
}

View File

@ -1,46 +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.integration;
import android.annotation.TargetApi;
import android.app.Fragment;
import android.content.Intent;
import android.os.Build;
/**
* ApgIntentHelper for Android version 3.0 and beyond.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public final class KeychainIntentHelperV30 extends KeychainIntentHelper {
private final Fragment fragment;
/**
* @param fragment
* Fragment to handle activity response.
*/
public KeychainIntentHelperV30(Fragment fragment) {
super(fragment.getActivity());
this.fragment = fragment;
}
@Override
protected void startActivityForResult(Intent intent, int code) {
fragment.startActivityForResult(intent, code);
}
}

View File

@ -1,102 +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.integration;
import java.io.InputStream;
import java.io.OutputStream;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.net.Uri;
import android.util.Log;
public class KeychainServiceHelper {
private final static String BLOB_URI = "content://org.sufficientlysecure.keychain.provider.apgserviceblobprovider";
private Context context;
public KeychainServiceHelper(Context context) {
this.context = context;
}
/**
* Set up binary data to en/decrypt
*
* @param is
* InputStream to get the data from
*/
public void setBlob(InputStream is) {
Log.d(Constants.TAG, "setBlob() called");
// 1. get the new contentUri
ContentResolver cr = context.getContentResolver();
Uri contentUri = cr.insert(Uri.parse(BLOB_URI), new ContentValues());
// 2. insert binary data
OutputStream os = null;
try {
os = cr.openOutputStream(contentUri, "w");
} catch (Exception e) {
Log.e(Constants.TAG, "... exception on setBlob", e);
}
byte[] buffer = new byte[8];
int len = 0;
try {
while ((len = is.read(buffer)) != -1) {
os.write(buffer, 0, len);
}
Log.d(Constants.TAG, "... write finished, now closing");
os.close();
} catch (Exception e) {
Log.e(Constants.TAG, "... error on writing buffer", e);
}
// mArgs.putString("BLOB", contentUri.toString());
}
/**
* Get the binary result
*
* <p>
* This gets your binary result. It only works if you called {@link #setBlob(InputStream)}
* before.
*
* If you did not call encrypt nor decrypt, this will be the same data as you inputed.
* </p>
*
* @return InputStream of the binary data which was en/decrypted
*
* @see #setBlob(InputStream)
* @see #getResult()
*/
public InputStream getBlobResult() {
// if (mArgs.containsKey("BLOB")) {
ContentResolver cr = context.getContentResolver();
InputStream in = null;
try {
// in = cr.openInputStream(Uri.parse(mArgs.getString("BLOB")));
} catch (Exception e) {
Log.e(Constants.TAG, "Could not return blob in result", e);
}
return in;
// } else {
// return null;
// }
}
}

View File

@ -1,73 +0,0 @@
/*
* Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
* Copyright (C) 2010-2011 K-9 Mail Contributors
*
* 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.integration;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.widget.Toast;
public class KeychainUtil {
/**
* Check whether OpenPGP Keychain is installed and at a high enough version.
*
* @param context
* @return whether a suitable version of APG was found
*/
public boolean isApgAvailable(Context context) {
try {
PackageInfo pi = context.getPackageManager().getPackageInfo(
Constants.KEYCHAIN_PACKAGE_NAME, 0);
if (pi.versionCode >= Constants.MIN_REQUIRED_VERSION) {
return true;
} else {
Toast.makeText(
context,
"This OpenPGP Keychain version is not supported! Please update to a newer one!",
Toast.LENGTH_LONG).show();
}
} catch (NameNotFoundException e) {
// not found
}
return false;
}
/**
* Splits userId string into naming part and email part
*
* @param userId
* @return array with naming (0) and email (1)
*/
public static String[] splitUserId(String userId) {
String[] output = new String[2];
String chunks[] = userId.split(" <", 2);
userId = chunks[0];
if (chunks.length > 1) {
output[1] = "<" + chunks[1];
output[1] = output[1].replaceAll("<", "");
output[1] = output[1].replaceAll(">", "");
}
output[0] = userId;
return output;
}
}

View File

@ -1,146 +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.service;
import org.sufficientlysecure.keychain.service.handler.IKeychainEncryptHandler;
import org.sufficientlysecure.keychain.service.handler.IKeychainDecryptHandler;
import org.sufficientlysecure.keychain.service.handler.IKeychainGetDecryptionKeyIdHandler;
/**
* All methods are oneway, which means they are asynchronous and non-blocking.
* Results are returned into given Handler, which has to be implemented on client side.
*/
interface IKeychainApiService {
/**
* Encrypt
*
* Either inputBytes or inputUri is given, the other should be null.
*
* @param inputBytes
* Byte array you want to encrypt
* @param inputUri
* Blob in ContentProvider you want to encrypt
* @param useAsciiArmor
* Convert bytes to ascii armored text to guard against encoding problems
* @param compression
* Compression: 0x21070001: none, 1: Zip, 2: Zlib, 3: BZip2
* @param encryptionKeyIds
* Ids of public keys used for encryption
* @param symmetricEncryptionAlgorithm
* 7: AES-128, 8: AES-192, 9: AES-256, 4: Blowfish, 10: Twofish, 3: CAST5,
* 6: DES, 2: Triple DES, 1: IDEA
* @param handler
* Results are returned to this IKeychainEncryptDecryptHandler Handler
* to onSuccessEncrypt(in byte[] output), after successful encryption
*/
oneway void encryptAsymmetric(in byte[] inputBytes, in String inputUri, in boolean useAsciiArmor,
in int compression, in long[] encryptionKeyIds, in int symmetricEncryptionAlgorithm,
in IKeychainEncryptHandler handler);
/**
* Same as encryptAsymmetric but using a passphrase for symmetric encryption
*
* @param encryptionPassphrase
* Passphrase for direct symmetric encryption using symmetricEncryptionAlgorithm
*/
oneway void encryptSymmetric(in byte[] inputBytes, in String inputUri, in boolean useAsciiArmor,
in int compression, in String encryptionPassphrase, in int symmetricEncryptionAlgorithm,
in IKeychainEncryptHandler handler);
/**
* Encrypt and sign
*
* Either inputBytes or inputUri is given, the other should be null.
*
* @param inputBytes
* Byte array you want to encrypt
* @param inputUri
* Blob in ContentProvider you want to encrypt
* @param useAsciiArmor
* Convert bytes to ascii armored text to guard against encoding problems
* @param compression
* Compression: 0x21070001: none, 1: Zip, 2: Zlib, 3: BZip2
* @param encryptionKeyIds
* Ids of public keys used for encryption
* @param symmetricEncryptionAlgorithm
* 7: AES-128, 8: AES-192, 9: AES-256, 4: Blowfish, 10: Twofish, 3: CAST5,
* 6: DES, 2: Triple DES, 1: IDEA
* @param signatureKeyId
* Key id of key to sign with
* @param signatureHashAlgorithm
* 1: MD5, 3: RIPEMD-160, 2: SHA-1, 11: SHA-224, 8: SHA-256, 9: SHA-384,
* 10: SHA-512
* @param signatureForceV3
* Force V3 signatures
* @param signaturePassphrase
* Passphrase to unlock signature key
* @param handler
* Results are returned to this IKeychainEncryptDecryptHandler Handler
* to onSuccessEncrypt(in byte[] output), after successful encryption and signing
*/
oneway void encryptAndSignAsymmetric(in byte[] inputBytes, in String inputUri,
in boolean useAsciiArmor, in int compression, in long[] encryptionKeyIds,
in int symmetricEncryptionAlgorithm, in long signatureKeyId, in int signatureHashAlgorithm,
in boolean signatureForceV3, in String signaturePassphrase,
in IKeychainEncryptHandler handler);
/**
* Same as encryptAndSignAsymmetric but using a passphrase for symmetric encryption
*
* @param encryptionPassphrase
* Passphrase for direct symmetric encryption using symmetricEncryptionAlgorithm
*/
oneway void encryptAndSignSymmetric(in byte[] inputBytes, in String inputUri,
in boolean useAsciiArmor, in int compression, in String encryptionPassphrase,
in int symmetricEncryptionAlgorithm, in long signatureKeyId, in int signatureHashAlgorithm,
in boolean signatureForceV3, in String signaturePassphrase,
in IKeychainEncryptHandler handler);
/**
* Decrypts and verifies given input bytes. If no signature is present this method
* will only decrypt.
*
* @param inputBytes
* Byte array you want to decrypt and verify
* @param inputUri
* Blob in ContentProvider you want to decrypt and verify
* @param keyPassphrase
* Passphrase to unlock secret key for decryption.
* @param handler
* Handler where to return results to after successful encryption
*/
oneway void decryptAndVerifyAsymmetric(in byte[] inputBytes, in String inputUri,
in String keyPassphrase, in IKeychainDecryptHandler handler);
/**
* Same as decryptAndVerifyAsymmetric but for symmetric decryption.
*
* @param encryptionPassphrase
* Passphrase to decrypt
*/
oneway void decryptAndVerifySymmetric(in byte[] inputBytes, in String inputUri,
in String encryptionPassphrase, in IKeychainDecryptHandler handler);
/**
*
*/
oneway void getDecryptionKeyId(in byte[] inputBytes, in String inputUri,
in IKeychainGetDecryptionKeyIdHandler handler);
}

View File

@ -1,32 +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.service;
import org.sufficientlysecure.keychain.service.handler.IKeychainGetKeyringsHandler;
/**
* All methods are oneway, which means they are asynchronous and non-blocking.
* Results are returned into given Handler, which has to be implemented on client side.
*/
interface IKeychainKeyService {
oneway void getPublicKeyRings(in long[] masterKeyIds, in boolean asAsciiArmoredStringArray,
in IKeychainGetKeyringsHandler handler);
oneway void getSecretKeyRings(in long[] masterKeyIds, in boolean asAsciiArmoredStringArray,
in IKeychainGetKeyringsHandler handler);
}

View File

@ -1,27 +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.service.handler;
interface IKeychainDecryptHandler {
oneway void onSuccess(in byte[] outputBytes, in String outputUri, in boolean signature,
in long signatureKeyId, in String signatureUserId, in boolean signatureSuccess,
in boolean signatureUnknown);
oneway void onException(in int exceptionNumber, in String message);
}

View File

@ -1,28 +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.service.handler;
interface IKeychainEncryptHandler {
/**
* Either output or streamUri is given. One of them is null
*
*/
oneway void onSuccess(in byte[] outputBytes, in String outputUri);
oneway void onException(in int exceptionNumber, in String message);
}

View File

@ -1,28 +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.service.handler;
interface IKeychainGetKeyringsHandler {
/**
* Either outputBytes or outputString is given. One of them is null
*
*/
oneway void onSuccess(in byte[] outputBytes, in List<String> outputString);
oneway void onException(in int exceptionNumber, in String message);
}

View File

@ -1,28 +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.service.handler;
interface IKeychainSignHandler {
/**
* Either output or streamUri is given. One of them is null
*
*/
oneway void onSuccess(in byte[] outputBytes, in String outputUri);
oneway void onException(in int exceptionNumber, in String message);
}

View File

@ -1,26 +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.service.handler;
interface IKeychainVerifyHandler {
oneway void onSuccess(in boolean signature, in long signatureKeyId,
in String signatureUserId, in boolean signatureSuccess, in boolean signatureUnknown);
oneway void onException(in int exceptionNumber, in String message);
}

View File

@ -413,7 +413,7 @@
android:name="org.sufficientlysecure.keychain.remote_api.RegisteredAppsListActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:exported="false"
android:label="@string/title_crypto_consumers" />
android:label="@string/title_api_registered_apps" />
<activity
android:name="org.sufficientlysecure.keychain.remote_api.AppSettingsActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"

View File

@ -30,7 +30,7 @@
<string name="title_createKey">Create Key</string>
<string name="title_editKey">Edit Key</string>
<string name="title_preferences">Preferences</string>
<string name="title_crypto_consumers">Registered Applications</string>
<string name="title_api_registered_apps">Registered Applications</string>
<string name="title_keyServerPreference">Key Server Preference</string>
<string name="title_changePassPhrase">Change Passphrase</string>
<string name="title_setPassPhrase">Set Passphrase</string>