Module: Moxml::Signature::Algorithms
- Defined in:
- lib/moxml/signature/algorithms.rb,
lib/moxml/signature/algorithms/sha1.rb,
lib/moxml/signature/algorithms/sha224.rb,
lib/moxml/signature/algorithms/sha256.rb,
lib/moxml/signature/algorithms/sha384.rb,
lib/moxml/signature/algorithms/sha512.rb,
lib/moxml/signature/algorithms/dsa_sha.rb,
lib/moxml/signature/algorithms/hmac_sha.rb,
lib/moxml/signature/algorithms/ecdsa_sha.rb,
lib/moxml/signature/algorithms/digest_base.rb,
lib/moxml/signature/algorithms/exc_c14n_10.rb,
lib/moxml/signature/algorithms/rsa_pkcs1_sha.rb,
lib/moxml/signature/algorithms/transform_base.rb,
lib/moxml/signature/algorithms/base64_transform.rb,
lib/moxml/signature/algorithms/inclusive_c14n_10.rb,
lib/moxml/signature/algorithms/inclusive_c14n_11.rb,
lib/moxml/signature/algorithms/canonicalization_base.rb,
lib/moxml/signature/algorithms/signature_method_base.rb,
lib/moxml/signature/algorithms/enveloped_signature_transform.rb
Overview
Open-closed registry of W3C XML Signature algorithms keyed by URI.
Adding a new algorithm:
1. Subclass the relevant base (DigestBase, SignatureMethodBase, etc.)
2. Declare `identifier "http://..."` on the subclass.
3. Add an autoload entry below and a reference in `load_builtins!`.
No edits to existing classes are required to add a new algorithm.
Defined Under Namespace
Classes: Base64Transform, CanonicalizationBase, DigestBase, DsaSha, EcdsaSha, EnvelopedSignatureTransform, ExcC14n10, HmacSha, InclusiveC14n10, InclusiveC14n11, RsaPkcs1Sha, SHA1, SHA224, SHA256, SHA384, SHA512, SignatureMethodBase, TransformBase
Constant Summary collapse
- CATEGORIES =
%i[digest signature_method canonicalization transform].freeze
Class Method Summary collapse
- .[](category) ⇒ Object
-
.load_builtins! ⇒ Object
Forces autoload of every built-in algorithm class so that self-registration runs.
- .lookup(category, uri) ⇒ Object
- .register(category, uri, klass) ⇒ Object
- .registered?(category, uri) ⇒ Boolean
- .registry ⇒ Object
Class Method Details
.[](category) ⇒ Object
38 39 40 41 |
# File 'lib/moxml/signature/algorithms.rb', line 38 def [](category) validate_category!(category) registry[category] end |
.load_builtins! ⇒ Object
Forces autoload of every built-in algorithm class so that
self-registration runs. Pure autoload — no require calls.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/moxml/signature/algorithms.rb', line 45 def load_builtins! return if @builtins_loaded # Digests SHA1 SHA224 SHA256 SHA384 SHA512 # Signature methods RsaPkcs1Sha HmacSha EcdsaSha DsaSha # Canonicalization ExcC14n10 InclusiveC14n10 InclusiveC14n11 # Transforms Base64Transform EnvelopedSignatureTransform @builtins_loaded = true end |
.lookup(category, uri) ⇒ Object
27 28 29 30 31 |
# File 'lib/moxml/signature/algorithms.rb', line 27 def lookup(category, uri) load_builtins! unless @builtins_loaded registry[category][uri] || raise(UnknownAlgorithm.new(category, uri)) end |
.register(category, uri, klass) ⇒ Object
21 22 23 24 25 |
# File 'lib/moxml/signature/algorithms.rb', line 21 def register(category, uri, klass) validate_category!(category) registry[category][uri] = klass klass end |
.registered?(category, uri) ⇒ Boolean
33 34 35 36 |
# File 'lib/moxml/signature/algorithms.rb', line 33 def registered?(category, uri) load_builtins! unless @builtins_loaded registry[category].key?(uri) end |
.registry ⇒ Object
17 18 19 |
# File 'lib/moxml/signature/algorithms.rb', line 17 def registry @registry ||= CATEGORIES.to_h { |c| [c, {}] } end |