Supported Languages
void
NonCAPICertificateStoreAlternatives()
{
//Declare and
initialize an empty cache mediator. The
default
//parameter
value is false, which indicates that the defaults
//colleagues
should not be included automatically.
CPKIFCacheMediator2Ptr ecm(new CPKIFCacheMediator2());
ecm->InitializeMediator(NULL);
//Create a
simple in-memory trust store, simple in-memory cert
//store and a
simple in-memory CRL store
SimpleRootStorePtr simpleRootStore(new SimpleRootStore());
SimpleCertCachePtr simpleCertCache(new SimpleCertCache());
SimpleCRLCachePtr simpleCRLCache(new SimpleCRLCache());
//Create an LDAP
source for certs and CRLs
CPKIFLDAPRepositoryPtr ldap(new CPKIFLDAPRepository());
ldap->SetHost("smime2.nist.gov");
//Add each to
the empty cache mediator object. Pass
true
//to transfer
lifetime management to the mediator object.
ecm->AddColleague(dynamic_pointer_cast<IPKIFColleague,
SimpleRootStore>(simpleRootStore));
ecm->AddColleague(dynamic_pointer_cast<IPKIFColleague,
SimpleCertCache>(simpleCertCache));
ecm->AddColleague(dynamic_pointer_cast<IPKIFColleague,
SimpleCRLCache>(simpleCRLCache));
ecm->AddColleague(dynamic_pointer_cast<IPKIFColleague,
CPKIFLDAPRepository>(ldap));
//Parse a
certificate for use as a trust anchor
CPKIFCertificatePtr rootCert(new CPKIFCertificate);
rootCert->Decode(rootCertBuf,
rootCertBufLen);
//Create a trust
root object containing the cert
CPKIFTrustRootPtr trustRoot(new CPKIFTrustRoot);
trustRoot->SetCert(rootCert);
//Add the trust
root object to the simple root store
simpleRootStore->AddTrustRoot(trustRoot);
//Create and
initialize the remaining mediators needed to form a complete set
CPKIFCryptoMediator2Ptr cryptoMed2(new CPKIFCryptoMediator2(true));
cryptoMed2->InitializeMediator(NULL);
CPKIFRevocationStatusMediator2Ptr
revocStatMed2(new
CPKIFRevocationStatusMediator2(true));
revocStatMed2->InitializeMediator(NULL);
//declare an
instance of a path processor and associated it with the above mediators
CPKIFPathProcessingMediator2Ptr pm(new CPKIFPathProcessingMediator2(true));
pm->InitializeMediator(NULL);
pm->AddMediator(dynamic_pointer_cast<IPKIFMediator,
CPKIFCryptoMediator2>(cryptoMed2));
pm->AddMediator(dynamic_pointer_cast<IPKIFMediator,
CPKIFRevocationStatusMediator2>(revocStatMed2));
pm->AddMediator(dynamic_pointer_cast<IPKIFMediator,
CPKIFCacheMediator2>(ecm));
//The mediator
collection is now ready for use. As
paths are constructed using the LDAP directory
//the in-memory
simple cert and CRL caches will be populated.
All paths must terminate
//at the lone
trust root placed into the simple trust store.
//Get a pointer
to the CacheMediator from the mediator collection held
CPKIFCacheMediator2* pECM =
pm->GetMediator<CPKIFCacheMediator2>();
//Get a pointer
to an interface
IPKIFCryptoMisc* pMisc =
pm->GetMediator<IPKIFCryptoMisc>();
}
public void NonCAPICertificateStoreAlternatives()
{
//Declare and
initialize an empty cache mediator. The
default
//parameter value
is false, which indicates that the defaults
//colleagues
should not be included automatically.
IPKIFColleaguePtr
ecmInter = pkif_module.make_NewCPKIFCacheMediator2(false);
CPKIFCacheMediator2
ecm = pkif_module.Get_CacheMediator(ecmInter);
ecm.Initialize();
//Create a simple
in-memory trust store, simple in-memory cert
//store and a
simple in-memory CRL store
IPKIFColleaguePtr
simpleRootStoreCol = pkif_module.make_NewSimpleRootStore();
SimpleRootStorePtr
simpleRootStore = pkif_module.cast_ToSimpleRootStore(simpleRootStoreCol);
IPKIFColleaguePtr
simpleCertCacheCol = pkif_module.make_NewSimpleCertCache();
SimpleCertCachePtr
simpleCertCache = pkif_module.cast_ToSimpleCertCache(simpleCertCacheCol);
IPKIFColleaguePtr
simpleCRLCacheCol = pkif_module.make_NewSimpleCRLCache();
SimpleCRLCachePtr
simpleCRLCache = pkif_module.cast_ToSimpleCRLCache(simpleCRLCacheCol);
//Create an LDAP
source for certs and CRLs
IPKIFColleaguePtr
ldapCol = pkif_module.make_NewCPKIFLDAPRepository();
CPKIFLDAPRepositoryPtr
ldap = pkif_module.cast_ToCPKIFLDAPRepository(ldapCol);
ldap.SetHost("smime2.nist.gov");
//Add each to the
empty cache mediator object.
ecm.AddColleague(simpleRootStoreCol);
ecm.AddColleague(simpleCertCacheCol);
ecm.AddColleague(simpleCRLCacheCol);
ecm.AddColleague(ldapCol);
rootCert.Decode(rootCertBuf,
rootCertBuf.Length);
//Create a trust
root object containing the cert
CPKIFTrustRootPtr
trustRoot = pkif_module.make_CPKIFTrustRootPtr();
trustRoot.SetCert(rootCert);
//Add the trust
root object to the simple root store
simpleRootStore.AddTrustRoot(pkif_module.cast_ToIPKIFTrustAnchorPtr(trustRoot));
//Create and
initialize the remaining mediators needed to form a complete set
//Create and
initialize a crypto mediator with the default colleagues
IPKIFColleaguePtr
cryptoMedInter = pkif_module.make_NewCPKIFCryptoMediator2(true);
CPKIFCryptoMediator2
cryptoMed = pkif_module.Get_CryptoMediator(cryptoMedInter);
cryptoMed.InitializeMediator();
//Create and
initialize a revocation status mediator the default colleagues
IPKIFColleaguePtr
rsmInter = pkif_module.make_NewCPKIFRevocationStatusMediator2(true);
CPKIFRevocationStatusMediator2
rsm = pkif_module.Get_RevocationStatusMediator(rsmInter);
rsm.InitializeMediator();
//declare an
instance of a path processor and associated it with the above mediators
//Create and
initialize a path mediator with the default colleagues
IPKIFColleaguePtr
pathMedInter = pkif_module.make_NewCPKIFPathProcessingMediator2(true);
CPKIFPathProcessingMediator2
pathMed = pkif_module.Get_PathProcessingMediator(pathMedInter);
pathMed.InitializeMediator();
pathMed.AddMediator(cryptoMedInter);
pathMed.AddMediator(rsmInter);
pathMed.AddMediator(ecmInter);
//The mediator
collection is now ready for use. As
paths are constructed using the LDAP directory
//the in-memory
simple cert and CRL caches will be populated.
All paths must terminate
//at the lone
trust root placed into the simple trust store.
//Get a pointer
to the CacheMediator from the mediator collection held
CPKIFCacheMediator2
pECM = pkif_module.Get_CacheMediator(pathMedInter);
//Get a pointer
to an interface
IPKIFCryptoMisc
pMisc = pkif_module.Get_IPKIFCryptoMisc(pathMedInter);
}
public void
NonCAPICertificateStoreAlternatives()
{
//Declare and initialize an empty
cache mediator. The default
//parameter value is false, which
indicates that the defaults
//colleagues should not be included
automatically.
IPKIFColleaguePtr ecmInter = pkif_module.make_NewCPKIFCacheMediator2(false);
CPKIFCacheMediator2 ecm = pkif_module.Get_CacheMediator(ecmInter);
ecm.Initialize();
//Create a simple in-memory trust
store, simple in-memory cert
//store and a simple in-memory CRL
store
IPKIFColleaguePtr simpleRootStoreCol =
pkif_module.make_NewSimpleRootStore();
SimpleRootStorePtr simpleRootStore = pkif_module.cast_ToSimpleRootStore(simpleRootStoreCol);
IPKIFColleaguePtr simpleCertCacheCol =
pkif_module.make_NewSimpleCertCache();
SimpleCertCachePtr simpleCertCache =
pkif_module.cast_ToSimpleCertCache(simpleCertCacheCol);
IPKIFColleaguePtr simpleCRLCacheCol =
pkif_module.make_NewSimpleCRLCache();
SimpleCRLCachePtr simpleCRLCache =
pkif_module.cast_ToSimpleCRLCache(simpleCRLCacheCol);
//Create an LDAP source for certs and
CRLs
IPKIFColleaguePtr ldapCol = pkif_module.make_NewCPKIFLDAPRepository();
CPKIFLDAPRepositoryPtr ldap = pkif_module.cast_ToCPKIFLDAPRepository(ldapCol);
ldap.SetHost("smime2.nist.gov");
//Add each to the empty cache mediator
object.
ecm.AddColleague(simpleRootStoreCol);
ecm.AddColleague(simpleCertCacheCol);
ecm.AddColleague(simpleCRLCacheCol);
ecm.AddColleague(ldapCol);
//Parse a certificate for use as a
trust anchor
CPKIFCertificatePtr rootCert = pkif_module.make_CPKIFCertificatePtr();
rootCert.Decode(IntArrayToByteArray(rootCertBuf), rootCertBuf.length);
//Create a trust root object
containing the cert
CPKIFTrustRootPtr trustRoot = pkif_module.make_CPKIFTrustRootPtr();
trustRoot.SetCert(rootCert);
//Add the trust root object to the
simple root store
simpleRootStore.AddTrustRoot(pkif_module.cast_ToIPKIFTrustAnchorPtr(trustRoot));
//Create and initialize the remaining
mediators needed to form a complete set
//Create and initialize a crypto
mediator with the default colleagues
IPKIFColleaguePtr cryptoMedInter =
pkif_module.make_NewCPKIFCryptoMediator2(true);
CPKIFCryptoMediator2 cryptoMed =
pkif_module.Get_CryptoMediator(cryptoMedInter);
cryptoMed.InitializeMediator();
//Create and initialize a revocation
status mediator the default colleagues
IPKIFColleaguePtr rsmInter = pkif_module.make_NewCPKIFRevocationStatusMediator2(true);
CPKIFRevocationStatusMediator2 rsm =
pkif_module.Get_RevocationStatusMediator(rsmInter);
rsm.InitializeMediator();
//declare an instance of a path
processor and associated it with the above mediators
//Create and initialize a path
mediator with the default colleagues
IPKIFColleaguePtr pathMedInter =
pkif_module.make_NewCPKIFPathProcessingMediator2(true);
CPKIFPathProcessingMediator2 pathMed =
pkif_module.Get_PathProcessingMediator(pathMedInter);
pathMed.InitializeMediator();
pathMed.AddMediator(cryptoMedInter);
pathMed.AddMediator(rsmInter);
pathMed.AddMediator(ecmInter);
//The mediator collection is now ready
for use. As paths are constructed using
the LDAP directory
//the in-memory simple cert and CRL
caches will be populated. All paths must
terminate
//at the lone trust root placed into
the simple trust store.
//Get a pointer to the CacheMediator
from the mediator collection held
CPKIFCacheMediator2 pECM = pkif_module.Get_CacheMediator(pathMedInter);
//Get a pointer to an interface
IPKIFCryptoMisc pMisc = pkif_module.Get_IPKIFCryptoMisc(pathMedInter);
}