コード例 #1
0
ndnboost::any
PublicKeyVisitor::visit(DerSequence& derSeq)
{
  DerNodePtrList& children = derSeq.getChildren();

  SimpleVisitor simpleVisitor;
  ptr_lib::shared_ptr<DerSequence> algoSeq = ptr_lib::dynamic_pointer_cast<DerSequence>(children[0]);
  Blob raw = derSeq.getRaw();
  // TODO: Determine and pass the correct KeyType.
  return ndnboost::any(ptr_lib::shared_ptr<PublicKey>(new PublicKey(KEY_TYPE_RSA, raw)));
}
コード例 #2
0
ファイル: print-visitor.cpp プロジェクト: doudouOUC/ndn-cpp
void 
PrintVisitor::visit(DerSequence& derSequence, ndnboost::any param)
{
  const string& indent = ndnboost::any_cast<const string&>(param);
  
  printData(derSequence.getHeader(), indent);

  const DerNodePtrList& children = derSequence.getChildren();
  DerNodePtrList::const_iterator it = children.begin();
  for(; it != children.end(); it++)
  (*it)->accept(*this, indent + " | ");
}
コード例 #3
0
/*
 * CertExtensionVisitor
 */
void 
CertificateExtensionVisitor::visit(DerSequence& derSeq, ndnboost::any param)
{
  const DerNodePtrList& children = derSeq.getChildren();
  
  CertificateExtensionEntryVisitor extnEntryVisitor;

  DerNodePtrList::const_iterator it = children.begin();

  while(it != children.end()) {
    (*it)->accept(extnEntryVisitor, param);
    it++;
  }
}
コード例 #4
0
/*
 * CertSubjectVisitor
 */
void 
CertificateSubjectVisitor::visit(DerSequence& derSeq, ndnboost::any param)
{
  // _LOG_DEBUG("CertSubjectVisitor::visit");

  const DerNodePtrList& children = derSeq.getChildren();
  
  CertificateSubjectDescriptionVisitor descryptVisitor;

  DerNodePtrList::const_iterator it = children.begin();

  while(it != children.end()) {
    (*it)->accept(descryptVisitor, param);
    it++;
  }
}
コード例 #5
0
/*
 * CertSubDescryptVisitor
 */
void
CertificateSubjectDescriptionVisitor::visit(DerSequence& derSeq, ndnboost::any param)
{
  Certificate* certData = ndnboost::any_cast<Certificate*>(param); 
  
  const DerNodePtrList& children = derSeq.getChildren();
  
  SimpleVisitor simpleVisitor;

  OID oid = ndnboost::any_cast<OID>(children[0]->accept(simpleVisitor));
  string value = ndnboost::any_cast<string>(children[1]->accept(simpleVisitor));

  CertificateSubjectDescription subDescrypt(oid, value);

  certData->addSubjectDescription(subDescrypt);
}
コード例 #6
0
/*
 * CertExtnEntryVisitor
 */
void 
CertificateExtensionEntryVisitor::visit(DerSequence& derSeq, ndnboost::any param)
{
  Certificate* certData = ndnboost::any_cast<Certificate*>(param); 
  
  const DerNodePtrList& children = derSeq.getChildren();
  
  SimpleVisitor simpleVisitor;

  OID oid = ndnboost::any_cast<OID>(children[0]->accept(simpleVisitor));
  bool critical = ndnboost::any_cast<bool>(children[1]->accept(simpleVisitor));
  const Blob& value = ndnboost::any_cast<const Blob&>(children[2]->accept(simpleVisitor));

  CertificateExtension extension(oid, critical, value);

  certData->addExtension(extension);
}
コード例 #7
0
/*
 * CertValidityVisitor
 */
void 
CertificateValidityVisitor::visit(DerSequence& derSeq, ndnboost::any param)
{
  // _LOG_DEBUG("CertValidityVisitor::visit");
  
  Certificate* certData = ndnboost::any_cast<Certificate*>(param); 

  const DerNodePtrList& children = derSeq.getChildren();
  
  SimpleVisitor simpleVisitor;

  MillisecondsSince1970 notBefore = ndnboost::any_cast<MillisecondsSince1970>(children[0]->accept(simpleVisitor));
  MillisecondsSince1970 notAfter = ndnboost::any_cast<MillisecondsSince1970>(children[1]->accept(simpleVisitor));

  // _LOG_DEBUG("parsed notBefore: " << notBefore);
  // _LOG_DEBUG("parsed notAfter: " << notAfter);

  certData->setNotBefore(notBefore);
  certData->setNotAfter(notAfter);
}
コード例 #8
0
/*
 * CertificateDataVisitor
 */
void 
CertificateDataVisitor::visit(DerSequence& derSeq, ndnboost::any param)
{
  // _LOG_DEBUG("CertificateDataVisitor::visit");

  const DerNodePtrList& children = derSeq.getChildren();
  CertificateValidityVisitor validityVisitor;
  children[0]->accept(validityVisitor, param);
  CertificateSubjectVisitor subjectVisitor;
  children[1]->accept(subjectVisitor, param);
  PublicKeyVisitor pubkeyVisitor;
  Certificate* certData = ndnboost::any_cast<Certificate*>(param);
  certData->setPublicKeyInfo(*ndnboost::any_cast<shared_ptr<PublicKey> >(children[2]->accept(pubkeyVisitor)));
      
  if(children.size() > 3)
    {
      CertificateExtensionVisitor extnVisitor;
      children[3]->accept(extnVisitor, param);
    }
}