Class: ApnsGatling::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/apns_gatling/jwt_token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(team_id, auth_key_id, ecdsa_key) ⇒ Token

Returns a new instance of Token.



7
8
9
10
11
# File 'lib/apns_gatling/jwt_token.rb', line 7

def initialize(team_id, auth_key_id, ecdsa_key)
  @team_id = team_id
  @auth_key_id = auth_key_id
  @ecdsa_key = ecdsa_key
end

Instance Attribute Details

#auth_key_idObject (readonly)

Returns the value of attribute auth_key_id.



5
6
7
# File 'lib/apns_gatling/jwt_token.rb', line 5

def auth_key_id
  @auth_key_id
end

#ecdsa_keyObject (readonly)

Returns the value of attribute ecdsa_key.



5
6
7
# File 'lib/apns_gatling/jwt_token.rb', line 5

def ecdsa_key
  @ecdsa_key
end

#team_idObject (readonly)

Returns the value of attribute team_id.



5
6
7
# File 'lib/apns_gatling/jwt_token.rb', line 5

def team_id
  @team_id
end

Instance Method Details

#new_tokenObject



13
14
15
16
17
# File 'lib/apns_gatling/jwt_token.rb', line 13

def new_token
  payload = {iss: @team_id, iat: Time.now.to_i}
  header = {kid: @auth_key_id}
  JWT.encode payload, @ecdsa_key, 'ES256', header
end