github.com/jcmturner/gokrb5/v8@v8.4.4/pac/client_claims.go (about)

     1  package pac
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  
     7  	"github.com/jcmturner/rpc/v2/mstypes"
     8  	"github.com/jcmturner/rpc/v2/ndr"
     9  )
    10  
    11  // Claims reference: https://msdn.microsoft.com/en-us/library/hh553895.aspx
    12  
    13  // ClientClaimsInfo implements https://msdn.microsoft.com/en-us/library/hh536365.aspx
    14  type ClientClaimsInfo struct {
    15  	ClaimsSetMetadata mstypes.ClaimsSetMetadata
    16  	ClaimsSet         mstypes.ClaimsSet
    17  }
    18  
    19  // Unmarshal bytes into the ClientClaimsInfo struct
    20  func (k *ClientClaimsInfo) Unmarshal(b []byte) (err error) {
    21  	dec := ndr.NewDecoder(bytes.NewReader(b))
    22  	m := new(mstypes.ClaimsSetMetadata)
    23  	err = dec.Decode(m)
    24  	if err != nil {
    25  		err = fmt.Errorf("error unmarshaling ClientClaimsInfo ClaimsSetMetadata: %v", err)
    26  		return
    27  	}
    28  	k.ClaimsSetMetadata = *m
    29  	k.ClaimsSet, err = k.ClaimsSetMetadata.ClaimsSet()
    30  	if err != nil {
    31  		err = fmt.Errorf("error unmarshaling ClientClaimsInfo ClaimsSet: %v", err)
    32  	}
    33  	return
    34  }