Class: Vcert::Policy
- Inherits:
-
Object
- Object
- Vcert::Policy
- Defined in:
- lib/objects/objects.rb
Instance Attribute Summary collapse
-
#creation_date ⇒ Object
readonly
Returns the value of attribute creation_date.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#policy_id ⇒ Object
readonly
Returns the value of attribute policy_id.
-
#system_generated ⇒ Object
readonly
Returns the value of attribute system_generated.
Instance Method Summary collapse
- #check_request(request) ⇒ Object
-
#initialize(policy_id:, name:, system_generated:, creation_date:, subject_cn_regexes:, subject_o_regexes:, subject_ou_regexes:, subject_st_regexes:, subject_l_regexes:, subject_c_regexes:, san_regexes:, key_types:) ⇒ Policy
constructor
A new instance of Policy.
- #simple_check_request(request) ⇒ Object
Constructor Details
#initialize(policy_id:, name:, system_generated:, creation_date:, subject_cn_regexes:, subject_o_regexes:, subject_ou_regexes:, subject_st_regexes:, subject_l_regexes:, subject_c_regexes:, san_regexes:, key_types:) ⇒ Policy
Returns a new instance of Policy.
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/objects/objects.rb', line 168 def initialize(policy_id:, name:, system_generated:, creation_date:, subject_cn_regexes:, subject_o_regexes:, subject_ou_regexes:, subject_st_regexes:, subject_l_regexes:, subject_c_regexes:, san_regexes:, key_types:) @policy_id = policy_id @name = name @system_generated = system_generated @creation_date = creation_date @subject_cn_regexes = subject_cn_regexes @subject_c_regexes = subject_c_regexes @subject_st_regexes = subject_st_regexes @subject_l_regexes = subject_l_regexes @subject_o_regexes = subject_o_regexes @subject_ou_regexes = subject_ou_regexes @san_regexes = san_regexes @key_types = key_types end |
Instance Attribute Details
#creation_date ⇒ Object (readonly)
Returns the value of attribute creation_date.
166 167 168 |
# File 'lib/objects/objects.rb', line 166 def creation_date @creation_date end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
166 167 168 |
# File 'lib/objects/objects.rb', line 166 def name @name end |
#policy_id ⇒ Object (readonly)
Returns the value of attribute policy_id.
166 167 168 |
# File 'lib/objects/objects.rb', line 166 def policy_id @policy_id end |
#system_generated ⇒ Object (readonly)
Returns the value of attribute system_generated.
166 167 168 |
# File 'lib/objects/objects.rb', line 166 def system_generated @system_generated end |
Instance Method Details
#check_request(request) ⇒ Object
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/objects/objects.rb', line 207 def check_request(request) simple_check_request(request) if request.csr? csr = parse_csr_fields(request.csr) unless component_is_valid?(csr[:C], @subject_c_regexes) raise ValidationError, "Country #{csr[:C]} doesnt match #{@subject_c_regexes}" end unless component_is_valid?(csr[:ST], @subject_st_regexes) raise ValidationError, "Province #{csr[:ST]} doesnt match #{@subject_st_regexes}" end unless component_is_valid?(csr[:L], @subject_l_regexes) raise ValidationError, "Locality #{csr[:L]} doesnt match #{@subject_l_regexes}" end unless component_is_valid?(csr[:O], @subject_o_regexes) raise ValidationError, "Organization #{csr[:O]} doesnt match #{@subject_o_regexes}" end unless component_is_valid?(csr[:OU], @subject_ou_regexes) raise ValidationError, "Organizational unit #{csr[:OU]} doesnt match #{@subject_ou_regexes}" end #todo: add uri, upn, ip, email unless is_key_type_is_valid?(csr[:key_type], @key_types) raise ValidationError, "Key Type #{csr[:key_type]} doesnt match allowed #{@key_types}" end else # subject unless component_is_valid?(request.country, @subject_c_regexes) raise ValidationError, "Country #{request.country} doesnt match #{@subject_c_regexes}" end unless component_is_valid?(request.province, @subject_st_regexes) raise ValidationError, "Province #{request.province} doesnt match #{@subject_st_regexes}" end unless component_is_valid?(request.locality, @subject_l_regexes) raise ValidationError, "Locality #{request.locality} doesnt match #{@subject_l_regexes}" end unless component_is_valid?(request.organization, @subject_o_regexes) raise ValidationError, "Organization #{request.organization} doesnt match #{@subject_o_regexes}" end unless component_is_valid?(request.organizational_unit, @subject_ou_regexes) raise ValidationError, "Organizational unit #{request.organizational_unit} doesnt match #{@subject_ou_regexes}" end #todo: add uri, upn, ip, email unless is_key_type_is_valid?(request.key_type, @key_types) raise ValidationError, "Key Type #{request.key_type} doesnt match allowed #{@key_types}" end end # todo: (!important!) parse csr if it alredy generated (!important!) end |
#simple_check_request(request) ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/objects/objects.rb', line 187 def simple_check_request(request) if request.csr? csr = parse_csr_fields(request.csr) unless component_is_valid?(csr[:CN], @subject_cn_regexes) raise ValidationError, "Common name #{csr[:CN]} doesnt match #{@subject_cn_regexes}" end unless component_is_valid?(request.san_dns, @san_regexes, optional: true) raise ValidationError, "SANs #{csr[:DNS]} doesnt match #{ @san_regexes }" end else unless component_is_valid?(request.common_name, @subject_cn_regexes) raise ValidationError, "Common name #{request.common_name} doesnt match #{@subject_cn_regexes}" end unless component_is_valid?(request.san_dns, @san_regexes, optional: true) raise ValidationError, "SANs #{request.san_dns} doesnt match #{ @san_regexes }" end end end |