API

AIS client

class AIS.AIS(customer: str, key_static: str, cert_file: str, cert_key: str)[source]

Client object holding connection information to the AIS service.

last_request_id: Optional[str]

Contains the id of the last request made to the AIS API.

post(payload: str) Dict[str, Any][source]

Do the post request for this payload and return the signature part of the json response.

sign_batch(pdfs: Sequence[PDF]) None[source]

Sign a batch of files.

sign_one_pdf(pdf: PDF) None[source]

Sign the given pdf file.

PDF file

class AIS.PDF(input_file: FileLike, *, out_stream: Optional[BinaryIO] = ..., sig_name: str = ..., sig_size: int = ...)[source]
class AIS.PDF(*, inout_stream: BinaryIO, sig_name: str = ..., sig_size: int = ...)

A container for a PDF file to be signed and the signed version.

cms_writer

CMS Writer used for embedding the signature

digest() str[source]

Computes the PDF digest.

property out_stream: BinaryIO

Output stream for the signed PDF.

sig_io_setup

Signing I/O setup to be passed to pyHanko

sig_size

Number of bytes reserved for the signature. It is the caller’s responsibility to ensure that this is large enough to store the entire signature.

Currently 64KiB (the default) appear to be enough. But the signature has been known to grow in size over the years.

write_signature(signature: bytes) None[source]

Writes the signature into the pdf file.

digest needs to be called first.

Raises

SignatureTooLarge: If sig_size is

too small to store the entire signature.

Exceptions

exception AIS.AISError[source]

Generic AIS Error.

exception AIS.AuthenticationFailed[source]

Authentication with AIS failed.

This means that AIS returned http://ais.swisscom.ch/1.0/resultminor/AuthenticationFailed

exception AIS.UnknownAISError[source]

Unknown AIS Error.

exception AIS.AISError[source]

Generic AIS Error.

exception AIS.SignatureTooLarge(signature_size: int)[source]

The signature received from AIS is too large to store.

This means the PDF needs to be created with a larger value for sig_size to store the signature.