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

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: MainWindow.h,v 1.69 2003/01/06 19:35:46 chris Exp $ 
  48.  *
  49.  */                           
  50. #ifdef HAVE_CONFIG_H
  51. #include "config.h"
  52. #endif
  53. #include "lib/base.h"
  54. #include "MainWindow_UI.h"
  55. #include "KeyDetail.h"
  56. #include "ReqDetail.h"
  57. #include "CertDetail.h"
  58. #include "PassRead.h"
  59. #include "PassWrite.h"
  60. #include "NewKey.h"
  61. #include "NewX509.h"
  62. #include "NewX509_UI.h"
  63. #include "CertExtend.h"
  64. #include "TrustState.h"
  65. #include "ExportCert.h"
  66. #include "ExportKey.h"
  67. #include <iostream>
  68. #include <qtextview.h>
  69. #include <qapplication.h>
  70. #include <qdir.h>
  71. #include <qlineedit.h>
  72. #include <qpopupmenu.h>
  73. #include <qcombobox.h>
  74. #include <qradiobutton.h>
  75. #include <qlistview.h>
  76. #include <qlistbox.h>
  77. #include <qobjectlist.h>
  78. #include <qobjcoll.h>
  79. #include <qlabel.h>
  80. #include <qfiledialog.h>
  81. #include <qmessagebox.h>
  82. #include <qinputdialog.h>
  83. #include <qcheckbox.h>
  84. #include <qprogressdialog.h>
  85. #include <qpushbutton.h>
  86. #include <qasciidict.h>
  87. #include <qpixmap.h>
  88. #include <qobject.h>
  89. #include <qmultilineedit.h>
  90. #include "lib/pki_key.h"
  91. #include "lib/pki_x509req.h"
  92. #include "lib/pki_x509.h"
  93. #include "lib/pki_pkcs12.h"
  94. #include "lib/pki_pkcs7.h"
  95. #include "lib/pki_temp.h"
  96. #include "lib/db_key.h"
  97. #include "lib/db_x509req.h"
  98. #include "lib/db_x509.h"
  99. #include "lib/db_temp.h"
  100. #ifndef MAINWINDOW_H
  101. #define MAINWINDOW_H
  102. #define DBFILE "xca.db"
  103. class MainWindow: public MainWindow_UI
  104. {
  105. Q_OBJECT
  106.    protected:
  107. void addStr(string &str, const char *add);
  108.    friend class pki_key;
  109. db_x509 *certs;
  110. db_x509req *reqs;
  111. db_key *keys;
  112. db_temp *temps;
  113. DbEnv *dbenv;
  114. db_base *settings;
  115. static QPixmap *keyImg, *csrImg, *certImg, *tempImg, *nsImg, *revImg;
  116.    public:
  117. QString baseDir, dbfile;
  118. static const int sizeList[];
  119. MainWindow(QWidget *parent, const char *name);
  120. ~MainWindow(); 
  121. void loadSettings();
  122. void saveSettings();
  123. void initPass();
  124. bool showDetailsKey(pki_key *key, bool import = false);
  125. void showDetailsReq(pki_x509req *req);
  126. bool showDetailsCert(pki_x509 *cert, bool import = false);
  127. bool showDetailsTemp(pki_temp *temp);
  128. static int passRead(char *buf, int size, int rwflag, void *userdata);
  129. static int passWrite(char *buf, int size, int rwflag, void *userdata);
  130. static void incProgress(int a, int b, void *progress);
  131. static void dberr(const char *errpfx, char *msg);
  132. pki_key *getSelectedKey();
  133. void insertKey(pki_key *lkey);
  134. void insertReq(pki_x509req *req);
  135. void insertCert(pki_x509 *cert);
  136. void insertTemp(pki_temp *temp);
  137. string md5passwd();
  138. bool opensslError(pki_base *pki);
  139. QPixmap *loadImg(const char *name);
  140. void renamePKI(db_base *db);
  141. bool alterTemp(pki_temp *temp);
  142. void Error(errorEx &err);
  143. void writePKCS12(QString s, bool chain);
  144.    public slots:
  145. void loadKey();
  146. void loadReq();
  147. void loadCert();
  148. void loadPKCS12();
  149. void loadPKCS7();
  150. void newKey();
  151. void newReq(pki_temp *templ);
  152. void newCert(pki_temp *templ);
  153. void newCert(pki_x509req *req);
  154. void newCert(NewX509 *dlg);
  155. void newReq(){newReq(NULL);}
  156. void newCert();
  157. void newTemp(int type = tEMPTY);
  158. void newEmpTemp(){ newTemp(tEMPTY); }
  159. void newCATemp(){ newTemp(tCA); }
  160. void newCliTemp(){ newTemp(tCLIENT); }
  161. void newSerTemp(){ newTemp(tSERVER); }
  162. void certFromTemp();
  163. void reqFromTemp();
  164. void showDetailsKey(QListViewItem *item);
  165. void showDetailsKey();
  166. void showDetailsReq(QListViewItem *item);
  167. void showDetailsReq();
  168. void showDetailsCert();
  169. void showDetailsCert(QListViewItem *item);
  170. void deleteKey();
  171. void deleteReq();
  172. void deleteCert();
  173. void deleteTemp();
  174. void writeKey();
  175. void writeReq();
  176. void writeCert();
  177. void showPopupCert(QListViewItem *item,const QPoint &pt, int x);
  178. void showPopupKey(QListViewItem *item,const QPoint &pt, int x);
  179. void showPopupReq(QListViewItem *item,const QPoint &pt, int x);
  180. void showPopupTemp(QListViewItem *item,const QPoint &pt, int x);
  181. void startRenameCert();
  182. void startRenameKey();
  183. void startRenameReq();
  184. void startRenameTemp();
  185. void setTrust();
  186. void revoke();
  187. void unRevoke();
  188. void renameKey(QListViewItem *item, int col, const QString &text);
  189. void renameReq(QListViewItem *item, int col, const QString &text);
  190. void renameCert(QListViewItem *item, int col, const QString &text);
  191. void renameTemp(QListViewItem *item, int col, const QString &text);
  192. void alterTemp();
  193. void setSerial();
  194. void setCrlDays();
  195. void setTemplate();
  196. void genCrl();
  197. void signReq();
  198. void crashApp();
  199. void toRequest();
  200. void setPath(QFileDialog *dlg);
  201. void newPath(QFileDialog *dlg);
  202. void extendCert();
  203. void signP7();
  204. void encryptP7();
  205.    signals:
  206. void keyDone(QString name);
  207. };
  208. #endif