File: NewCrl.cpp

package info (click to toggle)
xca 2.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,328 kB
  • sloc: cpp: 30,584; sh: 341; xml: 74; makefile: 56; python: 34
file content (85 lines) | stat: -rw-r--r-- 2,056 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* vi: set sw=4 ts=4:
 *
 * Copyright (C) 2010 - 2011 Christian Hohnstaedt.
 *
 * All rights reserved.
 */


#include "NewCrl.h"
#include "XcaDialog.h"
#include "validity.h"
#include "MainWindow.h"
#include "lib/base.h"
#include "lib/func.h"
#include <QLabel>
#include <QLineEdit>
#include <QComboBox>
#include <QCheckBox>
#include <QMessageBox>

NewCrl::NewCrl(const crljob &j, QWidget *w)
	: QWidget(w ? w : mainwin), task(j)
{
	pki_x509 *issuer = task.issuer;
	pki_key *key = issuer->getRefKey();

	setupUi(this);
	dateBox->setTitle(issuer->getIntName());
	validNumber->setText(QString::number(task.crlDays));
	validRange->setCurrentIndex(0);
	on_applyTime_clicked();
	nextUpdate->setEndDate(true);

	hashAlgo->setupHashes(key->possibleHashNids());
	hashAlgo->setCurrent(task.hashAlgo);

	crlNumber->setText(task.crlNumber.toDec());
	if (issuer->hasExtension(NID_subject_alt_name)) {
		subAltName->setEnabled(true);
		subAltName->setChecked(task.subAltName);
	} else {
		subAltName->setEnabled(false);
	}
	revocationReasons->setChecked(task.withReason);
	authKeyId->setChecked(task.authKeyId);
}

crljob NewCrl::getCrlJob() const
{
	crljob t = task;
	t.withReason = revocationReasons->isChecked();
	t.authKeyId = authKeyId->isChecked();
	t.subAltName = subAltName->isChecked();
	t.setCrlNumber = setCrlNumber->isChecked();
	t.lastUpdate = lastUpdate->getDate();
	t.nextUpdate = nextUpdate->getDate();
    t.hashAlgo = hashAlgo->current();
    t.crlNumber = crlNumber->text().toLong();
	return t;
}

void NewCrl::on_applyTime_clicked()
{
	nextUpdate->setDiff(lastUpdate, validNumber->text().toInt(),
					validRange->currentIndex());
}

NewCrl::~NewCrl()
{
	qDebug() << "NewCrl::~NewCrl() -- DELETED";
}

void NewCrl::newCrl(QWidget *parent, pki_x509 *issuer)
{
	crljob task(issuer);
	NewCrl *widget = new NewCrl(task);
	XcaDialog *dlg = new XcaDialog(parent, revocation, widget,
				tr("Create CRL"), QString(), "crlgenerate");
	if (dlg->exec()) {
		db_crl *db = Database.model<db_crl>();
		if (db)
			db->newCrl(widget->getCrlJob());
	}
	delete dlg;
}