Java Code Examples for org.openintents.openpgp.util.OpenPgpApi#executeApiAsync()

The following examples show how to use org.openintents.openpgp.util.OpenPgpApi#executeApiAsync() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenPgpApiActivity.java    From openpgp-api with Apache License 2.0 5 votes vote down vote up
public void cleartextSign(Intent data) {
    data.setAction(OpenPgpApi.ACTION_CLEARTEXT_SIGN);
    data.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, mSignKeyId);

    InputStream is = getInputstream(false);
    ByteArrayOutputStream os = new ByteArrayOutputStream();

    OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
    api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_CLEARTEXT_SIGN));
}
 
Example 2
Source File: OpenPgpApiActivity.java    From openpgp-api with Apache License 2.0 5 votes vote down vote up
public void detachedSign(Intent data) {
    data.setAction(OpenPgpApi.ACTION_DETACHED_SIGN);
    data.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, mSignKeyId);

    InputStream is = getInputstream(false);
    // no output stream needed, detached signature is returned as RESULT_DETACHED_SIGNATURE

    OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
    api.executeApiAsync(data, is, null, new MyCallback(true, null, REQUEST_CODE_DETACHED_SIGN));
}
 
Example 3
Source File: OpenPgpApiActivity.java    From openpgp-api with Apache License 2.0 5 votes vote down vote up
public void encrypt(Intent data) {
    data.setAction(OpenPgpApi.ACTION_ENCRYPT);
    if (!TextUtils.isEmpty(mEncryptUserIds.getText().toString())) {
        data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mEncryptUserIds.getText().toString().split(","));
    }
    data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);

    InputStream is = getInputstream(false);
    ByteArrayOutputStream os = new ByteArrayOutputStream();

    OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
    api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_ENCRYPT));
}
 
Example 4
Source File: OpenPgpApiActivity.java    From openpgp-api with Apache License 2.0 5 votes vote down vote up
public void signAndEncrypt(Intent data) {
    data.setAction(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT);
    data.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, mSignKeyId);
    if (!TextUtils.isEmpty(mEncryptUserIds.getText().toString())) {
        data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mEncryptUserIds.getText().toString().split(","));
    }
    data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);

    InputStream is = getInputstream(false);
    ByteArrayOutputStream os = new ByteArrayOutputStream();

    OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
    api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_SIGN_AND_ENCRYPT));
}
 
Example 5
Source File: OpenPgpApiActivity.java    From openpgp-api with Apache License 2.0 5 votes vote down vote up
public void decryptAndVerify(Intent data) {
    data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);

    InputStream is = getInputstream(true);
    ByteArrayOutputStream os = new ByteArrayOutputStream();

    OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
    api.executeApiAsync(data, is, os, new MyCallback(false, os, REQUEST_CODE_DECRYPT_AND_VERIFY));
}
 
Example 6
Source File: OpenPgpApiActivity.java    From openpgp-api with Apache License 2.0 5 votes vote down vote up
public void decryptAndVerifyDetached(Intent data) {
    data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
    data.putExtra(OpenPgpApi.EXTRA_DETACHED_SIGNATURE, mDetachedSignature.getText().toString().getBytes());

    // use from text from mMessage
    InputStream is = getInputstream(false);

    OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
    api.executeApiAsync(data, is, null, new MyCallback(false, null, REQUEST_CODE_DECRYPT_AND_VERIFY_DETACHED));
}
 
Example 7
Source File: OpenPgpApiActivity.java    From openpgp-api with Apache License 2.0 5 votes vote down vote up
public void getKey(Intent data) {
    data.setAction(OpenPgpApi.ACTION_GET_KEY);
    data.putExtra(OpenPgpApi.EXTRA_KEY_ID, Long.decode(mGetKeyEdit.getText().toString()));

    OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
    api.executeApiAsync(data, null, null, new MyCallback(false, null, REQUEST_CODE_GET_KEY));
}
 
Example 8
Source File: OpenPgpApiActivity.java    From openpgp-api with Apache License 2.0 5 votes vote down vote up
public void getKeyIds(Intent data) {
    data.setAction(OpenPgpApi.ACTION_GET_KEY_IDS);
    data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mGetKeyIdsEdit.getText().toString().split(","));

    OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
    api.executeApiAsync(data, null, null, new MyCallback(false, null, REQUEST_CODE_GET_KEY_IDS));
}
 
Example 9
Source File: OpenPgpApiActivity.java    From openpgp-api with Apache License 2.0 5 votes vote down vote up
public void backup(Intent data) {
    data.setAction(OpenPgpApi.ACTION_BACKUP);
    data.putExtra(OpenPgpApi.EXTRA_KEY_IDS, new long[]{Long.decode(mGetKeyEdit.getText().toString())});
    data.putExtra(OpenPgpApi.EXTRA_BACKUP_SECRET, true);
    data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);

    ByteArrayOutputStream os = new ByteArrayOutputStream();

    OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
    api.executeApiAsync(data, null, os, new MyCallback(true, os, REQUEST_CODE_BACKUP));
}
 
Example 10
Source File: OpenPgpApiActivity.java    From openpgp-api with Apache License 2.0 4 votes vote down vote up
public void getAnyKeyIds(Intent data) {
    data.setAction(OpenPgpApi.ACTION_GET_KEY_IDS);

    OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
    api.executeApiAsync(data, null, null, new MyCallback(false, null, REQUEST_CODE_GET_KEY_IDS));
}