Class: Saml::Kit::Certificate

Inherits:
Object
  • Object
show all
Defined in:
lib/saml/kit/certificate.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, use:) ⇒ Certificate

Returns a new instance of Certificate.



6
7
8
9
# File 'lib/saml/kit/certificate.rb', line 6

def initialize(value, use:)
  @value = value
  @use = use.downcase.to_sym
end

Instance Attribute Details

#use ⇒ Object (readonly)

Returns the value of attribute use.



4
5
6
# File 'lib/saml/kit/certificate.rb', line 4

def use
  @use
end

#value ⇒ Object (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/saml/kit/certificate.rb', line 4

def value
  @value
end

Class Method Details

.to_x509(value) ⇒ Object



51
52
53
54
55
56
# File 'lib/saml/kit/certificate.rb', line 51

def self.to_x509(value)
  OpenSSL::X509::Certificate.new(Base64.decode64(value))
rescue OpenSSL::X509::CertificateError => error
  Saml::Kit.logger.warn(error)
  OpenSSL::X509::Certificate.new(value)
end

Instance Method Details

#==(other) ⇒ Object



35
36
37
# File 'lib/saml/kit/certificate.rb', line 35

def ==(other)
  self.to_s == other.to_s
end

#encryption? ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/saml/kit/certificate.rb', line 19

def encryption?
  :encryption == use
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/saml/kit/certificate.rb', line 39

def eql?(other)
  self == other
end

#fingerprint ⇒ Object



11
12
13
# File 'lib/saml/kit/certificate.rb', line 11

def fingerprint
  Fingerprint.new(value)
end

#for?(use) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/saml/kit/certificate.rb', line 15

def for?(use)
  self.use == use.to_sym
end

#hash ⇒ Object



43
44
45
# File 'lib/saml/kit/certificate.rb', line 43

def hash
  value.hash
end

#public_key ⇒ Object



31
32
33
# File 'lib/saml/kit/certificate.rb', line 31

def public_key
  x509.public_key
end

#signing? ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/saml/kit/certificate.rb', line 23

def signing?
  :signing == use
end

#to_s ⇒ Object



47
48
49
# File 'lib/saml/kit/certificate.rb', line 47

def to_s
  value
end

#x509 ⇒ Object



27
28
29
# File 'lib/saml/kit/certificate.rb', line 27

def x509
  self.class.to_x509(value)
end