r509 0.8.1 → 0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +343 -151
- data/Rakefile +26 -23
- data/bin/r509 +126 -112
- data/bin/r509-parse +24 -24
- data/doc/R509.html +169 -7
- data/doc/R509/ASN1.html +370 -0
- data/doc/R509/ASN1/GeneralName.html +1121 -0
- data/doc/R509/ASN1/GeneralNames.html +843 -0
- data/doc/R509/ASN1/NoticeReference.html +392 -0
- data/doc/R509/ASN1/PolicyInformation.html +387 -0
- data/doc/R509/ASN1/PolicyQualifiers.html +455 -0
- data/doc/R509/ASN1/UserNotice.html +386 -0
- data/doc/R509/{Crl.html → CRL.html} +7 -7
- data/doc/R509/CRL/Administrator.html +1559 -0
- data/doc/R509/{Crl/Parser.html → CRL/SignedList.html} +501 -210
- data/doc/R509/{Csr.html → CSR.html} +444 -314
- data/doc/R509/Cert.html +866 -617
- data/doc/R509/Cert/Extensions.html +52 -41
- data/doc/R509/Cert/Extensions/AuthorityInfoAccess.html +70 -35
- data/doc/R509/Cert/Extensions/AuthorityKeyIdentifier.html +387 -4
- data/doc/R509/Cert/Extensions/BasicConstraints.html +61 -25
- data/doc/R509/Cert/Extensions/CRLDistributionPoints.html +354 -0
- data/doc/R509/Cert/Extensions/CertificatePolicies.html +340 -0
- data/doc/R509/Cert/Extensions/ExtendedKeyUsage.html +440 -49
- data/doc/R509/Cert/Extensions/{CrlDistributionPoints.html → InhibitAnyPolicy.html} +52 -35
- data/doc/R509/Cert/Extensions/KeyUsage.html +247 -121
- data/doc/R509/Cert/Extensions/NameConstraints.html +445 -0
- data/doc/R509/Cert/Extensions/OCSPNoCheck.html +239 -0
- data/doc/R509/Cert/Extensions/PolicyConstraints.html +424 -0
- data/doc/R509/Cert/Extensions/SubjectAlternativeName.html +437 -62
- data/doc/R509/Cert/Extensions/SubjectKeyIdentifier.html +52 -10
- data/doc/R509/CertificateAuthority.html +4 -4
- data/doc/R509/CertificateAuthority/Signer.html +154 -187
- data/doc/R509/Config.html +6 -6
- data/doc/R509/Config/{CaConfig.html → CAConfig.html} +451 -348
- data/doc/R509/Config/{CaConfigPool.html → CAConfigPool.html} +47 -47
- data/doc/R509/Config/CAProfile.html +1015 -0
- data/doc/R509/Config/SubjectItemPolicy.html +86 -86
- data/doc/R509/IOHelpers.html +22 -22
- data/doc/R509/MessageDigest.html +14 -14
- data/doc/R509/NameSanitizer.html +53 -53
- data/doc/R509/{Ocsp.html → OCSP.html} +9 -9
- data/doc/R509/{Ocsp → OCSP}/Request.html +7 -7
- data/doc/R509/{Ocsp → OCSP}/Request/Nonce.html +56 -11
- data/doc/R509/{Ocsp → OCSP}/Response.html +44 -44
- data/doc/R509/{OidMapper.html → OIDMapper.html} +23 -39
- data/doc/R509/PrivateKey.html +415 -168
- data/doc/R509/R509Error.html +3 -3
- data/doc/R509/{Spki.html → SPKI.html} +354 -192
- data/doc/R509/Subject.html +224 -113
- data/doc/R509/Validity.html +27 -5
- data/doc/R509/Validity/Checker.html +13 -13
- data/doc/R509/Validity/DefaultChecker.html +13 -13
- data/doc/R509/Validity/DefaultWriter.html +14 -14
- data/doc/R509/Validity/Status.html +39 -39
- data/doc/R509/Validity/Writer.html +18 -18
- data/doc/_index.html +138 -35
- data/doc/class_list.html +1 -1
- data/doc/css/style.css +10 -0
- data/doc/file.README.html +368 -171
- data/doc/file.r509.html +92 -69
- data/doc/frames.html +1 -1
- data/doc/index.html +368 -171
- data/doc/method_list.html +910 -390
- data/doc/top-level-namespace.html +3 -3
- data/lib/r509.rb +32 -16
- data/lib/r509/asn1.rb +375 -0
- data/lib/r509/cert.rb +381 -364
- data/lib/r509/cert/extensions.rb +443 -76
- data/lib/r509/certificate_authority.rb +407 -0
- data/lib/r509/config.rb +547 -351
- data/lib/r509/crl.rb +336 -366
- data/lib/r509/csr.rb +278 -289
- data/lib/r509/ec-hack.rb +37 -0
- data/lib/r509/exceptions.rb +3 -3
- data/lib/r509/io_helpers.rb +44 -44
- data/lib/r509/message_digest.rb +53 -0
- data/lib/r509/ocsp.rb +80 -70
- data/lib/r509/oid_mapper.rb +32 -0
- data/lib/r509/private_key.rb +228 -0
- data/lib/r509/spki.rb +145 -93
- data/lib/r509/subject.rb +203 -110
- data/lib/r509/validity.rb +70 -68
- data/lib/r509/version.rb +2 -2
- data/r509.yaml +92 -69
- data/spec/asn1_spec.rb +402 -0
- data/spec/cert/extensions_spec.rb +957 -494
- data/spec/cert_spec.rb +382 -307
- data/spec/certificate_authority_spec.rb +668 -250
- data/spec/config_spec.rb +515 -302
- data/spec/crl_spec.rb +197 -198
- data/spec/csr_spec.rb +334 -289
- data/spec/fixtures.rb +247 -171
- data/spec/fixtures/cert1.der +0 -0
- data/spec/fixtures/cert1.pem +0 -0
- data/spec/fixtures/cert1_public_key_modulus.txt +0 -0
- data/spec/fixtures/cert3.p12 +0 -0
- data/spec/fixtures/cert3.pem +0 -0
- data/spec/fixtures/cert3_key.pem +0 -0
- data/spec/fixtures/cert3_key_des3.pem +0 -0
- data/spec/fixtures/cert4.pem +0 -0
- data/spec/fixtures/cert5.pem +0 -0
- data/spec/fixtures/cert6.pem +0 -0
- data/spec/fixtures/cert_expired.pem +0 -0
- data/spec/fixtures/cert_inhibit.pem +24 -0
- data/spec/fixtures/cert_name_constraints.pem +29 -0
- data/spec/fixtures/cert_not_yet_valid.pem +0 -0
- data/spec/fixtures/cert_ocsp_no_check.pem +18 -0
- data/spec/fixtures/cert_policy_constraints.pem +31 -0
- data/spec/fixtures/cert_san.pem +0 -0
- data/spec/fixtures/cert_san2.pem +0 -0
- data/spec/fixtures/cert_unknown_extension.pem +28 -0
- data/spec/fixtures/config_pool_test_minimal.yaml +11 -11
- data/spec/fixtures/config_test.yaml +54 -36
- data/spec/fixtures/config_test_dsa.yaml +35 -0
- data/spec/fixtures/config_test_ec.yaml +35 -0
- data/spec/fixtures/config_test_engine_key.yaml +5 -5
- data/spec/fixtures/config_test_engine_no_key_name.yaml +4 -4
- data/spec/fixtures/config_test_minimal.yaml +4 -4
- data/spec/fixtures/config_test_password.yaml +5 -5
- data/spec/fixtures/config_test_various.yaml +111 -74
- data/spec/fixtures/crl_list_file.txt +0 -0
- data/spec/fixtures/crl_with_reason.pem +0 -0
- data/spec/fixtures/csr1.der +0 -0
- data/spec/fixtures/csr1.pem +0 -0
- data/spec/fixtures/csr1_key.der +0 -0
- data/spec/fixtures/csr1_key.pem +0 -0
- data/spec/fixtures/csr1_key_encrypted_des3.pem +0 -0
- data/spec/fixtures/csr1_newlines.pem +0 -0
- data/spec/fixtures/csr1_no_begin_end.pem +0 -0
- data/spec/fixtures/csr1_public_key_modulus.txt +0 -0
- data/spec/fixtures/csr2.pem +0 -0
- data/spec/fixtures/csr2_key.pem +0 -0
- data/spec/fixtures/csr3.pem +0 -0
- data/spec/fixtures/csr4.pem +0 -0
- data/spec/fixtures/csr_dsa.pem +0 -0
- data/spec/fixtures/csr_invalid_signature.pem +0 -0
- data/spec/fixtures/dsa_key.pem +0 -0
- data/spec/fixtures/dsa_root.cer +28 -0
- data/spec/fixtures/dsa_root.key +20 -0
- data/spec/fixtures/ec_csr2.der +0 -0
- data/spec/fixtures/ec_csr2.pem +8 -0
- data/spec/fixtures/ec_key1.der +0 -0
- data/spec/fixtures/ec_key1.pem +6 -0
- data/spec/fixtures/ec_key1_encrypted.pem +9 -0
- data/spec/fixtures/ec_key2.pem +6 -0
- data/spec/fixtures/hmacsha1.sig +1 -0
- data/spec/fixtures/hmacsha512.sig +1 -0
- data/spec/fixtures/key4.pem +0 -0
- data/spec/fixtures/key4_encrypted_des3.pem +0 -0
- data/spec/fixtures/missing_key_identifier_ca.cer +0 -0
- data/spec/fixtures/missing_key_identifier_ca.key +0 -0
- data/spec/fixtures/ocsptest.r509.local.pem +0 -0
- data/spec/fixtures/ocsptest.r509.local_ocsp_request.der +0 -0
- data/spec/fixtures/ocsptest2.r509.local.pem +0 -0
- data/spec/fixtures/second_ca.cer +0 -0
- data/spec/fixtures/second_ca.key +0 -0
- data/spec/fixtures/spkac.der +0 -0
- data/spec/fixtures/spkac.txt +0 -0
- data/spec/fixtures/spkac_dsa.txt +1 -1
- data/spec/fixtures/spkac_dsa_no_verify.txt +1 -0
- data/spec/fixtures/spkac_ec.txt +1 -0
- data/spec/fixtures/spkac_rsa_newlines.txt +13 -0
- data/spec/fixtures/stca.pem +0 -0
- data/spec/fixtures/stca_ocsp_request.der +0 -0
- data/spec/fixtures/stca_ocsp_response.der +0 -0
- data/spec/fixtures/test1.csr +0 -0
- data/spec/fixtures/test_ca.cer +0 -0
- data/spec/fixtures/test_ca.key +0 -0
- data/spec/fixtures/test_ca.p12 +0 -0
- data/spec/fixtures/test_ca_des3.key +0 -0
- data/spec/fixtures/test_ca_ec.cer +14 -0
- data/spec/fixtures/test_ca_ec.key +6 -0
- data/spec/fixtures/test_ca_ec_ee.cer +22 -0
- data/spec/fixtures/test_ca_ec_ee.key +6 -0
- data/spec/fixtures/test_ca_ocsp.cer +0 -0
- data/spec/fixtures/test_ca_ocsp.key +0 -0
- data/spec/fixtures/test_ca_ocsp.p12 +0 -0
- data/spec/fixtures/test_ca_ocsp_chain.txt +0 -0
- data/spec/fixtures/test_ca_ocsp_response.der +0 -0
- data/spec/fixtures/test_ca_subroot.cer +0 -0
- data/spec/fixtures/test_ca_subroot.key +0 -0
- data/spec/fixtures/test_ca_subroot_ocsp.cer +0 -0
- data/spec/fixtures/test_ca_subroot_ocsp.key +0 -0
- data/spec/fixtures/test_ca_subroot_ocsp_response.der +0 -0
- data/spec/fixtures/unknown_oid.csr +0 -0
- data/spec/message_digest_spec.rb +104 -84
- data/spec/ocsp_spec.rb +105 -105
- data/spec/oid_mapper_spec.rb +21 -21
- data/spec/private_key_spec.rb +275 -0
- data/spec/r509_spec.rb +35 -0
- data/spec/spec_helper.rb +15 -6
- data/spec/spki_spec.rb +221 -142
- data/spec/subject_spec.rb +232 -164
- data/spec/validity_spec.rb +91 -91
- metadata +79 -25
- data/doc/R509/Config/CaProfile.html +0 -651
- data/doc/R509/Crl/Administrator.html +0 -2073
- data/lib/r509/certificateauthority.rb +0 -290
- data/lib/r509/messagedigest.rb +0 -49
- data/lib/r509/oidmapper.rb +0 -32
- data/lib/r509/privatekey.rb +0 -185
- data/spec/privatekey_spec.rb +0 -198
data/doc/R509/Subject.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: R509::Subject
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.
|
9
|
+
— Documentation by YARD 0.8.5
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -110,6 +110,29 @@ fashion</p>
|
|
110
110
|
</div>
|
111
111
|
<div class="tags">
|
112
112
|
|
113
|
+
<div class="examples">
|
114
|
+
<p class="tag_title">Examples:</p>
|
115
|
+
|
116
|
+
|
117
|
+
<pre class="example code"><code><span class='id identifier rubyid_subject'>subject</span> <span class='op'>=</span> <span class='const'>R509</span><span class='op'>::</span><span class='const'>Subject</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
118
|
+
<span class='id identifier rubyid_subject'>subject</span><span class='period'>.</span><span class='const'>CN</span><span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>test.test</span><span class='tstring_end'>"</span></span>
|
119
|
+
<span class='id identifier rubyid_subject'>subject</span><span class='period'>.</span><span class='id identifier rubyid_organization'>organization</span><span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>r509 LLC</span><span class='tstring_end'>"</span></span></code></pre>
|
120
|
+
|
121
|
+
|
122
|
+
<pre class="example code"><code><span class='id identifier rubyid_subject'>subject</span> <span class='op'>=</span> <span class='const'>R509</span><span class='op'>::</span><span class='const'>Subject</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>CN</span><span class='tstring_end'>'</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>test.test</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>O</span><span class='tstring_end'>'</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>r509 LLC</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='rparen'>)</span></code></pre>
|
123
|
+
|
124
|
+
|
125
|
+
<pre class="example code"><code><span class='comment'># you can also use the friendly getter/setters with custom OIDs
|
126
|
+
</span><span class='const'>R509</span><span class='op'>::</span><span class='const'>OIDMapper</span><span class='period'>.</span><span class='id identifier rubyid_register'>register</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>1.2.3.4.5.6.7.8</span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>COI</span><span class='tstring_end'>"</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>customOID</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
127
|
+
<span class='id identifier rubyid_subject'>subject</span> <span class='op'>=</span> <span class='const'>R509</span><span class='op'>::</span><span class='const'>Subject</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
128
|
+
<span class='id identifier rubyid_subject'>subject</span><span class='period'>.</span><span class='const'>COI</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>test</span><span class='tstring_end'>"</span></span>
|
129
|
+
<span class='comment'># or
|
130
|
+
</span><span class='id identifier rubyid_subject'>subject</span><span class='period'>.</span><span class='id identifier rubyid_customOID'>customOID</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>test</span><span class='tstring_end'>"</span></span>
|
131
|
+
<span class='comment'># or
|
132
|
+
</span><span class='id identifier rubyid_subject'>subject</span><span class='period'>.</span><span class='id identifier rubyid_custom_oid'>custom_oid</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>test</span><span class='tstring_end'>"</span></span></code></pre>
|
133
|
+
|
134
|
+
</div>
|
135
|
+
|
113
136
|
|
114
137
|
</div>
|
115
138
|
|
@@ -284,7 +307,7 @@ fashion</p>
|
|
284
307
|
|
285
308
|
|
286
309
|
<span class="summary_desc"><div class='inline'>
|
287
|
-
<p>Array of form [['
|
310
|
+
<p>Array of form [['CN','langui.sh']].</p>
|
288
311
|
</div></span>
|
289
312
|
|
290
313
|
</li>
|
@@ -346,7 +369,7 @@ fashion</p>
|
|
346
369
|
<span class='name'>arg</span>
|
347
370
|
|
348
371
|
|
349
|
-
<span class='type'>(<tt>Array</tt>, <tt>OpenSSL::X509::Name</tt>, <tt><span class='object_link'><a href="" title="R509::Subject (class)">R509::Subject</a></span></tt>)</span>
|
372
|
+
<span class='type'>(<tt>Array</tt>, <tt>OpenSSL::X509::Name</tt>, <tt><span class='object_link'><a href="" title="R509::Subject (class)">R509::Subject</a></span></tt>, <tt>DER</tt>, <tt>nil</tt>)</span>
|
350
373
|
|
351
374
|
|
352
375
|
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
@@ -363,41 +386,129 @@ fashion</p>
|
|
363
386
|
<pre class="lines">
|
364
387
|
|
365
388
|
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
389
|
+
22
|
390
|
+
23
|
391
|
+
24
|
392
|
+
25
|
393
|
+
26
|
394
|
+
27
|
395
|
+
28
|
396
|
+
29
|
397
|
+
30
|
398
|
+
31
|
399
|
+
32
|
400
|
+
33
|
401
|
+
34
|
402
|
+
35
|
403
|
+
36
|
404
|
+
37
|
405
|
+
38
|
406
|
+
39</pre>
|
382
407
|
</td>
|
383
408
|
<td>
|
384
|
-
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line
|
409
|
+
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line 22</span>
|
385
410
|
|
386
411
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='op'>=</span><span class='kw'>nil</span><span class='rparen'>)</span>
|
387
|
-
|
388
|
-
<span class='
|
389
|
-
|
390
|
-
<span class='
|
391
|
-
|
392
|
-
|
393
|
-
<span class='
|
394
|
-
|
395
|
-
<span class='
|
396
|
-
|
412
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_arg'>arg</span><span class='period'>.</span><span class='id identifier rubyid_kind_of?'>kind_of?</span><span class='lparen'>(</span><span class='const'>Array</span><span class='rparen'>)</span>
|
413
|
+
<span class='ivar'>@array</span> <span class='op'>=</span> <span class='id identifier rubyid_arg'>arg</span>
|
414
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_arg'>arg</span><span class='period'>.</span><span class='id identifier rubyid_kind_of?'>kind_of?</span><span class='lparen'>(</span><span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>X509</span><span class='op'>::</span><span class='const'>Name</span><span class='rparen'>)</span>
|
415
|
+
<span class='id identifier rubyid_sanitizer'>sanitizer</span> <span class='op'>=</span> <span class='const'>R509</span><span class='op'>::</span><span class='const'>NameSanitizer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
416
|
+
<span class='ivar'>@array</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitizer'>sanitizer</span><span class='period'>.</span><span class='id identifier rubyid_sanitize'>sanitize</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='rparen'>)</span>
|
417
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_arg'>arg</span><span class='period'>.</span><span class='id identifier rubyid_kind_of?'>kind_of?</span><span class='lparen'>(</span><span class='const'>R509</span><span class='op'>::</span><span class='const'>Subject</span><span class='rparen'>)</span>
|
418
|
+
<span class='ivar'>@array</span> <span class='op'>=</span> <span class='id identifier rubyid_arg'>arg</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
|
419
|
+
<span class='kw'>else</span>
|
420
|
+
<span class='ivar'>@array</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
|
421
|
+
<span class='kw'>if</span> <span class='kw'>not</span> <span class='lparen'>(</span><span class='kw'>begin</span> <span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>ASN1</span><span class='period'>.</span><span class='id identifier rubyid_decode'>decode</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='rparen'>)</span> <span class='kw'>rescue</span> <span class='kw'>nil</span> <span class='kw'>end</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
422
|
+
<span class='id identifier rubyid_parse_asn1'>parse_asn1</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='rparen'>)</span>
|
397
423
|
<span class='kw'>end</span>
|
424
|
+
<span class='kw'>end</span>
|
398
425
|
|
399
|
-
|
400
|
-
</span>
|
426
|
+
<span class='comment'># see if X509 thinks this is okay
|
427
|
+
</span> <span class='id identifier rubyid_name'>name</span>
|
428
|
+
<span class='kw'>end</span></pre>
|
429
|
+
</td>
|
430
|
+
</tr>
|
431
|
+
</table>
|
432
|
+
</div>
|
433
|
+
|
434
|
+
</div>
|
435
|
+
<div id="method_missing_details" class="method_details_list">
|
436
|
+
<h2>Dynamic Method Handling</h2>
|
437
|
+
<p class="notice this">
|
438
|
+
This class handles dynamic methods through the <tt>method_missing</tt> method
|
439
|
+
|
440
|
+
</p>
|
441
|
+
|
442
|
+
<div class="method_details first">
|
443
|
+
<h3 class="signature first" id="method_missing-instance_method">
|
444
|
+
|
445
|
+
- (<tt>Object</tt>) <strong>method_missing</strong>(method_sym, *args, &block) <span class="extras">(private)</span>
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
</h3><div class="docstring">
|
452
|
+
<div class="discussion">
|
453
|
+
|
454
|
+
<p>Try to build methods for getting/setting various subject attributes
|
455
|
+
dynamically. this will also cache methods that get built via instance_eval.
|
456
|
+
This code will also allow you to set subject items for custom oids defined
|
457
|
+
via R509::OIDMapper</p>
|
458
|
+
|
459
|
+
|
460
|
+
</div>
|
461
|
+
</div>
|
462
|
+
<div class="tags">
|
463
|
+
|
464
|
+
|
465
|
+
</div><table class="source_code">
|
466
|
+
<tr>
|
467
|
+
<td>
|
468
|
+
<pre class="lines">
|
469
|
+
|
470
|
+
|
471
|
+
118
|
472
|
+
119
|
473
|
+
120
|
474
|
+
121
|
475
|
+
122
|
476
|
+
123
|
477
|
+
124
|
478
|
+
125
|
479
|
+
126
|
480
|
+
127
|
481
|
+
128
|
482
|
+
129
|
483
|
+
130
|
484
|
+
131
|
485
|
+
132
|
486
|
+
133
|
487
|
+
134
|
488
|
+
135
|
489
|
+
136</pre>
|
490
|
+
</td>
|
491
|
+
<td>
|
492
|
+
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line 118</span>
|
493
|
+
|
494
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_method_missing'>method_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_method_sym'>method_sym</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
495
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_method_sym'>method_sym</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(.*)=$</span><span class='regexp_end'>/</span></span>
|
496
|
+
<span class='id identifier rubyid_sn'>sn</span> <span class='op'>=</span> <span class='id identifier rubyid_oid_check'>oid_check</span><span class='lparen'>(</span><span class='backref'>$1</span><span class='rparen'>)</span>
|
497
|
+
<span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_sn'>sn</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
498
|
+
<span class='id identifier rubyid_define_dynamic_setter'>define_dynamic_setter</span><span class='lparen'>(</span><span class='id identifier rubyid_method_sym'>method_sym</span><span class='comma'>,</span><span class='id identifier rubyid_sn'>sn</span><span class='rparen'>)</span>
|
499
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_method_sym'>method_sym</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span>
|
500
|
+
<span class='kw'>else</span>
|
501
|
+
<span class='kw'>return</span> <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_method_sym'>method_sym</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
502
|
+
<span class='kw'>end</span>
|
503
|
+
<span class='kw'>else</span>
|
504
|
+
<span class='id identifier rubyid_sn'>sn</span> <span class='op'>=</span> <span class='id identifier rubyid_oid_check'>oid_check</span><span class='lparen'>(</span><span class='id identifier rubyid_method_sym'>method_sym</span><span class='rparen'>)</span>
|
505
|
+
<span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_sn'>sn</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
506
|
+
<span class='id identifier rubyid_define_dynamic_getter'>define_dynamic_getter</span><span class='lparen'>(</span><span class='id identifier rubyid_method_sym'>method_sym</span><span class='comma'>,</span><span class='id identifier rubyid_sn'>sn</span><span class='rparen'>)</span>
|
507
|
+
<span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_method_sym'>method_sym</span><span class='rparen'>)</span>
|
508
|
+
<span class='kw'>else</span>
|
509
|
+
<span class='kw'>return</span> <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_method_sym'>method_sym</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
510
|
+
<span class='kw'>end</span>
|
511
|
+
<span class='kw'>end</span>
|
401
512
|
<span class='kw'>end</span></pre>
|
402
513
|
</td>
|
403
514
|
</tr>
|
@@ -437,25 +548,25 @@ fashion</p>
|
|
437
548
|
<pre class="lines">
|
438
549
|
|
439
550
|
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
551
|
+
52
|
552
|
+
53
|
553
|
+
54
|
554
|
+
55
|
555
|
+
56
|
556
|
+
57
|
557
|
+
58
|
558
|
+
59</pre>
|
448
559
|
</td>
|
449
560
|
<td>
|
450
|
-
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line
|
561
|
+
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line 52</span>
|
451
562
|
|
452
563
|
<span class='kw'>def</span> <span class='op'>[]</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
<span class='kw'>end</span>
|
564
|
+
<span class='ivar'>@array</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
|
565
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_key'>key</span> <span class='op'>==</span> <span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
|
566
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
457
567
|
<span class='kw'>end</span>
|
458
|
-
|
568
|
+
<span class='kw'>end</span>
|
569
|
+
<span class='kw'>return</span> <span class='kw'>nil</span>
|
459
570
|
<span class='kw'>end</span></pre>
|
460
571
|
</td>
|
461
572
|
</tr>
|
@@ -488,49 +599,49 @@ fashion</p>
|
|
488
599
|
<pre class="lines">
|
489
600
|
|
490
601
|
|
491
|
-
45
|
492
|
-
46
|
493
|
-
47
|
494
|
-
48
|
495
|
-
49
|
496
|
-
50
|
497
|
-
51
|
498
|
-
52
|
499
|
-
53
|
500
|
-
54
|
501
|
-
55
|
502
|
-
56
|
503
|
-
57
|
504
|
-
58
|
505
|
-
59
|
506
|
-
60
|
507
|
-
61
|
508
602
|
62
|
509
603
|
63
|
510
|
-
64
|
604
|
+
64
|
605
|
+
65
|
606
|
+
66
|
607
|
+
67
|
608
|
+
68
|
609
|
+
69
|
610
|
+
70
|
611
|
+
71
|
612
|
+
72
|
613
|
+
73
|
614
|
+
74
|
615
|
+
75
|
616
|
+
76
|
617
|
+
77
|
618
|
+
78
|
619
|
+
79
|
620
|
+
80
|
621
|
+
81</pre>
|
511
622
|
</td>
|
512
623
|
<td>
|
513
|
-
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line
|
624
|
+
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line 62</span>
|
514
625
|
|
515
626
|
<span class='kw'>def</span> <span class='op'>[]=</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
<span class='kw'>end</span>
|
524
|
-
<span class='rbrace'>}</span>
|
525
|
-
|
526
|
-
<span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_added'>added</span>
|
527
|
-
<span class='ivar'>@array</span> <span class='op'><<</span> <span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rbracket'>]</span>
|
627
|
+
<span class='id identifier rubyid_added'>added</span> <span class='op'>=</span> <span class='kw'>false</span>
|
628
|
+
<span class='ivar'>@array</span> <span class='op'>=</span> <span class='ivar'>@array</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
|
629
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_key'>key</span> <span class='op'>==</span> <span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
|
630
|
+
<span class='id identifier rubyid_added'>added</span> <span class='op'>=</span> <span class='kw'>true</span>
|
631
|
+
<span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rbracket'>]</span>
|
632
|
+
<span class='kw'>else</span>
|
633
|
+
<span class='id identifier rubyid_item'>item</span>
|
528
634
|
<span class='kw'>end</span>
|
635
|
+
<span class='rbrace'>}</span>
|
636
|
+
|
637
|
+
<span class='kw'>if</span> <span class='kw'>not</span> <span class='id identifier rubyid_added'>added</span>
|
638
|
+
<span class='ivar'>@array</span> <span class='op'><<</span> <span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rbracket'>]</span>
|
639
|
+
<span class='kw'>end</span>
|
529
640
|
|
530
|
-
|
531
|
-
</span>
|
641
|
+
<span class='comment'># see if X509 thinks this is okay
|
642
|
+
</span> <span class='id identifier rubyid_name'>name</span>
|
532
643
|
|
533
|
-
|
644
|
+
<span class='ivar'>@array</span>
|
534
645
|
<span class='kw'>end</span></pre>
|
535
646
|
</td>
|
536
647
|
</tr>
|
@@ -581,19 +692,19 @@ fashion</p>
|
|
581
692
|
<pre class="lines">
|
582
693
|
|
583
694
|
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
695
|
+
84
|
696
|
+
85
|
697
|
+
86
|
698
|
+
87
|
699
|
+
88</pre>
|
589
700
|
</td>
|
590
701
|
<td>
|
591
|
-
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line
|
702
|
+
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line 84</span>
|
592
703
|
|
593
704
|
<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
594
|
-
|
595
|
-
|
596
|
-
|
705
|
+
<span class='ivar'>@array</span> <span class='op'>=</span> <span class='ivar'>@array</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
|
706
|
+
<span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>!=</span> <span class='id identifier rubyid_key'>key</span>
|
707
|
+
<span class='kw'>end</span>
|
597
708
|
<span class='kw'>end</span></pre>
|
598
709
|
</td>
|
599
710
|
</tr>
|
@@ -637,15 +748,15 @@ fashion</p>
|
|
637
748
|
<pre class="lines">
|
638
749
|
|
639
750
|
|
640
|
-
|
641
|
-
|
642
|
-
|
751
|
+
47
|
752
|
+
48
|
753
|
+
49</pre>
|
643
754
|
</td>
|
644
755
|
<td>
|
645
|
-
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line
|
756
|
+
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line 47</span>
|
646
757
|
|
647
758
|
<span class='kw'>def</span> <span class='id identifier rubyid_empty?'>empty?</span>
|
648
|
-
|
759
|
+
<span class='ivar'>@array</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
649
760
|
<span class='kw'>end</span></pre>
|
650
761
|
</td>
|
651
762
|
</tr>
|
@@ -689,15 +800,15 @@ fashion</p>
|
|
689
800
|
<pre class="lines">
|
690
801
|
|
691
802
|
|
692
|
-
|
693
|
-
|
694
|
-
|
803
|
+
42
|
804
|
+
43
|
805
|
+
44</pre>
|
695
806
|
</td>
|
696
807
|
<td>
|
697
|
-
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line
|
808
|
+
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line 42</span>
|
698
809
|
|
699
810
|
<span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
|
700
|
-
|
811
|
+
<span class='const'>OpenSSL</span><span class='op'>::</span><span class='const'>X509</span><span class='op'>::</span><span class='const'>Name</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@array</span><span class='rparen'>)</span>
|
701
812
|
<span class='kw'>end</span></pre>
|
702
813
|
</td>
|
703
814
|
</tr>
|
@@ -716,7 +827,7 @@ fashion</p>
|
|
716
827
|
</h3><div class="docstring">
|
717
828
|
<div class="discussion">
|
718
829
|
|
719
|
-
<p>Array of form [['
|
830
|
+
<p>Array of form [['CN','langui.sh']]</p>
|
720
831
|
|
721
832
|
|
722
833
|
</div>
|
@@ -735,7 +846,7 @@ fashion</p>
|
|
735
846
|
|
736
847
|
—
|
737
848
|
<div class='inline'>
|
738
|
-
<p>Array of form [['
|
849
|
+
<p>Array of form [['CN','langui.sh']]</p>
|
739
850
|
</div>
|
740
851
|
|
741
852
|
</li>
|
@@ -748,15 +859,15 @@ fashion</p>
|
|
748
859
|
<pre class="lines">
|
749
860
|
|
750
861
|
|
751
|
-
|
752
|
-
|
753
|
-
|
862
|
+
96
|
863
|
+
97
|
864
|
+
98</pre>
|
754
865
|
</td>
|
755
866
|
<td>
|
756
|
-
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line
|
867
|
+
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line 96</span>
|
757
868
|
|
758
869
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_a'>to_a</span>
|
759
|
-
|
870
|
+
<span class='ivar'>@array</span>
|
760
871
|
<span class='kw'>end</span></pre>
|
761
872
|
</td>
|
762
873
|
</tr>
|
@@ -807,15 +918,15 @@ fashion</p>
|
|
807
918
|
<pre class="lines">
|
808
919
|
|
809
920
|
|
810
|
-
|
811
|
-
|
812
|
-
|
921
|
+
91
|
922
|
+
92
|
923
|
+
93</pre>
|
813
924
|
</td>
|
814
925
|
<td>
|
815
|
-
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line
|
926
|
+
<pre class="code"><span class="info file"># File 'lib/r509/subject.rb', line 91</span>
|
816
927
|
|
817
928
|
<span class='kw'>def</span> <span class='id identifier rubyid_to_s'>to_s</span>
|
818
|
-
|
929
|
+
<span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
819
930
|
<span class='kw'>end</span></pre>
|
820
931
|
</td>
|
821
932
|
</tr>
|
@@ -827,9 +938,9 @@ fashion</p>
|
|
827
938
|
</div>
|
828
939
|
|
829
940
|
<div id="footer">
|
830
|
-
Generated on
|
941
|
+
Generated on Tue Apr 16 10:49:57 2013 by
|
831
942
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
832
|
-
0.8.
|
943
|
+
0.8.5 (ruby-1.9.3).
|
833
944
|
</div>
|
834
945
|
|
835
946
|
</body>
|