pki_express 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
1
+ require 'date'
2
+
3
+ module PkiExpress
4
+
5
+ class TrustServiceSessionResult
6
+
7
+ attr_accessor :session, :custom_state, :service, :session_type, :expires_on
8
+
9
+ def initialize(model)
10
+ @session = nil
11
+ @custom_state = nil
12
+ @service = nil
13
+ @session_type = nil
14
+ @expires_on = nil
15
+
16
+ unless model.nil?
17
+ @session = model.fetch(:session)
18
+ @custom_state = model.fetch(:customState)
19
+ @service = model.fetch(:service)
20
+ @session_type = model.fetch(:type)
21
+
22
+ expires_on = model.fetch(:expiresOn)
23
+ if expires_on
24
+ @expires_on = DateTime.iso8601(expires_on)
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,8 @@
1
+ module PkiExpress
2
+ class TrustServiceSessionTypes
3
+ SINGLE_SIGNATURE = 'SingleSignature',
4
+ MULTI_SIGNATURE = 'MultiSignature',
5
+ SIGNATURE_SESSION = 'SignatureSession',
6
+ AUTHENTICATION_SESSION = 'AuthenticationSession'
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ module PkiExpress
2
+ class TsaAuthenticationType < Enum
3
+ NONE = 'None'
4
+ BASIC_AUTH = 'BasicAuth'
5
+ SSL = 'SSL'
6
+ OAUTH_TOKEN = 'OAuthToken'
7
+
8
+ VALUES = [
9
+ NONE,
10
+ BASIC_AUTH,
11
+ SSL,
12
+ OAUTH_TOKEN
13
+ ]
14
+ end
15
+ end
@@ -9,13 +9,13 @@ module PkiExpress
9
9
  @detail = nil
10
10
  @inner_validation_results = nil
11
11
 
12
- unless model.nil?
12
+ if model
13
13
  @type = model.fetch(:type)
14
14
  @message = model.fetch(:message)
15
15
  @detail = model.fetch(:detail)
16
16
 
17
17
  inner_validation_results = model.fetch(:innerValidationResults)
18
- unless inner_validation_results.nil?
18
+ if inner_validation_results
19
19
  @inner_validation_results = ValidationResults.new(inner_validation_results)
20
20
  end
21
21
  end
@@ -26,12 +26,13 @@ module PkiExpress
26
26
  end
27
27
 
28
28
  def to_s(indentation_level=0)
29
- text = @message
30
- unless @detail.nil?
29
+ tab = '\t' * indentation_level
30
+ text = tab + @message
31
+ if @detail
31
32
  text += " (#{@detail})"
32
33
  end
33
34
 
34
- unless @inner_validation_results.nil?
35
+ if @inner_validation_results
35
36
  text += '\n'
36
37
  text += @inner_validation_results.to_s(indentation_level + 1)
37
38
  end
