Working with revocation source information

This code sample ilustrates working with revocation source information

upported Languages

C++

void WorkingWithRevocationSourceInformation()
{
      RevocationSourceList::iterator rslPos;
      RevocationSourceList::iterator rslEnd = g_rsl.end();
      for(rslPos = g_rsl.begin(); rslPos != rslEnd; ++rslPos)
      {
            //Source error code:
            int rsDiagnosticCode = (*rslPos)->m_errorCode; 

            //Source type:
            int rsType = (*rslPos)->m_sourceType; 

            //Source status:
            RevocationStatus rsStatus = (*rslPos)->m_status; 

            //Source info:
            IPKIFRevSourceInfoPtr rsip = (*rslPos)->m_sourceInfo;
            switch((*rslPos)->m_sourceType)
            {
                  case REVSOURCE_CRL:
                  {
                        CPKIFCRLInfoPtr crlInfo = RevInfoCast<CPKIFCRLInfo>(rsip);         

                        CPKIFCRLList crls;
                        crlInfo->GetCRLs(crls); 

                        CPKIFCRLList::iterator crlPos;
                        CPKIFCRLList::iterator crlEnd = crls.end();
                        for(crlPos = crls.begin(); crlPos != crlEnd; ++crlPos)
                        {
                              //access CRL information
                              CPKIFCRLPtr curCRL = *crlPos;
                        }
                        break;
                  }
                  case REVSOURCE_OCSP:
                  {
                        CPKIFOCSPInfoPtr ocspInfo = RevInfoCast<CPKIFOCSPInfo>(rsip); 

                        if(ocspInfo != (CPKIFOCSPInfo*)NULL)
                        {
                              CPKIFOCSPResponsePtr ocspResponse = ocspInfo->GetOCSPResponse();
                              if(ocspResponse != (CPKIFOCSPResponse*)NULL)
                              {

                                    //retrieve the overall status of the request the status of the request is identifued by an integer.
                                    //successful = 0,
                                    //malformedRequest = 1,
                                    //internalError = 2,
                                    //tryLater = 3,
                                    //sigRequired = 5,
                                    //unauthorized = 6
                                    int ors = ocspResponse->GetResponseStatus();
                                    if(0 == ors)
                                    {
                                          //process the response and extract general response details
                                          CPKIFResponseBytesPtr rb = ocspResponse->GetResponseBytes(); 

                                          CPKIFBasicOCSPResponse bor;
                                          bor.Decode(rb->GetResponse());
 

                                          CPKIFResponseDataPtr rd = bor.GetResponseData(); 

                                          CPKIFResponderIDPtr rid = rd->GetResponderID();
                                          CPKIFTimePtr producedAt = rd->GetProducedAt();
                                          CPKIFNamePtr tmpRIDName = rid->GetName();
                                    } 

                                    //extract the SingleResponse object associated with the certificate
                                    //from the OCSPInfo object (if present)
                                    CPKIFSingleResponsePtr singleResponse = ocspInfo->GetSingleResponse();
                                    if(singleResponse != (CPKIFSingleResponse*)NULL)
                                    {
                                          //extract the details from the SingleResponse, if present, including
                                          //status (which in this sample should always be UNKNOWN)
                                          CPKIFTimePtr thisUpdate = singleResponse->GetThisUpdate();
                                          CPKIFTimePtr nextUpdate = singleResponse->GetNextUpdate();
                                          CPKIFCertIDPtr certID = singleResponse->GetCertID(); 

                                          CPKIFOCSPCertStatusPtr ocspCertStatus = singleResponse->GetCertStatus();
                                          CPKIFOCSPCertStatus::CertStatusChoice choice = ocspCertStatus->GetChoice();
                                    }
                              }
                        }
                        break;
                  }
            }
      }
}

C#

