Module: As2

Defined in:
lib/as2.rb,
lib/as2/client.rb,
lib/as2/config.rb,
lib/as2/parser.rb,
lib/as2/server.rb,
lib/as2/message.rb,
lib/as2/version.rb,
lib/as2/base64_helper.rb,
lib/as2/client/result.rb,
lib/as2/mime_generator.rb,
lib/as2/digest_selector.rb,
lib/as2/parser/disposition_notification_options.rb

Defined Under Namespace

Modules: Base64Helper, Config, Parser Classes: Client, DigestSelector, Message, MimeGenerator, Server

Constant Summary collapse

VERSION =
"0.10.0"

Class Method Summary collapse

Class Method Details

.choose_mic_algorithm(disposition_notification_options) ⇒ String?

Select which algorithm to use for calculating a MIC, based on preferences stated by sender & our list of available algorithms.

Parameters:

  • disposition_notification_options (String)

    The content of an HTTP Disposition-Notification-Options header

Returns:

  • (String, nil)

    either an algorithm name, or nil if none is found in given header

See Also:



34
35
36
37
# File 'lib/as2.rb', line 34

def self.choose_mic_algorithm(disposition_notification_options)
  parsed = As2::Parser::DispositionNotificationOptions.parse(disposition_notification_options)
  Array(parsed['signed-receipt-micalg']).find { |m| As2::DigestSelector.valid?(m) }
end

.configure(&block) ⇒ Object



14
15
16
# File 'lib/as2.rb', line 14

def self.configure(&block)
  Config.configure(&block)
end

.generate_message_id(server_info) ⇒ Object



22
23
24
# File 'lib/as2.rb', line 22

def self.generate_message_id(server_info)
  "<#{server_info.name}-#{Time.now.strftime('%Y%m%d-%H%M%S')}-#{SecureRandom.uuid}@#{server_info.domain}>"
end

.quoted_system_identifier(name) ⇒ Object

surround an As2-From/As2-To value with double-quotes, if it contains a space.



40
41
42
43
44
45
46
# File 'lib/as2.rb', line 40

def self.quoted_system_identifier(name)
  if name.to_s.include?(' ') && !name.to_s.start_with?('"')
    "\"#{name}\""
  else
    name
  end
end

.reset_config!Object



18
19
20
# File 'lib/as2.rb', line 18

def self.reset_config!
  Config.reset!
end

.unquoted_system_identifier(name) ⇒ Object

remove double-quotes from an As2-From/As2-To value, if it contains any. this is useful in client code which may not automatically strip these quotes from a header value.



50
51
52
53
54
55
56
# File 'lib/as2.rb', line 50

def self.unquoted_system_identifier(name)
  if !name.is_a?(String)
    return name
  end

  name.delete_prefix('"').delete_suffix('"').gsub('\"', '"')
end