Class: SignIn::RefreshTokenEncryptor
- Inherits:
-
Object
- Object
- SignIn::RefreshTokenEncryptor
- Defined in:
- app/services/sign_in/refresh_token_encryptor.rb
Instance Attribute Summary collapse
-
#nonce ⇒ Object
readonly
Returns the value of attribute nonce.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #build_refresh_token_string(encrypted_refresh_token) ⇒ Object private
-
#initialize(refresh_token:) ⇒ RefreshTokenEncryptor
constructor
A new instance of RefreshTokenEncryptor.
- #message_encryptor ⇒ Object private
- #perform ⇒ Object
- #serialize_and_encrypt_refresh_token ⇒ Object private
- #validate_input ⇒ Object private
Constructor Details
#initialize(refresh_token:) ⇒ RefreshTokenEncryptor
Returns a new instance of RefreshTokenEncryptor.
7 8 9 10 11 12 |
# File 'app/services/sign_in/refresh_token_encryptor.rb', line 7 def initialize(refresh_token:) @refresh_token = refresh_token validate_input @version = refresh_token.version @nonce = refresh_token.nonce end |
Instance Attribute Details
#nonce ⇒ Object (readonly)
Returns the value of attribute nonce.
5 6 7 |
# File 'app/services/sign_in/refresh_token_encryptor.rb', line 5 def nonce @nonce end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
5 6 7 |
# File 'app/services/sign_in/refresh_token_encryptor.rb', line 5 def refresh_token @refresh_token end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'app/services/sign_in/refresh_token_encryptor.rb', line 5 def version @version end |
Instance Method Details
#build_refresh_token_string(encrypted_refresh_token) ⇒ Object (private)
27 28 29 30 31 32 33 |
# File 'app/services/sign_in/refresh_token_encryptor.rb', line 27 def build_refresh_token_string(encrypted_refresh_token) string_array = [] string_array[Constants::RefreshToken::ENCRYPTED_POSITION] = encrypted_refresh_token string_array[Constants::RefreshToken::NONCE_POSITION] = nonce string_array[Constants::RefreshToken::VERSION_POSITION] = version string_array.join('.') end |
#message_encryptor ⇒ Object (private)
40 41 42 |
# File 'app/services/sign_in/refresh_token_encryptor.rb', line 40 def KmsEncrypted::Box.new end |
#perform ⇒ Object
14 15 16 17 |
# File 'app/services/sign_in/refresh_token_encryptor.rb', line 14 def perform encrypted_refresh_token = serialize_and_encrypt_refresh_token build_refresh_token_string(encrypted_refresh_token) end |
#serialize_and_encrypt_refresh_token ⇒ Object (private)
35 36 37 38 |
# File 'app/services/sign_in/refresh_token_encryptor.rb', line 35 def serialize_and_encrypt_refresh_token serialized_refresh_token = refresh_token.to_json .encrypt(serialized_refresh_token) end |
#validate_input ⇒ Object (private)
21 22 23 24 25 |
# File 'app/services/sign_in/refresh_token_encryptor.rb', line 21 def validate_input unless refresh_token.version && refresh_token.nonce raise Errors::RefreshTokenMalformedError.new message: 'Refresh token is malformed' end end |