All C++ code samples provided in this section are included in the PKIFSample project in PKIFv2 distribution.
All C# code samples provided in this section are included in PKIFSample.Net project in PKIFv2 distribution.
All JAVA code samples provided in this section are inclided in PKIFSampleJAVA folder in PKIFv2 distribution.
The following samples are available:
· Discovering available credentials
· Decrypting encrypted messages
· Specifying an LDAP directory
· Specifying a trusted OCSP responder using MakeDefaultMediator
· Building and validating a certificate path
· Working with path validation results
· Working with revocation source information
· Performing symmetric key encryption operations
· Non-CAPI certificate store alternatives
· Automatic CAPI certificate store update
· Using a specific cryptographic service provider
· Specifying a trusted OCSP responder
*Most examples do not feature error handling. As a general rule, all PKIF operations should be performed inside a try/catch block capable of catching all CPKIFExceptions and/or all std::exceptions. CPKIFExceptions, or derived exception classes, are used to indicate operational exceptions within PKIF. Std::exceptions are used to indicate out of memory errors. CPKIFExceptions are derived from std::exceptions. Thus all exceptions can be caught by catching std::exceptions. CPKIFException information can be obtained by casting the exception using dynamic_cast. The following code sample demonstrates exception handling using std::exceptions and casting.
try
{
CPKIFCertificatePtr testCert(new CPKIFCertificate);
testCert->Decode(NULL, certDataLen);
}
catch(std::exception& se)
{
CPKIFException* pe = dynamic_cast<CPKIFException*>(&se);
if(pe)
{
cout << pe->print()->c_str() << endl;
}
else
{
cout << "non-CPKIFException object" << endl;
}
}