Class: OMF::SFA::AM::UserCredential
- Inherits:
-
Base::LObject
- Object
- Base::LObject
- OMF::SFA::AM::UserCredential
- Includes:
- Resource
- Defined in:
- lib/omf-sfa/am/user_credential.rb
Instance Attribute Summary collapse
-
#user_urn ⇒ Object
readonly
Returns the value of attribute user_urn.
-
#user_uuid ⇒ Object
readonly
Returns the value of attribute user_uuid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(cert) ⇒ UserCredential
constructor
A new instance of UserCredential.
- #subject ⇒ Object
- #valid_at?(time = Time.now) ⇒ Boolean
Constructor Details
#initialize(cert) ⇒ UserCredential
Returns a new instance of UserCredential.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/omf-sfa/am/user_credential.rb', line 20 def initialize(cert) @cert = cert @cert.extensions.each do |e| if e.oid == 'subjectAltName' #URI:urn:publicid:IDN+topdomain:subdomain+user+pi, URI:urn:uuid:759ae077-2fda-4d02-8921-ab0235a09920 e.value.split(',').each do |u| u.slice!('URI:') @user_urn = u.strip if u.start_with?('urn:publicid:IDN') @user_uuid = u.match(/^urn:uuid:(.*)/)[1] if u.start_with?('urn:uuid') end #e.value.split('URI:urn:').each do |u| # str = u.split('+') # if str.include?('publicid:IDN') # @user_urn = str[-3..-1].join('+').chomp(', ') # end # str = u.split(':') # if str.include?('uuid') # @user_uuid = str.last # end #end end end end |
Instance Attribute Details
#user_urn ⇒ Object (readonly)
Returns the value of attribute user_urn.
9 10 11 |
# File 'lib/omf-sfa/am/user_credential.rb', line 9 def user_urn @user_urn end |
#user_uuid ⇒ Object (readonly)
Returns the value of attribute user_uuid.
9 10 11 |
# File 'lib/omf-sfa/am/user_credential.rb', line 9 def user_uuid @user_uuid end |
Class Method Details
.unmarshall(cert_s) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/omf-sfa/am/user_credential.rb', line 11 def self.unmarshall(cert_s) cert = OpenSSL::X509::Certificate.new(cert_s) #puts cert unless OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE.verify(cert) raise OMF::SFA::AM::InsufficientPrivilegesException.new("Non valid user cert") end self.new(cert) end |
Instance Method Details
#subject ⇒ Object
45 46 47 |
# File 'lib/omf-sfa/am/user_credential.rb', line 45 def subject @cert.subject end |
#valid_at?(time = Time.now) ⇒ Boolean
49 50 51 52 |
# File 'lib/omf-sfa/am/user_credential.rb', line 49 def valid_at?(time = Time.now) debug "valid? #{@cert.not_before} < #{time} < #{@cert.not_after}" time >= @cert.not_before && time <= @cert.not_after end |