management.formsΒΆ
Forms definition.
ClassesΒΆ
Security configuration model form. |
|
Form for editing BackupOptions settings. |
|
A form for selecting and updating an IPv4 address. |
|
Form for importing an TLS-Server Credential using a PKCS#12 file. |
|
Form for importing a TLS-Server Credential using separate files. |
|
Form for configuring cryptographic material storage options. |
|
Form for configuring PKCS#11 settings including HSM PIN and token information. |
Module ContentsΒΆ
- class management.forms.SecurityConfigForm(*args, **kwargs)[source]ΒΆ
Bases:
django.forms.ModelForm[management.models.SecurityConfig]Security configuration model form.
- Parameters:
args (Any)
kwargs (Any)
- FEATURE_TO_FIELDS: ClassVar[dict[type[management.security.features.SecurityFeature], list[str]]][source]ΒΆ
- class management.forms.BackupOptionsForm[source]ΒΆ
Bases:
django.forms.ModelForm[management.models.BackupOptions]Form for editing BackupOptions settings.
- class Meta[source]ΒΆ
ModelForm Meta configuration for BackupOptions.
- clean()[source]ΒΆ
Validate required fields based on selected authentication method.
- Return type:
dict[str, Any]
- _validate_sftp_fields(cleaned)[source]ΒΆ
Validate required fields for SFTP storage.
- Parameters:
cleaned (dict[str, Any])
- Return type:
None
- _validate_authentication_fields(cleaned, auth)[source]ΒΆ
Validate fields based on the selected authentication method.
- Parameters:
cleaned (dict[str, Any])
auth (Any)
- Return type:
None
- class management.forms.IPv4AddressForm(*args, **kwargs)[source]ΒΆ
Bases:
django.forms.FormA form for selecting and updating an IPv4 address.
This form provides an interface for selecting an IPv4 address from a list of Subject Alternative Names (SANs).
- Parameters:
args (Any)
kwargs (Any)
- class management.forms.TlsAddFileImportPkcs12Form(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)[source]ΒΆ
Bases:
trustpoint.logger.LoggerMixin,django.forms.FormForm for importing an TLS-Server Credential using a PKCS#12 file.
This form allows the user to upload a PKCS#12 file containing the private key and certificate chain, along with an optional password. It validates the uploaded file and its contents.
- _raise_validation_error(message)[source]ΒΆ
Raises a validation error with the given message.
- Parameters:
message (str)
- Return type:
None
- _read_pkcs12_file(cleaned_data)[source]ΒΆ
Read and extract data from PKCS#12 file.
- Returns:
Tuple of (pkcs12_raw, pkcs12_password, domain_name)
- Parameters:
cleaned_data (dict[str, Any])
- Return type:
tuple[bytes, Any, Any]
- _encode_password(pkcs12_password)[source]ΒΆ
Encode PKCS#12 password if provided.
- Returns:
Encoded password bytes or None if no password provided
- Parameters:
pkcs12_password (Any)
- Return type:
bytes | None
- _parse_and_save_credential(pkcs12_raw, pkcs12_password, domain_name)[source]ΒΆ
Parse PKCS#12 data and save credential.
- Parameters:
pkcs12_raw (bytes)
pkcs12_password (bytes | None)
domain_name (Any)
- Return type:
None
- clean()[source]ΒΆ
Cleans and validates the entire form.
This method performs additional validation on the cleaned data to ensure all required fields are valid and consistent. It checks the uploaded PKCS#12 file and its password (if provided). Any issues during validation raise appropriate errors.
- Raises:
ValidationError β If the data is invalid, such as when the unique name
is already taken or the PKCS#12 file cannot be read or parsed. β
- Return type:
None
- class management.forms.TlsAddFileImportSeparateFilesForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None)[source]ΒΆ
Bases:
trustpoint.logger.LoggerMixin,django.forms.FormForm for importing a TLS-Server Credential using separate files.
This form allows the user to upload a private key file, its password (optional), an TLS certificate file, and an optional certificate chain. The form validates the uploaded files, ensuring they are correctly formatted, within size limits, and not already associated with an existing Issuing CA.
- tls_certificate[source]ΒΆ
The Issuing CA certificate file (.cer, .der, .pem, .p7b, .p7c).
- Type:
FileField
- clean_private_key_file()[source]ΒΆ
Validates the uploaded private key file.
This method checks if the private key file is provided and ensures it meets size constraints. The actual parsing happens in clean() where the password is available.
- Returns:
The raw bytes of the private key file.
- Return type:
bytes
- Raises:
ValidationError β If the private key file is missing or too large.
- clean_tls_certificate()[source]ΒΆ
Validates and parses the uploaded TLS certificate file.
This method ensures the provided TLS certificate file is valid and not already associated with an existing TLS in the database. If the file is too large, corrupted, or already in use, a validation error is raised.
- Returns:
A serializer containing the parsed certificate.
- Return type:
- Raises:
ValidationError β If the file is missing, too large, corrupted, or already
associated with an existing TLS. β
- clean_tls_certificate_chain()[source]ΒΆ
Validates and parses the uploaded TLS certificate chain file.
- Return type:
None | trustpoint_core.serializer.CertificateCollectionSerializer
- _raise_validation_error(message)[source]ΒΆ
Raises a validation error with the given message.
- Parameters:
message (str)
- Return type:
None
- _encode_private_key_password(private_key_password)[source]ΒΆ
Encode private key password if provided.
- Parameters:
private_key_password (Any)
- Return type:
bytes | None
- _parse_private_key(private_key_bytes, private_key_password_bytes)[source]ΒΆ
Parse private key with optional password.
- Parameters:
private_key_bytes (bytes)
private_key_password_bytes (bytes | None)
- Return type:
Any
- _create_and_save_credential(private_key_serializer, tls_certificate_serializer, tls_certificate_chain_serializer, domain_name)[source]ΒΆ
Create credential from serializers, verify, and save.
- Parameters:
private_key_serializer (Any)
tls_certificate_serializer (Any)
tls_certificate_chain_serializer (Any)
domain_name (str)
- Return type:
None
- clean()[source]ΒΆ
Cleans and validates the form data.
This method performs additional validation on the provided data, such as ensuring the private key file, and certificates are valid. It also activates and saves the TLS certificate if all checks pass.
- Raises:
ValidationError β If the form data is invalid or there is an error during processing.
- Return type:
dict[str, Any] | None
- class management.forms.KeyStorageConfigForm(*args, **kwargs)[source]ΒΆ
Bases:
django.forms.ModelForm[management.models.KeyStorageConfig]Form for configuring cryptographic material storage options.
- Parameters:
args (Any)
kwargs (Any)
- class management.forms.PKCS11ConfigForm(*args, **kwargs)[source]ΒΆ
Bases:
django.forms.FormForm for configuring PKCS#11 settings including HSM PIN and token information.
- Parameters:
args (Any)
kwargs (Any)
- clean_label()[source]ΒΆ
Validate that label is unique, excluding current token if updating.
- Return type:
str