aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/tvmauth/client/misc/roles/decoder.h
blob: ef77cab56de0ae6a71cc46f1602ef1c0b479a141 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once 
 
#include <util/generic/string.h> 
 
namespace NTvmAuth::NRoles { 
    class TDecoder { 
    public: 
        static TString Decode(const TStringBuf codec, TString&& blob); 
 
    public: 
        struct TCodecInfo { 
            TStringBuf Type; 
            size_t Size = 0; 
            TStringBuf Sha256; 
 
            bool operator==(const TCodecInfo& o) const { 
                return Type == o.Type && 
                       Size == o.Size && 
                       Sha256 == o.Sha256; 
            } 
        }; 
 
        static TCodecInfo ParseCodec(TStringBuf codec); 
        static TString DecodeImpl(TStringBuf codec, const TString& blob); 
        static TString DecodeBrolti(const TString& blob); 
        static TString DecodeGzip(const TString& blob); 
        static TString DecodeZstd(const TString& blob); 
 
        static void VerifySize(const TStringBuf decoded, size_t expected); 
        static void VerifyChecksum(const TStringBuf decoded, const TStringBuf expected); 
    }; 
}