IdTokenParser

class IdTokenParser : ITokenParser

Parses the id token string obtained via the AppAuth framework.

  • header index in id token string

    Declaration

    Swift

    private let headerIdx: Int
  • payload index in id token string

    Declaration

    Swift

    private let payloadIdx: Int
  • signature index in id token string

    Declaration

    Swift

    private let signatureIdx: Int
  • default token components count

    Declaration

    Swift

    private let defaultTokenPartsCount: Int
  • token components separator

    Declaration

    Swift

    private let tokenPartsSeparator: String.Element
  • Parses the id token string

    Declaration

    Swift

    func parse(_ stringToParse: String, error: inout NSError?) -> IdToken?

    Parameters

    stringToParse

    The string obtained using AppAuth framework.

    error

    An error which can occur during the parsing (it is passed as inout parameter so, its value can be set inside the function).

    Return Value

    Valid [IdToken] object is returned on success or nil on failure.

  • Parses the id token header string

    Declaration

    Swift

    private func parseHeader(_ header: String, error: inout NSError?) -> IdTokenHeader?

    Parameters

    header

    The string represents the header of the id token.

    error

    An error which can occur during the parsing (it is passed as inout parameter so, its value can be set inside the function).

    Return Value

    Valid [IdTokenHeader] object is returned on success or nil on failure.

  • Parses the id token payload string

    Declaration

    Swift

    private func parsePayload(_ payload: String, error: inout NSError?) -> IdTokenPayload?

    Parameters

    payload

    The string represents the payload of the id token.

    error

    An error which can occur during the parsing (it is passed as inout parameter so, its value can be set inside the function).

    Return Value

    Valid [IdTokenPayload] object is returned on success or nil on failure.

  • Creates Dictionary object from part of the id token string

    Declaration

    Swift

    private func getDictionary(_ base64UrlEncodedString: String) -> Dictionary<String, Any>?

    Parameters

    base64UrlEncodedString

    The part of the id token string (header or payload), it has the base64url format. In order to get human readable data, we need to convert the base64url string to base64 string, then create Data object with it, then this Data object can be used to create Dictionary.

    Return Value

    Valid Dictionary object is returned on success or nil on failure.

  • Gets string value from dictionary

    Declaration

    Swift

    private func getStringValue(from dictionary: Dictionary<String, Any>, for key: String) -> String

    Parameters

    dictionary

    The Dictionary object which contains values

    key

    The key which is used to obtain value from the dictionary.

    Return Value

    String value is returned on success or empty string on failure.

  • Gets Date value from dictionary

    Declaration

    Swift

    private func getDateValue(from dictionary: Dictionary<String, Any>, for key: String) -> Date

    Parameters

    dictionary

    The Dictionary object which contains values

    key

    The key which is used to obtain value from the dictionary.

    Return Value

    Date value is returned, it contains valid date on success or current date on failure.