@@ -0,0 +1,103 @@
1
+ module PkiExpress
2
+ class ValidationItemTypes < Enum
3
+ SUCCESS = 'Success'
4
+ CERTIFICATE_NOT_YET_VALID = 'CertificateNotYetValid'
5
+ CERTIFICATE_EXPIRED = 'CertificateExpired'
6
+ CERTIFICATE_REVOKED = 'CertificateRevoked'
7
+ CERTIFICATE_ISSUER_NOT_FOUND = 'CertificateIssuerNotFound'
8
+ CERTIFICATE_REVOCATION_STATUS_UNKNOWN = 'CertificateRevocationStatusUnknown'
9
+ CERTIFICATE_CHAIN_ROOT_NOT_TRUSTED = 'CertificateChainRootNotTrusted'
10
+ INVALID_CERTIFICATE_SIGNATURE = 'InvalidCertificateSignature'
11
+ DECODE_ERROR = 'DecodeError'
12
+ REQUIRED_SIGNED_ATTRIBUTE_MISSING = 'RequiredSignedAttributeMissing'
13
+ FORBIDDEN_SIGNED_ATTRIBUTE_PRESENT = 'ForbiddenSignedAttributePresent'
14
+ REQUIRED_UNSIGNED_ATTRIBUTE_MISSING = 'RequiredUnsignedAttributeMissing'
15
+ FORBIDDEN_UNSIGNED_ATTRIBUTE_PRESENT = 'ForbiddenUnsignedAttributePresent'
16
+ CONTENT_TYPE_MISMATCH = 'ContentTypeMismatch'
17
+ MESSAGE_DIGEST_MISMATCH = 'MessageDigestMismatch'
18
+ SIGNING_CERTIFICATE_DIGEST_MISMATCH = 'SigningCertificateDigestMismatch'
19
+ SIGNATURE_ALGORITHM_VALIDATION_FAILED = 'SignatureAlgorithmValidationFailed'
20
+ REVOCATION_DATA_ISSUED_BEFORE_GRACE_PERIOD = 'RevocationDataIssuedBeforeGracePeriod'
21
+ UNCERTIFIED_DATE_REFERENCE = 'UncertifiedDateReference'
22
+ SIGNATURE_POLICY_MISMATCH = 'SignaturePolicyMismatch'
23
+ SIGNING_TIME_OUT_OF_CERTIFICATE_VALIDITY = 'SigningTimeOutOfCertificateValidity'
24
+ UNKNOWN_SIGNED_ATTRIBUTES_PRESENT = 'UnknownSignedAttributesPresent'
25
+ UNKNOWN_UNSIGNED_ATTRIBUTES_PRESENT = 'UnknownUnsignedAttributesPresent'
26
+ TIMESTAMP_WITH_MORE_THAN_ONE_SIGNED = 'TimestampWithMoreThanOneSigned'
27
+ TIMESTAMP_MESSAGE_IMPRINT_MISMATCH = 'TimestampMessageImprintMismatch'
28
+ TIMESTAMP_VALIDATION_EXCEPTION = 'TimestampValidationException'
29
+ COMPLETE_REFERENCES_MISMATCH = 'CompleteReferencesMismatch'
30
+ INVALID_SIGNATURE_TIMESTAMP = 'InvalidSignatureTimestamp'
31
+ INVALID_REFERENCES_TIMESTAMP = 'InvalidReferencesTimestamp'
32
+ INVALID_ARCHIVE_TIMESTAMP = 'InvalidArchiveTimestamp'
33
+ INVALID_KEY_USAGE = 'InvalidKeyUsage'
34
+ INVALID_OCSP_RESPONSE = 'InvalidOcspResponse'
35
+ UNAUTHORIZED_ISSUER = 'UnauthorizedIssuer'
36
+ UNKNOWN_ROOT_TRUST_STATUS = 'UnknownRootTrustStatus'
37
+ INVALID_TSL = 'InvalidTsl'
38
+ INVALID_CRL = 'InvalidCrl'
39
+ CERTIFICATE_ISSUER_VALID = 'CertificateIssuerValid'
40
+ CERTIFICATE_ISSUER_INVALID = 'CertificateIssuerInvalid'
41
+ CERTIFICATE_VALIDATION_FAILED = 'CertificateValidationFailed'
42
+ SIGNATURE_VULNERABLE_TO_SIGNER_SUBSTITUTION = 'SignatureVulnerableToSignerSubstitution'
43
+ INVALID_XML_SIGNATURE_SCHEME = 'InvalidXmlSignatureScheme'
44
+ XML_DSIG_CORE_VALIDATION_FAILED = 'XmlDSigCoreValidationFailed'
45
+ SIGNATURE_TIMESTAMP_IGNORED = 'SignatureTimestampIgnored'
46
+ INVALID_CERTIFICATION_PATH_LEN = 'InvalidCertificationPathLen'
47
+ SIGNING_CERTIFICATE_NOT_FOUND = 'SigningCertificateNotFound'
48
+ UNAUTHORIZED_AC_ISSUER = 'UnauthorizedACIssuer'
49
+ ALGORITHM_NOT_ALLOWED = 'AlgorithmNotAllowed'
50
+ UNACCEPTABLE_SIGNATURE_POLICY = 'UnacceptableSignaturePolicy'
51
+
52
+ VALUES = [
53
+ SUCCESS,
54
+ CERTIFICATE_NOT_YET_VALID,
55
+ CERTIFICATE_EXPIRED,
56
+ CERTIFICATE_REVOKED,
57
+ CERTIFICATE_ISSUER_NOT_FOUND,
58
+ CERTIFICATE_REVOCATION_STATUS_UNKNOWN,
59
+ CERTIFICATE_CHAIN_ROOT_NOT_TRUSTED,
60
+ INVALID_CERTIFICATE_SIGNATURE,
61
+ DECODE_ERROR,
62
+ REQUIRED_SIGNED_ATTRIBUTE_MISSING,
63
+ FORBIDDEN_SIGNED_ATTRIBUTE_PRESENT,
64
+ REQUIRED_UNSIGNED_ATTRIBUTE_MISSING,
65
+ FORBIDDEN_UNSIGNED_ATTRIBUTE_PRESENT,
66
+ CONTENT_TYPE_MISMATCH,
67
+ MESSAGE_DIGEST_MISMATCH,
68
+ SIGNING_CERTIFICATE_DIGEST_MISMATCH,
69
+ SIGNATURE_ALGORITHM_VALIDATION_FAILED,
70
+ REVOCATION_DATA_ISSUED_BEFORE_GRACE_PERIOD,
71
+ UNCERTIFIED_DATE_REFERENCE,
72
+ SIGNATURE_POLICY_MISMATCH,
73
+ SIGNING_TIME_OUT_OF_CERTIFICATE_VALIDITY,
74
+ UNKNOWN_SIGNED_ATTRIBUTES_PRESENT,
75
+ UNKNOWN_UNSIGNED_ATTRIBUTES_PRESENT,
76
+ TIMESTAMP_WITH_MORE_THAN_ONE_SIGNED,
77
+ TIMESTAMP_MESSAGE_IMPRINT_MISMATCH,
78
+ TIMESTAMP_VALIDATION_EXCEPTION,
79
+ COMPLETE_REFERENCES_MISMATCH,
80
+ INVALID_SIGNATURE_TIMESTAMP,
81
+ INVALID_REFERENCES_TIMESTAMP,
82
+ INVALID_ARCHIVE_TIMESTAMP,
83
+ INVALID_KEY_USAGE,
84
+ INVALID_OCSP_RESPONSE,
85
+ UNAUTHORIZED_ISSUER,
86
+ UNKNOWN_ROOT_TRUST_STATUS,
87
+ INVALID_TSL,
88
+ INVALID_CRL,
89
+ CERTIFICATE_ISSUER_VALID,
90
+ CERTIFICATE_ISSUER_INVALID,
91
+ CERTIFICATE_VALIDATION_FAILED,
92
+ SIGNATURE_VULNERABLE_TO_SIGNER_SUBSTITUTION,
93
+ INVALID_XML_SIGNATURE_SCHEME,
94
+ XML_DSIG_CORE_VALIDATION_FAILED,
95
+ SIGNATURE_TIMESTAMP_IGNORED,
96
+ INVALID_CERTIFICATION_PATH_LEN,
97
+ SIGNING_CERTIFICATE_NOT_FOUND,
98
+ UNAUTHORIZED_AC_ISSUER,
99
+ ALGORITHM_NOT_ALLOWED,
100
+ UNACCEPTABLE_SIGNATURE_POLICY
101
+ ]
102
+ end
103
+ end
@@ -8,19 +8,19 @@ module PkiExpress
8
8
  @warnings = []
