📄 policyinfo.c
字号:
VoltLibCtx *libCtx,
int **result
));
int VoltLocalPolicyGetInfoAlloc (
VtPolicyCtx policyCtx,
VoltPolicyGetType policyGetType,
Pointer definition,
Pointer *info
)
{
int status;
unsigned int flag;
VoltPolicyCtx *ctx = (VoltPolicyCtx *)policyCtx;
VoltLibCtx *libCtx = (VoltLibCtx *)(ctx->voltObject.libraryCtx);
VOLT_DECLARE_ERROR_TYPE (errorType)
VOLT_DECLARE_FNCT_LINE (fnctLine)
*info = (Pointer)0;
switch (policyGetType)
{
default:
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_POLICY_NOT_SUPPORTED;
break;
case VOLT_POLICY_GET_IS_LOCAL_ID:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = IsIdentityLocalAlloc (
ctx, libCtx, (VoltIdentityObject *)definition,
(VtItem **)info);
break;
case VOLT_POLICY_GET_LOCAL_DOMAIN:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = GetLocalDomainAlloc (ctx, libCtx, (VtItem **)info);
break;
case VOLT_POLICY_GET_PROVISIONED_DISTRICT:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = ProvisionedDistrictAlloc (
ctx, libCtx, (VoltIdentityObject *)definition,
(VtItem **)info);
break;
case VOLT_POLICY_GET_DEFAULT_DISTRICT_COMPUTED:
/* This policy does not override the regular default algorithm.
* *info is initialized to NULL.
*/
status = 0;
break;
case VOLT_POLICY_GET_FALL_THROUGH_DISTRICT:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = FallThroughDistrictAlloc (ctx, libCtx, (VtItem **)info);
break;
case VOLT_POLICY_GET_IS_DISTRICT_AGGRESSIVE:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = IsDistrictAggressiveAlloc (
ctx, libCtx, (VoltDistrictObject *)definition, (int **)info);
break;
case VOLT_POLICY_GET_REFRESH_RATE_NEGATIVE:
case VOLT_POLICY_GET_REFRESH_RATE_POSITIVE:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = RefreshRateAlloc (ctx, libCtx, policyGetType, (int **)info);
break;
case VOLT_POLICY_GET_IS_PARAM_CHECKING_STRICT:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = IsParamCheckingStrictAlloc (ctx, libCtx, (int **)info);
break;
case VOLT_POLICY_GET_IS_TRUSTED_DISTRICT:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = IsDistrictTrustedAlloc (
ctx, libCtx, (VoltDistrictObject *)definition, (int **)info);
break;
case VOLT_POLICY_GET_CREDENTIAL_CACHE_MODE:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = CredentialCacheModeAlloc (ctx, libCtx, (int **)info);
break;
case VOLT_POLICY_GET_SECURE_MAIL_HEADER:
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_INVALID_TYPE;
if (definition == (Pointer)0)
break;
flag = *((unsigned int *)definition);
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = HeaderFooterAlloc (ctx, libCtx, flag, (VtItem **)info);
break;
case VOLT_POLICY_GET_MESSAGE_HEADER_INTERNAL:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = MessageHeaderInternalAlloc(ctx, libCtx, (VtItem**)info);
break;
case VOLT_POLICY_GET_MESSAGE_HEADER_EXTERNAL:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = MessageHeaderExternalAlloc(ctx, libCtx, (VtItem**)info);
break;
case VOLT_POLICY_GET_CONTENT_FOOTER:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = HeaderFooterAlloc (ctx, libCtx, 0, (VtItem **)info);
break;
case VOLT_POLICY_GET_ZERO_DOWNLOAD_TEMPLATE:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = ZdrTemplateAlloc (ctx, libCtx, (VtItem **)info);
break;
case VOLT_POLICY_GET_ZDM2_TEMPLATE:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = Zdm2TemplateAlloc (ctx, libCtx, (VtItem **)info);
break;
case VOLT_POLICY_GET_HTML_MESSAGE_BODY_TEMPLATE:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = HTMLMessageBodyTemplateAlloc (ctx, libCtx, (VtItem **)info);
break;
case VOLT_POLICY_GET_ENCRYPT_RULES:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = EncryptRulesAlloc (ctx, libCtx, (VtItem **)info);
break;
case VOLT_POLICY_GET_DEFAULT_ZDR_LOCATION:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = DefaultZdrLocationAlloc (ctx, libCtx, (VtItem **)info);
break;
case VOLT_POLICY_GET_DECRYPT_POLICY:
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = DecryptPolicyAlloc (ctx, libCtx, (int **)info);
}
VOLT_LOG_ERROR_INFO_COMPARE (
status, 0, policyCtx, status, 0, errorType,
(char *)0, "VoltLocalPolicyGetInfoAlloc", fnctLine, (char *)0)
return (status);
}
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;
VOLT_DECLARE_ERROR_TYPE (errorType)
VOLT_DECLARE_FNCT_LINE (fnctLine)
do
{
/* This policy looks at email only. Get the domain.
*/
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = VoltGetEmailAndDomain (
idObj, &emailAddress, &emailAddressLen, &domain, &domainLen);
if (status != 0)
break;
/* 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)
break;
/* 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)
break;
/* This is a local domain. Allocate space for a VtItem and a copy of
* the district name and return it.
*/
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_MEMORY;
bufferSize = sizeof (VtItem) + domainLen + 1;
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, domain, domainLen);
retVal->len = domainLen;
*districtName = retVal;
status = 0;
} while (0);
VOLT_LOG_ERROR_INFO_COMPARE (
status, 0, ctx, status, 0, errorType,
(char *)0, "IsIdentityLocalAlloc", fnctLine, (char *)0)
return (status);
}
static int GetLocalDomainAlloc (
VoltPolicyCtx *ctx,
VoltLibCtx *libCtx,
VtItem **domainName
)
{
int status;
unsigned int bufferSize, domainLen;
VoltDefaultPolicyCtx *localPolicyCtx =
(VoltDefaultPolicyCtx *)(ctx->localCtx);
char *domain = (char *)0;
unsigned char *buffer = (unsigned char *)0;
VtItem *retVal;
VOLT_DECLARE_ERROR_TYPE (errorType)
VOLT_DECLARE_FNCT_LINE (fnctLine)
*domainName = (VtItem *)0;
do
{
/* This checks the XML data. If the return is NULL, there is no
* local domain.
*/
status = 0;
domain = m_vs_cp_get_primary_domain (localPolicyCtx->vsPolicyObj);
if (domain == (char *)0)
break;
domainLen = Z2Strlen (domain);
/* There is a local domain. Allocate space for a VtItem and a copy of
* the domain name and return it.
*/
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_MEMORY;
bufferSize = sizeof (VtItem) + domainLen + 1;
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, domain, domainLen);
retVal->len = domainLen;
*domainName = retVal;
status = 0;
} while (0);
if (domain != (char *)0)
Z2Free (domain);
VOLT_LOG_ERROR_INFO_COMPARE (
status, 0, ctx, status, 0, errorType,
(char *)0, "GetLocalDomainAlloc", fnctLine, (char *)0)
return (status);
}
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;
VOLT_DECLARE_ERROR_TYPE (errorType)
VOLT_DECLARE_FNCT_LINE (fnctLine)
do
{
/* This policy looks at email only. Get the email address.
*/
VOLT_SET_ERROR_TYPE (errorType, 0)
VOLT_SET_FNCT_LINE (fnctLine)
status = VoltGetEmailAndDomain (
idObj, &emailAddress, &emailAddressLen, &domain, &domainLen);
if (status != 0)
break;
/* 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)
break;
/* 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)
break;
/* The address is provisioned.
*/
/* 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.
*/
VOLT_SET_ERROR_TYPE (errorType, VT_ERROR_TYPE_PRIMARY)
VOLT_SET_FNCT_LINE (fnctLine)
status = VT_ERROR_MEMORY;
domainLen = Z2Strlen (newName);
bufferSize = sizeof (VtItem) + domainLen + 1;
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);
VOLT_LOG_ERROR_INFO_COMPARE (
status, libCtx, ctx, status, 0, errorType,
(char *)0, "ProvisionedDistrictAlloc", fnctLine, (char *)0)
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;
VOLT_DECLARE_ERROR_TYPE (errorType)
VOLT_DECLARE_FNCT_LINE (fnctLine)
do
{
/* This checks the XML data. If the return is null, there is no fall
* through district.
*/
status = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -