diff --git a/app/controllers/api/v1/documents_controller.rb b/app/controllers/api/v1/documents_controller.rb index 65500f2..6b2ed42 100644 --- a/app/controllers/api/v1/documents_controller.rb +++ b/app/controllers/api/v1/documents_controller.rb @@ -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) diff --git a/app/models/document.rb b/app/models/document.rb index 0f101e6..79639d6 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -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