device_claims.go 908 B

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