Commit 727a70d
Changed files (1)
lib
saml
kit
lib/saml/kit/certificate.rb
@@ -3,33 +3,51 @@ module Saml
class Certificate
BEGIN_CERT=/-----BEGIN CERTIFICATE-----/
END_CERT=/-----END CERTIFICATE-----/
- attr_reader :value, :use
+ # The use can be `:signing` or `:encryption`
+ attr_reader :use
def initialize(value, use:)
@value = value
@use = use.downcase.to_sym
end
+ # @return [Saml::Kit::Fingerprint] the certificate fingerprint.
def fingerprint
Fingerprint.new(value)
end
+ # Returns true if this certificate is for the specified use.
+ #
+ # @param use [Symbol] `:signing` or `:encryption`.
+ # @return [Boolean] true or false.
def for?(use)
self.use == use.to_sym
end
+ # Returns true if this certificate is used for encryption.
+ #
+ # return [Boolean] true or false.
def encryption?
for?(:encryption)
end
+ # Returns true if this certificate is used for signing.
+ #
+ # return [Boolean] true or false.
def signing?
for?(:signing)
end
+ # Returns the x509 form.
+ #
+ # return [OpenSSL::X509::Certificate] the OpenSSL equivalent.
def x509
self.class.to_x509(value)
end
+ # Returns the public key.
+ #
+ # @return [OpenSSL::PKey::RSA] the RSA public key.
def public_key
x509.public_key
end
@@ -68,6 +86,10 @@ module Saml
Saml::Kit.logger.warn(error)
OpenSSL::X509::Certificate.new(value)
end
+
+ private
+
+ attr_reader :value
end
end
end