📄 gotourl.c
字号:
/* Copyright 2003-2006, Voltage Security, all rights reserved.
*/
#include "vibe.h"
#include "environment.h"
#include "base.h"
#include "libctx.h"
#include "transport.h"
#include "deftrans.h"
#include "vsdistrict.h"
#include "idobj.h"
#include "distobj.h"
#include "vstorage.h"
#include "defaultstore.h"
#include "derhelp.h"
#include "oidlist.h"
#include "ibe.h"
#include "errorctx.h"
int VoltContinueDownloadKeyAndCert (
VtTransportCtx transportCtx,
VtIdentityObject identity,
VtPolicyCtx policyCtx,
VtStorageCtx storageCtx,
VtCertObject signingCert,
VtKeyObject ibePriKey,
VtAuthTokenList **tokenList,
unsigned int *asyncContinueFlag,
Pointer appSpecificData
)
{
int status;
unsigned int flag, tokenCount;
VoltTransportCtx *transCtx = (VoltTransportCtx *)transportCtx;
VoltStorageCtx *storeCtx = (VoltStorageCtx *)storageCtx;
VoltLibCtx *libCtx = (VoltLibCtx *)(transCtx->voltObject.libraryCtx);
VoltIdentityObject *obj = (VoltIdentityObject *)identity;
VoltAsyncSaveInfo *asyncInfo = (VoltAsyncSaveInfo *)(obj->asyncDownloadInfo);
VOLT_DECLARE_ERROR_TYPE (errorType)
VOLT_DECLARE_FNCT_LINE (fnctLine)
flag = 0;
tokenCount = 0;
/* The only Async function this provider is capable of doing is the
* goto URL operation.
*/
do
{
/* Check the state, if it is START, we have not yet called
* Continue. The first call to Continue launches the URL auth.
* If the state is CONTINUE, we've called this function before, so
* don't launch, just check to see if the key and/or auth token
* have been deposited to the special location since the last call.
*/
if (asyncInfo->state == VOLT_ASYNC_STATE_START)
{
/* Call the routine that will launch the new process.
*/
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = mDoActivateURL (libCtx, asyncInfo->url);
/* If successful, set the state. Then return that the download is
* pending.
*/
if (status == 0)
{
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
VOLT_SET_FNCT_LINE (fnctLine)
asyncInfo->state = VOLT_ASYNC_STATE_CONTINUE;
status = VT_ERROR_DOWNLOAD_PENDING;
}
break;
}
/* If the state is not CONTINUE, this was called improperly.
*/
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_CALL_ORDER;
if (asyncInfo->state != VOLT_ASYNC_STATE_CONTINUE)
break;
/* Was a cert deposited?
* If we found cert set the flag to indicate that.
*/
if (signingCert != (VtCertObject)0)
{
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = storeCtx->RetrievePublicSigningCert (
storageCtx, identity, 0, signingCert);
if (status == 0)
flag |= VOLT_ASYNC_CONTINUE_CERT;
/* If the return was an error other than NOT_FOUND, return that
* error.
*/
if ( (status != 0) && (status != VT_ERROR_ENTRY_NOT_FOUND) )
break;
}
/* Was a key deposited?
*/
if (ibePriKey != (VtKeyObject)0)
{
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = storeCtx->RetrieveIBEPrivateKey (
storageCtx, identity, policyCtx, 0, ibePriKey);
/* If we found the key we are done set the flag to indicate that.
*/
if (status == 0)
flag |= VOLT_ASYNC_CONTINUE_KEY;
/* If the return was an error other than NOT_FOUND, return that
* error.
*/
if ( (status != 0) && (status != VT_ERROR_ENTRY_NOT_FOUND) )
break;
}
/* If we found either key or cert we should figure out if
* we got evrything that the caller wants. If not we should
* continue the download operation.
*/
if (flag != 0)
{
status = VT_ERROR_DOWNLOAD_PENDING;
if (signingCert != (VtCertObject)0 &&
(flag & VOLT_ASYNC_CONTINUE_CERT) == 0)
break;
if (ibePriKey != (VtKeyObject) 0 &&
(flag & VOLT_ASYNC_CONTINUE_KEY) == 0)
break;
/* If we are here means we got both key and cert so return success
*/
status = 0;
break;
}
/* Are there any tokens?
*/
VOLT_SET_FNCT_LINE (fnctLine)
status = storeCtx->RetrieveNewAuthTokens (
storageCtx, obj->district, asyncInfo->tokenListObj, &tokenCount);
if (status != 0)
break;
/* If no tokens or key/cert was found, the download is still pending.
* if the tokens were found we need to make another request to the server
* to download the key so set the state to VOLT_ASYNC_STATE_SETUP.
*/
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_DOWNLOAD_PENDING;
if (tokenCount > 0)
asyncInfo->state = VOLT_ASYNC_STATE_RESTART;
} while (0);
*asyncContinueFlag = flag;
VOLT_LOG_ERROR_COMPARE (
status, (VtLibCtx)libCtx, status, errorType, fnctLine,
"VoltContinueDownloadKeyAndCert", (char *)0)
return (status);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -