db_key.cpp
上传用户:stc1860
上传日期:2007-01-12
资源大小:234k
文件大小:4k
源码类别:

CA认证

开发平台:

MultiPlatform

  1. /*
  2.  * Copyright (C) 2001 Christian Hohnstaedt.
  3.  *
  4.  *  All rights reserved.
  5.  *
  6.  *
  7.  *  Redistribution and use in source and binary forms, with or without 
  8.  *  modification, are permitted provided that the following conditions are met:
  9.  *
  10.  *  - Redistributions of source code must retain the above copyright notice,
  11.  *    this list of conditions and the following disclaimer.
  12.  *  - Redistributions in binary form must reproduce the above copyright notice,
  13.  *    this list of conditions and the following disclaimer in the documentation
  14.  *    and/or other materials provided with the distribution.
  15.  *  - Neither the name of the author nor the names of its contributors may be 
  16.  *    used to endorse or promote products derived from this software without
  17.  *    specific prior written permission.
  18.  *
  19.  *
  20.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  22.  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23.  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  24.  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25.  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26.  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  27.  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  28.  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  29.  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  30.  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31.  *
  32.  *
  33.  * This program links to software with different licenses from:
  34.  *
  35.  * http://www.openssl.org which includes cryptographic software
  36.  *  written by Eric Young (eay@cryptsoft.com)"
  37.  *
  38.  * http://www.sleepycat.com
  39.  *
  40.  * http://www.trolltech.com
  41.  * 
  42.  *
  43.  *
  44.  * http://www.hohnstaedt.de/xca
  45.  * email: christian@hohnstaedt.de
  46.  *
  47.  * $Id: db_key.cpp,v 1.25 2003/01/06 19:35:50 chris Exp $
  48.  *
  49.  */                           
  50. #include "db_key.h"
  51. db_key::db_key(DbEnv *dbe, string DBfile, QListView *l)
  52. :db_base(dbe, DBfile, "keydb")
  53. {
  54. listView = l;
  55. loadContainer();
  56. keyicon[0] = loadImg("key.png");
  57. keyicon[1] = loadImg("halfkey.png");
  58. listView->addColumn(tr("Keysize"));
  59. listView->addColumn(tr("Use count"));
  60. updateView();
  61. }
  62. pki_base *db_key::newPKI(){
  63. return new pki_key("");
  64. }
  65. QStringList db_key::getPrivateDesc()
  66. {
  67. pki_key *pki;
  68. QStringList x;
  69. x.clear();
  70. for ( pki = (pki_key *)container.first(); pki != 0; pki = (pki_key *)container.next() ) {
  71. if (pki->isPrivKey()) {
  72. x.append(pki->getDescription().c_str());
  73. }
  74. }
  75. return x;
  76. }
  77. QStringList db_key::get0PrivateDesc()
  78. {
  79. pki_key *pki;
  80. QStringList x;
  81. x.clear();
  82. for ( pki = (pki_key *)container.first(); pki != 0; pki = (pki_key *)container.next() ) {
  83. if (pki->isPrivKey() && pki->getUcount() == 0) {
  84. x.append(pki->getDescription().c_str());
  85. }
  86. }
  87. return x;
  88. }
  89. void db_key::remFromCont(pki_base *pki)
  90. {
  91. db_base::remFromCont(pki);
  92. emit delKey((pki_key *)pki);
  93. }
  94. void db_key::inToCont(pki_base *pki) 
  95. {
  96. db_base::inToCont(pki);
  97. emit newKey((pki_key *)pki);
  98. }
  99. void db_key::updateViewPKI(pki_base *pki)
  100. {
  101. CERR("updateViewPKI()");
  102.         if (! pki) return;
  103.         db_base::updateViewPKI(pki);
  104.         int pixnum = 0;
  105.         QListViewItem *current = (QListViewItem *)pki->getPointer();
  106.         if (!current) return;
  107. if (((pki_key *)pki)->isPubKey()) pixnum += 1;
  108. current->setPixmap(0, *keyicon[pixnum]);
  109. current->setText(1, ((pki_key *)pki)->length().c_str());
  110. current->setText(2, QString::number(((pki_key *)pki)->getUcount()));
  111. }