public void WorkingWithRevocationSourceInformation()
{ 
    for(int ii = 0; ii < g_rsl.Count; ii++)
    {

        //Source error code:
        int rsDiagnosticCode = g_rsl[ii].m_errorCode; 

        //Source type:
        int rsType = g_rsl[ii].m_sourceType; 

        //Source status:
        RevocationStatus rsStatus = g_rsl[ii].m_status; 

        //Source info:
        IPKIFRevSourceInfoPtr rsip = g_rsl[ii].m_sourceInfo;
        switch (g_rsl[ii].m_sourceType)
        {
            case 1: //REVSOURCE_CRL = 1
                {
                    CPKIFCRLInfoPtr crlInfo = pkif_module.cast_ToCPKIFCRLInfoPtr(rsip);
                    CPKIFCRLList crls = new CPKIFCRLList();

                    crlInfo.GetCRLs(crls); 

                    for (int jj = 0; jj < crls.Count; jj++)
                    {
                        CPKIFCRLPtr curCRL = crls[jj]; ;
                    }
                    break;
                }
            case 2: //REVSOURCE_OCSP = 2:
                {
                    CPKIFOCSPInfoPtr ocspInfo = pkif_module.cast_ToCPKIFOCSPInfoPtr(rsip); 

                    if (ocspInfo.get() != null)
                    {
                        CPKIFOCSPResponsePtr ocspResponse = ocspInfo.GetOCSPResponse();
                        if (ocspResponse.get() != null)
                        {
                            //retrieve the overall status of the request the status of the request is identifued by an integer.
                            //successful = 0,
                            //malformedRequest = 1,
                            //internalError = 2,
                            //tryLater = 3,
                            //sigRequired = 5,
                            //unauthorized = 6
                            int ors = ocspResponse.GetResponseStatus();
                            if (0 == ors)
                            {
                                //process the response and extract general response details
                                CPKIFResponseBytesPtr rb = ocspResponse.GetResponseBytes(); 

                                CPKIFBasicOCSPResponse bor = new CPKIFBasicOCSPResponse();
                                bor.Decode(rb.GetResponse()); 

                                CPKIFResponseDataPtr rd = bor.GetResponseData(); 

                                CPKIFResponderIDPtr rid = rd.GetResponderID();
                                CPKIFTimePtr producedAt = rd.GetProducedAt();
                                CPKIFNamePtr tmpRIDName = rid.GetName();
                            } 

                            //extract the SingleResponse object associated with the certificate
                            //from the OCSPInfo object (if present)
                            CPKIFSingleResponsePtr singleResponse = ocspInfo.GetSingleResponse();
                            if (singleResponse.get() != null)
                            {
                                //extract the details from the SingleResponse, if present, including
                                //status (which in this sample should always be UNKNOWN)
                                CPKIFTimePtr thisUpdate = singleResponse.GetThisUpdate();
                                CPKIFTimePtr nextUpdate = singleResponse.GetNextUpdate();
                                CPKIFCertIDPtr certID = singleResponse.GetCertID();

                                CPKIFOCSPCertStatusPtr ocspCertStatus = singleResponse.GetCertStatus();
                                CPKIFOCSPCertStatus.CertStatusChoice choice = ocspCertStatus.GetChoice();
                            }
                        }
                    }
                    break;
                }
        }
     }
}

JAVA

public void WorkingWithRevocationSourceInformation()
{
 

    for(int ii = 0; ii < g_rsl.size(); ii++)
    {
       
//Source error code:
        int rsDiagnosticCode = g_rsl.get(ii).getM_errorCode(); 

        //Source type:
        int rsType = g_rsl.get(ii).getM_sourceType(); 

        //Source status:
        RevocationStatus rsStatus = g_rsl.get(ii).getM_status(); 

        //Source info:
        IPKIFRevSourceInfoPtr rsip = g_rsl.get(ii).getM_sourceInfo();
       
switch (g_rsl.get(ii).getM_sourceType())
        {
           
case 1: //REVSOURCE_CRL = 1
                    {
                        CPKIFCRLInfoPtr crlInfo = pkif_module.cast_ToCPKIFCRLInfoPtr(rsip); 

                        CPKIFCRLList crls = new CPKIFCRLList();
                        crlInfo.GetCRLs(crls);
 

                        for (int jj = 0; jj < crls.size(); jj++)
                        {

                            CPKIFCRLPtr curCRL = crls.get(jj); ;
                        }

                        break;
                    }
               
case 2: //REVSOURCE_OCSP = 2:
                {
                    CPKIFOCSPInfoPtr ocspInfo = pkif_module.cast_ToCPKIFOCSPInfoPtr(rsip);
 

                    if (ocspInfo.get() != null)
                    {
                        CPKIFOCSPResponsePtr ocspResponse = ocspInfo.GetOCSPResponse();
                       
if (ocspResponse.get() != null)
                        {
                           
//retrieve the overall status of the request the status of the request is identifued by an integer.
                            //successful = 0,
                            //malformedRequest = 1,
                            //internalError = 2,
                            //tryLater = 3,
                            //sigRequired = 5,
                            //unauthorized = 6
                            int ors = ocspResponse.GetResponseStatus();
                            
if (0 == ors)
                            {
                               
//process the response and extract general response details
                                CPKIFResponseBytesPtr rb = ocspResponse.GetResponseBytes(); 

                                CPKIFBasicOCSPResponse bor = new CPKIFBasicOCSPResponse();
                                bor.Decode(rb.GetResponse());

                                CPKIFResponseDataPtr rd = bor.GetResponseData(); 

                                CPKIFResponderIDPtr rid = rd.GetResponderID();
                                CPKIFTimePtr producedAt = rd.GetProducedAt();
                                CPKIFNamePtr tmpRIDName = rid.GetName();
                            }
 

                            //extract the SingleResponse object associated with the certificate
                            //from the OCSPInfo object (if present)
                            CPKIFSingleResponsePtr singleResponse = ocspInfo.GetSingleResponse();
                           
if (singleResponse.get() != null)
                            {
                               
//extract the details from the SingleResponse, if present, including
                                //status (which in this sample should always be UNKNOWN)
                                CPKIFTimePtr thisUpdate = singleResponse.GetThisUpdate();
                                CPKIFTimePtr nextUpdate = singleResponse.GetNextUpdate();
                                CPKIFCertIDPtr certID = singleResponse.GetCertID();
 

                                CPKIFOCSPCertStatusPtr ocspCertStatus = singleResponse.GetCertStatus();
                                CPKIFOCSPCertStatus.CertStatusChoice choice = ocspCertStatus.GetChoice();
                            }
                        }
                    }

                    break;
                }
        }
    }
}