9
9
  @passed_checks = []
10
10
 
11
- unless model.nil?
11
+ if model
12
12
  errors = model.fetch(:errors)
13
- unless errors.nil?
13
+ if errors
14
14
  @errors = convert_items(errors)
15
15
  end
16
16
 
17
17
  warnings = model.fetch(:warnings)
18
- unless warnings.nil?
18
+ if warnings
19
19
  @warnings = convert_items(warnings)
20
20
  end
21
21
 
22
22
  passed_checks = model.fetch(:passedChecks)
23
- unless passed_checks.nil?
23
+ if passed_checks
24
24
  @passed_checks = convert_items(passed_checks)
25
25
  end
26
26
  end
@@ -62,11 +62,11 @@ module PkiExpress
62
62
  end
63
63
 
64
64
  def has_errors
65
- @errors.length > 0
65
+ @errors && @errors.length > 0
66
66
  end
67
67
 
68
68
  def has_warnings
69
- @errors.length > 0
69
+ @warnings && @warnings.length > 0
70
70
  end
71
71
 
72
72
  def get_summary(indentation_level=0)
@@ -1,3 +1,3 @@
1
1
  module PkiExpress
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
23
23
  }
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.7'
26
- spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'rake', '~> 13'
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pki_express
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Medeiros
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-13 00:00:00.000000000 Z
11
+ date: 2020-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13'
41
41
  description: Classes to use Lacuna Software's PKI Express
