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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#!/usr/bin/pkiperl
#
# --- BEGIN COPYRIGHT BLOCK ---
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
# --- END COPYRIGHT BLOCK ---
#
#
#
#
use strict;
use warnings;
use PKI::RA::GlobalVar;
use PKI::RA::Common;
package PKI::RA::CertInfo;
$PKI::RA::CertInfo::VERSION = '1.00';
sub new {
my ($class, $name, $dn, $tag) = @_;
my $self = {};
&PKI::RA::Wizard::debug_log("CertInfo: start new");
$self->{"getUserFriendlyName"} = \&get_user_friendly_name;
$self->{"getCertTag"} = \&get_cert_tag;
$self->{"getDN"} = \&get_dn;
$self->{"getNickname"} = \&get_nickname;
$self->{"useDefaultKey"} = \&use_default_key;
$self->{"getCustomKeysize"} = \&get_custom_keysize;
$self->{"keyOption"} = \&get_key_option;
&PKI::RA::Wizard::debug_log("CertInfo: end new");
$self->{name} = $name;
$self->{dn} = $dn;
$self->{tag} = $tag;
bless $self, $class;
return $self;
}
sub get_user_friendly_name
{
my ($self) = @_;
&PKI::RA::Wizard::debug_log("CertInfo: get_user_friendly_name");
return $self->{name};
}
sub get_cert_tag
{
my ($self) = @_;
&PKI::RA::Wizard::debug_log("CertInfo: get_cert_tag");
return $self->{tag};
}
sub get_dn
{
my ($self) = @_;
&PKI::RA::Wizard::debug_log("CertInfo: get_cert_dn");
return $self->{dn};
}
sub use_default_key
{
my ($self) = @_;
&PKI::RA::Wizard::debug_log("CertInfo: use_default_key");
my $option = $::config->get("preop.cert.$self->{tag}.keysize.select");
if (($option ne "") && ($option ne "default")) {
return 0;
}
return 1;
}
sub get_nickname
{
my ($self) = @_;
&PKI::RA::Wizard::debug_log("CertInfo: get_nickname");
my $nickname = $::config->get("preop.cert.$self->{tag}.nickname");
my $flavor = `pkiflavor`;
$flavor =~ s/\n//g;
if ($nickname ne "") {
return $nickname;
} else {
return $self->{tag}."cert cert-$flavor-tps";
}
}
sub get_key_option
{
my ($self) = @_;
&PKI::RA::Wizard::debug_log("CertInfo: get_key_option");
my $option = $::config->get("preop.cert.$self->{tag}.keysize.select");
if ($option ne "") {
&PKI::RA::Wizard::debug_log("CertInfo: get_key_option from config = $option");
return $option;
} else {
&PKI::RA::Wizard::debug_log("CertInfo: get_key_option not from config");
return "default";
}
}
sub get_custom_keysize
{
my ($self) = @_;
&PKI::RA::Wizard::debug_log("CertInfo: get_custom_keysize");
my $size = $::config->get("preop.cert.$self->{tag}.keysize.customsize");
&PKI::RA::Wizard::debug_log("CertInfo: get_custom_keysize for preop.cert.$self->{tag}.keysize.customsize is $size");
if ($size ne "") {
&PKI::RA::Wizard::debug_log("CertInfo: get_custom_keysize from config is $size");
return $size;
} else {
&PKI::RA::Wizard::debug_log("CertInfo: get_custom_keysize not from config");
return 2048;
}
}
1;
|