mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 12:32:17 -05:00
API update: boolean to allow/disallow user interaction allow real background pgp operations that will not require user input
This commit is contained in:
parent
53f33dc3cb
commit
4e23cf2edc
@ -33,10 +33,13 @@ interface IOpenPgpService {
|
|||||||
* User Ids (emails) of recipients
|
* User Ids (emails) of recipients
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
|
* @param allowUserInteraction
|
||||||
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @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 IOpenPgpCallback callback);
|
oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds,
|
||||||
|
in boolean asciiArmor, in boolean allowUserInteraction, in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign
|
* Sign
|
||||||
@ -45,10 +48,13 @@ interface IOpenPgpService {
|
|||||||
* Byte array you want to encrypt
|
* Byte array you want to encrypt
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
|
* @param allowUserInteraction
|
||||||
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in IOpenPgpCallback callback);
|
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in boolean allowUserInteraction,
|
||||||
|
in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign then encrypt
|
* Sign then encrypt
|
||||||
@ -61,10 +67,13 @@ interface IOpenPgpService {
|
|||||||
* User Ids (email) of sender
|
* User Ids (email) of sender
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
|
* @param allowUserInteraction
|
||||||
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void signAndEncrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor, in IOpenPgpCallback callback);
|
oneway void signAndEncrypt(in byte[] inputBytes, in String[] encryptionUserIds,
|
||||||
|
in boolean asciiArmor, in boolean allowUserInteraction, 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
|
||||||
@ -72,9 +81,12 @@ interface IOpenPgpService {
|
|||||||
*
|
*
|
||||||
* @param inputBytes
|
* @param inputBytes
|
||||||
* Byte array you want to decrypt and verify
|
* Byte array you want to decrypt and verify
|
||||||
|
* @param allowUserInteraction
|
||||||
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void decryptAndVerify(in byte[] inputBytes, in IOpenPgpCallback callback);
|
oneway void decryptAndVerify(in byte[] inputBytes, in boolean allowUserInteraction,
|
||||||
|
in IOpenPgpCallback callback);
|
||||||
|
|
||||||
}
|
}
|
@ -139,7 +139,7 @@ public class OpenPgpProviderActivity extends Activity {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
mCryptoServiceConnection.getService().encrypt(inputBytes,
|
mCryptoServiceConnection.getService().encrypt(inputBytes,
|
||||||
mEncryptUserIds.getText().toString().split(","), true, encryptCallback);
|
mEncryptUserIds.getText().toString().split(","), true, true, encryptCallback);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ public class OpenPgpProviderActivity extends Activity {
|
|||||||
byte[] inputBytes = mMessage.getText().toString().getBytes();
|
byte[] inputBytes = mMessage.getText().toString().getBytes();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mCryptoServiceConnection.getService().sign(inputBytes, true, encryptCallback);
|
mCryptoServiceConnection.getService().sign(inputBytes, true, true, encryptCallback);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
||||||
}
|
}
|
||||||
@ -160,7 +160,7 @@ public class OpenPgpProviderActivity extends Activity {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
mCryptoServiceConnection.getService().signAndEncrypt(inputBytes,
|
mCryptoServiceConnection.getService().signAndEncrypt(inputBytes,
|
||||||
mEncryptUserIds.getText().toString().split(","), true, encryptCallback);
|
mEncryptUserIds.getText().toString().split(","), true, true, encryptCallback);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ public class OpenPgpProviderActivity extends Activity {
|
|||||||
byte[] inputBytes = mCiphertext.getText().toString().getBytes();
|
byte[] inputBytes = mCiphertext.getText().toString().getBytes();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mCryptoServiceConnection.getService().decryptAndVerify(inputBytes,
|
mCryptoServiceConnection.getService().decryptAndVerify(inputBytes, true,
|
||||||
decryptAndVerifyCallback);
|
decryptAndVerifyCallback);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
Log.e(Constants.TAG, "CryptoProviderDemo", e);
|
||||||
@ -228,8 +228,8 @@ public class OpenPgpProviderActivity extends Activity {
|
|||||||
|
|
||||||
if (!providerList.isEmpty()) {
|
if (!providerList.isEmpty()) {
|
||||||
// add "disable OpenPGP provider"
|
// add "disable OpenPGP provider"
|
||||||
providerList.add(0, new OpenPgpProviderElement(null, "Disable OpenPGP Provider", getResources()
|
providerList.add(0, new OpenPgpProviderElement(null, "Disable OpenPGP Provider",
|
||||||
.getDrawable(android.R.drawable.ic_menu_close_clear_cancel)));
|
getResources().getDrawable(android.R.drawable.ic_menu_close_clear_cancel)));
|
||||||
|
|
||||||
// Init ArrayAdapter with OpenPGP Providers
|
// Init ArrayAdapter with OpenPGP Providers
|
||||||
ListAdapter adapter = new ArrayAdapter<OpenPgpProviderElement>(this,
|
ListAdapter adapter = new ArrayAdapter<OpenPgpProviderElement>(this,
|
||||||
|
@ -33,10 +33,13 @@ interface IOpenPgpService {
|
|||||||
* User Ids (emails) of recipients
|
* User Ids (emails) of recipients
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
|
* @param allowUserInteraction
|
||||||
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @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 IOpenPgpCallback callback);
|
oneway void encrypt(in byte[] inputBytes, in String[] encryptionUserIds,
|
||||||
|
in boolean asciiArmor, in boolean allowUserInteraction, in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign
|
* Sign
|
||||||
@ -45,10 +48,13 @@ interface IOpenPgpService {
|
|||||||
* Byte array you want to encrypt
|
* Byte array you want to encrypt
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
|
* @param allowUserInteraction
|
||||||
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in IOpenPgpCallback callback);
|
oneway void sign(in byte[] inputBytes, in boolean asciiArmor, in boolean allowUserInteraction,
|
||||||
|
in IOpenPgpCallback callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign then encrypt
|
* Sign then encrypt
|
||||||
@ -61,10 +67,13 @@ interface IOpenPgpService {
|
|||||||
* User Ids (email) of sender
|
* User Ids (email) of sender
|
||||||
* @param asciiArmor
|
* @param asciiArmor
|
||||||
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
* Encode for ASCII (Radix-64, 33 percent overhead compared to binary)
|
||||||
|
* @param allowUserInteraction
|
||||||
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void signAndEncrypt(in byte[] inputBytes, in String[] encryptionUserIds, in boolean asciiArmor, in IOpenPgpCallback callback);
|
oneway void signAndEncrypt(in byte[] inputBytes, in String[] encryptionUserIds,
|
||||||
|
in boolean asciiArmor, in boolean allowUserInteraction, 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
|
||||||
@ -72,9 +81,12 @@ interface IOpenPgpService {
|
|||||||
*
|
*
|
||||||
* @param inputBytes
|
* @param inputBytes
|
||||||
* Byte array you want to decrypt and verify
|
* Byte array you want to decrypt and verify
|
||||||
|
* @param allowUserInteraction
|
||||||
|
* Allows the OpenPGP Provider to handle missing keys by showing activities
|
||||||
* @param callback
|
* @param callback
|
||||||
* Callback where to return results
|
* Callback where to return results
|
||||||
*/
|
*/
|
||||||
oneway void decryptAndVerify(in byte[] inputBytes, in IOpenPgpCallback callback);
|
oneway void decryptAndVerify(in byte[] inputBytes, in boolean allowUserInteraction,
|
||||||
|
in IOpenPgpCallback callback);
|
||||||
|
|
||||||
}
|
}
|
@ -217,8 +217,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private synchronized void encryptAndSignSafe(byte[] inputBytes, String[] encryptionUserIds,
|
private synchronized void encryptAndSignSafe(byte[] inputBytes, String[] encryptionUserIds,
|
||||||
boolean asciiArmor, IOpenPgpCallback callback, AppSettings appSettings, boolean sign)
|
boolean asciiArmor, boolean allowUserInteraction, IOpenPgpCallback callback,
|
||||||
throws RemoteException {
|
AppSettings appSettings, boolean sign) throws RemoteException {
|
||||||
try {
|
try {
|
||||||
// build InputData and write into OutputStream
|
// build InputData and write into OutputStream
|
||||||
InputStream inputStream = new ByteArrayInputStream(inputBytes);
|
InputStream inputStream = new ByteArrayInputStream(inputBytes);
|
||||||
@ -269,8 +269,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: asciiArmor?!
|
// TODO: asciiArmor?!
|
||||||
private void signSafe(byte[] inputBytes, IOpenPgpCallback callback, AppSettings appSettings)
|
private void signSafe(byte[] inputBytes, boolean allowUserInteraction,
|
||||||
throws RemoteException {
|
IOpenPgpCallback callback, AppSettings appSettings) throws RemoteException {
|
||||||
try {
|
try {
|
||||||
Log.d(Constants.TAG, "current therad id: " + Thread.currentThread().getId());
|
Log.d(Constants.TAG, "current therad id: " + Thread.currentThread().getId());
|
||||||
|
|
||||||
@ -309,8 +309,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void decryptAndVerifySafe(byte[] inputBytes, IOpenPgpCallback callback,
|
private synchronized void decryptAndVerifySafe(byte[] inputBytes, boolean allowUserInteraction,
|
||||||
AppSettings appSettings) throws RemoteException {
|
IOpenPgpCallback callback, AppSettings appSettings) throws RemoteException {
|
||||||
try {
|
try {
|
||||||
// TODO: this is not really needed
|
// TODO: this is not really needed
|
||||||
// checked if it is text with BEGIN and END tags
|
// checked if it is text with BEGIN and END tags
|
||||||
@ -459,7 +459,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encrypt(final byte[] inputBytes, final String[] encryptionUserIds,
|
public void encrypt(final byte[] inputBytes, final String[] encryptionUserIds,
|
||||||
final boolean asciiArmor, final IOpenPgpCallback callback) throws RemoteException {
|
final boolean asciiArmor, final boolean allowUserInteraction,
|
||||||
|
final IOpenPgpCallback callback) throws RemoteException {
|
||||||
|
|
||||||
final AppSettings settings = getAppSettings();
|
final AppSettings settings = getAppSettings();
|
||||||
|
|
||||||
@ -468,8 +469,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
encryptAndSignSafe(inputBytes, encryptionUserIds, asciiArmor, callback,
|
encryptAndSignSafe(inputBytes, encryptionUserIds, asciiArmor,
|
||||||
settings, false);
|
allowUserInteraction, callback, settings, false);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "OpenPgpService", e);
|
Log.e(Constants.TAG, "OpenPgpService", e);
|
||||||
}
|
}
|
||||||
@ -481,7 +482,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void signAndEncrypt(final byte[] inputBytes, final String[] encryptionUserIds,
|
public void signAndEncrypt(final byte[] inputBytes, final String[] encryptionUserIds,
|
||||||
final boolean asciiArmor, final IOpenPgpCallback callback) throws RemoteException {
|
final boolean asciiArmor, final boolean allowUserInteraction,
|
||||||
|
final IOpenPgpCallback callback) throws RemoteException {
|
||||||
|
|
||||||
final AppSettings settings = getAppSettings();
|
final AppSettings settings = getAppSettings();
|
||||||
|
|
||||||
@ -490,8 +492,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
encryptAndSignSafe(inputBytes, encryptionUserIds, asciiArmor, callback,
|
encryptAndSignSafe(inputBytes, encryptionUserIds, asciiArmor,
|
||||||
settings, true);
|
allowUserInteraction, callback, settings, true);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "OpenPgpService", e);
|
Log.e(Constants.TAG, "OpenPgpService", e);
|
||||||
}
|
}
|
||||||
@ -503,7 +505,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sign(final byte[] inputBytes, boolean asciiArmor,
|
public void sign(final byte[] inputBytes, boolean asciiArmor,
|
||||||
final IOpenPgpCallback callback) throws RemoteException {
|
final boolean allowUserInteraction, final IOpenPgpCallback callback)
|
||||||
|
throws RemoteException {
|
||||||
final AppSettings settings = getAppSettings();
|
final AppSettings settings = getAppSettings();
|
||||||
|
|
||||||
Runnable r = new Runnable() {
|
Runnable r = new Runnable() {
|
||||||
@ -511,7 +514,7 @@ public class OpenPgpService extends RemoteService {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
signSafe(inputBytes, callback, settings);
|
signSafe(inputBytes, allowUserInteraction, callback, settings);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "OpenPgpService", e);
|
Log.e(Constants.TAG, "OpenPgpService", e);
|
||||||
}
|
}
|
||||||
@ -523,8 +526,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decryptAndVerify(final byte[] inputBytes, final IOpenPgpCallback callback)
|
public void decryptAndVerify(final byte[] inputBytes, final boolean allowUserInteraction,
|
||||||
throws RemoteException {
|
final IOpenPgpCallback callback) throws RemoteException {
|
||||||
|
|
||||||
final AppSettings settings = getAppSettings();
|
final AppSettings settings = getAppSettings();
|
||||||
|
|
||||||
@ -533,7 +536,7 @@ public class OpenPgpService extends RemoteService {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
decryptAndVerifySafe(inputBytes, callback, settings);
|
decryptAndVerifySafe(inputBytes, allowUserInteraction, callback, settings);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "OpenPgpService", e);
|
Log.e(Constants.TAG, "OpenPgpService", e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user