42
42
  email:
43
43
  - ismaelm@lacunasoftware.com
@@ -57,18 +57,22 @@ files:
57
57
  - lib/pki_express/authentication.rb
58
58
  - lib/pki_express/base_signer.rb
59
59
  - lib/pki_express/cades_signature_starter.rb
60
+ - lib/pki_express/check_service_result.rb
60
61
  - lib/pki_express/command_error.rb
61
62
  - lib/pki_express/commands.rb
63
+ - lib/pki_express/discovery_service_result.rb
62
64
  - lib/pki_express/enum.rb
63
65
  - lib/pki_express/error_codes.rb
64
66
  - lib/pki_express/installation_not_found_error.rb
65
67
  - lib/pki_express/name.rb
68
+ - lib/pki_express/pades_certification_level.rb
66
69
  - lib/pki_express/pades_horizontal_align.rb
67
70
  - lib/pki_express/pades_measurement_units.rb
68
71
  - lib/pki_express/pades_page_optimization.rb
69
72
  - lib/pki_express/pades_page_orientation.rb
70
73
  - lib/pki_express/pades_paper_size.rb
71
74
  - lib/pki_express/pades_signature_starter.rb
75
+ - lib/pki_express/pades_signer.rb
72
76
  - lib/pki_express/pades_size.rb
73
77
  - lib/pki_express/pades_text_horizontal_align.rb
74
78
  - lib/pki_express/pades_vertical_align.rb
@@ -92,8 +96,15 @@ files:
92
96
  - lib/pki_express/signer.rb
93
97
  - lib/pki_express/standard_signature_policies.rb
94
98
  - lib/pki_express/timestamp_authority.rb
99
+ - lib/pki_express/trust_service_auth_parameters.rb
100
+ - lib/pki_express/trust_service_info.rb
101
+ - lib/pki_express/trust_service_manager.rb
102
+ - lib/pki_express/trust_service_session_result.rb
103
+ - lib/pki_express/trust_service_session_types.rb
104
+ - lib/pki_express/tsa_authentication_type.rb
95
105
  - lib/pki_express/validation_error.rb
96
106
  - lib/pki_express/validation_item.rb
107
+ - lib/pki_express/validation_item_types.rb
97
108
  - lib/pki_express/validation_results.rb
98
109
  - lib/pki_express/version.rb
99
110
  - lib/pki_express/version_manager.rb
@@ -121,8 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
132
  - !ruby/object:Gem::Version
122
133
  version: '0'
123
134
  requirements: []
124
- rubyforge_project:
125
- rubygems_version: 2.7.6
135
+ rubygems_version: 3.0.3
126
136
  signing_key:
127
137
  specification_version: 4
128
138
  summary: Gem for using PKI Express on Ruby