Sha256: e9d650cc6c4cf7d7e82001664447ccd3bbd6b68e60aea3bf9e0a64d872d0457c

Contents?: true

Size: 1.25 KB

Versions: 12

Compression:

Stored size: 1.25 KB

Contents

# ********** Copyright Viacom, Inc. Apache 2.0 **********

module RokuBuilder

  # Change or get dev key
  class Keyer < Util

    # Sets the key on the roku device
    # @param keyed_pkg [String] Path for a package signed with the desired key
    # @param password [String] Password for the package
    # @return [Boolean] True if key changed, false otherwise
    def rekey(keyed_pkg:, password:)
      oldId = dev_id

      # upload new key with password
      path = "/plugin_inspect"
      conn = multipart_connection
      payload =  {
        mysubmit: "Rekey",
        passwd: password,
        archive: Faraday::UploadIO.new(keyed_pkg, 'application/octet-stream')
      }
      conn.post path, payload

      # check key
      newId = dev_id
      @logger.info("Key did not change") unless newId != oldId
      newId != oldId
    end

    # Get the current dev id
    # @return [String] The current dev id
    def dev_id
      path = "/plugin_package"
      conn = simple_connection
      response = conn.get path

      dev_id = /Your Dev ID:\s*<font[^>]*>([^<]*)<\/font>/.match(response.body)
      if dev_id
        dev_id = dev_id[1]
      else
        dev_id = /Your Dev ID:[^>]*<\/label> ([^<]*)/.match(response.body)[1]
      end
      dev_id
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
roku_builder-3.8.3 lib/roku_builder/keyer.rb
roku_builder-3.8.2 lib/roku_builder/keyer.rb
roku_builder-3.8.1 lib/roku_builder/keyer.rb
roku_builder-3.8.0 lib/roku_builder/keyer.rb
roku_builder-3.7.3 lib/roku_builder/keyer.rb
roku_builder-3.7.2 lib/roku_builder/keyer.rb
roku_builder-3.7.1 lib/roku_builder/keyer.rb
roku_builder-3.7.0 lib/roku_builder/keyer.rb
roku_builder-3.6.6 lib/roku_builder/keyer.rb
roku_builder-3.6.5 lib/roku_builder/keyer.rb
roku_builder-3.6.4 lib/roku_builder/keyer.rb
roku_builder-3.6.3 lib/roku_builder/keyer.rb