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


Java OpenPgpApi.executeApi方法代码示例

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


在下文中一共展示了OpenPgpApi.executeApi方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendOpenKeychainIntent

import org.openintents.openpgp.util.OpenPgpApi; //导入方法依赖的package包/类
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,代码行数:25,代码来源:Logic.java

示例2: testResponse

import org.openintents.openpgp.util.OpenPgpApi; //导入方法依赖的package包/类
public void testResponse(Context context, Intent intent, long[] keyIds)
{
    /*
     * this method is only used to cause the user interaction screen
     * to be displayed if necessary before looping over the files to
     * to be de/encrypted since that would otherwise trigger it multiple
     * times.
     */
    java.io.InputStream is = new java.io.ByteArrayInputStream(new byte[]{0});
    java.io.ByteArrayOutputStream os = new java.io.ByteArrayOutputStream();
    intent.setAction(OpenPgpApi.ACTION_ENCRYPT);
    // this way the key ids are remembered if the user ids are unknown
    // and a user interaction screen is shown
    if(keyIds != null)
        this.keyIds = keyIds;
    intent.putExtra(OpenPgpApi.EXTRA_USER_IDS, userIds);
    OpenPgpApi api = new OpenPgpApi(context, service.getService());
    Intent result = api.executeApi(intent, is, os);
    handleResult(context, result, BaseActivity.OPENPGP_REQUEST_TESTRESPONSE);
}
 
开发者ID:jensstein,项目名称:oandbackup,代码行数:21,代码来源:Crypto.java

示例3: retrieveCryptoProviderRecipientStatus

import org.openintents.openpgp.util.OpenPgpApi; //导入方法依赖的package包/类
@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,代码行数:29,代码来源:AutocryptStatusInteractor.java

示例4: getKeyMaterialFromApi

import org.openintents.openpgp.util.OpenPgpApi; //导入方法依赖的package包/类
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,代码行数:16,代码来源:AutocryptOpenPgpApiInteractor.java

示例5: doAction

import org.openintents.openpgp.util.OpenPgpApi; //导入方法依赖的package包/类
public void doAction(Context context, Intent intent, int requestCode)
{
    errorFlag = false;
    if(!testFlag)
    {
        testResponse(context, new Intent(), null);
        waitForResult();
    }
    try
    {
        if(files != null)
        {
            if(requestCode == BaseActivity.OPENPGP_REQUEST_ENCRYPT && keyIds != null)
                intent.putExtra(OpenPgpApi.EXTRA_KEY_IDS, keyIds);
            for(File file : files)
            {
                // not all slots in the File array are necessarily used.
                // an ArrayList would probably be better
                if(file == null)
                    continue;
                String outputFilename;
                if(requestCode == BaseActivity.OPENPGP_REQUEST_DECRYPT)
                    outputFilename = file.getAbsolutePath().substring(0, file.getAbsolutePath().lastIndexOf(".gpg"));
                else
                    outputFilename = file.getAbsolutePath() + ".gpg";
                Log.i(TAG, "crypto input: " + file.getAbsolutePath() + " output: " + outputFilename);
                FileInputStream is = new FileInputStream(file);
                FileOutputStream os = new FileOutputStream(outputFilename);
                OpenPgpApi api = new OpenPgpApi(context, service.getService());
                Intent result = api.executeApi(intent, is, os);
                handleResult(context, result, requestCode);
                waitForResult();
            }
        }
        else
        {
            logError("Crypto: no files to de/encrypt");
        }
    }
    catch(IOException e)
    {
        logError("Crypto error: " + e.toString());
    }
}
 
开发者ID:jensstein,项目名称:oandbackup,代码行数:45,代码来源:Crypto.java


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