本文整理汇总了Java中org.openintents.openpgp.util.OpenPgpApi.RESULT_CODE_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java OpenPgpApi.RESULT_CODE_ERROR属性的具体用法?Java OpenPgpApi.RESULT_CODE_ERROR怎么用?Java OpenPgpApi.RESULT_CODE_ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.openintents.openpgp.util.OpenPgpApi
的用法示例。
在下文中一共展示了OpenPgpApi.RESULT_CODE_ERROR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleOpenPgpOperationResult
private void handleOpenPgpOperationResult(MimeBodyPart outputPart) {
int resultCode = currentCryptoResult.getIntExtra(OpenPgpApi.RESULT_CODE, INVALID_OPENPGP_RESULT_CODE);
Timber.d("OpenPGP API decryptVerify result code: %d", resultCode);
switch (resultCode) {
case INVALID_OPENPGP_RESULT_CODE: {
Timber.e("Internal error: no result code!");
break;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
handleOpenPgpUserInteractionRequest();
break;
}
case OpenPgpApi.RESULT_CODE_ERROR: {
handleOpenPgpOperationError();
break;
}
case OpenPgpApi.RESULT_CODE_SUCCESS: {
handleOpenPgpOperationSuccess(outputPart);
break;
}
}
}
示例2: handleCryptoOperationResult
private void handleCryptoOperationResult(MimeBodyPart outputPart) {
int resultCode = currentCryptoResult.getIntExtra(OpenPgpApi.RESULT_CODE, INVALID_OPENPGP_RESULT_CODE);
if (K9.DEBUG) {
Log.d(K9.LOG_TAG, "OpenPGP API decryptVerify result code: " + resultCode);
}
switch (resultCode) {
case INVALID_OPENPGP_RESULT_CODE: {
Log.e(K9.LOG_TAG, "Internal error: no result code!");
break;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
handleUserInteractionRequest();
break;
}
case OpenPgpApi.RESULT_CODE_ERROR: {
handleCryptoOperationError();
break;
}
case OpenPgpApi.RESULT_CODE_SUCCESS: {
handleCryptoOperationSuccess(outputPart);
break;
}
}
}
示例3: onPgpPermissionCheckResult
@Override
public void onPgpPermissionCheckResult(Intent result) {
int resultCode = result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
switch (resultCode) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
cryptoProviderState = CryptoProviderState.OK;
break;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
recipientMvpView.showErrorOpenPgpUserInteractionRequired();
pendingUserInteractionIntent = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
cryptoProviderState = CryptoProviderState.ERROR;
break;
case OpenPgpApi.RESULT_CODE_ERROR:
default:
recipientMvpView.showErrorOpenPgpConnection();
cryptoProviderState = CryptoProviderState.ERROR;
break;
}
updateCryptoStatus();
}
示例4: onReturn
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS: {
//long keyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, NO_KEY);
break;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
try {
act.startIntentSenderFromChild(
act, pi.getIntentSender(), requestCode, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Pager.log += e.getMessage() + "\n\n";
}
break;
}
case OpenPgpApi.RESULT_CODE_ERROR: {
Pager.log += ((OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR))
.getMessage() + "\n\n";
break;
}
}
}
示例5: sendOpenKeychainIntent
private void sendOpenKeychainIntent(Intent data) throws Exception {
InputStream is = new ByteArrayInputStream(data.getExtras().getString("PGPAuth_SIGNDATA").getBytes());
ByteArrayOutputStream os = new ByteArrayOutputStream();
OpenPgpApi api = new OpenPgpApi(_context, _serviceConnection.getService());
Intent result = api.executeApi(data, is, os);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS: {
_signedData = os.toString("UTF-8");
_event.set();
break;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
_guiHelper.startIntentSenderForResult(pi.getIntentSender(), 2);
break;
}
case OpenPgpApi.RESULT_CODE_ERROR: {
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
throw new RuntimeException(error.getMessage());
}
}
}
示例6: retrieveCryptoProviderRecipientStatus
@WorkerThread
public RecipientAutocryptStatus retrieveCryptoProviderRecipientStatus(
OpenPgpApi openPgpApi, String[] recipientAddresses) {
Intent intent = new Intent(OpenPgpApi.ACTION_QUERY_AUTOCRYPT_STATUS);
intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, recipientAddresses);
Intent result = openPgpApi.executeApi(intent, (InputStream) null, null);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
RecipientAutocryptStatusType type = getRecipientAutocryptStatusFromIntent(result);
PendingIntent pendingIntent = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
return new RecipientAutocryptStatus(type, pendingIntent);
case OpenPgpApi.RESULT_CODE_ERROR:
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
if (error != null) {
Timber.w("OpenPGP API Error #%s: %s", error.getErrorId(), error.getMessage());
} else {
Timber.w("OpenPGP API Unknown Error");
}
return new RecipientAutocryptStatus(RecipientAutocryptStatusType.ERROR, null);
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
// should never happen, so treat as error!
default:
return new RecipientAutocryptStatus(RecipientAutocryptStatusType.ERROR, null);
}
}
示例7: onPgpPermissionCheckResult
@Override
public void onPgpPermissionCheckResult(Intent result) {
int resultCode = result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR);
switch (resultCode) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
setCryptoProviderState(CryptoProviderState.OK);
break;
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
recipientMvpView.showErrorOpenPgpUserInteractionRequired();
pendingUserInteractionIntent = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
setCryptoProviderState(CryptoProviderState.ERROR);
break;
case OpenPgpApi.RESULT_CODE_ERROR:
default:
if (result.hasExtra(OpenPgpApi.RESULT_ERROR)) {
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
if (error != null) {
handleOpenPgpError(error);
} else {
recipientMvpView.showErrorOpenPgpConnection();
setCryptoProviderState(CryptoProviderState.ERROR);
}
} else {
recipientMvpView.showErrorOpenPgpConnection();
setCryptoProviderState(CryptoProviderState.ERROR);
}
break;
}
}
示例8: triggerRecipientSelection
public PendingIntent triggerRecipientSelection(Intent actionIntent) {
Intent data = new Intent();
if (actionIntent != null) {
data = actionIntent;
} else {
data.setAction(OpenPgpApi.ACTION_ENCRYPT); //we do not encrypt nothing, just use this to bring up the public key selection dialog
data.putExtra(OpenPgpApi.EXTRA_USER_IDS, new String[0]);
}
InputStream is = new ByteArrayInputStream("dummy".getBytes());
ByteArrayOutputStream os = new ByteArrayOutputStream();
Intent result = executeApi(data, is, os);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS: {
//ok, it has workd now, i.e. the recipients have been selected
return null;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
//this is the intent we can use to bring up the key selection
PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
return pi;
}
case OpenPgpApi.RESULT_CODE_ERROR: {
//this should never happen
return null;
}
}
return null;
}
示例9: triggerSigningKeySelection
public PendingIntent triggerSigningKeySelection(Intent actionIntent) {
Intent data = new Intent();
if (actionIntent != null) {
data = actionIntent;
} else {
data.setAction(OpenPgpApi.ACTION_GET_SIGN_KEY_ID);
}
InputStream is = new ByteArrayInputStream("dummy".getBytes());
ByteArrayOutputStream os = new ByteArrayOutputStream();
Intent result = executeApi(data, is, os);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS: {
//this should never happen
return null;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
//this is the intent we can use to bring up the key selection
PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
return pi;
}
case OpenPgpApi.RESULT_CODE_ERROR: {
//this should never happen
return null;
}
}
return null;
}
示例10: getDownloadKeyPendingIntent
public PendingIntent getDownloadKeyPendingIntent(long keyId, Intent actionIntent) {
Intent id = new Intent();
if (actionIntent != null) {
id = actionIntent;
} else {
id.setAction(OpenPgpApi.ACTION_GET_KEY);
id.putExtra(OpenPgpApi.EXTRA_KEY_ID, keyId);
}
Intent result = executeApi(id, null, null);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS: {
return null;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
return pi;
}
case OpenPgpApi.RESULT_CODE_ERROR: {
return null;
}
}
return null;
}
示例11: fetchKeyId
public long fetchKeyId(Account account, String status, String signature) {
if ((signature == null) || (api == null)) {
return 0;
}
if (status == null) {
status = "";
}
final StringBuilder pgpSig = new StringBuilder();
pgpSig.append("-----BEGIN PGP SIGNED MESSAGE-----");
pgpSig.append('\n');
pgpSig.append('\n');
pgpSig.append(status);
pgpSig.append('\n');
pgpSig.append("-----BEGIN PGP SIGNATURE-----");
pgpSig.append('\n');
pgpSig.append('\n');
pgpSig.append(signature.replace("\n", "").trim());
pgpSig.append('\n');
pgpSig.append("-----END PGP SIGNATURE-----");
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
InputStream is = new ByteArrayInputStream(pgpSig.toString().getBytes());
ByteArrayOutputStream os = new ByteArrayOutputStream();
Intent result = api.executeApi(params, is, os);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
OpenPgpSignatureResult sigResult = result
.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE);
if (sigResult != null) {
return sigResult.getKeyId();
} else {
return 0;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
return 0;
case OpenPgpApi.RESULT_CODE_ERROR:
logError(account, (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR));
return 0;
}
return 0;
}
示例12: encrypt
@SuppressWarnings("RedundantThrows")
private Outer.Msg encrypt(byte[] raw, GpgEncryptionParams pp, Intent actionIntent) throws OpenPGPParamsException, OpenPGPErrorException, UserInteractionRequiredException {
Intent data = new Intent();
if (actionIntent != null) {
data = actionIntent;
} else {
data.setAction(pp.isSign() ? OpenPgpApi.ACTION_SIGN_AND_ENCRYPT : OpenPgpApi.ACTION_ENCRYPT);
if (pp.getAllPublicKeyIds().length == 0) {
throw new IllegalArgumentException();
}
data.putExtra(OpenPgpApi.EXTRA_KEY_IDS, pp.getAllPublicKeyIds());
if (pp.isSign()) {
data.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, pp.getOwnPublicKey());
}
data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, false);
}
InputStream is = new ByteArrayInputStream(raw);
ByteArrayOutputStream os = new ByteArrayOutputStream();
Intent result = executeApi(data, is, os);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS: {
byte[] encrypted = os.toByteArray();
Outer.Msg.Builder builderMsg = Outer.Msg.newBuilder();
Outer.MsgTextGpgV0.Builder pgpMsgBuilder = builderMsg.getMsgTextGpgV0Builder();
pgpMsgBuilder.setCiphertext(ByteString.copyFrom(encrypted));
for (long pkId : pp.getAllPublicKeyIds()) {
pgpMsgBuilder.addPubKeyIdV0(pkId);
}
builderMsg.setMsgTextGpgV0(pgpMsgBuilder);
Outer.Msg msg = builderMsg.build();
return msg;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
throw new UserInteractionRequiredException(pi, GpgEncryptionParams.longArrayToLongArray(pp.getAllPublicKeyIds()));
}
case OpenPgpApi.RESULT_CODE_ERROR: {
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
Ln.e("encryption error: %s", error.getMessage());
throw new OpenPGPErrorException(error);
}
default:
return null;
}
}
示例13: fetchKeyId
public long fetchKeyId(Account account, String status, String signature) {
if ((signature == null) || (api == null)) {
return 0;
}
if (status == null) {
status = "";
}
final StringBuilder pgpSig = new StringBuilder();
pgpSig.append("-----BEGIN PGP SIGNED MESSAGE-----");
pgpSig.append('\n');
pgpSig.append('\n');
pgpSig.append(status);
pgpSig.append('\n');
pgpSig.append("-----BEGIN PGP SIGNATURE-----");
pgpSig.append('\n');
pgpSig.append('\n');
pgpSig.append(signature.replace("\n", "").trim());
pgpSig.append('\n');
pgpSig.append("-----END PGP SIGNATURE-----");
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
InputStream is = new ByteArrayInputStream(pgpSig.toString().getBytes());
ByteArrayOutputStream os = new ByteArrayOutputStream();
Intent result = api.executeApi(params, is, os);
notifyPgpDecryptionService(account, OpenPgpApi.ACTION_DECRYPT_VERIFY, result);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
OpenPgpSignatureResult sigResult = result
.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE);
if (sigResult != null) {
return sigResult.getKeyId();
} else {
return 0;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
return 0;
case OpenPgpApi.RESULT_CODE_ERROR:
return 0;
}
return 0;
}
示例14: fetchKeyId
public long fetchKeyId(Account account, String status, String signature) {
if ((signature == null) || (api == null)) {
return 0;
}
if (status == null) {
status = "";
}
final StringBuilder pgpSig = new StringBuilder();
pgpSig.append("-----BEGIN PGP SIGNED MESSAGE-----");
pgpSig.append('\n');
pgpSig.append('\n');
pgpSig.append(status);
pgpSig.append('\n');
pgpSig.append("-----BEGIN PGP SIGNATURE-----");
pgpSig.append('\n');
pgpSig.append('\n');
pgpSig.append(signature.replace("\n", "").trim());
pgpSig.append('\n');
pgpSig.append("-----END PGP SIGNATURE-----");
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
InputStream is = new ByteArrayInputStream(pgpSig.toString().getBytes());
ByteArrayOutputStream os = new ByteArrayOutputStream();
Intent result = api.executeApi(params, is, os);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
OpenPgpSignatureResult sigResult = result
.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE);
if (sigResult != null) {
return sigResult.getKeyId();
} else {
return 0;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
return 0;
case OpenPgpApi.RESULT_CODE_ERROR:
logError(account, (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR));
return 0;
}
return 0;
}
示例15: fetchKeyId
public long fetchKeyId(Account account, String status, String signature) {
if ((signature == null) || (api == null)) {
return 0;
}
if (status == null) {
status = "";
}
final StringBuilder pgpSig = new StringBuilder();
pgpSig.append("-----BEGIN PGP SIGNED MESSAGE-----");
pgpSig.append('\n');
pgpSig.append('\n');
pgpSig.append(status);
pgpSig.append('\n');
pgpSig.append("-----BEGIN PGP SIGNATURE-----");
pgpSig.append('\n');
pgpSig.append('\n');
pgpSig.append(signature.replace("\n", "").trim());
pgpSig.append('\n');
pgpSig.append("-----END PGP SIGNATURE-----");
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, account.getJid().toBareJid().toString());
InputStream is = new ByteArrayInputStream(pgpSig.toString().getBytes());
ByteArrayOutputStream os = new ByteArrayOutputStream();
Intent result = api.executeApi(params, is, os);
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
OpenPgpSignatureResult sigResult = result
.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE);
if (sigResult != null) {
return sigResult.getKeyId();
} else {
return 0;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
return 0;
case OpenPgpApi.RESULT_CODE_ERROR:
return 0;
}
return 0;
}