How to use the fints.formals.SegmentSequence function in fints

To help you get started, we’ve selected a few fints examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github raphaelm / python-fints / tests / test_message_serializer.py View on Github external
def test_serialize_2():
    from fints.formals import SegmentSequence
    import fints.segments
    s = SegmentSequence([fints.segments.message.HNHBK3(header=fints.formals.SegmentHeader('HNHBK', 1, 3), message_size='000000000428', hbci_version=300,
                                                       dialog_id='430711670077=043999659571CN9D=', message_number=2,
                                                       reference_message=fints.formals.ReferenceMessage(dialog_id='430711670077=043999659571CN9D=',
                                                                                                        message_number=2)),
                         fints.segments.message.HNVSK3(header=fints.formals.SegmentHeader('HNVSK', 998, 3),
                                                       security_profile=fints.formals.SecurityProfile(security_method='PIN', security_method_version=1),
                                                       security_function='998', security_role='1',
                                                       security_identification_details=fints.formals.SecurityIdentificationDetails(identified_role='2',
                                                                                                                                   cid=None,
                                                                                                                                   identifier='oIm3BlHv6mQBAADYgbPpp+kWrAQA'),
                                                       security_datetime=fints.formals.SecurityDateTime(date_time_type='1'),
                                                       encryption_algorithm=fints.formals.EncryptionAlgorithm(usage_encryption='2', operation_mode='2',
                                                                                                              encryption_algorithm='13',
                                                                                                              algorithm_parameter_value=b'00000000',
                                                                                                              algorithm_parameter_name='5',
                                                                                                              algorithm_parameter_iv_name='1'),
                                                       key_name=fints.formals.KeyName(
github raphaelm / python-fints / tests / test_models.py View on Github external
def test_nested_output_evalable():
    import fints.segments, fints.formals

    a = SegmentSequence([fints.segments.message.HNHBK3(header=fints.formals.SegmentHeader('HNHBK', 1, 3, None), message_size='000000000428', hbci_version=300,
                                                       dialog_id='430711670077=043999659571CN9D=', message_number=2,
                                                       reference_message=fints.formals.ReferenceMessage(dialog_id='430711670077=043999659571CN9D=',
                                                                                                        message_number=2)),
                         fints.segments.message.HNVSK3(header=fints.formals.SegmentHeader('HNVSK', 998, 3, None),
                                                       security_profile=fints.formals.SecurityProfile(security_method='PIN', security_method_version=1),
                                                       security_function='998', security_role='1',
                                                       security_identification_details=fints.formals.SecurityIdentificationDetails(identified_role='2',
                                                                                                                                   cid=None,
                                                                                                                                   identifier='oIm3BlHv6mQBAADYgbPpp+kWrAQA'),
                                                       security_datetime=fints.formals.SecurityDateTime(date_time_type='1', date=None, time=None),
                                                       encryption_algorithm=fints.formals.EncryptionAlgorithm(usage_encryption='2', operation_mode='2',
                                                                                                              encryption_algorithm='13',
                                                                                                              algorithm_parameter_value=b'00000000',
                                                                                                              algorithm_parameter_name='5',
                                                                                                              algorithm_parameter_iv_name='1',
                                                                                                              algorithm_parameter_iv_value=None),
github raphaelm / python-fints / tests / test_message_serializer.py View on Github external
def test_serialize_roundtrips_complex_1():
    from fints.formals import SegmentSequence
    m1 = SegmentSequence(TEST_MESSAGES['basic_complicated'])
    b1 = m1.render_bytes()

    m2 = SegmentSequence(b1)
    b2 = m2.render_bytes()

    m3 = SegmentSequence(b2)
    b3 = m3.render_bytes()

    assert b2 == b3
github raphaelm / python-fints / tests / test_message_serializer.py View on Github external
fints.segments.message.HNVSK3(header=fints.formals.SegmentHeader('HNVSK', 998, 3),
                                                       security_profile=fints.formals.SecurityProfile(security_method='PIN', security_method_version=1),
                                                       security_function='998', security_role='1',
                                                       security_identification_details=fints.formals.SecurityIdentificationDetails(identified_role='2',
                                                                                                                                   cid=None,
                                                                                                                                   identifier='oIm3BlHv6mQBAADYgbPpp+kWrAQA'),
                                                       security_datetime=fints.formals.SecurityDateTime(date_time_type='1'),
                                                       encryption_algorithm=fints.formals.EncryptionAlgorithm(usage_encryption='2', operation_mode='2',
                                                                                                              encryption_algorithm='13',
                                                                                                              algorithm_parameter_value=b'00000000',
                                                                                                              algorithm_parameter_name='5',
                                                                                                              algorithm_parameter_iv_name='1'),
                                                       key_name=fints.formals.KeyName(
                                                           bank_identifier=fints.formals.BankIdentifier(country_identifier='280', bank_code='15050500'),
                                                           user_id='hermes', key_type='S', key_number=0, key_version=0), compression_function='0'),
                         fints.segments.message.HNVSD1(header=fints.formals.SegmentHeader('HNVSD', 999, 1), data=SegmentSequence([fints.segments.message.HNSHK4(
                             header=fints.formals.SegmentHeader('HNSHK', 2, 4),
                             security_profile=fints.formals.SecurityProfile(security_method='PIN', security_method_version=1), security_function='999',
                             security_reference='9166926', security_application_area='1', security_role='1',
                             security_identification_details=fints.formals.SecurityIdentificationDetails(identified_role='2', cid=None,
                                                                                                         identifier='oIm3BlHv6mQBAADYgbPpp+kWrAQA'),
                             security_reference_number=1, security_datetime=fints.formals.SecurityDateTime(date_time_type='1'),
                             hash_algorithm=fints.formals.HashAlgorithm(usage_hash='1', hash_algorithm='999', algorithm_parameter_name='1'),
                             signature_algorithm=fints.formals.SignatureAlgorithm(usage_signature='6', signature_algorithm='10', operation_mode='16'),
                             key_name=fints.formals.KeyName(bank_identifier=fints.formals.BankIdentifier(country_identifier='280', bank_code='15050500'),
                                                            user_id='hermes', key_type='S', key_number=0, key_version=0)), fints.segments.dialog.HIRMG2(
                             header=fints.formals.SegmentHeader('HIRMG', 3, 2),
                             responses=[fints.formals.Response(code='0010', reference_element=None, text='Nachricht entgegengenommen.'),
                                        fints.formals.Response(code='0100', reference_element=None, text='Dialog beendet.')]), fints.segments.message.HNSHA2(
                             header=fints.formals.SegmentHeader('HNSHA', 4, 2), security_reference='9166926')])),
                         fints.segments.message.HNHBS1(header=fints.formals.SegmentHeader('HNHBS', 5, 1), message_number=2)])
github raphaelm / python-fints / tests / test_message_serializer.py View on Github external
def test_serialize_roundtrips_complex_1():
    from fints.formals import SegmentSequence
    m1 = SegmentSequence(TEST_MESSAGES['basic_complicated'])
    b1 = m1.render_bytes()

    m2 = SegmentSequence(b1)
    b2 = m2.render_bytes()

    m3 = SegmentSequence(b2)
    b3 = m3.render_bytes()

    assert b2 == b3
github raphaelm / python-fints / tests / test_message_serializer.py View on Github external
def test_serialize_roundtrips_complex_1():
    from fints.formals import SegmentSequence
    m1 = SegmentSequence(TEST_MESSAGES['basic_complicated'])
    b1 = m1.render_bytes()

    m2 = SegmentSequence(b1)
    b2 = m2.render_bytes()

    m3 = SegmentSequence(b2)
    b3 = m3.render_bytes()

    assert b2 == b3
github raphaelm / python-fints / tests / test_models.py View on Github external
security_function='998', security_role='1',
                                                       security_identification_details=fints.formals.SecurityIdentificationDetails(identified_role='2',
                                                                                                                                   cid=None,
                                                                                                                                   identifier='oIm3BlHv6mQBAADYgbPpp+kWrAQA'),
                                                       security_datetime=fints.formals.SecurityDateTime(date_time_type='1', date=None, time=None),
                                                       encryption_algorithm=fints.formals.EncryptionAlgorithm(usage_encryption='2', operation_mode='2',
                                                                                                              encryption_algorithm='13',
                                                                                                              algorithm_parameter_value=b'00000000',
                                                                                                              algorithm_parameter_name='5',
                                                                                                              algorithm_parameter_iv_name='1',
                                                                                                              algorithm_parameter_iv_value=None),
                                                       key_name=fints.formals.KeyName(
                                                           bank_identifier=fints.formals.BankIdentifier(country_identifier='280', bank_code='15050500'),
                                                           user_id='hermes', key_type='S', key_number=0, key_version=0), compression_function='0',
                                                       certificate=fints.formals.Certificate(certificate_type=None, certificate_content=None)),
                         fints.segments.message.HNVSD1(header=fints.formals.SegmentHeader('HNVSD', 999, 1, None), data=SegmentSequence([
                                                                                                                                           fints.segments.message.HNSHK4(
                                                                                                                                               header=fints.formals.SegmentHeader(
                                                                                                                                                   'HNSHK', 2,
                                                                                                                                                   4, None),
                                                                                                                                               security_profile=fints.formals.SecurityProfile(
                                                                                                                                                   security_method='PIN',
                                                                                                                                                   security_method_version=1),
                                                                                                                                               security_function='999',
                                                                                                                                               security_reference='9166926',
                                                                                                                                               security_application_area='1',
                                                                                                                                               security_role='1',
                                                                                                                                               security_identification_details=fints.formals.SecurityIdentificationDetails(
                                                                                                                                                   identified_role='2',
                                                                                                                                                   cid=None,
                                                                                                                                                   identifier='oIm3BlHv6mQBAADYgbPpp+kWrAQA'),
                                                                                                                                               security_reference_number=1,
github raphaelm / python-fints / fints / parser.py View on Github external
def serialize_message(self, message: SegmentSequence) -> bytes:
        """Serialize a message (as SegmentSequence, list of FinTS3Segment, or FinTS3Segment) into a byte array"""
        if isinstance(message, FinTS3Segment):
            message = SegmentSequence([message])
        if isinstance(message, (list, tuple, Iterable)):
            message = SegmentSequence(list(message))

        result = []

        for segment in message.segments:
            result.append(self.serialize_segment(segment))

        return self.implode_segments(result)
github raphaelm / python-fints / fints / parser.py View on Github external
def serialize_message(self, message: SegmentSequence) -> bytes:
        """Serialize a message (as SegmentSequence, list of FinTS3Segment, or FinTS3Segment) into a byte array"""
        if isinstance(message, FinTS3Segment):
            message = SegmentSequence([message])
        if isinstance(message, (list, tuple, Iterable)):
            message = SegmentSequence(list(message))

        result = []

        for segment in message.segments:
            result.append(self.serialize_segment(segment))

        return self.implode_segments(result)
github raphaelm / python-fints / fints / parser.py View on Github external
def parse_message(self, data: bytes) -> SegmentSequence:
        """Takes a FinTS 3.0 message as byte array, and returns a parsed segment sequence"""
        if isinstance(data, bytes):
            data = self.explode_segments(data)

        message = SegmentSequence()
        for segment in data:
            seg = self.parse_segment(segment)
            message.segments.append(seg)
        return message