JWT

public class JWT

Encapsultes a JSON Web Token.

  • URL to token issuer.

    Declaration

    Swift

    public var issuer: String
  • Intended audience of the token.

    Declaration

    Swift

    public var audience: String
  • Identity associated with the token.

    Declaration

    Swift

    public var subject: String?
  • Signature algorithm.

    Declaration

    Swift

    public var algorithm: String
  • External Key ID.

    Declaration

    Swift

    public var keyId: String?
  • Token expiry.

    Declaration

    Swift

    public var expiry: Date
  • Date/time at which the token was issued.

    Declaration

    Swift

    public var issuedAt: Date
  • Token is not valid before this time.

    Declaration

    Swift

    public var notValidBefore: Date?
  • id

    Token ID.

    Declaration

    Swift

    public var id: String?
  • JWT payload.

    Declaration

    Swift

    public var payload: [String : Any]
  • Initialize and return JWT object.

    Declaration

    Swift

    public init(issuer: String, audience: String, subject: String, id: String)

    Parameters

    issuer

    Token issuer

    audience

    Intended audience of the token.

    subject

    Identity associated with the token.

    id

    Unique ID of this token.

    Return Value

    Reference to the initialized object.

  • Initialize and return the object.

    Declaration

    Swift

    public init(string: String, keyManager: SudoKeyManager? = nil) throws

    Parameters

    string

    JWT string.

    keyManager

    KeyManager instance used to validate the signature (optional).

  • Sign and encode the token.

    Declaration

    Swift

    public func signAndEncode(keyManager: SudoKeyManager, keyId: String) throws -> String

    Parameters

    keyManager

    KeyManager instance used to generate a digital signature.

    keyId

    Identifier of the key to use for generate the signature.