📄 ospproviderapi.c
字号:
/**########################################################################*########################################################################*########################################################################* * COPYRIGHT (c) 1998, 1999 by TransNexus, LLC * * This software contains proprietary and confidential information * of TransNexus, LLC. Except as may be set forth in the license * agreement under which this software is supplied, use, disclosure, * or reproduction is prohibited without the prior, express, written* consent of TransNexus, LLC. * *******#########################################################################*#########################################################################*#########################################################################*//* * ospproviderapi.cpp - API functions for provider. */#include "osp.h"#include "ospossys.h"#include "ospproviderapi.h"#include "ospprovider.h"#include "ospcomm.h"#include "ospsecurity.h"#include "osptrans.h"#include "ospmsgque.h"#include "ospssl.h"#include "ospconfig.h"/* * OSPPProviderDelete() * * Delete the Provider Object. * * The OSPPProviderDelete function tells the SDK library to delete a * provider object. This function immediately prevents the creation of * new transactions for the indicated provider. (Attempts to create new * transaction objects will be refused with an appropriate error code.). * The function also blocks until all pending transactions for the * provider have completed or the time limit has been exceeded. * The ospvTimeLimit parameter specifies the maximum number of seconds to * wait for pending transactions to complete. A negative value for this * parameter instructs the library to wait indefinitely, and a value of zero * indicates that the deletion should occur immediately without waiting. If * pending transactions are not complete within the time limit, those * transactions will be terminated abruptly and information, including * information necessary for billing, may be lost. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */int OSPPProviderDelete( OSPTPROVHANDLE ospvProvider, /* In - Provider object */ int ospvTimeLimit) /* In - Maximum delete time */{ OSPTPROVIDER *provider = OSPC_OSNULL; int errorcode = OSPC_ERR_NO_ERROR; provider = OSPPProviderGetContext(ospvProvider, &errorcode); if (errorcode == OSPC_ERR_NO_ERROR) { OSPPProviderSetNewTransactionAllowed(provider, OSPC_FALSE); if (errorcode == OSPC_ERR_NO_ERROR) { OSPPAuditDelete(&(provider->Audit)); /* * shutdown the communication thread and destroy all * communication resources and message queues */ OSPPCommSetShutdown(&(provider->Comm), ospvTimeLimit); OSPPSSLSessionCleanup((void *)provider->Security); OSPPSecDelete(&provider->Security); OSPPProviderTransactionCollectionDelete( &provider->TransCollection); OSPPTransIDTreeDelete(provider); errorcode = OSPPProviderInitializeStorage(provider); } } return errorcode;}/* * OSPPProviderGetAuthorityCertificates() * * Get trusted certificate authority public keys. * * The OSPPProviderGetAuthorityCertificates function returns the * certificate authority public keys that are currently trusted by * ospvProvider. These keys are returned in the form of X.509 formatted * certificates, and they are returned to the ospvAuthorityCertificates * array. The ospvSizeOfCertificate parameter indicates the maximum size * of any individual certificate. If any certificate exceeds that value * then no certificates are returned and an error is returned. The parameter * ospvNumberOfAuthorityCertificates points to the maximum number of * certificates to return. That variable is updated with the actual number * supplied when the function returns. If more certificates are available, * then only a partial list is returned. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderGetAuthorityCertificates( OSPTPROVHANDLE ospvProvider, /* In - Provider handle */ unsigned ospvSizeOfCertificate, /* In - Max cert size */ unsigned *ospvNumberOfAuthorityCertificates, /* In/Out - max to return/actual cnt */ void *ospvAuthorityCertificates[]) /* Out - Ptr to auth cert bufs */{ OSPTPROVIDER *provider = OSPC_OSNULL; int errorcode = OSPC_ERR_NO_ERROR; provider = OSPPProviderGetContext(ospvProvider, &errorcode); if (errorcode == OSPC_ERR_NO_ERROR) { errorcode = OSPPSecCopyAuthorityCertificates(provider->Security, ospvSizeOfCertificate, (unsigned char **)ospvAuthorityCertificates, ospvNumberOfAuthorityCertificates); } return errorcode;}/* * OSPPProviderGetHTTPMaxConnections() * * Get maximum number of simultaneous HTTP connections for provider. * * The OSPPProviderGetHTTPMaxConnections function returns the maximum * number of simultaneous HTTP connections that may be established with * ospvProvider. That number is returned in the variable pointed to by * ospvHTTPMaxConnections. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderGetHTTPMaxConnections( OSPTPROVHANDLE ospvProvider, /* In - Provider handle */ unsigned *ospvHTTPMaxConnections) /* Out - Ptr to result store */{ OSPTPROVIDER *provider = OSPC_OSNULL; int errorcode = OSPC_ERR_NO_ERROR; provider = OSPPProviderGetContext(ospvProvider, &errorcode); if (errorcode == OSPC_ERR_NO_ERROR) /* * get the maximum number of connections from * the Communication Manager module. */ errorcode = OSPPCommGetMaxConnections(provider->Comm, ospvHTTPMaxConnections); return errorcode;}/* * OSPPProviderGetHTTPPersistence() * * Get the persistence, in seconds, of connections established with * provider. * * The OSPPProviderGetHTTPPersistence function returns the persistence * of HTTP connections established with ospvProvider. That value, * returned in the location pointed to by ospvHTTPPersistence, is * measured in seconds. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderGetHTTPPersistence( OSPTPROVHANDLE ospvProvider, /* In - Provider handle */ unsigned *ospvHTTPPersistence) /* Out - Ptr to result store */{ OSPTPROVIDER *provider = OSPC_OSNULL; int errorcode = OSPC_ERR_NO_ERROR; provider = OSPPProviderGetContext(ospvProvider, &errorcode); if (errorcode == OSPC_ERR_NO_ERROR) errorcode = OSPPCommGetPersistence(provider->Comm, ospvHTTPPersistence); return errorcode;}/* * OSPPProviderGetHTTPRetryDelay() * * Get delay, in seconds, between retries for connection with provider. * * The OSPPProviderGetHTTPRetryDelay function returns the delay between * retries for HTTP connection attempts with ospvProvider. That value, * returned in the location pointed to by ospvHTTPRetryDelay, is measured * in seconds. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderGetHTTPRetryDelay( OSPTPROVHANDLE ospvProvider, /* In - Provider handle */ unsigned *ospvHTTPRetryDelay) /* Out - Ptr to result store */{ OSPTPROVIDER *provider = OSPC_OSNULL; int errorcode = OSPC_ERR_NO_ERROR; provider = OSPPProviderGetContext(ospvProvider, &errorcode); if (errorcode == OSPC_ERR_NO_ERROR) errorcode = OSPPCommGetRetryDelay(provider->Comm, ospvHTTPRetryDelay); return errorcode;}/* * OSPPProviderGetHTTPRetryLimit() * * Get maximum number of retries for HTTP connection with provider. * * The OSPPProviderGetHTTPRetryLimit function returns the maximum * number of * retries for HTTP connection attempts with ospvProvider. That value is returned * in the location pointed to by ospvHTTPRetryLimit. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderGetHTTPRetryLimit( OSPTPROVHANDLE ospvProvider, /* In - Provider handle */ unsigned *ospvHTTPRetryLimit) /* Out - Ptr to result store */{ OSPTPROVIDER *provider = OSPC_OSNULL; int errorcode = OSPC_ERR_NO_ERROR; provider = OSPPProviderGetContext(ospvProvider, &errorcode); if (errorcode == OSPC_ERR_NO_ERROR) errorcode = OSPPCommGetRetryLimit(provider->Comm, ospvHTTPRetryLimit); return errorcode;}/* * OSPPProviderGetHTTPTimeout() * * Get time, in milliseconds, to wait for a response from a provider * HTTP connection. * * The OSPPProviderGetHTTPTimeout function returns the timeout value * that specifies how long to wait for responses from HTTP connections * with ospvProvider. The value, returned in the location pointed to by * ospvHTTPTimeout, is measured in milliseconds. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderGetHTTPTimeout( OSPTPROVHANDLE ospvProvider, /* In - Provider handle */ unsigned *ospvHTTPTimeout) /* Out - Ptr to result store */{ OSPTPROVIDER *provider = OSPC_OSNULL; int errorcode = OSPC_ERR_NO_ERROR; provider = OSPPProviderGetContext(ospvProvider, &errorcode); if (errorcode == OSPC_ERR_NO_ERROR) errorcode = OSPPCommGetTimeout(provider->Comm, ospvHTTPTimeout); return errorcode;}/* * OSPPProviderGetLocalKeys() * * Get public and private key information being used by provider. * * The OSPPProviderGetLocalKeys function returns the public and * private key information currently in use by ospvProvider for * signing requests and indications. The RSA private key is returned * in the location pointed to by ospvLocalPrivateKey, and the X.509 * formatted public key certificate is stored in ospvLocalCertificate. * The ospvSizeOfCertificate parameter indicates the maximum size of * the ospvLocalCertificate array. If the certificate does not fit * within that limit, the function returns an appropriate error code. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderGetLocalKeys( OSPTPROVHANDLE ospvProvider, /* In - Provider handle */ OSPTPRIVATEKEY *ospvLocalPrivateKey, /* Out - Ptr to storage */ unsigned ospvSizeOfCertificate, /* In - Length of cert space */ void *ospvLocalCertificate) /* Out - Ptr to cert store */{ OSPTPROVIDER *provider = OSPC_OSNULL; int errorcode = OSPC_ERR_NO_ERROR; provider = OSPPProviderGetContext(ospvProvider, &errorcode); if (errorcode == OSPC_ERR_NO_ERROR) { /* * Copy the private key from the Security module */ errorcode = OSPPSecCopyPrivateKey( provider->Security, (OSPTPRIVATEKEY *)ospvLocalPrivateKey); } if (errorcode == OSPC_ERR_NO_ERROR) { /* * Copy the local certificate from the Security module */ errorcode = OSPPSecCopyLocalCertificate(provider->Security, &ospvSizeOfCertificate, (unsigned char *)ospvLocalCertificate); } return errorcode;}/* * OSPPProviderGetLocalValidation() * * Indicates whether to validate tokens locally or via a protocol exchange. * * The OSPPProviderGetLocalValidation function returns an indication of * whether or not ospvProvider is currently set to validate authorisation * tokens locally (i.e. by verifying their digital signature) or via a * protocol exchange. The return value is stored in the location pointed * to by ospvLocalValidation. * * returns OSPC_ERR_NO_ERROR if successful, OSPC_ERR_XXX otherwise. */intOSPPProviderGetLocalValidation( OSPTPROVHANDLE ospvProvider, /* In - Provider handle */ unsigned *ospvLocalValidation) /* Out - Local validation indicator */{ OSPTPROVIDER *provider = OSPC_OSNULL; int errorcode = OSPC_ERR_NO_ERROR; provider = OSPPProviderGetContext(ospvProvider, &errorcode); if (errorcode == OSPC_ERR_NO_ERROR) errorcode = OSPPSecGetLocalValidation(provider->Security, ospvLocalValidation); return errorcode;}/* * OSPPProviderGetNumberOfAuthorityCertificates() * * Get the number of trusted certificate authority certificates. * * The OSPPProviderGetNumberOfAuthorityCertificates function returns * the number of certificate authority public keys currently trusted * by ospvProvider.That value is stored in the location pointed to by * ospvNumberOfAuthorityCertificates. * * Returns: OSPC_ERR_NO_ERROR if successful, OSPC_ERR_xxx otherwise. */intOSPPProviderGetNumberOfAuthorityCertificates( OSPTPROVHANDLE ospvProvider, /* In - Provider handle */ unsigned *ospvNumberOfAuthorityCertificates) /* Out - Ptr to result store */{ OSPTPROVIDER *provider = OSPC_OSNULL; int errorcode = OSPC_ERR_NO_ERROR; provider = OSPPProviderGetContext(ospvProvider, &errorcode); if (errorcode == OSPC_ERR_NO_ERROR) { errorcode = OSPPSecGetNumberOfAuthorityCertificates(provider->Security, ospvNumberOfAuthorityCertificates); } return errorcode;}/* * OSPPProviderGetNumberOfServicePoints()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -