Beispiel #1
0
/*
* Get the contents of this X.500 Name
*/
std::multimap<std::string, std::string> X509_DN::contents() const
   {
   std::multimap<std::string, std::string> retval;
   for(auto i = m_dn_info.begin(); i != m_dn_info.end(); ++i)
      multimap_insert(retval, OIDS::lookup(i->first), i->second.value());
   return retval;
   }
Beispiel #2
0
/*
* Get the attributes of this X509_DN
*/
std::multimap<OID, std::string> X509_DN::get_attributes() const
   {
   std::multimap<OID, std::string> retval;
   for(auto i = m_dn_info.begin(); i != m_dn_info.end(); ++i)
      multimap_insert(retval, i->first, i->second.value());
   return retval;
   }
Beispiel #3
0
/*
* Get the contents of this X.500 Name
*/
std::multimap<std::string, std::string> X509_DN::contents() const
   {
   typedef std::multimap<OID, ASN1_String>::const_iterator rdn_iter;

   std::multimap<std::string, std::string> retval;
   for(rdn_iter j = dn_info.begin(); j != dn_info.end(); ++j)
      multimap_insert(retval, OIDS::lookup(j->first), j->second.value());
   return retval;
   }
Beispiel #4
0
/*
* Get the attributes of this X509_DN
*/
std::multimap<OID, std::string> X509_DN::get_attributes() const
   {
   typedef std::multimap<OID, ASN1_String>::const_iterator rdn_iter;

   std::multimap<OID, std::string> retval;
   for(rdn_iter j = dn_info.begin(); j != dn_info.end(); ++j)
      multimap_insert(retval, j->first, j->second.value());
   return retval;
   }
Beispiel #5
0
/*
* Add an attribute to a X509_DN
*/
void X509_DN::add_attribute(const OID& oid, const std::string& str)
   {
   if(str.empty())
      return;

   auto range = m_dn_info.equal_range(oid);
   for(auto i = range.first; i != range.second; ++i)
      if(i->second.value() == str)
         return;

   multimap_insert(m_dn_info, oid, ASN1_String(str));
   m_dn_bits.clear();
   }
Beispiel #6
0
/*
* Add an attribute to a X509_DN
*/
void X509_DN::add_attribute(const OID& oid, const std::string& str)
   {
   if(str == "")
      return;

   typedef std::multimap<OID, ASN1_String>::iterator rdn_iter;

   std::pair<rdn_iter, rdn_iter> range = dn_info.equal_range(oid);
   for(rdn_iter j = range.first; j != range.second; ++j)
      if(j->second.value() == str)
         return;

   multimap_insert(dn_info, oid, ASN1_String(str));
   dn_bits.clear();
   }
Beispiel #7
0
void multimap_insert_range(
    multimap_t* pt_multimap, multimap_iterator_t t_begin, multimap_iterator_t t_end)
{
    multimap_iterator_t t_iterator;

    assert(pt_multimap != NULL);
    assert(
        _GET_MULTIMAP_CONTAINER_TYPE(&t_begin) == _MULTIMAP_CONTAINER &&
        _GET_MULTIMAP_ITERATOR_TYPE(&t_begin) == _BIDIRECTIONAL_ITERATOR &&
        _GET_MULTIMAP_CONTAINER_TYPE(&t_end) == _MULTIMAP_CONTAINER &&
        _GET_MULTIMAP_ITERATOR_TYPE(&t_end) == _BIDIRECTIONAL_ITERATOR);
    assert(
        _GET_MULTIMAP_CONTAINER(&t_begin) != pt_multimap &&
        _GET_MULTIMAP_CONTAINER(&t_end) != pt_multimap &&
        _GET_MULTIMAP_CONTAINER(&t_begin) == _GET_MULTIMAP_CONTAINER(&t_end));

    for(t_iterator = t_begin;
        !iterator_equal(&t_iterator, t_end);
        iterator_next(&t_iterator))
    {
        multimap_insert(
            pt_multimap, (pair_t*)iterator_get_pointer(&t_iterator));
    }
}
void _attribute_sort_items_(container **X, enum attr_sort_enum sort, char sort_reverse)
{
    if (*X == NULL) return;

    int		i, j;
    container	*N = NULL;

    /*
    printf("sort: ");
    switch (sort)
    {
	case sort_none: printf("sort_none"); break;
	case sort_hits: printf("sort_hits"); break;
	case sort_alpha: printf("sort_alpha"); break;
    }
    if (sort_reverse) printf(" (reverse)");
    printf("\n");

    for (i=0; i<vector_size(*X); i++)
	{
	    struct _attr_tree_	*item = vector_get(*X, i).ptr;
	    printf("  %.8x name:%s hits:%i\n", (int)X, item->name, item->hits);
	}
    */

    if (sort == sort_hits) N = multimap_container( int_container(), ptr_container() );
    else if (sort == sort_alpha) N = multimap_container( string_container(), ptr_container() );

    for (i=0; i<vector_size(*X); i++)
	{
	    struct _attr_tree_	*item = vector_get(*X, i).ptr;

	    if (item->children != NULL)
		_attribute_sort_items_(&(item->children), item->sort, item->sort_reverse);

	    if (sort == sort_hits) multimap_insert(N, item->hits, item);
	    else if (sort == sort_alpha)
		{
		    if (item->name!=NULL) multimap_insert(N, item->name, item);
		    else if (item->value!=NULL) multimap_insert(N, item->name, item);
		    else if (item->name!=NULL) multimap_insert(N, item->name, item);
		    else multimap_insert(N, item->name, item);
		}
	}

    if (!sort_reverse && sort != sort_hits && sort != sort_alpha) return;

    container	*Y = vector_container( ptr_container() );
    iterator	it;

    if ((sort == sort_hits && sort_reverse) || (sort == sort_alpha && !sort_reverse))
	{
	    it = multimap_begin(N);
	    for (; it.valid; it=multimap_next(it))
		vector_pushback(Y, map_val(it).ptr);
	}
    else
	{
	    if (sort != sort_hits && sort != sort_alpha)
		{
		    for (i=vector_size(*X)-1; i>=0; i--)
			vector_pushback(Y, vector_get(*X, i).ptr);
		}
	    else
		{
		    it = multimap_end(N);
		    for (; it.valid; it=multimap_previous(it))
			vector_pushback(Y, map_val(it).ptr);
		}
	}

    if (N != NULL) destroy(N);
    destroy(*X);
    *X = Y;

    /*
    for (i=0; i<vector_size(*X); i++)
	{
	    struct _attr_tree_	*item = vector_get(*X, i).ptr;
	    printf("  %.8x name:%s hits:%i\n", (int)X, item->name, item->hits);
	}
    */

    return;
}
Beispiel #9
0
/*
* Insert a single key and value
*/
void Data_Store::add(const std::string& key, const std::string& val)
   {
   multimap_insert(m_contents, key, val);
   }