Class: JOSE::JWE::ZIP_DEF

Inherits:
Object
  • Object
show all
Defined in:
lib/jose/jwe/zip_def.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_map(fields) ⇒ Object

JOSE::JWE callbacks


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

def self.from_map(fields)
  case fields['zip']
  when 'DEF'
    return new(), fields.except('zip')
  else
    raise ArgumentError, "invalid 'zip' for JWE: #{fields['zip'].inspect}"
  end
end

Instance Method Details

#compress(plain_text) ⇒ Object

JOSE::JWE::ZIP callbacks


20
21
22
# File 'lib/jose/jwe/zip_def.rb', line 20

def compress(plain_text)
  return Zlib.deflate(plain_text)
end

#to_map(fields) ⇒ Object


14
15
16
# File 'lib/jose/jwe/zip_def.rb', line 14

def to_map(fields)
  return fields.put('zip', 'DEF')
end

#uncompress(cipher_text) ⇒ Object


24
25
26
# File 'lib/jose/jwe/zip_def.rb', line 24

def uncompress(cipher_text)
  return Zlib.inflate(cipher_text)
end