signer.formsΒΆ

Contains Logic for Form on Add/Edit Signer Page.

ClassesΒΆ

SignerAddMethodSelectForm

Form for selecting the method to add a Signer.

SignerAddFileTypeSelectForm

Form for selecting the file type when importing a Signer.

SignerAddFileImportPkcs12Form

Form for importing an Signer using a PKCS#12 file.

SignerAddFileImportSeparateFilesForm

Form for importing a Signer using separate files.

SignHashForm

Form for signing a hash value with a selected signer.

FunctionsΒΆ

get_private_key_location_from_config()

Determine the appropriate PrivateKeyLocation based on KeyStorageConfig.

Module ContentsΒΆ

signer.forms.get_private_key_location_from_config()[source]ΒΆ

Determine the appropriate PrivateKeyLocation based on KeyStorageConfig.

Return type:

trustpoint_core.serializer.PrivateKeyLocation

class signer.forms.SignerAddMethodSelectForm(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: django.forms.Form

Form for selecting the method to add a Signer.

method_select[source]ΒΆ
class signer.forms.SignerAddFileTypeSelectForm(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: django.forms.Form

Form for selecting the file type when importing a Signer.

method_select[source]ΒΆ
class signer.forms.SignerAddFileImportPkcs12Form(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.Form

Form for importing an Signer using a PKCS#12 file.

unique_name[source]ΒΆ
pkcs12_file[source]ΒΆ
pkcs12_password[source]ΒΆ
clean_unique_name()[source]ΒΆ

Validates the unique name to ensure it is not already in use.

Return type:

str

_raise_validation_error(message)[source]ΒΆ

Helper method to raise a ValidationError with a given message.

Parameters:

message (str)

Return type:

NoReturn

clean()[source]ΒΆ

Cleans and validates the entire form.

Return type:

None

_validate_pkcs12_file(cleaned_data)[source]ΒΆ

Validates and reads the PKCS#12 file.

Parameters:

cleaned_data (dict[str, Any])

Return type:

tuple[bytes, bytes | None]

_process_pkcs12_file(pkcs12_raw, pkcs12_password, unique_name)[source]ΒΆ

Processes the PKCS#12 file and returns a credential serializer.

Parameters:
  • pkcs12_raw (bytes)

  • pkcs12_password (bytes | None)

  • unique_name (str | None)

Return type:

trustpoint_core.serializer.CredentialSerializer

_validate_certificate(cert_crypto)[source]ΒΆ

Validates the certificate for required extensions.

Parameters:

cert_crypto (cryptography.x509.Certificate)

Return type:

None

_save_signer(cleaned_data, credential_serializer)[source]ΒΆ

Saves the signer to the database.

Parameters:
  • cleaned_data (dict[str, Any])

  • credential_serializer (trustpoint_core.serializer.CredentialSerializer)

Return type:

None

class signer.forms.SignerAddFileImportSeparateFilesForm(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.Form

Form for importing a Signer using separate files.

unique_name[source]ΒΆ
signer_certificate[source]ΒΆ
signer_certificate_chain[source]ΒΆ
private_key_file[source]ΒΆ
private_key_file_password[source]ΒΆ
clean_private_key_file()[source]ΒΆ

Validates and parses the uploaded private key file.

Return type:

trustpoint_core.serializer.PrivateKeySerializer

clean_signer_certificate()[source]ΒΆ

Validates and parses the uploaded signer certificate file.

Return type:

trustpoint_core.serializer.CertificateSerializer

clean_signer_certificate_chain()[source]ΒΆ

Validates and parses the uploaded signer certificate chain file.

Return type:

None | trustpoint_core.serializer.CertificateCollectionSerializer

_raise_validation_error(message)[source]ΒΆ

Helper method to raise a ValidationError with a given message.

Parameters:

message (str)

Return type:

None

clean()[source]ΒΆ

Cleans and validates the form data.

Return type:

None

_validate_required_fields(cleaned_data)[source]ΒΆ

Validates required fields.

Parameters:

cleaned_data (dict[str, Any])

Return type:

None

_create_credential_serializer(cleaned_data)[source]ΒΆ

Creates a credential serializer from the cleaned data.

Parameters:

cleaned_data (dict[str, Any])

Return type:

trustpoint_core.serializer.CredentialSerializer

_validate_credential_serializer(credential_serializer)[source]ΒΆ

Validates the credential serializer.

Parameters:

credential_serializer (trustpoint_core.serializer.CredentialSerializer)

Return type:

None

_save_signer(cleaned_data, credential_serializer)[source]ΒΆ

Saves the signer to the database.

Parameters:
  • cleaned_data (dict[str, Any])

  • credential_serializer (trustpoint_core.serializer.CredentialSerializer)

Return type:

None

class signer.forms.SignHashForm(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.Form

Form for signing a hash value with a selected signer.

signer[source]ΒΆ
hash_value[source]ΒΆ
clean()[source]ΒΆ

Validate the hash value format based on the selected signer’s hash algorithm.

Return type:

dict[str, Any]