interface_gen.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // This file is auto-generated. DO NOT EDIT
  2. package jwk
  3. import (
  4. "context"
  5. "crypto"
  6. "crypto/x509"
  7. "github.com/lestrrat-go/jwx/jwa"
  8. )
  9. const (
  10. KeyTypeKey = "kty"
  11. KeyUsageKey = "use"
  12. KeyOpsKey = "key_ops"
  13. AlgorithmKey = "alg"
  14. KeyIDKey = "kid"
  15. X509URLKey = "x58"
  16. X509CertChainKey = "x5c"
  17. X509CertThumbprintKey = "x5t"
  18. X509CertThumbprintS256Key = "x5t#S256"
  19. )
  20. // Key defines the minimal interface for each of the
  21. // key types. Their use and implementation differ significantly
  22. // between each key types, so you should use type assertions
  23. // to perform more specific tasks with each key
  24. type Key interface {
  25. // Get returns the value of a single field. The second boolean return value
  26. // will be false if the field is not stored in the source
  27. //
  28. // This method, which returns an `interface{}`, exists because
  29. // these objects can contain extra _arbitrary_ fields that users can
  30. // specify, and there is no way of knowing what type they could be
  31. Get(string) (interface{}, bool)
  32. // Set sets the value of a single field. Note that certain fields,
  33. // notably "kty", cannot be altered, but will not return an error
  34. //
  35. // This method, which takes an `interface{}`, exists because
  36. // these objects can contain extra _arbitrary_ fields that users can
  37. // specify, and there is no way of knowing what type they could be
  38. Set(string, interface{}) error
  39. // Remove removes the field associated with the specified key.
  40. // There is no way to remove the `kty` (key type). You will ALWAYS be left with one field in a jwk.Key.
  41. Remove(string) error
  42. // Raw creates the corresponding raw key. For example,
  43. // EC types would create *ecdsa.PublicKey or *ecdsa.PrivateKey,
  44. // and OctetSeq types create a []byte key.
  45. //
  46. // If you do not know the exact type of a jwk.Key before attempting
  47. // to obtain the raw key, you can simply pass a pointer to an
  48. // empty interface as the first argument.
  49. //
  50. // If you already know the exact type, it is recommended that you
  51. // pass a pointer to the zero value of the actual key type (e.g. &rsa.PrivateKey)
  52. // for efficiency.
  53. Raw(interface{}) error
  54. // Thumbprint returns the JWK thumbprint using the indicated
  55. // hashing algorithm, according to RFC 7638
  56. Thumbprint(crypto.Hash) ([]byte, error)
  57. // Iterate returns an iterator that returns all keys and values.
  58. // See github.com/lestrrat-go/iter for a description of the iterator.
  59. Iterate(ctx context.Context) HeaderIterator
  60. // Walk is a utility tool that allows a visitor to iterate all keys and values
  61. Walk(context.Context, HeaderVisitor) error
  62. // AsMap is a utility tool that returns a new map that contains the same fields as the source
  63. AsMap(context.Context) (map[string]interface{}, error)
  64. // PrivateParams returns the non-standard elements in the source structure
  65. // WARNING: DO NOT USE PrivateParams() IF YOU HAVE CONCURRENT CODE ACCESSING THEM.
  66. // Use `AsMap()` to get a copy of the entire header, or use `Iterate()` instead
  67. PrivateParams() map[string]interface{}
  68. // Clone creates a new instance of the same type
  69. Clone() (Key, error)
  70. // PublicKey creates the corresponding PublicKey type for this object.
  71. // All fields are copied onto the new public key, except for those that are not allowed.
  72. //
  73. // If the key is already a public key, it returns a new copy minus the disallowed fields as above.
  74. PublicKey() (Key, error)
  75. // KeyType returns the `kid` of a JWK
  76. KeyType() jwa.KeyType
  77. // KeyUsage returns `use` of a JWK
  78. KeyUsage() string
  79. // KeyOps returns `key_ops` of a JWK
  80. KeyOps() KeyOperationList
  81. // Algorithm returns `alg` of a JWK
  82. Algorithm() string
  83. // KeyID returns `kid` of a JWK
  84. KeyID() string
  85. // X509URL returns `x58` of a JWK
  86. X509URL() string
  87. // X509CertChain returns `x5c` of a JWK
  88. X509CertChain() []*x509.Certificate
  89. // X509CertThumbprint returns `x5t` of a JWK
  90. X509CertThumbprint() string
  91. // X509CertThumbprintS256 returns `x5t#S256` of a JWK
  92. X509CertThumbprintS256() string
  93. makePairs() []*HeaderPair
  94. }