Module: As2::Config

Defined in:
lib/as2/config.rb

Defined Under Namespace

Classes: Partner, ServerInfo

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.server_infoObject (readonly)

Returns the value of attribute server_info.



144
145
146
# File 'lib/as2/config.rb', line 144

def server_info
  @server_info
end

Class Method Details

.build_certificate(input) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/as2/config.rb', line 4

def self.build_certificate(input)
  if input.kind_of? OpenSSL::X509::Certificate
    input
  elsif input.kind_of? String
    OpenSSL::X509::Certificate.new File.read(input)
  else
    raise ArgumentError, "Invalid certificate. Provide a string (file path)" \
      " or an OpenSSL::X509::Certificate instance. Got a #{input.class} instead."
  end
end

.configure {|@server_info| ... } ⇒ Object

Yields:



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/as2/config.rb', line 146

def configure
  @server_info ||= ServerInfo.new
  yield @server_info
  unless @server_info.name
    raise 'Your Partner name is required'
  end
  unless @server_info.certificate
    raise 'Your certificate is required'
  end
  unless @server_info.url
    raise 'Your URL is required'
  end
  unless @server_info.domain
    raise 'Your domain name is required'
  end
  store.add_cert @server_info.certificate
end

.partnersObject



164
165
166
# File 'lib/as2/config.rb', line 164

def partners
  @partners ||= {}
end

.reset!Object



173
174
175
176
# File 'lib/as2/config.rb', line 173

def reset!
  @partners = {}
  @store = OpenSSL::X509::Store.new
end

.storeObject

TODO: deprecate this.



169
170
171
# File 'lib/as2/config.rb', line 169

def store
  @store ||= OpenSSL::X509::Store.new
end