Exemple #1
0
 def _get_segment_max_version(self, name):
     v = 3
     segs = self._find_segments(name)
     for s in segs:
         parts = split_for_data_groups(s)
         segheader = split_for_data_elements(parts[0])
         curver = int(segheader[2])
         if curver > v:
             v = curver
     return v
Exemple #2
0
 def get_supported_tan_mechanisms(self):
     segs = self._find_segments('HIRMS')
     for s in segs:
         seg = split_for_data_groups(s)[1:]
         for s in seg:
             id, msg = s.split('::', 1)
             if id == "3920":
                 m = self.RE_TANMECH.search(msg)
                 if m:
                     return [m.group(0)]
     return False
Exemple #3
0
    def get_summary_by_segment(self, name):
        if name not in ('HIRMS', 'HIRMG'):
            raise ValueError('Unsupported segment for message summary')

        res = {}
        seg = self._find_segment(name)
        parts = split_for_data_groups(seg)[1:]
        for de in parts:
            de = split_for_data_elements(de)
            res[de[0]] = de[2]
        return res
Exemple #4
0
 def get_touchdowns(self, msg: FinTSMessage):
     touchdown = {}
     for msgseg in msg.encrypted_segments:
         seg = self._find_segment_for_reference('HIRMS', msgseg)
         if seg:
             parts = split_for_data_groups(seg)[1:]
             for p in parts:
                 psplit = split_for_data_elements(p)
                 if psplit[0] == "3040":
                     td = psplit[3]
                     touchdown[msgseg.type] = fints_unescape(td)
     return touchdown
Exemple #5
0
    def get_supported_tan_mechanisms(self):
        segs = self._find_segments('HIRMS')
        tan_methods = []
        for seg in segs:
            deg = split_for_data_groups(seg)
            for de in deg:
                if de[0:4] == '3920':
                    d = split_for_data_elements(de)
                    for i in range(3, len(d)):
                        tan_methods.append(d[i])

        # Get parameters for tan methods
        seg = self._find_segments('HITANS')
        methods = []
        for s in seg:
            spl = split_for_data_elements(s)
            if spl[2] == '1':
                model = TANMethod1
            elif spl[2] == '2':
                model = TANMethod2
            elif spl[2] == '3':
                model = TANMethod3
            elif spl[2] == '4':
                model = TANMethod4
            elif spl[2] == '5':
                model = TANMethod5
            elif spl[2] == '6':
                model = TANMethod6
            else:
                raise NotImplementedError(
                    "HITANS segment version {} is currently not implemented".
                    format(spl[2]))

            step = len(model.args)
            for i in range(len(spl) // step):
                part = spl[6 + i * step:6 + (i + 1) * step]
                method = model(*part)
                if method.security_feature in tan_methods:
                    methods.append(method)

        return methods
Exemple #6
0
 def _find_segment_for_reference(self, name, ref):
     segs = self._find_segments(name)
     for seg in segs:
         segsplit = split_for_data_elements(split_for_data_groups(seg)[0])
         if segsplit[3] == str(ref.segmentno):
             return seg
Exemple #7
0
 def get_bank_name(self):
     seg = self._find_segment('HIBPA')
     if seg:
         parts = split_for_data_groups(seg)
         if len(parts) > 3:
             return parts[3]
Exemple #8
0
 def _get_segment_index(self, idx, seg):
     seg = split_for_data_groups(seg)
     if len(seg) > idx - 1:
         return seg[idx - 1]
     return None