Class: OCI::Apigateway::Models::JsonWebKey

Inherits:
StaticPublicKey show all
Defined in:
lib/oci/apigateway/models/json_web_key.rb

Overview

A JSON Web Key that represents the public key used for verifying the JWT signature.

Constant Summary collapse

KTY_ENUM =
[
  KTY_RSA = 'RSA'.freeze,
  KTY_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze
USE_ENUM =
[
  USE_SIG = 'sig'.freeze,
  USE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze
KEY_OPS_ENUM =
[
  KEY_OPS_VERIFY = 'verify'.freeze,
  KEY_OPS_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Constants inherited from StaticPublicKey

StaticPublicKey::FORMAT_ENUM

Instance Attribute Summary collapse

Attributes inherited from StaticPublicKey

#format, #kid

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StaticPublicKey

get_subtype

Constructor Details

#initialize(attributes = {}) ⇒ JsonWebKey

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):

  • :kid (String)

    The value to assign to the #kid proprety

  • :kty (String)

    The value to assign to the #kty property

  • :use (String)

    The value to assign to the #use property

  • :key_ops (Array<String>)

    The value to assign to the #key_ops property

  • :alg (String)

    The value to assign to the #alg property

  • :n (String)

    The value to assign to the #n property

  • :e (String)

    The value to assign to the #e property



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/oci/apigateway/models/json_web_key.rb', line 101

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  attributes['format'] = 'JSON_WEB_KEY'

  super(attributes)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.kty = attributes[:'kty'] if attributes[:'kty']

  self.use = attributes[:'use'] if attributes[:'use']

  self.key_ops = attributes[:'key_ops'] if attributes[:'key_ops']

  self.alg = attributes[:'alg'] if attributes[:'alg']

  self.n = attributes[:'n'] if attributes[:'n']

  self.e = attributes[:'e'] if attributes[:'e']
end

Instance Attribute Details

#algString

[Required] The algorithm intended for use with this key.

Returns:

  • (String)


42
43
44
# File 'lib/oci/apigateway/models/json_web_key.rb', line 42

def alg
  @alg
end

#eString

[Required] The base64 url encoded exponent of the RSA public key represented by this key.

Returns:

  • (String)


54
55
56
# File 'lib/oci/apigateway/models/json_web_key.rb', line 54

def e
  @e
end

#key_opsArray<String>

The operations for which this key is to be used.

Returns:

  • (Array<String>)


38
39
40
# File 'lib/oci/apigateway/models/json_web_key.rb', line 38

def key_ops
  @key_ops
end

#ktyString

[Required] The key type.

Returns:

  • (String)


30
31
32
# File 'lib/oci/apigateway/models/json_web_key.rb', line 30

def kty
  @kty
end

#nString

[Required] The base64 url encoded modulus of the RSA public key represented by this key.

Returns:

  • (String)


48
49
50
# File 'lib/oci/apigateway/models/json_web_key.rb', line 48

def n
  @n
end

#useString

The intended use of the public key.

Returns:

  • (String)


34
35
36
# File 'lib/oci/apigateway/models/json_web_key.rb', line 34

def use
  @use
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/oci/apigateway/models/json_web_key.rb', line 57

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'kid': :'kid',
    'format': :'format',
    'kty': :'kty',
    'use': :'use',
    'key_ops': :'key_ops',
    'alg': :'alg',
    'n': :'n',
    'e': :'e'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/oci/apigateway/models/json_web_key.rb', line 73

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'kid': :'String',
    'format': :'String',
    'kty': :'String',
    'use': :'String',
    'key_ops': :'Array<String>',
    'alg': :'String',
    'n': :'String',
    'e': :'String'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/oci/apigateway/models/json_web_key.rb', line 177

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    kid == other.kid &&
    format == other.format &&
    kty == other.kty &&
    use == other.use &&
    key_ops == other.key_ops &&
    alg == other.alg &&
    n == other.n &&
    e == other.e
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/oci/apigateway/models/json_web_key.rb', line 214

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


194
195
196
# File 'lib/oci/apigateway/models/json_web_key.rb', line 194

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



203
204
205
# File 'lib/oci/apigateway/models/json_web_key.rb', line 203

def hash
  [kid, format, kty, use, key_ops, alg, n, e].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



247
248
249
250
251
252
253
254
255
256
# File 'lib/oci/apigateway/models/json_web_key.rb', line 247

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



241
242
243
# File 'lib/oci/apigateway/models/json_web_key.rb', line 241

def to_s
  to_hash.to_s
end