...

Source file src/github.com/lestrrat-go/jwx/jwk/interface_gen.go

Documentation: github.com/lestrrat-go/jwx/jwk

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

View as plain text