当前位置: 首页>>代码示例>>Java>>正文


Java OpenPgpApi.RESULT_CODE_SUCCESS属性代码示例

本文整理汇总了Java中org.openintents.openpgp.util.OpenPgpApi.RESULT_CODE_SUCCESS属性的典型用法代码示例。如果您正苦于以下问题:Java OpenPgpApi.RESULT_CODE_SUCCESS属性的具体用法?Java OpenPgpApi.RESULT_CODE_SUCCESS怎么用?Java OpenPgpApi.RESULT_CODE_SUCCESS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.openintents.openpgp.util.OpenPgpApi的用法示例。

在下文中一共展示了OpenPgpApi.RESULT_CODE_SUCCESS属性的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
        }
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:23,代码来源:MessageCryptoHelper.java


示例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;
        }
    }
}
 
开发者ID:scoute-dich,项目名称:K9-MailClient,代码行数:25,代码来源:MessageCryptoHelper.java


示例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();
}
 
开发者ID:scoute-dich,项目名称:K9-MailClient,代码行数:22,代码来源:RecipientPresenter.java


示例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;
        }
    }
}
 
开发者ID:itprojects,项目名称:InboxPager,代码行数:24,代码来源:InboxGPG.java


示例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());
        }
    }
}
 
开发者ID:PGPAuth,项目名称:PGPAuth_Android,代码行数:24,代码来源:Logic.java


示例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);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:28,代码来源:AutocryptStatusInteractor.java


示例7: getKeyMaterialFromApi

public byte[] getKeyMaterialFromApi(OpenPgpApi openPgpApi, long keyId, String minimizeForUserId) {
    Intent retreiveKeyIntent = new Intent(OpenPgpApi.ACTION_GET_KEY);
    retreiveKeyIntent.putExtra(OpenPgpApi.EXTRA_KEY_ID, keyId);
    retreiveKeyIntent.putExtra(OpenPgpApi.EXTRA_MINIMIZE, true);
    retreiveKeyIntent.putExtra(OpenPgpApi.EXTRA_MINIMIZE_USER_ID, minimizeForUserId);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Intent result = openPgpApi.executeApi(retreiveKeyIntent, (InputStream) null, baos);

    if (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR) ==
            OpenPgpApi.RESULT_CODE_SUCCESS) {
        return baos.toByteArray();
    } else{
        return null;
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:15,代码来源:AutocryptOpenPgpApiInteractor.java


示例8: 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;
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:31,代码来源:RecipientPresenter.java


示例9: 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;
}
 
开发者ID:oversecio,项目名称:oversec_crypto,代码行数:31,代码来源:GpgCryptoHandler.java


示例10: 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;
}
 
开发者ID:oversecio,项目名称:oversec_crypto,代码行数:30,代码来源:GpgCryptoHandler.java


示例11: 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;
}
 
开发者ID:oversecio,项目名称:oversec_crypto,代码行数:27,代码来源:GpgCryptoHandler.java


示例12: notifyPgpDecryptionService

private void notifyPgpDecryptionService(Account account, String action, final Intent result) {
	switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
		case OpenPgpApi.RESULT_CODE_SUCCESS:
			if (OpenPgpApi.ACTION_SIGN.equals(action)) {
				account.getPgpDecryptionService().onKeychainUnlocked();
			}
			break;
		case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
			account.getPgpDecryptionService().onKeychainLocked();
			break;
	}
}
 
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:12,代码来源:PgpEngine.java


示例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);
	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;
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:43,代码来源:PgpEngine.java


示例14: 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;
    }
}
 
开发者ID:oversecio,项目名称:oversec_crypto,代码行数:58,代码来源:GpgCryptoHandler.java


示例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);
	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;
}
 
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:43,代码来源:PgpEngine.java


示例16: 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;
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:43,代码来源:PgpEngine.java


示例17: 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;
}
 
开发者ID:juanignaciomolina,项目名称:txtr,代码行数:43,代码来源:PgpEngine.java


示例18: fetchKeyId

public long fetchKeyId(Account account, String status, String signature) {
	if ((signature == null) || (api == null)) {
		return 0;
	}
	if (status == null) {
		status = "";
	}
	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());
	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:
		Log.d("xmppService",
				"openpgp error: "
						+ ((OpenPgpError) result
								.getParcelableExtra(OpenPgpApi.RESULT_ERROR))
								.getMessage());
		return 0;
	}
	return 0;
}
 
开发者ID:GitESS,项目名称:SyncChatAndroid,代码行数:48,代码来源:PgpEngine.java



注:本文中的org.openintents.openpgp.util.OpenPgpApi.RESULT_CODE_SUCCESS属性示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。