# Path: esteid/types.py
# class ResponderCertificate(Certificate):
#     pass
# 
# class SignedDocInfo(FromDictMixin):
#     format = attr.ib(default="BDOC")
#     version = attr.ib(default="2.1")
#     mime_type = attr.ib(default=pyasice.Container.MIME_TYPE)
# 
#     data_file_info: List[DataFileInfo] = attr.ib(
#         default=attr.Factory(list),
#         validator=[
#             attr.validators.instance_of(list),
#             get_typed_list_validator(DataFileInfo),
#         ],
#         converter=get_typed_list_converter(DataFileInfo),
#     )
# 
#     signature_info: List[SignatureInfo] = attr.ib(
#         default=attr.Factory(list),
#         validator=[
#             attr.validators.instance_of(list),
#             get_typed_list_validator(SignatureInfo),
#         ],
#         converter=get_typed_list_converter(SignatureInfo),
#     )
# 
# class Signer(FromDictMixin):
#     id_code = attr.ib()
# 
#     # Note: This should also support common_name argument coming in
#     full_name = attr.ib()
# 
#     certificate: Certificate = attr.ib(
#         validator=attr.validators.instance_of(Certificate), converter=get_instance_converter(Certificate)
#     )
# 
#     @staticmethod
#     def prepare_kwargs(kwargs):
#         kwargs = camel_2_py(kwargs)
#         full_name = kwargs.get("full_name", None)
# 
#         # If the full_name is None, check common_name field and use that
#         if full_name is None:
#             full_name = get_name_from_legacy_common_name(kwargs.pop("common_name", None))
# 
#         kwargs["full_name"] = full_name
# 
#         return kwargs
# 
#     @classmethod
#     def from_certificate(cls, cert: "Union[bytes, Asn1CryptoCertificate, OsCryptoCertificate]"):
#         """
#         Get personal info from an oscrypto/asn1crypto Certificate object
# 
#         For a closer look at where the attributes come from:
#         asn1crypto.x509.NameType
#         """
#         cert_holder_info = CertificateHolderInfo.from_certificate(cert)
#         return cls(
#             certificate=Certificate.from_certificate(cert_holder_info.asn1_certificate),
#             full_name=f"{cert_holder_info.given_name} {cert_holder_info.surname}",
#             id_code=cert_holder_info.id_code,
#         )


import base64
import hashlib
import attr
from pyasice import Container, XmlSignature
from esteid.types import ResponderCertificate, SignedDocInfo, Signer
            # if ever needed
            "produced_at": signing_time,
            "responder_id": "OCSP",
            "responder_certificate": ResponderCertificate.from_certificate(ocsp_cert),
        },
        "signer_role": [{"certified": 0, "role": None}],
    }


def container_info(bdoc_container: Container, full=True):
    if full:
        data_files_info = [
            {
                "digest_type": "sha256",
                "digest_value": base64.b64encode(hashlib.sha256(content).digest()).decode(),
                "filename": name,
                "id": name,
                "mime_type": mimetype,
                "content_type": mimetype,
                "size": len(content),
            }
            for name, content, mimetype in bdoc_container.iter_data_files()
        ]
    else:
        data_files_info = [
            {
                "filename": name,
            }
            for name in bdoc_container.data_file_names
        ]

# Path: esteid/types.py
# class ResponderCertificate(Certificate):
#     pass
# 
# class SignedDocInfo(FromDictMixin):
#     format = attr.ib(default="BDOC")
#     version = attr.ib(default="2.1")
#     mime_type = attr.ib(default=pyasice.Container.MIME_TYPE)
# 
#     data_file_info: List[DataFileInfo] = attr.ib(
#         default=attr.Factory(list),
#         validator=[
#             attr.validators.instance_of(list),
#             get_typed_list_validator(DataFileInfo),
#         ],
#         converter=get_typed_list_converter(DataFileInfo),
#     )
# 
#     signature_info: List[SignatureInfo] = attr.ib(
#         default=attr.Factory(list),
#         validator=[
#             attr.validators.instance_of(list),
#             get_typed_list_validator(SignatureInfo),
#         ],
#         converter=get_typed_list_converter(SignatureInfo),
#     )
# 
# class Signer(FromDictMixin):
#     id_code = attr.ib()
# 
#     # Note: This should also support common_name argument coming in
#     full_name = attr.ib()
# 
#     certificate: Certificate = attr.ib(
#         validator=attr.validators.instance_of(Certificate), converter=get_instance_converter(Certificate)
#     )
# 
#     @staticmethod
#     def prepare_kwargs(kwargs):
#         kwargs = camel_2_py(kwargs)
#         full_name = kwargs.get("full_name", None)
# 
#         # If the full_name is None, check common_name field and use that
#         if full_name is None:
#             full_name = get_name_from_legacy_common_name(kwargs.pop("common_name", None))
# 
#         kwargs["full_name"] = full_name
# 
#         return kwargs
# 
#     @classmethod
#     def from_certificate(cls, cert: "Union[bytes, Asn1CryptoCertificate, OsCryptoCertificate]"):
#         """
#         Get personal info from an oscrypto/asn1crypto Certificate object
# 
#         For a closer look at where the attributes come from:
#         asn1crypto.x509.NameType
#         """
#         cert_holder_info = CertificateHolderInfo.from_certificate(cert)
#         return cls(
#             certificate=Certificate.from_certificate(cert_holder_info.asn1_certificate),
#             full_name=f"{cert_holder_info.given_name} {cert_holder_info.surname}",
#             id_code=cert_holder_info.id_code,
#         )


# Path: esteid/compat.py
import base64
import hashlib
import attr
from pyasice import Container, XmlSignature
from esteid.types import ResponderCertificate, SignedDocInfo, Signer

            # if ever needed
            "produced_at": signing_time,
            "responder_id": "OCSP",
            "responder_certificate": ResponderCertificate.from_certificate(ocsp_cert),
        },
        "signer_role": [{"certified": 0, "role": None}],
    }


def container_info(bdoc_container: Container, full=True):
    if full:
        data_files_info = [
            {
                "digest_type": "sha256",
                "digest_value": base64.b64encode(hashlib.sha256(content).digest()).decode(),
                "filename": name,
                "id": name,
                "mime_type": mimetype,
                "content_type": mimetype,
                "size": len(content),
            }
            for name, content, mimetype in bdoc_container.iter_data_files()
        ]
    else:
        data_files_info = [
            {
                "filename": name,
            }
            for name in bdoc_container.data_file_names
        ]

    return SignedDocInfo.from_dict(