Skip to content

Commit

Permalink
Fix - Ignore level with asice inputs (#40)
Browse files Browse the repository at this point in the history
* ignore signature level when asice container provided

* fix syntax

* use .in? instead of in
  • Loading branch information
celuchmarek authored Oct 31, 2024
1 parent 0ec5165 commit 70ba4c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/api/v1/documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def create
mimetype, content, parameters = Document.convert_to_b64(mimetype, p[:document][:content], p[:parameters])

@document = Document.new(parameters: parameters)
@document.reset_signature_level if 'vnd.etsi.asic'.in?(mimetype)
@document.encrypt_file(@key, filename, mimetype, content)
@document.validate_parameters(content, mimetype)

Expand Down
5 changes: 5 additions & 0 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def self.convert_to_b64(mimetype, content, params)
[mimetype + ';base64', Base64.strict_encode64(content), params]
end

def reset_signature_level
return unless parameters['level']
parameters['level'] = parameters['level'].gsub(/XAdES_BASELINE_/, '').gsub(/CAdES_BASELINE_/, '')
end

def decrypt_content(key)
decryptor = ActiveSupport::MessageEncryptor.new(key)
begin
Expand Down

0 comments on commit 70ba4c9

Please sign in to comment.