public_key_credential_user_entity.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef DEVICE_FIDO_PUBLIC_KEY_CREDENTIAL_USER_ENTITY_H_
  5. #define DEVICE_FIDO_PUBLIC_KEY_CREDENTIAL_USER_ENTITY_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include <vector>
  9. #include "base/component_export.h"
  10. #include "components/cbor/values.h"
  11. #include "third_party/abseil-cpp/absl/types/optional.h"
  12. #include "url/gurl.h"
  13. namespace device {
  14. // Data structure containing a user id, an optional user name, an optional user
  15. // display image url, and an optional user display name as specified by the CTAP
  16. // spec. Used as required parameter type for AuthenticatorMakeCredential
  17. // request.
  18. class COMPONENT_EXPORT(DEVICE_FIDO) PublicKeyCredentialUserEntity {
  19. public:
  20. static absl::optional<PublicKeyCredentialUserEntity> CreateFromCBORValue(
  21. const cbor::Value& cbor);
  22. PublicKeyCredentialUserEntity();
  23. explicit PublicKeyCredentialUserEntity(std::vector<uint8_t> id);
  24. PublicKeyCredentialUserEntity(std::vector<uint8_t> id,
  25. absl::optional<std::string> name,
  26. absl::optional<std::string> display_name,
  27. absl::optional<GURL> icon_url);
  28. PublicKeyCredentialUserEntity(const PublicKeyCredentialUserEntity& other);
  29. PublicKeyCredentialUserEntity(PublicKeyCredentialUserEntity&& other);
  30. PublicKeyCredentialUserEntity& operator=(
  31. const PublicKeyCredentialUserEntity& other);
  32. PublicKeyCredentialUserEntity& operator=(
  33. PublicKeyCredentialUserEntity&& other);
  34. bool operator==(const PublicKeyCredentialUserEntity& other) const;
  35. ~PublicKeyCredentialUserEntity();
  36. std::vector<uint8_t> id;
  37. absl::optional<std::string> name;
  38. absl::optional<std::string> display_name;
  39. absl::optional<GURL> icon_url;
  40. };
  41. cbor::Value AsCBOR(const PublicKeyCredentialUserEntity&);
  42. } // namespace device
  43. #endif // DEVICE_FIDO_PUBLIC_KEY_CREDENTIAL_USER_ENTITY_H_