📄 policyinfo.c
字号:
case VOLT_POLICY_GET_MESSAGE_HEADER_INTERNAL:
return (MessageHeaderInternalAlloc(ctx, libCtx, (VtItem**)info));
case VOLT_POLICY_GET_MESSAGE_HEADER_EXTERNAL:
return (MessageHeaderExternalAlloc(ctx, libCtx, (VtItem**)info));
case VOLT_POLICY_GET_CONTENT_FOOTER:
return (HeaderFooterAlloc (
ctx, libCtx, (VoltIdentityList *)0, (VtItem **)info));
case VOLT_POLICY_GET_ZERO_DOWNLOAD_TEMPLATE:
return (ZdrTemplateAlloc (ctx, libCtx, (VtItem **)info));
break;
case VOLT_POLICY_GET_ZDM2_TEMPLATE:
return (Zdm2TemplateAlloc (ctx, libCtx, (VtItem **)info));
break;
case VOLT_POLICY_GET_HTML_MESSAGE_BODY_TEMPLATE:
return (HTMLMessageBodyTemplateAlloc (ctx, libCtx, (VtItem **)info));
break;
case VOLT_POLICY_GET_ENCRYPT_RULES:
return (EncryptRulesAlloc (ctx, libCtx, (VtItem **)info));
break;
case VOLT_POLICY_GET_DEFAULT_ZDR_LOCATION:
return (DefaultZdrLocationAlloc (ctx, libCtx, (VtItem **)info));
break;
case VOLT_POLICY_GET_DECRYPT_POLICY:
return (DecryptPolicyAlloc (ctx, libCtx, (int **)info));
}
return (VT_ERROR_POLICY_NOT_SUPPORTED);
}
void VoltLocalPolicyGetInfoFree (
VtPolicyCtx policyCtx,
Pointer info
)
{
VoltPolicyCtx *ctx = (VoltPolicyCtx *)policyCtx;
VoltLibCtx *libCtx = (VoltLibCtx *)(ctx->voltObject.libraryCtx);
/* Anything to free?
*/
if (info == (Pointer)0)
return;
/* Any info returned by GetInfoAlloc is indeed allocated.
* Furthermore, it is always a single, continuous piece of memory.
*/
Z2Free (info);
}
static int IsIdentityLocalAlloc (
VoltPolicyCtx *ctx,
VoltLibCtx *libCtx,
VoltIdentityObject *idObj,
VtItem **districtName
)
{
int status;
unsigned int bufferSize, emailAddressLen, domainLen;
VoltDefaultPolicyCtx *localPolicyCtx =
(VoltDefaultPolicyCtx *)(ctx->localCtx);
unsigned char *emailAddress, *domain;
unsigned char *buffer = (unsigned char *)0;
VtItem *retVal;
/* This policy looks at email only. Get the domain.
*/
status = VoltGetEmailAndDomain (
idObj, &emailAddress, &emailAddressLen, &domain, &domainLen);
if (status != 0)
return (status);
/* If there is no domain, there's no email address in this identity
* object, this policy can say nothing about non-email id's.
*/
if (domain == (unsigned char *)0)
return (0);
/* This checks the XML data. If the return is 0, this is not a local
* domain.
*/
status = m_vs_cp_is_local_domain (localPolicyCtx->vsPolicyObj, domain);
if (status == 0)
return (0);
/* This is a local domain. Allocate space for a VtItem and a copy of
* the district name and return it.
*/
bufferSize = sizeof (VtItem) + domainLen;
buffer = Z2Malloc (bufferSize, 0);
if (buffer == (unsigned char *)0)
return (VT_ERROR_MEMORY);
Z2Memset (buffer, 0, bufferSize);
retVal = (VtItem *)buffer;
/* Point the data to the space after the VtItem, it's a byte
* array, no need to worry about alignment.
*/
retVal->data = buffer + sizeof (VtItem);
Z2Memcpy (retVal->data, domain, domainLen);
retVal->len = domainLen;
*districtName = retVal;
return (0);
}
static int ProvisionedDistrictAlloc (
VoltPolicyCtx *ctx,
VoltLibCtx *libCtx,
VoltIdentityObject *idObj,
VtItem **districtName
)
{
int status;
unsigned int bufferSize, emailAddressLen, domainLen;
VoltDefaultPolicyCtx *localPolicyCtx =
(VoltDefaultPolicyCtx *)(ctx->localCtx);
unsigned char *emailAddress, *domain;
char *newName = (char *)0;
unsigned char *buffer = (unsigned char *)0;
VtItem *retVal;
/* This policy looks at email only. Get the email address.
*/
status = VoltGetEmailAndDomain (
idObj, &emailAddress, &emailAddressLen, &domain, &domainLen);
if (status != 0)
return (status);
/* If there is no domain, there's no email address in this identity
* object, this policy can say nothing about non-email id's.
*/
if (domain == (unsigned char *)0)
return (0);
/* This checks the XML data. If the return is 0, this is not a
* provisioned identity.
*/
status = m_vs_cp_is_user_provisioned (
localPolicyCtx->vsPolicyObj, emailAddress);
if (status == 0)
return (0);
/* The address is provisioned.
*/
do
{
/* Get the provisioned district name.
*/
status = 0;
newName = m_vs_cp_get_provisioned_district (localPolicyCtx->vsPolicyObj);
if (newName == (char *)0)
break;
/* Allocate space for a VtItem and a copy of the district name and
* return it.
*/
status = VT_ERROR_MEMORY;
domainLen = Z2Strlen (newName);
bufferSize = sizeof (VtItem) + domainLen;
buffer = Z2Malloc (bufferSize, 0);
if (buffer == (unsigned char *)0)
break;
Z2Memset (buffer, 0, bufferSize);
retVal = (VtItem *)buffer;
/* Point the data to the space after the VtItem, it's a byte
* array, no need to worry about alignment.
*/
retVal->data = buffer + sizeof (VtItem);
Z2Memcpy (retVal->data, newName, domainLen);
retVal->len = domainLen;
*districtName = retVal;
status = 0;
} while (0);
if (newName != (char *)0)
m_vs_free_memory (localPolicyCtx->vsPolicyObj, newName);
return (status);
}
static int FallThroughDistrictAlloc (
VoltPolicyCtx *ctx,
VoltLibCtx *libCtx,
VtItem **districtName
)
{
int status;
unsigned int bufferSize, districtLen;
VoltDefaultPolicyCtx *localPolicyCtx =
(VoltDefaultPolicyCtx *)(ctx->localCtx);
char *district = (char *)0;
unsigned char *buffer = (unsigned char *)0;
VtItem *retVal;
do
{
/* This checks the XML data. If the return is null, there is no fall
* through district.
*/
status = 0;
district = m_vs_cp_get_fallthrough_district (localPolicyCtx->vsPolicyObj);
if (district == (char *)0)
break;
/* There is a fall through district. Allocate space for a VtItem and
* a copy of the district name and return it.
*/
status = VT_ERROR_MEMORY;
districtLen = Z2Strlen (district);
bufferSize = sizeof (VtItem) + districtLen;
buffer = Z2Malloc (bufferSize, 0);
if (buffer == (unsigned char *)0)
break;
Z2Memset (buffer, 0, bufferSize);
retVal = (VtItem *)buffer;
/* Point the data to the space after the VtItem, it's a byte
* array, no need to worry about alignment.
*/
retVal->data = buffer + sizeof (VtItem);
Z2Memcpy (retVal->data, district, districtLen);
retVal->len = districtLen;
*districtName = retVal;
status = 0;
} while (0);
if (district != (char *)0)
m_vs_free_memory (localPolicyCtx->vsPolicyObj, district);
return (status);
}
static int RefreshRateAlloc (
VoltPolicyCtx *ctx,
VoltLibCtx *libCtx,
VoltPolicyGetType flag,
int **rate
)
{
int *theRate = (int *)0;
VoltDefaultPolicyCtx *localPolicyCtx =
(VoltDefaultPolicyCtx *)(ctx->localCtx);
/* Allocate the space for an int.
*/
theRate = (int *)Z2Malloc (sizeof (int), 0);
if (theRate == (int *)0)
return (VT_ERROR_MEMORY);
/* This checks the XML data.
*/
if (flag == VOLT_POLICY_GET_REFRESH_RATE_NEGATIVE)
*theRate = m_vs_cp_get_parameter_refresh_rate_negative (
localPolicyCtx->vsPolicyObj);
else
*theRate = m_vs_cp_get_parameter_refresh_rate_positive (
localPolicyCtx->vsPolicyObj);
*rate = theRate;
return (0);
}
static int IsParamCheckingStrictAlloc (
VoltPolicyCtx *ctx,
VoltLibCtx *libCtx,
int **result
)
{
int *theValue = (int *)0;
VoltDefaultPolicyCtx *localPolicyCtx =
(VoltDefaultPolicyCtx *)(ctx->localCtx);
/* Allocate the space for an int.
*/
theValue = (int *)Z2Malloc (sizeof (int), 0);
if (theValue == (int *)0)
return (VT_ERROR_MEMORY);
/* This checks the XML data.
*/
*theValue = m_vs_cp_is_parameter_checking_strict (
localPolicyCtx->vsPolicyObj);
/* Make sure it's 0 or 1, not 0 or non-zero.
*/
if (*theValue != 0)
*theValue = 1;
*result = theValue;
return (0);
}
static int IsDistrictAggressiveAlloc (
VoltPolicyCtx *ctx,
VoltLibCtx *libCtx,
VoltDistrictObject *distObj,
int **result
)
{
int status;
VoltDefaultPolicyCtx *localPolicyCtx =
(VoltDefaultPolicyCtx *)(ctx->localCtx);
VtItem *theName;
int *theValue = (int *)0;
/* Allocate the space for an int, initialize to 0.
*/
theValue = (int *)Z2Malloc (sizeof (int), 0);
if (theValue == (int *)0)
return (VT_ERROR_MEMORY);
*theValue = 0;
*result = theValue;
do
{
/* Is there a name to check?
*/
status = 0;
theName = &(distObj->unqualDistrictName);
/* This checks the XML data.
*/
*theValue = m_vs_cp_is_parameter_retrieval_aggressive (
localPolicyCtx->vsPolicyObj, distObj->unqualDistrictName.data);
/* Make sure it's 0 or 1, not 0 or non-zero.
*/
if (*theValue != 0)
*theValue = 1;
} while (0);
return (status);
}
static int IsDistrictTrustedAlloc (
VoltPolicyCtx *ctx,
VoltLibCtx *libCtx,
VoltDistrictObject *distObj,
int **result
)
{
int status;
VoltDefaultPolicyCtx *localPolicyCtx =
(VoltDefaultPolicyCtx *)(ctx->localCtx);
VtItem *theName;
int *theValue = (int *)0;
/* Allocate the space for an int, initialize to 0.
*/
theValue = (int *)Z2Malloc (sizeof (int), 0);
if (theValue == (int *)0)
return (VT_ERROR_MEMORY);
*theValue = 0;
*result = theValue;
do
{
/* Is there a name to check?
*/
status = 0;
theName = &(distObj->unqualDistrictName);
if (theName->data == (unsigned char *)0)
{
theName = &(distObj->qualDistrictName);
if (theName->data == (unsigned char *)0)
break;
}
/* This checks the XML data.
*/
if (distObj->qualDistrictName.data != (unsigned char *)0)
{
*theValue = m_vs_cp_is_trusted_district (
localPolicyCtx->vsPolicyObj, distObj->qualDistrictName.data);
}
else
{
*theValue = m_vs_cp_is_trusted_district (
localPolicyCtx->vsPolicyObj, distObj->unqualDistrictName.data);
}
/* Make sure it's 0 or 1, not 0 or non-zero.
*/
if (*theValue != 0)
*theValue = 1;
} while (0);
return (status);
}
static int CredentialCacheModeAlloc (
VoltPolicyCtx *ctx,
VoltLibCtx *libCtx,
int **cacheMode
)
{
int mode;
int *theValue = (int *)0;
VoltDefaultPolicyCtx *localPolicyCtx =
(VoltDefaultPolicyCtx *)(ctx->localCtx);
/* Allocate the space for an int, initialize to 0.
*/
theValue = (int *)Z2Malloc (sizeof (int), 0);
if (theValue == (int *)0)
return (VT_ERROR_MEMORY);
*theValue = 0;
*cacheMode = theValue;
/* This checks the XML data.
* It returns a 0 or 1 (yes/no, true/false). For this function, 0
* means no caching, which translates to a cache period of 0.
* A return of 1 means cache as long as the process is active.
*/
mode = m_vs_cp_get_password_caching_mode (localPolicyCtx->vsPolicyObj);
/* If mode is 0, the cacheMode is 0, we initialized it to 0 so all we
* have to do is return.
*/
if (mode == 0)
return (0);
/* The mode is cache for the life of the process, set the return to
* -1.
*/
*theValue = -1;
return (0);
}
static int HeaderFooterAlloc (
VoltPolicyCtx *ctx,
VoltLibCtx *libCtx,
VoltIdentityList *idList,
VtItem **result
)
{
int status;
unsigned int bufferSize, valueLen;
VoltDefaultPolicyCtx *localPolicyCtx =
(VoltDefaultPolicyCtx *)(ctx->localCtx);
char *value = (char *)0;
unsigned char *buffer = (unsigned char *)0;
VtItem *retVal;
do
{
/* This checks the XML data. If the return is null, there is no
* header.
*/
status = 0;
if (idList != (VoltIdentityList *)0)
{
/* This policy provider ignores the idList, we just used it as a
* flag.
*/
value = m_vs_cp_get_message_header_internal (
localPolicyCtx->vsPolicyObj);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -