pki.forms.cert_profilesΒΆ
Django forms for certificate profile configuration.
Module ContentsΒΆ
- pki.forms.cert_profiles.check_validity_days_against_security_config(total_days)[source]ΒΆ
Raise
ValidationErrorif total_days exceeds the policy limit.- Parameters:
total_days (float)
- Return type:
None
- class pki.forms.cert_profiles.CertProfileConfigForm[source]ΒΆ
Bases:
trustpoint.logger.LoggerMixin,django.forms.ModelForm[pki.models.cert_profile.CertificateProfileModel]Form for creating or updating Certificate Profiles.
This form is based on the CertificateProfileModel and allows users to create or update certificate profiles by specifying a unique name and profile JSON configuration.
- unique_nameΒΆ
A unique name for the certificate profile.
- Type:
CharField
- profile_jsonΒΆ
The JSON configuration for the certificate profile.
- Type:
JSONField
- clean_unique_name()[source]ΒΆ
Validates the unique name to ensure it is not already in use.
- Raises:
ValidationError β If the unique name is already associated with an existing certificate profile.
- Return type:
str
- clean_profile_json()[source]ΒΆ
Validates the profile JSON to ensure it is a valid certificate profile.
- Raises:
ValidationError β If the profile JSON is not a valid certificate profile, or if the configured validity exceeds the security policy limit.
- Return type:
str
- class pki.forms.cert_profiles.ProfileBasedFormFieldBuilder(profile)[source]ΒΆ
Bases:
trustpoint.logger.LoggerMixinDjango form field builder that leverages JSONProfileVerifier.
This builder uses JSONProfileVerifier.get_sample_request() to understand the profile structure, eliminating the need for manual profile parsing logic.
- Parameters:
profile (dict[str, Any])
- class pki.forms.cert_profiles.CertificateIssuanceForm(profile, *args, **kwargs)[source]ΒΆ
Bases:
trustpoint.logger.LoggerMixin,django.forms.FormForm for certificate issuance based on a certificate profile.
This form dynamically generates fields based on a certificate profile and leverages existing infrastructure for profile interpretation and certificate building:
Uses JSONProfileVerifier.get_sample_request() to understand what fields to show
Validates user input with JSONProfileVerifier.apply_profile_to_request()
Delegates certificate building to JSONCertRequestConverter.from_json()
This eliminates code duplication and ensures consistent profile interpretation across the application (55% code reduction from original implementation).
- Parameters:
profile (dict[str, Any])
args (Any)
kwargs (Any)
- get_certificate_builder()[source]ΒΆ
Build a CertificateBuilder from the form data.
This method converts the form data to JSON format and delegates to JSONCertRequestConverter.from_json() to create the CertificateBuilder.
- Returns:
CertificateBuilder ready for signing
- Return type:
cryptography.x509.base.CertificateBuilder