本文整理汇总了Java中org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback类的典型用法代码示例。如果您正苦于以下问题:Java IOpenPgpCallback类的具体用法?Java IOpenPgpCallback怎么用?Java IOpenPgpCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IOpenPgpCallback类属于org.openintents.openpgp.util.OpenPgpApi包,在下文中一共展示了IOpenPgpCallback类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processAutocryptHeaderForCurrentPart
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
private void processAutocryptHeaderForCurrentPart() {
Intent intent = new Intent(OpenPgpApi.ACTION_UPDATE_AUTOCRYPT_PEER);
boolean hasInlineKeyData = autocryptOperations.addAutocryptPeerUpdateToIntentIfPresent(
(Message) currentCryptoPart.part, intent);
if (hasInlineKeyData) {
Timber.d("Passing autocrypt data from plain mail to OpenPGP API");
// We don't care about the result here, so we just call this fire-and-forget wait to minimize delay
openPgpApi.executeApiAsync(intent, null, null, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
Timber.d("Autocrypt update OK!");
}
});
}
onCryptoFinished();
}
示例2: chooseKey
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
public void chooseKey(final Account account, final UiCallback<Account> callback) {
Intent p = new Intent();
p.setAction(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
api.executeApiAsync(p, null, null, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
callback.success(account);
return;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
callback.userInputRequried((PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT),
account);
return;
case OpenPgpApi.RESULT_CODE_ERROR:
logError(account, (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR));
callback.error(R.string.openpgp_error, account);
}
}
});
}
示例3: hasKey
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
public void hasKey(final Contact contact, final UiCallback<Contact> callback) {
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_GET_KEY);
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
api.executeApiAsync(params, null, null, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
callback.success(contact);
return;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
callback.userInputRequried((PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT),
contact);
return;
case OpenPgpApi.RESULT_CODE_ERROR:
logError(contact.getAccount(), (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR));
callback.error(R.string.openpgp_error, contact);
}
}
});
}
示例4: chooseKey
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
public void chooseKey(final Account account, final UiCallback<Account> callback) {
Intent p = new Intent();
p.setAction(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
api.executeApiAsync(p, null, null, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
callback.success(account);
return;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
callback.userInputRequried((PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT),
account);
return;
case OpenPgpApi.RESULT_CODE_ERROR:
callback.error(R.string.openpgp_error, account);
}
}
});
}
示例5: hasKey
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
public void hasKey(final Contact contact, final UiCallback<Contact> callback) {
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_GET_KEY);
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
api.executeApiAsync(params, null, null, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
callback.success(contact);
return;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
callback.userInputRequried((PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT),
contact);
return;
case OpenPgpApi.RESULT_CODE_ERROR:
callback.error(R.string.openpgp_error, contact);
}
}
});
}
示例6: chooseKey
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
public void chooseKey(final Account account, final UiCallback<Account> callback) {
Intent p = new Intent();
p.setAction(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
api.executeApiAsync(p, null, null, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
callback.success(account);
return;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
callback.userInputRequried((PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT),
account);
return;
case OpenPgpApi.RESULT_CODE_ERROR:
logError(account, (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR));
callback.error(R.string.openpgp_error, account);
}
}
});
}
示例7: hasKey
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
public void hasKey(final Contact contact, final UiCallback<Contact> callback) {
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_GET_KEY);
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
api.executeApiAsync(params, null, null, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
callback.success(contact);
return;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
callback.userInputRequried((PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT),
contact);
return;
case OpenPgpApi.RESULT_CODE_ERROR:
logError(contact.getAccount(), (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR));
callback.error(R.string.openpgp_error, contact);
}
}
});
}
示例8: hasKey
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
public void hasKey(final Contact contact, final UiCallback<Contact> callback) {
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_GET_KEY);
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, contact.getAccount()
.getJid().toBareJid().toString());
api.executeApiAsync(params, null, null, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
callback.success(contact);
return;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
callback.userInputRequried((PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT),
contact);
return;
case OpenPgpApi.RESULT_CODE_ERROR:
callback.error(R.string.openpgp_error, contact);
}
}
});
}
示例9: hasKey
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
public void hasKey(final Contact contact, final UiCallback<Contact> callback) {
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_GET_KEY);
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, contact.getAccount()
.getJid());
api.executeApiAsync(params, null, null, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
callback.success(contact);
return;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
callback.userInputRequried((PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT),
contact);
return;
case OpenPgpApi.RESULT_CODE_ERROR:
callback.error(R.string.openpgp_error, contact);
return;
}
}
});
}
示例10: textPlainWithAutocrypt_withOpenPgpApi
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
@Test
public void textPlainWithAutocrypt_withOpenPgpApi() throws Exception {
setUpWithOpenPgpApi();
MimeMessage message = new MimeMessage();
message.setUid("msguid");
message.setHeader("Content-Type", "text/plain");
when(autocryptOperations.hasAutocryptHeader(message)).thenReturn(true);
when(autocryptOperations.addAutocryptPeerUpdateToIntentIfPresent(same(message), any(Intent.class))).thenReturn(true);
MessageCryptoCallback messageCryptoCallback = mock(MessageCryptoCallback.class);
messageCryptoHelper.asyncStartOrResumeProcessingMessage(message, messageCryptoCallback,
null, null, false);
ArgumentCaptor<MessageCryptoAnnotations> captor = ArgumentCaptor.forClass(MessageCryptoAnnotations.class);
verify(messageCryptoCallback).onCryptoOperationsFinished(captor.capture());
MessageCryptoAnnotations annotations = captor.getValue();
assertTrue(annotations.isEmpty());
verifyNoMoreInteractions(messageCryptoCallback);
ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
verify(autocryptOperations).addAutocryptPeerUpdateToIntentIfPresent(same(message), intentCaptor.capture());
verify(openPgpApi).executeApiAsync(same(intentCaptor.getValue()), same((InputStream) null),
same((OutputStream) null), any(IOpenPgpCallback.class));
}
示例11: generateSignature
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
public void generateSignature(final Account account, String status,
final UiCallback<Account> callback) {
Intent params = new Intent();
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
params.setAction(OpenPgpApi.ACTION_SIGN);
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid());
InputStream is = new ByteArrayInputStream(status.getBytes());
final OutputStream os = new ByteArrayOutputStream();
api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
StringBuilder signatureBuilder = new StringBuilder();
String[] lines = os.toString().split("\n");
for (int i = 7; i < lines.length - 1; ++i) {
signatureBuilder.append(lines[i].trim());
}
account.setKey("pgp_signature", signatureBuilder.toString());
callback.success(account);
return;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
callback.userInputRequried((PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT),
account);
return;
case OpenPgpApi.RESULT_CODE_ERROR:
callback.error(R.string.openpgp_error, account);
return;
}
}
});
}
示例12: generateSignature
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
public void generateSignature(final Account account, String status,
final UiCallback<Account> callback) {
if (account.getPgpId() == -1) {
return;
}
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_CLEARTEXT_SIGN);
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
params.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, account.getPgpId());
InputStream is = new ByteArrayInputStream(status.getBytes());
final OutputStream os = new ByteArrayOutputStream();
api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
notifyPgpDecryptionService(account, OpenPgpApi.ACTION_SIGN, result);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
StringBuilder signatureBuilder = new StringBuilder();
try {
os.flush();
String[] lines = os.toString().split("\n");
boolean sig = false;
for (String line : lines) {
if (sig) {
if (line.contains("END PGP SIGNATURE")) {
sig = false;
} else {
if (!line.contains("Version")) {
signatureBuilder.append(line.trim());
}
}
}
if (line.contains("BEGIN PGP SIGNATURE")) {
sig = true;
}
}
} catch (IOException e) {
callback.error(R.string.openpgp_error, account);
return;
}
account.setPgpSignature(signatureBuilder.toString());
callback.success(account);
return;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
callback.userInputRequried((PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT),
account);
return;
case OpenPgpApi.RESULT_CODE_ERROR:
callback.error(R.string.openpgp_error, account);
}
}
});
}
示例13: generateSignature
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; //导入依赖的package包/类
public void generateSignature(final Account account, String status,
final UiCallback<Account> callback) {
Intent params = new Intent();
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
params.setAction(OpenPgpApi.ACTION_SIGN);
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid().toBareJid().toString());
InputStream is = new ByteArrayInputStream(status.getBytes());
final OutputStream os = new ByteArrayOutputStream();
api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
StringBuilder signatureBuilder = new StringBuilder();
try {
os.flush();
String[] lines = os.toString().split("\n");
boolean sig = false;
for (String line : lines) {
if (sig) {
if (line.contains("END PGP SIGNATURE")) {
sig = false;
} else {
if (!line.contains("Version")) {
signatureBuilder.append(line.trim());
}
}
}
if (line.contains("BEGIN PGP SIGNATURE")) {
sig = true;
}
}
} catch (IOException e) {
callback.error(R.string.openpgp_error, account);
return;
}
account.setKey("pgp_signature", signatureBuilder.toString());
callback.success(account);
return;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
callback.userInputRequried((PendingIntent) result
.getParcelableExtra(OpenPgpApi.RESULT_INTENT),
account);
return;
case OpenPgpApi.RESULT_CODE_ERROR:
callback.error(R.string.openpgp_error, account);
}
}
});
}