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.0.0.beta3 ostatus/app/models/actor_key.rb
social_stream-ostatus-2.0.0.beta3 app/models/actor_key.rb
social_stream-2.0.0.beta2 ostatus/app/models/actor_key.rb
social_stream-ostatus-2.0.0.beta2 app/models/actor_key.rb
social_stream-2.0.0.beta1 ostatus/app/models/actor_key.rb
social_stream-ostatus-2.0.0.beta1 app/models/actor_key.rb
social_stream-1.1.7 ostatus/app/models/actor_key.rb
social_stream-1.1.6 ostatus/app/models/actor_key.rb
social_stream-1.1.5 ostatus/app/models/actor_key.rb
social_stream-1.1.4 ostatus/app/models/actor_key.rb
social_stream-1.1.3 ostatus/app/models/actor_key.rb
social_stream-1.1.2 ostatus/app/models/actor_key.rb
social_stream-1.1.1 ostatus/app/models/actor_key.rb
social_stream-1.1.0 ostatus/app/models/actor_key.rb
social_stream-ostatus-1.1.0 app/models/actor_key.rb
social_stream-1.0.1 ostatus/app/models/actor_key.rb
social_stream-ostatus-1.0.0 app/models/actor_key.rb
social_stream-0.30.2 ostatus/app/models/actor_key.rb
social_stream-0.30.1 ostatus/app/models/actor_key.rb
social_stream-0.30.0 ostatus/app/models/actor_key.rb