Sha256: d4ad0adb8074c401f8e49e7a125a0753966db9019c9be01b3d0a9a192a8c4f16

Contents?: true

Size: 488 Bytes

Versions: 43

Compression:

Stored size: 488 Bytes

Contents

require 'openssl'

# Store OStatus private and public key
class ActorKey < ActiveRecord::Base
  KEY_SIZE = 1024

  belongs_to :actor

  validates_presence_of :key_der

  before_validation :generate_key, on: :create

  def key
    @key ||=
      OpenSSL::PKey::RSA.new(key_der)
  end

  def key= new_key
    @key = new_key
    self.key_der = new_key.to_der
  end

  private

  def generate_key
    return if key_der.present?

    self.key = OpenSSL::PKey::RSA.generate(KEY_SIZE)
  end
end

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
social_stream-2.2.2 ostatus/app/models/actor_key.rb
social_stream-ostatus-2.2.1 app/models/actor_key.rb
social_stream-2.2.1 ostatus/app/models/actor_key.rb
social_stream-2.2.0 ostatus/app/models/actor_key.rb
social_stream-ostatus-2.2.0 app/models/actor_key.rb
social_stream-2.1.1 ostatus/app/models/actor_key.rb
social_stream-1.1.12 ostatus/app/models/actor_key.rb
social_stream-2.1.0 ostatus/app/models/actor_key.rb
social_stream-ostatus-2.1.0 app/models/actor_key.rb
social_stream-2.0.4 ostatus/app/models/actor_key.rb
social_stream-2.0.3 ostatus/app/models/actor_key.rb
social_stream-1.1.11 ostatus/app/models/actor_key.rb
social_stream-1.1.10 ostatus/app/models/actor_key.rb
social_stream-1.1.9 ostatus/app/models/actor_key.rb
social_stream-ostatus-1.1.1 app/models/actor_key.rb
social_stream-1.1.8 ostatus/app/models/actor_key.rb
social_stream-2.0.2 ostatus/app/models/actor_key.rb
social_stream-2.0.1 ostatus/app/models/actor_key.rb
social_stream-2.0.0 ostatus/app/models/actor_key.rb
social_stream-ostatus-2.0.0 app/models/actor_key.rb