EdgexAgent/device-gps-go/vendor/github.com/openziti/edge-api/rest_model/jwk.go
2025-07-10 20:30:06 +08:00

216 lines
5.0 KiB
Go

// Code generated by go-swagger; DO NOT EDIT.
//
// Copyright NetFoundry Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// __ __ _
// \ \ / / (_)
// \ \ /\ / /_ _ _ __ _ __ _ _ __ __ _
// \ \/ \/ / _` | '__| '_ \| | '_ \ / _` |
// \ /\ / (_| | | | | | | | | | | (_| | : This file is generated, do not edit it.
// \/ \/ \__,_|_| |_| |_|_|_| |_|\__, |
// __/ |
// |___/
package rest_model
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// Jwk jwk
//
// swagger:model jwk
type Jwk struct {
// Algorithm intended for use with the key.
Alg string `json:"alg,omitempty"`
// Curve for ECC Public Keys.
Crv string `json:"crv,omitempty"`
// ECC Private Key or RSA Private Exponent.
D string `json:"d,omitempty"`
// First Factor CRT Exponent for RSA.
Dp string `json:"dp,omitempty"`
// Second Factor CRT Exponent for RSA.
Dq string `json:"dq,omitempty"`
// Exponent for RSA Public Key.
E string `json:"e,omitempty"`
// Intended key operations, e.g., sign, verify.
KeyOps []string `json:"key_ops"`
// Key ID.
Kid string `json:"kid,omitempty"`
// Key Type.
// Required: true
Kty *string `json:"kty"`
// Modulus for RSA Public Key.
N string `json:"n,omitempty"`
// Other Primes Info not represented by the first two primes.
Oth []*OtherPrime `json:"oth"`
// First Prime Factor for RSA.
P string `json:"p,omitempty"`
// Second Prime Factor for RSA.
Q string `json:"q,omitempty"`
// First CRT Coefficient for RSA.
Qi string `json:"qi,omitempty"`
// Public key use, e.g., sig (signature) or enc (encryption).
Use string `json:"use,omitempty"`
// X Coordinate for ECC Public Keys.
X string `json:"x,omitempty"`
// X.509 Certificate Chain.
X5c []string `json:"x5c"`
// X.509 Certificate SHA-1 Thumbprint.
X5t string `json:"x5t,omitempty"`
// X.509 Certificate SHA-256 Thumbprint.
X5tS256 string `json:"x5t#S256,omitempty"`
// X.509 URL.
X5u string `json:"x5u,omitempty"`
// Y Coordinate for ECC Public Keys.
Y string `json:"y,omitempty"`
}
// Validate validates this jwk
func (m *Jwk) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateKty(formats); err != nil {
res = append(res, err)
}
if err := m.validateOth(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Jwk) validateKty(formats strfmt.Registry) error {
if err := validate.Required("kty", "body", m.Kty); err != nil {
return err
}
return nil
}
func (m *Jwk) validateOth(formats strfmt.Registry) error {
if swag.IsZero(m.Oth) { // not required
return nil
}
for i := 0; i < len(m.Oth); i++ {
if swag.IsZero(m.Oth[i]) { // not required
continue
}
if m.Oth[i] != nil {
if err := m.Oth[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("oth" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("oth" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this jwk based on the context it is used
func (m *Jwk) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateOth(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Jwk) contextValidateOth(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Oth); i++ {
if m.Oth[i] != nil {
if err := m.Oth[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("oth" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("oth" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *Jwk) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Jwk) UnmarshalBinary(b []byte) error {
var res Jwk
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}