Class: ActiveCipherStorage::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/active_cipher_storage/configuration.rb

Constant Summary collapse

ALGORITHMS =

Supported algorithm identifiers.

%w[aes-256-gcm].freeze
DEFAULT_CHUNK_SIZE =

Bytes per plaintext chunk in streaming mode (default 5 MiB — matches the minimum S3 multipart part size, so each chunk maps to exactly one part).

5 * 1024 * 1024

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



15
16
17
18
19
20
# File 'lib/active_cipher_storage/configuration.rb', line 15

def initialize
  @algorithm  = "aes-256-gcm"
  @chunk_size = DEFAULT_CHUNK_SIZE
  @provider   = nil
  @logger     = Logger.new($stdout, level: Logger::WARN)
end

Instance Attribute Details

#algorithmObject

Returns the value of attribute algorithm.



13
14
15
# File 'lib/active_cipher_storage/configuration.rb', line 13

def algorithm
  @algorithm
end

#chunk_sizeObject

Returns the value of attribute chunk_size.



13
14
15
# File 'lib/active_cipher_storage/configuration.rb', line 13

def chunk_size
  @chunk_size
end

#loggerObject

Returns the value of attribute logger.



13
14
15
# File 'lib/active_cipher_storage/configuration.rb', line 13

def logger
  @logger
end

#providerObject

Returns the value of attribute provider.



12
13
14
# File 'lib/active_cipher_storage/configuration.rb', line 12

def provider
  @provider
end

Instance Method Details

#validate!Object

Raises:



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/active_cipher_storage/configuration.rb', line 34

def validate!
  raise ProviderError, "No KMS provider configured. " \
        "Set ActiveCipherStorage.configuration.provider." unless @provider

  unless ALGORITHMS.include?(@algorithm)
    raise ArgumentError, "Unsupported algorithm: #{@algorithm.inspect}. " \
          "Supported: #{ALGORITHMS.join(', ')}"
  end

  raise ArgumentError, "chunk_size must be positive" unless @chunk_size.positive?
end