Class: JOSE::JWS::ALG_none

Inherits:
Struct
  • Object
show all
Defined in:
lib/jose/jws/alg_none.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#noneObject

Returns the value of attribute none


1
2
3
# File 'lib/jose/jws/alg_none.rb', line 1

def none
  @none
end

Class Method Details

.from_map(fields) ⇒ Object

JOSE::JWS callbacks


5
6
7
8
9
10
11
12
# File 'lib/jose/jws/alg_none.rb', line 5

def self.from_map(fields)
  case fields['alg']
  when 'none'
    return new(true), fields.delete('alg')
  else
    raise ArgumentError, "invalid 'alg' for JWS: #{fields['alg'].inspect}"
  end
end

Instance Method Details

#generate_key(fields) ⇒ Object

JOSE::JWS::ALG callbacks

Raises:

  • (NotImplementedError)

20
21
22
# File 'lib/jose/jws/alg_none.rb', line 20

def generate_key(fields)
  raise NotImplementedError
end

#sign(jwk, message) ⇒ Object


24
25
26
27
28
29
30
# File 'lib/jose/jws/alg_none.rb', line 24

def sign(jwk, message)
  if JOSE.unsecured_signing
    return ''
  else
    raise NotImplementedError
  end
end

#to_map(fields) ⇒ Object


14
15
16
# File 'lib/jose/jws/alg_none.rb', line 14

def to_map(fields)
  return fields.put('alg', 'none')
end

#verify(jwk, message, signature) ⇒ Object


32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jose/jws/alg_none.rb', line 32

def verify(jwk, message, signature)
  if JOSE.unsecured_signing
    if signature == ''
      return true
    else
      return false
    end
  else
    raise NotImplementedError
  end
end