module Origami::Encryption::EncryptedDocument
Attributes
encryption_handler[RW]
encryption_key[RW]
Public Instance Methods
encryption_cipher(name)
click to toggle source
Get the encryption cipher from the crypt filter name.
# File lib/origami/encryption.rb, line 249 def encryption_cipher(name) @encryption_handler.encryption_cipher(name) end
stream_encryption_cipher()
click to toggle source
Get the default stream encryption cipher.
# File lib/origami/encryption.rb, line 259 def stream_encryption_cipher @encryption_handler.stream_encryption_cipher end
string_encryption_cipher()
click to toggle source
Get the default string encryption cipher.
# File lib/origami/encryption.rb, line 254 def string_encryption_cipher @encryption_handler.string_encryption_cipher end
Private Instance Methods
build_object(object, revision, options)
click to toggle source
Calls superclass method
# File lib/origami/encryption.rb, line 338 def build_object(object, revision, options) if object.is_a?(EncryptedObject) and options[:decrypt] object.pre_build object.decrypt! object.decrypted = false # makes it believe no encryption pass is required object.post_build return end super end
decrypt_objects()
click to toggle source
For each object subject to encryption, convert it to an EncryptedObject
and decrypt it if necessary.
# File lib/origami/encryption.rb, line 268 def decrypt_objects each_encryptable_object do |object| case object when String object.extend(EncryptedString) unless object.is_a?(EncryptedString) object.decrypt! when Stream object.extend(EncryptedStream) unless object.is_a?(EncryptedStream) end end end
each_encryptable_object(&b)
click to toggle source
Iterates over each encryptable objects in the document.
# File lib/origami/encryption.rb, line 305 def each_encryptable_object(&b) # Metadata may not be encrypted depending on the security handler configuration. encrypt_metadata = (@encryption_handler.EncryptMetadata != false) metadata = self.Catalog.Metadata self.each_object(recursive: true) .lazy .select { |object| case object when Stream not object.is_a?(XRefStream) or (encrypt_metadata and object.equal?(metadata)) when String not object.parent.equal?(@encryption_handler) end } .each(&b) end
encrypt_objects()
click to toggle source
For each object subject to encryption, convert it to an EncryptedObject
and mark it as not encrypted yet.
# File lib/origami/encryption.rb, line 284 def encrypt_objects each_encryptable_object do |object| case object when String unless object.is_a?(EncryptedString) object.extend(EncryptedString) object.decrypted = true end when Stream unless object.is_a?(EncryptedStream) object.extend(EncryptedStream) object.decrypted = true end end end end
physicalize(options = {})
click to toggle source
Calls superclass method
# File lib/origami/encryption.rb, line 324 def physicalize(options = {}) encrypt_objects super # remove encrypt dictionary if requested if options[:decrypt] delete_object(self.trailer[:Encrypt]) self.trailer[:Encrypt] = nil end self end