package mstypes
import (
"bytes"
"encoding/hex"
"errors"
"fmt"
"github.com/jcmturner/rpc/v2/ndr"
"golang.org/x/net/http2/hpack"
)
const (
CompressionFormatNone uint16 = 0
CompressionFormatLZNT1 uint16 = 2
CompressionFormatXPress uint16 = 3
CompressionFormatXPressHuff uint16 = 4
)
const ClaimsSourceTypeAD uint16 = 1
const (
ClaimTypeIDInt64 uint16 = 1
ClaimTypeIDUInt64 uint16 = 2
ClaimTypeIDString uint16 = 3
ClaimsTypeIDBoolean uint16 = 6
)
type ClaimsBlob struct {
Size uint32
EncodedBlob EncodedBlob
}
type EncodedBlob []byte
func (b EncodedBlob ) Size (c interface {}) int {
cb := c .(ClaimsBlob )
return int (cb .Size )
}
type ClaimsSetMetadata struct {
ClaimsSetSize uint32
ClaimsSetBytes []byte `ndr:"pointer,conformant"`
CompressionFormat uint16
UncompressedClaimsSetSize uint32
ReservedType uint16
ReservedFieldSize uint32
ReservedField []byte `ndr:"pointer,conformant"`
}
func (m *ClaimsSetMetadata ) ClaimsSet () (c ClaimsSet , err error ) {
if len (m .ClaimsSetBytes ) < 1 {
err = errors .New ("no bytes available for ClaimsSet" )
return
}
switch m .CompressionFormat {
case CompressionFormatLZNT1 :
s := hex .EncodeToString (m .ClaimsSetBytes )
err = fmt .Errorf ("ClaimsSet compressed, format LZNT1 not currently supported: %s" , s )
return
case CompressionFormatXPress :
s := hex .EncodeToString (m .ClaimsSetBytes )
err = fmt .Errorf ("ClaimsSet compressed, format XPress not currently supported: %s" , s )
return
case CompressionFormatXPressHuff :
var b []byte
buff := bytes .NewBuffer (b )
_ , e := hpack .HuffmanDecode (buff , m .ClaimsSetBytes )
if e != nil {
err = fmt .Errorf ("error deflating: %v" , e )
return
}
m .ClaimsSetBytes = buff .Bytes ()
}
dec := ndr .NewDecoder (bytes .NewReader (m .ClaimsSetBytes ))
err = dec .Decode (&c )
return
}
type ClaimsSet struct {
ClaimsArrayCount uint32
ClaimsArrays []ClaimsArray `ndr:"pointer,conformant"`
ReservedType uint16
ReservedFieldSize uint32
ReservedField []byte `ndr:"pointer,conformant"`
}
type ClaimsArray struct {
ClaimsSourceType uint16
ClaimsCount uint32
ClaimEntries []ClaimEntry `ndr:"pointer,conformant"`
}
type ClaimEntry struct {
ID string `ndr:"pointer,conformant,varying"`
Type uint16 `ndr:"unionTag"`
TypeInt64 ClaimTypeInt64 `ndr:"unionField"`
TypeUInt64 ClaimTypeUInt64 `ndr:"unionField"`
TypeString ClaimTypeString `ndr:"unionField"`
TypeBool ClaimTypeBoolean `ndr:"unionField"`
}
func (u ClaimEntry ) SwitchFunc (_ interface {}) string {
switch u .Type {
case ClaimTypeIDInt64 :
return "TypeInt64"
case ClaimTypeIDUInt64 :
return "TypeUInt64"
case ClaimTypeIDString :
return "TypeString"
case ClaimsTypeIDBoolean :
return "TypeBool"
}
return ""
}
type ClaimTypeInt64 struct {
ValueCount uint32
Value []int64 `ndr:"pointer,conformant"`
}
type ClaimTypeUInt64 struct {
ValueCount uint32
Value []uint64 `ndr:"pointer,conformant"`
}
type ClaimTypeString struct {
ValueCount uint32
Value []LPWSTR `ndr:"pointer,conformant"`
}
type ClaimTypeBoolean struct {
ValueCount uint32
Value []bool `ndr:"pointer,conformant"`
}
The pages are generated with Golds v0.6.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds .