~ubuntu-branches/ubuntu/oneiric/xca/oneiric

« back to all changes in this revision

Viewing changes to lib/load_obj.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Tino Keitel
  • Date: 2009-09-14 20:55:44 UTC
  • Revision ID: james.westby@ubuntu.com-20090914205544-l4qsm2tjimhd62vo
Tags: upstream-0.7.0
ImportĀ upstreamĀ versionĀ 0.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vi: set sw=4 ts=4:
 
2
 *
 
3
 * Copyright (C) 2001 - 2007 Christian Hohnstaedt.
 
4
 *
 
5
 * All rights reserved.
 
6
 */
 
7
 
 
8
#include "load_obj.h"
 
9
#include "pki_x509.h"
 
10
#include "pki_key.h"
 
11
#include "pki_x509req.h"
 
12
#include "pki_pkcs7.h"
 
13
#include "pki_pkcs12.h"
 
14
#include "pki_multi.h"
 
15
#include "widgets/MainWindow.h"
 
16
 
 
17
load_base::load_base()
 
18
{
 
19
        filter = QObject::tr("All files ( * )");
 
20
        caption = "";
 
21
}
 
22
 
 
23
pki_base *load_base::loadItem(QString s)
 
24
{
 
25
        pki_base *pki = newItem();
 
26
        if (!pki)
 
27
                return NULL;
 
28
        try {
 
29
                pki->fload(s);
 
30
        }
 
31
        catch (errorEx &err){
 
32
                delete pki;
 
33
                throw err;
 
34
        }
 
35
        return pki;
 
36
}
 
37
 
 
38
pki_base * load_base::newItem()
 
39
{
 
40
        return NULL;
 
41
}
 
42
 
 
43
load_base::~load_base()
 
44
{
 
45
}
 
46
 
 
47
/* Keys */
 
48
load_key::load_key()
 
49
        :load_base()
 
50
{
 
51
        filter = QObject::tr("PKI Keys ( *.pem *.der *.key );;"
 
52
                        "PKCS#8 Keys ( *.p8 *.pk8 );;") + filter;
 
53
        caption = QObject::tr("Import RSA key");
 
54
}
 
55
 
 
56
pki_base * load_key::newItem()
 
57
{
 
58
        return new pki_key();
 
59
}
 
60
 
 
61
/* Requests */
 
62
load_req::load_req()
 
63
        :load_base()
 
64
{
 
65
        filter = QObject::tr("PKCS#10 CSR ( *.pem *.der *.csr );;"
 
66
                        "Netscape Request ( *.spkac *.spc );;") + filter;
 
67
        caption = QObject::tr("Import Request");
 
68
}
 
69
 
 
70
pki_base * load_req::newItem()
 
71
{
 
72
        return new pki_x509req();
 
73
}
 
74
 
 
75
/* Certificates */
 
76
load_cert::load_cert()
 
77
        :load_base()
 
78
{
 
79
        filter = QObject::tr("Certificates ( *.pem *.der *.crt *.cer );;") + filter;
 
80
        caption = QObject::tr("Import X.509 Certificate");
 
81
}
 
82
 
 
83
pki_base * load_cert::newItem()
 
84
{
 
85
        return new pki_x509();
 
86
}
 
87
 
 
88
/* PKCS#7 Certificates */
 
89
load_pkcs7::load_pkcs7()
 
90
        :load_base()
 
91
{
 
92
        filter = QObject::tr("PKCS#7 data ( *.p7s *.p7m *.p7b );;") + filter;
 
93
        caption = QObject::tr("Import PKCS#7 Certificates");
 
94
}
 
95
 
 
96
pki_base * load_pkcs7::newItem()
 
97
{
 
98
        return new pki_pkcs7();
 
99
}
 
100
 
 
101
/* PKCS#12 Certificates */
 
102
load_pkcs12::load_pkcs12()
 
103
        :load_base()
 
104
{
 
105
        filter = QObject::tr("PKCS#12 Certificates ( *.p12 *.pfx );;") + filter;
 
106
        caption = QObject::tr("Import PKCS#12 Private Certificate");
 
107
}
 
108
 
 
109
pki_base * load_pkcs12::loadItem(QString s)
 
110
{
 
111
        pki_base *p12 = new pki_pkcs12(s, MainWindow::passRead);
 
112
        return p12;
 
113
}
 
114
 
 
115
/* Templates */
 
116
load_temp::load_temp()
 
117
        :load_base()
 
118
{
 
119
        filter = QObject::tr("XCA templates ( *.xca );;") + filter;
 
120
        caption = QObject::tr("Import XCA Templates");
 
121
}
 
122
 
 
123
pki_base * load_temp::newItem()
 
124
{
 
125
        return new pki_temp();
 
126
}
 
127
 
 
128
/* CRLs */
 
129
load_crl::load_crl()
 
130
        :load_base()
 
131
{
 
132
        filter = QObject::tr("Revocation lists ( *.pem *.der *.crl );;") + filter;
 
133
        caption = QObject::tr("Import Certificate Revocation List");
 
134
}
 
135
 
 
136
pki_base * load_crl::newItem()
 
137
{
 
138
        return new pki_crl();
 
139
}
 
140
 
 
141
/* Database */
 
142
load_db::load_db()
 
143
        :load_base()
 
144
{
 
145
        filter = QObject::tr("XCA Databases ( *.xdb );;") + filter;
 
146
        caption = QObject::tr("Open XCA Database");
 
147
}
 
148
 
 
149
/* General PEM loader */
 
150
load_pem::load_pem()
 
151
        :load_base()
 
152
{
 
153
        filter = QObject::tr("PEM files ( *.pem );;") + filter;
 
154
        caption = QObject::tr("Load PEM encoded file");
 
155
}
 
156
 
 
157
pki_base *load_pem::newItem()
 
158
{
 
159
        return new pki_multi();
 
160
}