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



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

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)


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

def alg
  @alg
end

#eString

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

Returns:

  • (String)


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

def e
  @e
end

#key_opsArray<String>

The operations for which this key is to be used.

Returns:

  • (Array<String>)


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

def key_ops
  @key_ops
end

#ktyString

[Required] The key type.

Returns:

  • (String)


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

def kty
  @kty
end

#nString

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

Returns:

  • (String)


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

def n
  @n
end

#useString

The intended use of the public key.

Returns:

  • (String)


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

def use
  @use
end

Class Method Details

.attribute_mapObject

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



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

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.



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

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



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

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



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

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


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

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



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

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



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

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



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

def to_s
  to_hash.to_s
end