mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
rename api to openpgp api
This commit is contained in:
parent
aa449d2d4f
commit
9a5707c415
@ -4,9 +4,6 @@
|
|||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0" >
|
android:versionName="1.0" >
|
||||||
|
|
||||||
<uses-permission android:name="org.sufficientlysecure.keychain.permission.ACCESS_API" />
|
|
||||||
<uses-permission android:name="org.sufficientlysecure.keychain.permission.ACCESS_KEYS" />
|
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="7"
|
android:minSdkVersion="7"
|
||||||
android:targetSdkVersion="14" />
|
android:targetSdkVersion="14" />
|
||||||
@ -25,25 +22,13 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".IntentDemoActivity"
|
android:name=".OpenPGPProviderActivity"
|
||||||
android:label="Intent Demo 1"
|
android:label="OpenPGP Provider"
|
||||||
android:windowSoftInputMode="stateHidden" />
|
|
||||||
<activity
|
|
||||||
android:name=".CryptoProviderDemoActivity"
|
|
||||||
android:label="Crypto Provider"
|
|
||||||
android:windowSoftInputMode="stateHidden" />
|
|
||||||
<activity
|
|
||||||
android:name=".AidlDemoActivity"
|
|
||||||
android:label="Aidl Demo (ACCESS_API permission)"
|
|
||||||
android:windowSoftInputMode="stateHidden" />
|
android:windowSoftInputMode="stateHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".AidlDemoActivity2"
|
android:name=".AidlDemoActivity2"
|
||||||
android:label="Aidl Demo (ACCESS_KEYS permission)"
|
android:label="Aidl Demo (ACCESS_KEYS permission)"
|
||||||
android:windowSoftInputMode="stateHidden" />
|
android:windowSoftInputMode="stateHidden" />
|
||||||
<activity
|
|
||||||
android:name=".ContentProviderDemoActivity"
|
|
||||||
android:label="Content Provider Demo"
|
|
||||||
android:windowSoftInputMode="stateHidden" />
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -14,18 +14,18 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
import org.openintents.crypto.CryptoSignatureResult;
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
import org.openintents.crypto.CryptoError;
|
import org.openintents.openpgp.OpenPgpError;
|
||||||
|
|
||||||
interface ICryptoCallback {
|
interface IOpenPgpCallback {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CryptoSignatureResult is only returned if the Callback was used from decryptAndVerify
|
* CryptoSignatureResult is only returned if the Callback was used from decryptAndVerify
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
oneway void onSuccess(in byte[] outputBytes, in CryptoSignatureResult signatureResult);
|
oneway void onSuccess(in byte[] outputBytes, in OpenPgpSignatureResult signatureResult);
|
||||||
|
|
||||||
oneway void onError(in CryptoError error);
|
oneway void onError(in OpenPgpError error);
|
||||||
}
|
}
|
@ -14,15 +14,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
import org.openintents.crypto.ICryptoCallback;
|
import org.openintents.openpgp.IOpenPgpCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All methods are oneway, which means they are asynchronous and non-blocking.
|
* 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.
|
* Results are returned to the callback, which has to be implemented on client side.
|
||||||
*/
|
*/
|
||||||
interface ICryptoService {
|
interface IOpenPgpService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt
|
* Encrypt
|
||||||
@ -36,7 +36,7 @@ interface ICryptoService {
|
|||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor, in ICryptoCallback callback);
|
oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor, in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign
|
* Sign
|
||||||
@ -48,7 +48,7 @@ interface ICryptoService {
|
|||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in ICryptoCallback callback);
|
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt and sign
|
* Encrypt and sign
|
||||||
@ -64,7 +64,7 @@ interface ICryptoService {
|
|||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void encryptAndSign(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor, in ICryptoCallback callback);
|
oneway void encryptAndSign(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor, in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypts and verifies given input bytes. If no signature is present this method
|
* Decrypts and verifies given input bytes. If no signature is present this method
|
||||||
@ -75,6 +75,6 @@ interface ICryptoService {
|
|||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void decryptAndVerify(in byte[] inputBytes, in ICryptoCallback callback);
|
oneway void decryptAndVerify(in byte[] inputBytes, in IOpenPgpCallback callback);
|
||||||
|
|
||||||
}
|
}
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
// Declare CryptoError so AIDL can find it and knows that it implements the parcelable protocol.
|
// Declare OpenPgpError so AIDL can find it and knows that it implements the parcelable protocol.
|
||||||
parcelable CryptoError;
|
parcelable OpenPgpError;
|
@ -14,27 +14,27 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
public class CryptoError implements Parcelable {
|
public class OpenPgpError implements Parcelable {
|
||||||
public static final int ID_NO_OR_WRONG_PASSPHRASE = 1;
|
public static final int ID_NO_OR_WRONG_PASSPHRASE = 1;
|
||||||
public static final int ID_NO_USER_IDS = 2;
|
public static final int ID_NO_USER_IDS = 2;
|
||||||
|
|
||||||
int errorId;
|
int errorId;
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
public CryptoError() {
|
public OpenPgpError() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoError(int errorId, String message) {
|
public OpenPgpError(int errorId, String message) {
|
||||||
this.errorId = errorId;
|
this.errorId = errorId;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoError(CryptoError b) {
|
public OpenPgpError(OpenPgpError b) {
|
||||||
this.errorId = b.errorId;
|
this.errorId = b.errorId;
|
||||||
this.message = b.message;
|
this.message = b.message;
|
||||||
}
|
}
|
||||||
@ -64,16 +64,16 @@ public class CryptoError implements Parcelable {
|
|||||||
dest.writeString(message);
|
dest.writeString(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<CryptoError> CREATOR = new Creator<CryptoError>() {
|
public static final Creator<OpenPgpError> CREATOR = new Creator<OpenPgpError>() {
|
||||||
public CryptoError createFromParcel(final Parcel source) {
|
public OpenPgpError createFromParcel(final Parcel source) {
|
||||||
CryptoError error = new CryptoError();
|
OpenPgpError error = new OpenPgpError();
|
||||||
error.errorId = source.readInt();
|
error.errorId = source.readInt();
|
||||||
error.message = source.readString();
|
error.message = source.readString();
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoError[] newArray(final int size) {
|
public OpenPgpError[] newArray(final int size) {
|
||||||
return new CryptoError[size];
|
return new OpenPgpError[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -14,9 +14,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
import org.openintents.crypto.ICryptoService;
|
import org.openintents.openpgp.IOpenPgpService;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -25,27 +25,27 @@ import android.content.ServiceConnection;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class CryptoServiceConnection {
|
public class OpenPgpServiceConnection {
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
|
|
||||||
private ICryptoService mService;
|
private IOpenPgpService mService;
|
||||||
private boolean bound;
|
private boolean bound;
|
||||||
private String cryptoProviderPackageName;
|
private String cryptoProviderPackageName;
|
||||||
|
|
||||||
private static final String TAG = "CryptoConnection";
|
private static final String TAG = "OpenPgpServiceConnection";
|
||||||
|
|
||||||
public CryptoServiceConnection(Context context, String cryptoProviderPackageName) {
|
public OpenPgpServiceConnection(Context context, String cryptoProviderPackageName) {
|
||||||
mApplicationContext = context.getApplicationContext();
|
mApplicationContext = context.getApplicationContext();
|
||||||
this.cryptoProviderPackageName = cryptoProviderPackageName;
|
this.cryptoProviderPackageName = cryptoProviderPackageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICryptoService getService() {
|
public IOpenPgpService getService() {
|
||||||
return mService;
|
return mService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceConnection mCryptoServiceConnection = new ServiceConnection() {
|
private ServiceConnection mCryptoServiceConnection = new ServiceConnection() {
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
mService = ICryptoService.Stub.asInterface(service);
|
mService = IOpenPgpService.Stub.asInterface(service);
|
||||||
Log.d(TAG, "connected to service");
|
Log.d(TAG, "connected to service");
|
||||||
bound = true;
|
bound = true;
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ public class CryptoServiceConnection {
|
|||||||
Log.d(TAG, "not bound yet");
|
Log.d(TAG, "not bound yet");
|
||||||
|
|
||||||
Intent serviceIntent = new Intent();
|
Intent serviceIntent = new Intent();
|
||||||
serviceIntent.setAction("org.openintents.crypto.ICryptoService");
|
serviceIntent.setAction(IOpenPgpService.class.getName());
|
||||||
serviceIntent.setPackage(cryptoProviderPackageName);
|
serviceIntent.setPackage(cryptoProviderPackageName);
|
||||||
mApplicationContext.bindService(serviceIntent, mCryptoServiceConnection,
|
mApplicationContext.bindService(serviceIntent, mCryptoServiceConnection,
|
||||||
Context.BIND_AUTO_CREATE);
|
Context.BIND_AUTO_CREATE);
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
// Declare CryptoSignatureResult so AIDL can find it and knows that it implements the parcelable protocol.
|
// Declare OpenPgpSignatureResult so AIDL can find it and knows that it implements the parcelable protocol.
|
||||||
parcelable CryptoSignatureResult;
|
parcelable OpenPgpSignatureResult;
|
@ -14,23 +14,23 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
public class CryptoSignatureResult implements Parcelable {
|
public class OpenPgpSignatureResult implements Parcelable {
|
||||||
String signatureUserId;
|
String signatureUserId;
|
||||||
|
|
||||||
boolean signature;
|
boolean signature;
|
||||||
boolean signatureSuccess;
|
boolean signatureSuccess;
|
||||||
boolean signatureUnknown;
|
boolean signatureUnknown;
|
||||||
|
|
||||||
public CryptoSignatureResult() {
|
public OpenPgpSignatureResult() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoSignatureResult(String signatureUserId, boolean signature,
|
public OpenPgpSignatureResult(String signatureUserId, boolean signature,
|
||||||
boolean signatureSuccess, boolean signatureUnknown) {
|
boolean signatureSuccess, boolean signatureUnknown) {
|
||||||
this.signatureUserId = signatureUserId;
|
this.signatureUserId = signatureUserId;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class CryptoSignatureResult implements Parcelable {
|
|||||||
this.signatureUnknown = signatureUnknown;
|
this.signatureUnknown = signatureUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoSignatureResult(CryptoSignatureResult b) {
|
public OpenPgpSignatureResult(OpenPgpSignatureResult b) {
|
||||||
this.signatureUserId = b.signatureUserId;
|
this.signatureUserId = b.signatureUserId;
|
||||||
|
|
||||||
this.signature = b.signature;
|
this.signature = b.signature;
|
||||||
@ -59,9 +59,9 @@ public class CryptoSignatureResult implements Parcelable {
|
|||||||
dest.writeByte((byte) (signatureUnknown ? 1 : 0));
|
dest.writeByte((byte) (signatureUnknown ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<CryptoSignatureResult> CREATOR = new Creator<CryptoSignatureResult>() {
|
public static final Creator<OpenPgpSignatureResult> CREATOR = new Creator<OpenPgpSignatureResult>() {
|
||||||
public CryptoSignatureResult createFromParcel(final Parcel source) {
|
public OpenPgpSignatureResult createFromParcel(final Parcel source) {
|
||||||
CryptoSignatureResult vr = new CryptoSignatureResult();
|
OpenPgpSignatureResult vr = new OpenPgpSignatureResult();
|
||||||
vr.signatureUserId = source.readString();
|
vr.signatureUserId = source.readString();
|
||||||
vr.signature = source.readByte() == 1;
|
vr.signature = source.readByte() == 1;
|
||||||
vr.signatureSuccess = source.readByte() == 1;
|
vr.signatureSuccess = source.readByte() == 1;
|
||||||
@ -69,8 +69,8 @@ public class CryptoSignatureResult implements Parcelable {
|
|||||||
return vr;
|
return vr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoSignatureResult[] newArray(final int size) {
|
public OpenPgpSignatureResult[] newArray(final int size) {
|
||||||
return new CryptoSignatureResult[size];
|
return new OpenPgpSignatureResult[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -67,7 +67,7 @@ public class BaseActivity extends PreferenceActivity {
|
|||||||
mCryptoProvider.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
mCryptoProvider.setOnPreferenceClickListener(new OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
startActivity(new Intent(mActivity, CryptoProviderDemoActivity.class));
|
startActivity(new Intent(mActivity, OpenPGPProviderActivity.class));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,11 @@ package org.sufficientlysecure.keychain.demo;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.openintents.crypto.CryptoError;
|
import org.openintents.openpgp.OpenPgpError;
|
||||||
import org.openintents.crypto.CryptoServiceConnection;
|
import org.openintents.openpgp.OpenPgpServiceConnection;
|
||||||
import org.openintents.crypto.CryptoSignatureResult;
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
import org.openintents.crypto.ICryptoCallback;
|
import org.openintents.openpgp.IOpenPgpCallback;
|
||||||
import org.openintents.crypto.ICryptoService;
|
import org.openintents.openpgp.IOpenPgpService;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@ -42,14 +42,14 @@ import android.widget.ListAdapter;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class CryptoProviderDemoActivity extends Activity {
|
public class OpenPGPProviderActivity extends Activity {
|
||||||
Activity mActivity;
|
Activity mActivity;
|
||||||
|
|
||||||
EditText mMessage;
|
EditText mMessage;
|
||||||
EditText mCiphertext;
|
EditText mCiphertext;
|
||||||
EditText mEncryptUserIds;
|
EditText mEncryptUserIds;
|
||||||
|
|
||||||
private CryptoServiceConnection mCryptoServiceConnection;
|
private OpenPgpServiceConnection mCryptoServiceConnection;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
@ -68,10 +68,10 @@ public class CryptoProviderDemoActivity extends Activity {
|
|||||||
/**
|
/**
|
||||||
* Callback from remote crypto service
|
* Callback from remote crypto service
|
||||||
*/
|
*/
|
||||||
final ICryptoCallback.Stub encryptCallback = new ICryptoCallback.Stub() {
|
final IOpenPgpCallback.Stub encryptCallback = new IOpenPgpCallback.Stub() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final byte[] outputBytes, CryptoSignatureResult signatureResult)
|
public void onSuccess(final byte[] outputBytes, OpenPgpSignatureResult signatureResult)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
Log.d(Constants.TAG, "encryptCallback");
|
Log.d(Constants.TAG, "encryptCallback");
|
||||||
|
|
||||||
@ -85,16 +85,16 @@ public class CryptoProviderDemoActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(CryptoError error) throws RemoteException {
|
public void onError(OpenPgpError error) throws RemoteException {
|
||||||
handleError(error);
|
handleError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
final ICryptoCallback.Stub decryptAndVerifyCallback = new ICryptoCallback.Stub() {
|
final IOpenPgpCallback.Stub decryptAndVerifyCallback = new IOpenPgpCallback.Stub() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final byte[] outputBytes, final CryptoSignatureResult signatureResult)
|
public void onSuccess(final byte[] outputBytes, final OpenPgpSignatureResult signatureResult)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
Log.d(Constants.TAG, "decryptAndVerifyCallback");
|
Log.d(Constants.TAG, "decryptAndVerifyCallback");
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ public class CryptoProviderDemoActivity extends Activity {
|
|||||||
public void run() {
|
public void run() {
|
||||||
mMessage.setText(new String(outputBytes));
|
mMessage.setText(new String(outputBytes));
|
||||||
if (signatureResult != null) {
|
if (signatureResult != null) {
|
||||||
Toast.makeText(CryptoProviderDemoActivity.this,
|
Toast.makeText(OpenPGPProviderActivity.this,
|
||||||
"signature result:\n" + signatureResult.toString(),
|
"signature result:\n" + signatureResult.toString(),
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
@ -114,13 +114,13 @@ public class CryptoProviderDemoActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(CryptoError error) throws RemoteException {
|
public void onError(OpenPgpError error) throws RemoteException {
|
||||||
handleError(error);
|
handleError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private void handleError(final CryptoError error) {
|
private void handleError(final OpenPgpError error) {
|
||||||
mActivity.runOnUiThread(new Runnable() {
|
mActivity.runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -186,12 +186,12 @@ public class CryptoProviderDemoActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CryptoProviderElement {
|
private static class OpenPGPProviderElement {
|
||||||
private String packageName;
|
private String packageName;
|
||||||
private String simpleName;
|
private String simpleName;
|
||||||
private Drawable icon;
|
private Drawable icon;
|
||||||
|
|
||||||
public CryptoProviderElement(String packageName, String simpleName, Drawable icon) {
|
public OpenPGPProviderElement(String packageName, String simpleName, Drawable icon) {
|
||||||
this.packageName = packageName;
|
this.packageName = packageName;
|
||||||
this.simpleName = simpleName;
|
this.simpleName = simpleName;
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
@ -204,9 +204,9 @@ public class CryptoProviderDemoActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void selectCryptoProvider() {
|
private void selectCryptoProvider() {
|
||||||
Intent intent = new Intent(ICryptoService.class.getName());
|
Intent intent = new Intent(IOpenPgpService.class.getName());
|
||||||
|
|
||||||
final ArrayList<CryptoProviderElement> providerList = new ArrayList<CryptoProviderElement>();
|
final ArrayList<OpenPGPProviderElement> providerList = new ArrayList<OpenPGPProviderElement>();
|
||||||
|
|
||||||
List<ResolveInfo> resInfo = getPackageManager().queryIntentServices(intent, 0);
|
List<ResolveInfo> resInfo = getPackageManager().queryIntentServices(intent, 0);
|
||||||
if (!resInfo.isEmpty()) {
|
if (!resInfo.isEmpty()) {
|
||||||
@ -218,17 +218,17 @@ public class CryptoProviderDemoActivity extends Activity {
|
|||||||
String simpleName = String.valueOf(resolveInfo.serviceInfo
|
String simpleName = String.valueOf(resolveInfo.serviceInfo
|
||||||
.loadLabel(getPackageManager()));
|
.loadLabel(getPackageManager()));
|
||||||
Drawable icon = resolveInfo.serviceInfo.loadIcon(getPackageManager());
|
Drawable icon = resolveInfo.serviceInfo.loadIcon(getPackageManager());
|
||||||
providerList.add(new CryptoProviderElement(packageName, simpleName, icon));
|
providerList.add(new OpenPGPProviderElement(packageName, simpleName, icon));
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
||||||
alert.setTitle("Select Crypto Provider!");
|
alert.setTitle("Select OpenPGP Provider!");
|
||||||
alert.setCancelable(false);
|
alert.setCancelable(false);
|
||||||
|
|
||||||
if (!providerList.isEmpty()) {
|
if (!providerList.isEmpty()) {
|
||||||
|
|
||||||
// Init ArrayAdapter with Crypto Providers
|
// Init ArrayAdapter with Crypto Providers
|
||||||
ListAdapter adapter = new ArrayAdapter<CryptoProviderElement>(this,
|
ListAdapter adapter = new ArrayAdapter<OpenPGPProviderElement>(this,
|
||||||
android.R.layout.select_dialog_item, android.R.id.text1, providerList) {
|
android.R.layout.select_dialog_item, android.R.id.text1, providerList) {
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
// User super class to create the View
|
// User super class to create the View
|
||||||
@ -253,15 +253,15 @@ public class CryptoProviderDemoActivity extends Activity {
|
|||||||
String packageName = providerList.get(position).packageName;
|
String packageName = providerList.get(position).packageName;
|
||||||
|
|
||||||
// bind to service
|
// bind to service
|
||||||
mCryptoServiceConnection = new CryptoServiceConnection(
|
mCryptoServiceConnection = new OpenPgpServiceConnection(
|
||||||
CryptoProviderDemoActivity.this, packageName);
|
OpenPGPProviderActivity.this, packageName);
|
||||||
mCryptoServiceConnection.bindToService();
|
mCryptoServiceConnection.bindToService();
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
alert.setMessage("No Crypto Provider installed!");
|
alert.setMessage("No OpenPGP Provider installed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
@ -380,10 +380,10 @@
|
|||||||
<!-- android:permission="org.sufficientlysecure.keychain.permission.ACCESS_API" /> -->
|
<!-- android:permission="org.sufficientlysecure.keychain.permission.ACCESS_API" /> -->
|
||||||
|
|
||||||
|
|
||||||
<!-- Remote API internal intents -->
|
<!-- OpenPGP Remote Service API internal -->
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="org.sufficientlysecure.keychain.remote_api.CryptoServiceActivity"
|
android:name="org.sufficientlysecure.keychain.remote_api.OpenPgpServiceActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
@ -399,10 +399,10 @@
|
|||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
||||||
<!-- Remote API -->
|
<!-- OpenPGP Remote Service API -->
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="org.sufficientlysecure.keychain.remote_api.CryptoService"
|
android:name="org.sufficientlysecure.keychain.remote_api.OpenPgpService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:process=":crypto" >
|
android:process=":crypto" >
|
||||||
|
@ -14,19 +14,18 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
import org.openintents.crypto.CryptoSignatureResult;
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
import org.openintents.crypto.CryptoError;
|
import org.openintents.openpgp.OpenPgpError;
|
||||||
|
|
||||||
interface ICryptoCallback {
|
interface IOpenPgpCallback {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CryptoSignatureResult is only returned if the Callback was used from decryptAndVerify
|
* CryptoSignatureResult is only returned if the Callback was used from decryptAndVerify
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
oneway void onSuccess(in byte[] outputBytes, in CryptoSignatureResult signatureResult);
|
oneway void onSuccess(in byte[] outputBytes, in OpenPgpSignatureResult signatureResult);
|
||||||
|
|
||||||
|
oneway void onError(in OpenPgpError error);
|
||||||
oneway void onError(in CryptoError error);
|
|
||||||
}
|
}
|
@ -14,15 +14,15 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
import org.openintents.crypto.ICryptoCallback;
|
import org.openintents.openpgp.IOpenPgpCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All methods are oneway, which means they are asynchronous and non-blocking.
|
* 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.
|
* Results are returned to the callback, which has to be implemented on client side.
|
||||||
*/
|
*/
|
||||||
interface ICryptoService {
|
interface IOpenPgpService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt
|
* Encrypt
|
||||||
@ -36,7 +36,7 @@ interface ICryptoService {
|
|||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor, in ICryptoCallback callback);
|
oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor, in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign
|
* Sign
|
||||||
@ -48,7 +48,7 @@ interface ICryptoService {
|
|||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in ICryptoCallback callback);
|
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt and sign
|
* Encrypt and sign
|
||||||
@ -64,7 +64,7 @@ interface ICryptoService {
|
|||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void encryptAndSign(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor, in ICryptoCallback callback);
|
oneway void encryptAndSign(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor, in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypts and verifies given input bytes. If no signature is present this method
|
* Decrypts and verifies given input bytes. If no signature is present this method
|
||||||
@ -75,6 +75,6 @@ interface ICryptoService {
|
|||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void decryptAndVerify(in byte[] inputBytes, in ICryptoCallback callback);
|
oneway void decryptAndVerify(in byte[] inputBytes, in IOpenPgpCallback callback);
|
||||||
|
|
||||||
}
|
}
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
// Declare CryptoError so AIDL can find it and knows that it implements the parcelable protocol.
|
// Declare OpenPgpError so AIDL can find it and knows that it implements the parcelable protocol.
|
||||||
parcelable CryptoError;
|
parcelable OpenPgpError;
|
@ -14,24 +14,27 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
public class CryptoError implements Parcelable {
|
public class OpenPgpError implements Parcelable {
|
||||||
|
public static final int ID_NO_OR_WRONG_PASSPHRASE = 1;
|
||||||
|
public static final int ID_NO_USER_IDS = 2;
|
||||||
|
|
||||||
int errorId;
|
int errorId;
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
public CryptoError() {
|
public OpenPgpError() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoError(int errorId, String message) {
|
public OpenPgpError(int errorId, String message) {
|
||||||
this.errorId = errorId;
|
this.errorId = errorId;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoError(CryptoError b) {
|
public OpenPgpError(OpenPgpError b) {
|
||||||
this.errorId = b.errorId;
|
this.errorId = b.errorId;
|
||||||
this.message = b.message;
|
this.message = b.message;
|
||||||
}
|
}
|
||||||
@ -61,16 +64,16 @@ public class CryptoError implements Parcelable {
|
|||||||
dest.writeString(message);
|
dest.writeString(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<CryptoError> CREATOR = new Creator<CryptoError>() {
|
public static final Creator<OpenPgpError> CREATOR = new Creator<OpenPgpError>() {
|
||||||
public CryptoError createFromParcel(final Parcel source) {
|
public OpenPgpError createFromParcel(final Parcel source) {
|
||||||
CryptoError error = new CryptoError();
|
OpenPgpError error = new OpenPgpError();
|
||||||
error.errorId = source.readInt();
|
error.errorId = source.readInt();
|
||||||
error.message = source.readString();
|
error.message = source.readString();
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoError[] newArray(final int size) {
|
public OpenPgpError[] newArray(final int size) {
|
||||||
return new CryptoError[size];
|
return new OpenPgpError[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -14,9 +14,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
import org.openintents.crypto.ICryptoService;
|
import org.openintents.openpgp.IOpenPgpService;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -25,27 +25,27 @@ import android.content.ServiceConnection;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class CryptoServiceConnection {
|
public class OpenPgpServiceConnection {
|
||||||
private Context mApplicationContext;
|
private Context mApplicationContext;
|
||||||
|
|
||||||
private ICryptoService mService;
|
private IOpenPgpService mService;
|
||||||
private boolean bound;
|
private boolean bound;
|
||||||
private String cryptoProviderPackageName;
|
private String cryptoProviderPackageName;
|
||||||
|
|
||||||
private static final String TAG = "CryptoConnection";
|
private static final String TAG = "OpenPgpServiceConnection";
|
||||||
|
|
||||||
public CryptoServiceConnection(Context context, String cryptoProviderPackageName) {
|
public OpenPgpServiceConnection(Context context, String cryptoProviderPackageName) {
|
||||||
mApplicationContext = context.getApplicationContext();
|
mApplicationContext = context.getApplicationContext();
|
||||||
this.cryptoProviderPackageName = cryptoProviderPackageName;
|
this.cryptoProviderPackageName = cryptoProviderPackageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICryptoService getService() {
|
public IOpenPgpService getService() {
|
||||||
return mService;
|
return mService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceConnection mCryptoServiceConnection = new ServiceConnection() {
|
private ServiceConnection mCryptoServiceConnection = new ServiceConnection() {
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
mService = ICryptoService.Stub.asInterface(service);
|
mService = IOpenPgpService.Stub.asInterface(service);
|
||||||
Log.d(TAG, "connected to service");
|
Log.d(TAG, "connected to service");
|
||||||
bound = true;
|
bound = true;
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ public class CryptoServiceConnection {
|
|||||||
Log.d(TAG, "not bound yet");
|
Log.d(TAG, "not bound yet");
|
||||||
|
|
||||||
Intent serviceIntent = new Intent();
|
Intent serviceIntent = new Intent();
|
||||||
serviceIntent.setAction("org.openintents.crypto.ICryptoService");
|
serviceIntent.setAction(IOpenPgpService.class.getName());
|
||||||
serviceIntent.setPackage(cryptoProviderPackageName);
|
serviceIntent.setPackage(cryptoProviderPackageName);
|
||||||
mApplicationContext.bindService(serviceIntent, mCryptoServiceConnection,
|
mApplicationContext.bindService(serviceIntent, mCryptoServiceConnection,
|
||||||
Context.BIND_AUTO_CREATE);
|
Context.BIND_AUTO_CREATE);
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
// Declare CryptoSignatureResult so AIDL can find it and knows that it implements the parcelable protocol.
|
// Declare OpenPgpSignatureResult so AIDL can find it and knows that it implements the parcelable protocol.
|
||||||
parcelable CryptoSignatureResult;
|
parcelable OpenPgpSignatureResult;
|
@ -14,23 +14,23 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.openintents.crypto;
|
package org.openintents.openpgp;
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
public class CryptoSignatureResult implements Parcelable {
|
public class OpenPgpSignatureResult implements Parcelable {
|
||||||
String signatureUserId;
|
String signatureUserId;
|
||||||
|
|
||||||
boolean signature;
|
boolean signature;
|
||||||
boolean signatureSuccess;
|
boolean signatureSuccess;
|
||||||
boolean signatureUnknown;
|
boolean signatureUnknown;
|
||||||
|
|
||||||
public CryptoSignatureResult() {
|
public OpenPgpSignatureResult() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoSignatureResult(String signatureUserId, boolean signature,
|
public OpenPgpSignatureResult(String signatureUserId, boolean signature,
|
||||||
boolean signatureSuccess, boolean signatureUnknown) {
|
boolean signatureSuccess, boolean signatureUnknown) {
|
||||||
this.signatureUserId = signatureUserId;
|
this.signatureUserId = signatureUserId;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class CryptoSignatureResult implements Parcelable {
|
|||||||
this.signatureUnknown = signatureUnknown;
|
this.signatureUnknown = signatureUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoSignatureResult(CryptoSignatureResult b) {
|
public OpenPgpSignatureResult(OpenPgpSignatureResult b) {
|
||||||
this.signatureUserId = b.signatureUserId;
|
this.signatureUserId = b.signatureUserId;
|
||||||
|
|
||||||
this.signature = b.signature;
|
this.signature = b.signature;
|
||||||
@ -59,9 +59,9 @@ public class CryptoSignatureResult implements Parcelable {
|
|||||||
dest.writeByte((byte) (signatureUnknown ? 1 : 0));
|
dest.writeByte((byte) (signatureUnknown ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<CryptoSignatureResult> CREATOR = new Creator<CryptoSignatureResult>() {
|
public static final Creator<OpenPgpSignatureResult> CREATOR = new Creator<OpenPgpSignatureResult>() {
|
||||||
public CryptoSignatureResult createFromParcel(final Parcel source) {
|
public OpenPgpSignatureResult createFromParcel(final Parcel source) {
|
||||||
CryptoSignatureResult vr = new CryptoSignatureResult();
|
OpenPgpSignatureResult vr = new OpenPgpSignatureResult();
|
||||||
vr.signatureUserId = source.readString();
|
vr.signatureUserId = source.readString();
|
||||||
vr.signature = source.readByte() == 1;
|
vr.signature = source.readByte() == 1;
|
||||||
vr.signatureSuccess = source.readByte() == 1;
|
vr.signatureSuccess = source.readByte() == 1;
|
||||||
@ -69,8 +69,8 @@ public class CryptoSignatureResult implements Parcelable {
|
|||||||
return vr;
|
return vr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CryptoSignatureResult[] newArray(final int size) {
|
public OpenPgpSignatureResult[] newArray(final int size) {
|
||||||
return new CryptoSignatureResult[size];
|
return new OpenPgpSignatureResult[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -26,10 +26,10 @@ import java.util.concurrent.ArrayBlockingQueue;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import org.openintents.crypto.CryptoError;
|
import org.openintents.openpgp.IOpenPgpCallback;
|
||||||
import org.openintents.crypto.CryptoSignatureResult;
|
import org.openintents.openpgp.IOpenPgpService;
|
||||||
import org.openintents.crypto.ICryptoCallback;
|
import org.openintents.openpgp.OpenPgpError;
|
||||||
import org.openintents.crypto.ICryptoService;
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.Id;
|
import org.sufficientlysecure.keychain.Id;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
@ -56,7 +56,7 @@ import android.os.Message;
|
|||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
public class CryptoService extends Service {
|
public class OpenPgpService extends Service {
|
||||||
Context mContext;
|
Context mContext;
|
||||||
|
|
||||||
final ArrayBlockingQueue<Runnable> mPoolQueue = new ArrayBlockingQueue<Runnable>(100);
|
final ArrayBlockingQueue<Runnable> mPoolQueue = new ArrayBlockingQueue<Runnable>(100);
|
||||||
@ -103,12 +103,12 @@ public class CryptoService extends Service {
|
|||||||
|
|
||||||
// start passphrase dialog
|
// start passphrase dialog
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putLong(CryptoServiceActivity.EXTRA_SECRET_KEY_ID, keyId);
|
extras.putLong(OpenPgpServiceActivity.EXTRA_SECRET_KEY_ID, keyId);
|
||||||
|
|
||||||
PassphraseActivityCallback callback = new PassphraseActivityCallback();
|
PassphraseActivityCallback callback = new PassphraseActivityCallback();
|
||||||
Messenger messenger = new Messenger(new Handler(getMainLooper(), callback));
|
Messenger messenger = new Messenger(new Handler(getMainLooper(), callback));
|
||||||
|
|
||||||
pauseQueueAndStartServiceActivity(CryptoServiceActivity.ACTION_CACHE_PASSPHRASE,
|
pauseQueueAndStartServiceActivity(OpenPgpServiceActivity.ACTION_CACHE_PASSPHRASE,
|
||||||
messenger, extras);
|
messenger, extras);
|
||||||
|
|
||||||
if (callback.isSuccess()) {
|
if (callback.isSuccess()) {
|
||||||
@ -199,12 +199,12 @@ public class CryptoService extends Service {
|
|||||||
Messenger messenger = new Messenger(new Handler(getMainLooper(), callback));
|
Messenger messenger = new Messenger(new Handler(getMainLooper(), callback));
|
||||||
|
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putLongArray(CryptoServiceActivity.EXTRA_SELECTED_MASTER_KEY_IDS, keyIdsArray);
|
extras.putLongArray(OpenPgpServiceActivity.EXTRA_SELECTED_MASTER_KEY_IDS, keyIdsArray);
|
||||||
extras.putStringArrayList(CryptoServiceActivity.EXTRA_MISSING_USER_IDS, missingUserIds);
|
extras.putStringArrayList(OpenPgpServiceActivity.EXTRA_MISSING_USER_IDS, missingUserIds);
|
||||||
extras.putStringArrayList(CryptoServiceActivity.EXTRA_DUBLICATE_USER_IDS,
|
extras.putStringArrayList(OpenPgpServiceActivity.EXTRA_DUBLICATE_USER_IDS,
|
||||||
dublicateUserIds);
|
dublicateUserIds);
|
||||||
|
|
||||||
pauseQueueAndStartServiceActivity(CryptoServiceActivity.ACTION_SELECT_PUB_KEYS,
|
pauseQueueAndStartServiceActivity(OpenPgpServiceActivity.ACTION_SELECT_PUB_KEYS,
|
||||||
messenger, extras);
|
messenger, extras);
|
||||||
|
|
||||||
if (callback.isSuccess()) {
|
if (callback.isSuccess()) {
|
||||||
@ -255,7 +255,7 @@ public class CryptoService extends Service {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private synchronized void encryptAndSignSafe(byte[] inputBytes, String[] encryptionUserIds,
|
private synchronized void encryptAndSignSafe(byte[] inputBytes, String[] encryptionUserIds,
|
||||||
boolean asciiArmor, ICryptoCallback callback, AppSettings appSettings, boolean sign)
|
boolean asciiArmor, IOpenPgpCallback callback, AppSettings appSettings, boolean sign)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
try {
|
try {
|
||||||
// build InputData and write into OutputStream
|
// build InputData and write into OutputStream
|
||||||
@ -267,14 +267,14 @@ public class CryptoService extends Service {
|
|||||||
|
|
||||||
long[] keyIds = getKeyIdsFromEmails(encryptionUserIds, appSettings.getKeyId());
|
long[] keyIds = getKeyIdsFromEmails(encryptionUserIds, appSettings.getKeyId());
|
||||||
if (keyIds == null) {
|
if (keyIds == null) {
|
||||||
callback.onError(new CryptoError(CryptoError.ID_NO_USER_IDS, "No user ids!"));
|
callback.onError(new OpenPgpError(OpenPgpError.ID_NO_USER_IDS, "No user ids!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sign) {
|
if (sign) {
|
||||||
String passphrase = getCachedPassphrase(appSettings.getKeyId());
|
String passphrase = getCachedPassphrase(appSettings.getKeyId());
|
||||||
if (passphrase == null) {
|
if (passphrase == null) {
|
||||||
callback.onError(new CryptoError(CryptoError.ID_NO_OR_WRONG_PASSPHRASE,
|
callback.onError(new OpenPgpError(OpenPgpError.ID_NO_OR_WRONG_PASSPHRASE,
|
||||||
"No or wrong passphrase!"));
|
"No or wrong passphrase!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ public class CryptoService extends Service {
|
|||||||
Log.e(Constants.TAG, "KeychainService, Exception!", e);
|
Log.e(Constants.TAG, "KeychainService, Exception!", e);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
callback.onError(new CryptoError(0, e.getMessage()));
|
callback.onError(new OpenPgpError(0, e.getMessage()));
|
||||||
} catch (Exception t) {
|
} catch (Exception t) {
|
||||||
Log.e(Constants.TAG, "Error returning exception to client", t);
|
Log.e(Constants.TAG, "Error returning exception to client", t);
|
||||||
}
|
}
|
||||||
@ -308,7 +308,7 @@ public class CryptoService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: asciiArmor?!
|
// TODO: asciiArmor?!
|
||||||
private void signSafe(byte[] inputBytes, ICryptoCallback callback, AppSettings appSettings)
|
private void signSafe(byte[] inputBytes, IOpenPgpCallback callback, AppSettings appSettings)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
try {
|
try {
|
||||||
Log.d(Constants.TAG, "current therad id: " + Thread.currentThread().getId());
|
Log.d(Constants.TAG, "current therad id: " + Thread.currentThread().getId());
|
||||||
@ -322,7 +322,7 @@ public class CryptoService extends Service {
|
|||||||
|
|
||||||
String passphrase = getCachedPassphrase(appSettings.getKeyId());
|
String passphrase = getCachedPassphrase(appSettings.getKeyId());
|
||||||
if (passphrase == null) {
|
if (passphrase == null) {
|
||||||
callback.onError(new CryptoError(CryptoError.ID_NO_OR_WRONG_PASSPHRASE,
|
callback.onError(new OpenPgpError(OpenPgpError.ID_NO_OR_WRONG_PASSPHRASE,
|
||||||
"No or wrong passphrase!"));
|
"No or wrong passphrase!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -341,14 +341,14 @@ public class CryptoService extends Service {
|
|||||||
Log.e(Constants.TAG, "KeychainService, Exception!", e);
|
Log.e(Constants.TAG, "KeychainService, Exception!", e);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
callback.onError(new CryptoError(0, e.getMessage()));
|
callback.onError(new OpenPgpError(0, e.getMessage()));
|
||||||
} catch (Exception t) {
|
} catch (Exception t) {
|
||||||
Log.e(Constants.TAG, "Error returning exception to client", t);
|
Log.e(Constants.TAG, "Error returning exception to client", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void decryptAndVerifySafe(byte[] inputBytes, ICryptoCallback callback,
|
private synchronized void decryptAndVerifySafe(byte[] inputBytes, IOpenPgpCallback callback,
|
||||||
AppSettings appSettings) throws RemoteException {
|
AppSettings appSettings) throws RemoteException {
|
||||||
try {
|
try {
|
||||||
// TODO: this is not really needed
|
// TODO: this is not really needed
|
||||||
@ -432,7 +432,7 @@ public class CryptoService extends Service {
|
|||||||
|
|
||||||
passphrase = getCachedPassphrase(secretKeyId);
|
passphrase = getCachedPassphrase(secretKeyId);
|
||||||
if (passphrase == null) {
|
if (passphrase == null) {
|
||||||
callback.onError(new CryptoError(CryptoError.ID_NO_OR_WRONG_PASSPHRASE,
|
callback.onError(new OpenPgpError(OpenPgpError.ID_NO_OR_WRONG_PASSPHRASE,
|
||||||
"No or wrong passphrase!"));
|
"No or wrong passphrase!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -470,10 +470,10 @@ public class CryptoService extends Service {
|
|||||||
boolean signatureUnknown = outputBundle
|
boolean signatureUnknown = outputBundle
|
||||||
.getBoolean(KeychainIntentService.RESULT_SIGNATURE_UNKNOWN);
|
.getBoolean(KeychainIntentService.RESULT_SIGNATURE_UNKNOWN);
|
||||||
|
|
||||||
CryptoSignatureResult sigResult = null;
|
OpenPgpSignatureResult sigResult = null;
|
||||||
if (signature) {
|
if (signature) {
|
||||||
sigResult = new CryptoSignatureResult(signatureUserId, signature, signatureSuccess,
|
sigResult = new OpenPgpSignatureResult(signatureUserId, signature,
|
||||||
signatureUnknown);
|
signatureSuccess, signatureUnknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return over handler on client side
|
// return over handler on client side
|
||||||
@ -482,18 +482,18 @@ public class CryptoService extends Service {
|
|||||||
Log.e(Constants.TAG, "KeychainService, Exception!", e);
|
Log.e(Constants.TAG, "KeychainService, Exception!", e);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
callback.onError(new CryptoError(0, e.getMessage()));
|
callback.onError(new OpenPgpError(0, e.getMessage()));
|
||||||
} catch (Exception t) {
|
} catch (Exception t) {
|
||||||
Log.e(Constants.TAG, "Error returning exception to client", t);
|
Log.e(Constants.TAG, "Error returning exception to client", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ICryptoService.Stub mBinder = new ICryptoService.Stub() {
|
private final IOpenPgpService.Stub mBinder = new IOpenPgpService.Stub() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encrypt(final byte[] inputBytes, final String[] encryptionUserIds,
|
public void encrypt(final byte[] inputBytes, final String[] encryptionUserIds,
|
||||||
final boolean asciiArmor, final ICryptoCallback callback) throws RemoteException {
|
final boolean asciiArmor, final IOpenPgpCallback callback) throws RemoteException {
|
||||||
|
|
||||||
final AppSettings settings = getAppSettings();
|
final AppSettings settings = getAppSettings();
|
||||||
|
|
||||||
@ -515,7 +515,7 @@ public class CryptoService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encryptAndSign(final byte[] inputBytes, final String[] encryptionUserIds,
|
public void encryptAndSign(final byte[] inputBytes, final String[] encryptionUserIds,
|
||||||
final boolean asciiArmor, final ICryptoCallback callback) throws RemoteException {
|
final boolean asciiArmor, final IOpenPgpCallback callback) throws RemoteException {
|
||||||
|
|
||||||
final AppSettings settings = getAppSettings();
|
final AppSettings settings = getAppSettings();
|
||||||
|
|
||||||
@ -536,8 +536,8 @@ public class CryptoService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sign(final byte[] inputBytes, boolean asciiArmor, final ICryptoCallback callback)
|
public void sign(final byte[] inputBytes, boolean asciiArmor,
|
||||||
throws RemoteException {
|
final IOpenPgpCallback callback) throws RemoteException {
|
||||||
final AppSettings settings = getAppSettings();
|
final AppSettings settings = getAppSettings();
|
||||||
|
|
||||||
Runnable r = new Runnable() {
|
Runnable r = new Runnable() {
|
||||||
@ -557,7 +557,7 @@ public class CryptoService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decryptAndVerify(final byte[] inputBytes, final ICryptoCallback callback)
|
public void decryptAndVerify(final byte[] inputBytes, final IOpenPgpCallback callback)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
|
||||||
final AppSettings settings = getAppSettings();
|
final AppSettings settings = getAppSettings();
|
||||||
@ -591,12 +591,12 @@ public class CryptoService extends Service {
|
|||||||
Log.e(Constants.TAG, "Not allowed to use service! Starting activity for registration!");
|
Log.e(Constants.TAG, "Not allowed to use service! Starting activity for registration!");
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
// TODO: currently simply uses first entry
|
// TODO: currently simply uses first entry
|
||||||
extras.putString(CryptoServiceActivity.EXTRA_PACKAGE_NAME, callingPackages[0]);
|
extras.putString(OpenPgpServiceActivity.EXTRA_PACKAGE_NAME, callingPackages[0]);
|
||||||
|
|
||||||
RegisterActivityCallback callback = new RegisterActivityCallback();
|
RegisterActivityCallback callback = new RegisterActivityCallback();
|
||||||
Messenger messenger = new Messenger(new Handler(getMainLooper(), callback));
|
Messenger messenger = new Messenger(new Handler(getMainLooper(), callback));
|
||||||
|
|
||||||
pauseQueueAndStartServiceActivity(CryptoServiceActivity.ACTION_REGISTER, messenger,
|
pauseQueueAndStartServiceActivity(OpenPgpServiceActivity.ACTION_REGISTER, messenger,
|
||||||
extras);
|
extras);
|
||||||
|
|
||||||
if (callback.isAllowed()) {
|
if (callback.isAllowed()) {
|
||||||
@ -726,11 +726,11 @@ public class CryptoService extends Service {
|
|||||||
mThreadPool.pause();
|
mThreadPool.pause();
|
||||||
|
|
||||||
Log.d(Constants.TAG, "starting activity...");
|
Log.d(Constants.TAG, "starting activity...");
|
||||||
Intent intent = new Intent(getBaseContext(), CryptoServiceActivity.class);
|
Intent intent = new Intent(getBaseContext(), OpenPgpServiceActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
intent.setAction(action);
|
intent.setAction(action);
|
||||||
|
|
||||||
extras.putParcelable(CryptoServiceActivity.EXTRA_MESSENGER, messenger);
|
extras.putParcelable(OpenPgpServiceActivity.EXTRA_MESSENGER, messenger);
|
||||||
intent.putExtras(extras);
|
intent.putExtras(extras);
|
||||||
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
@ -41,7 +41,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||||
|
|
||||||
public class CryptoServiceActivity extends SherlockFragmentActivity {
|
public class OpenPgpServiceActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
public static final String ACTION_REGISTER = Constants.INTENT_PREFIX + "API_ACTIVITY_REGISTER";
|
public static final String ACTION_REGISTER = Constants.INTENT_PREFIX + "API_ACTIVITY_REGISTER";
|
||||||
public static final String ACTION_CACHE_PASSPHRASE = Constants.INTENT_PREFIX
|
public static final String ACTION_CACHE_PASSPHRASE = Constants.INTENT_PREFIX
|
||||||
@ -84,7 +84,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
|
|
||||||
if (!finishHandled) {
|
if (!finishHandled) {
|
||||||
Message msg = Message.obtain();
|
Message msg = Message.obtain();
|
||||||
msg.arg1 = CryptoService.RegisterActivityCallback.CANCEL;
|
msg.arg1 = OpenPgpService.RegisterActivityCallback.CANCEL;
|
||||||
try {
|
try {
|
||||||
mMessenger.send(msg);
|
mMessenger.send(msg);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@ -120,17 +120,17 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
|
|
||||||
// user needs to select a key!
|
// user needs to select a key!
|
||||||
if (mSettingsFragment.getAppSettings().getKeyId() == Id.key.none) {
|
if (mSettingsFragment.getAppSettings().getKeyId() == Id.key.none) {
|
||||||
Toast.makeText(CryptoServiceActivity.this,
|
Toast.makeText(OpenPgpServiceActivity.this,
|
||||||
R.string.api_register_error_select_key, Toast.LENGTH_LONG)
|
R.string.api_register_error_select_key, Toast.LENGTH_LONG)
|
||||||
.show();
|
.show();
|
||||||
} else {
|
} else {
|
||||||
ProviderHelper.insertApiApp(CryptoServiceActivity.this,
|
ProviderHelper.insertApiApp(OpenPgpServiceActivity.this,
|
||||||
mSettingsFragment.getAppSettings());
|
mSettingsFragment.getAppSettings());
|
||||||
|
|
||||||
Message msg = Message.obtain();
|
Message msg = Message.obtain();
|
||||||
msg.arg1 = CryptoService.RegisterActivityCallback.OKAY;
|
msg.arg1 = OpenPgpService.RegisterActivityCallback.OKAY;
|
||||||
Bundle data = new Bundle();
|
Bundle data = new Bundle();
|
||||||
data.putString(CryptoService.RegisterActivityCallback.PACKAGE_NAME,
|
data.putString(OpenPgpService.RegisterActivityCallback.PACKAGE_NAME,
|
||||||
packageName);
|
packageName);
|
||||||
msg.setData(data);
|
msg.setData(data);
|
||||||
try {
|
try {
|
||||||
@ -149,7 +149,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
// Disallow
|
// Disallow
|
||||||
|
|
||||||
Message msg = Message.obtain();
|
Message msg = Message.obtain();
|
||||||
msg.arg1 = CryptoService.RegisterActivityCallback.CANCEL;
|
msg.arg1 = OpenPgpService.RegisterActivityCallback.CANCEL;
|
||||||
try {
|
try {
|
||||||
mMessenger.send(msg);
|
mMessenger.send(msg);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@ -210,10 +210,10 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
// ok
|
// ok
|
||||||
|
|
||||||
Message msg = Message.obtain();
|
Message msg = Message.obtain();
|
||||||
msg.arg1 = CryptoService.SelectPubKeysActivityCallback.OKAY;
|
msg.arg1 = OpenPgpService.SelectPubKeysActivityCallback.OKAY;
|
||||||
Bundle data = new Bundle();
|
Bundle data = new Bundle();
|
||||||
data.putLongArray(
|
data.putLongArray(
|
||||||
CryptoService.SelectPubKeysActivityCallback.PUB_KEY_IDS,
|
OpenPgpService.SelectPubKeysActivityCallback.PUB_KEY_IDS,
|
||||||
mSelectFragment.getSelectedMasterKeyIds());
|
mSelectFragment.getSelectedMasterKeyIds());
|
||||||
msg.setData(data);
|
msg.setData(data);
|
||||||
try {
|
try {
|
||||||
@ -231,7 +231,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
// cancel
|
// cancel
|
||||||
|
|
||||||
Message msg = Message.obtain();
|
Message msg = Message.obtain();
|
||||||
msg.arg1 = CryptoService.SelectPubKeysActivityCallback.CANCEL;
|
msg.arg1 = OpenPgpService.SelectPubKeysActivityCallback.CANCEL;
|
||||||
;
|
;
|
||||||
try {
|
try {
|
||||||
mMessenger.send(msg);
|
mMessenger.send(msg);
|
||||||
@ -287,7 +287,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
public void handleMessage(Message message) {
|
public void handleMessage(Message message) {
|
||||||
if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) {
|
if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) {
|
||||||
Message msg = Message.obtain();
|
Message msg = Message.obtain();
|
||||||
msg.arg1 = CryptoService.PassphraseActivityCallback.OKAY;
|
msg.arg1 = OpenPgpService.PassphraseActivityCallback.OKAY;
|
||||||
try {
|
try {
|
||||||
mMessenger.send(msg);
|
mMessenger.send(msg);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@ -295,7 +295,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Message msg = Message.obtain();
|
Message msg = Message.obtain();
|
||||||
msg.arg1 = CryptoService.PassphraseActivityCallback.CANCEL;
|
msg.arg1 = OpenPgpService.PassphraseActivityCallback.CANCEL;
|
||||||
try {
|
try {
|
||||||
mMessenger.send(msg);
|
mMessenger.send(msg);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
Loading…
Reference in New Issue
Block a user