Class: PkiExpress::TimestampAuthority

Inherits:
Object
  • Object
show all
Defined in:
lib/pki_express/timestamp_authority.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ TimestampAuthority

Returns a new instance of TimestampAuthority.



5
6
7
8
9
10
11
# File 'lib/pki_express/timestamp_authority.rb', line 5

def initialize(url)
  @url = url
  @auth_type = TsaAuthenticationType::NONE
  @token = nil
  @ssl_thumbprint = nil
  @basic_auth = nil
end

Instance Attribute Details

#auth_typeObject (readonly)

Returns the value of attribute auth_type.



3
4
5
# File 'lib/pki_express/timestamp_authority.rb', line 3

def auth_type
  @auth_type
end

#basic_authObject (readonly)

Returns the value of attribute basic_auth.



3
4
5
# File 'lib/pki_express/timestamp_authority.rb', line 3

def basic_auth
  @basic_auth
end

#ssl_thumbprintObject (readonly)

Returns the value of attribute ssl_thumbprint.



3
4
5
# File 'lib/pki_express/timestamp_authority.rb', line 3

def ssl_thumbprint
  @ssl_thumbprint
end

#tokenObject (readonly)

Returns the value of attribute token.



3
4
5
# File 'lib/pki_express/timestamp_authority.rb', line 3

def token
  @token
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/pki_express/timestamp_authority.rb', line 3

def url
  @url
end

Instance Method Details

#get_cmd_argumentsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/pki_express/timestamp_authority.rb', line 28

def get_cmd_arguments
  args = []
  args.append('--tsa-url')
  args.append(url)

  case auth_type
  when TsaAuthenticationType::NONE
  when TsaAuthenticationType::BASIC_AUTH
    args.append('--tsa-basic-auth')
    args.append(@basic_auth)
  when TsaAuthenticationType::SSL
    args.append('--tsa-ssl-thumbprint')
    args.append(@ssl_thumbprint)
  when TsaAuthenticationType::OAUTH_TOKEN
    args.append('--tsa-token')
    args.append(token)
  else
    raise 'Unknown authentication type of the timestamp authority'
  end

  args
end

#set_basic_authentication(username, password) ⇒ Object



18
19
20
21
# File 'lib/pki_express/timestamp_authority.rb', line 18

def set_basic_authentication(username, password)
  @basic_auth = "#{username}:#{password}"
  @auth_type = TsaAuthenticationType::BASIC_AUTH
end

#set_oauth_token_authentication(token) ⇒ Object



13
14
15
16
# File 'lib/pki_express/timestamp_authority.rb', line 13

def set_oauth_token_authentication(token)
  @token = token
  @auth_type = TsaAuthenticationType::OAUTH_TOKEN
end

#set_ssl_thumbprint(ssl_thumbprint) ⇒ Object



23
24
25
26
# File 'lib/pki_express/timestamp_authority.rb', line 23

def set_ssl_thumbprint(ssl_thumbprint)
  @ssl_thumbprint = ssl_thumbprint
  @auth_type = TsaAuthenticationType::SSL
end