iOS HMAccessCertificate
Access Certificate is used to recognise and authenticate with another HMKit enabled device.
Initialising
Initialises an access certificate object from binary
Declaration
init?<C>(binary: C) where C : Collection, C.Element == UInt8
Parameters
binary | (UInt8 Collection) binary representation of Access Certificate |
Returns
HMAccessCertificate
Example
import HMKit
let bytes: [UInt8] = [0x01, 0x02, 0x03...0xA0, 0xB1, 0xC2]
let certificate: HMAccessCertificate? = HMAccessCertificate(binary: bytes)
Initialises an access certificate object from a base64 encoded string
Declaration
convenience init?(base64Encoded string: String)
Parameters
base64Encoded | (String) Base64 encoded representation of Access Certificate |
Returns
HMAccessCertificate
Read More
Example
import HMKit
let str: String = "ASPx9P5Dd1Lu8y+fOjmmyR0...swj3OEzMkdfGFh5uUWdZ0Q2k="
let certificate: HMAccessCertificate? = HMAccessCertificate(base64Encoded: str)
Initialises an access certificate object with its required values
Declaration
convenience init?<C>(gainingSerial: C, gainingPublicKey: C, providingSerial: C, signature: C, validity: HMPeriod, version: Version, permissions: C? = default) where C : Collection, C.Element == UInt8
Parameters
gainingSerial | (UInt8 Collection) serial of connection to |
gainingPublicKey | (UInt8 Collection) public key of connection to |
providingSerial | (UInt8 Collection) serial of connection from |
signature | (UInt8 Collection) signature of the certificate |
validity | (HMPeriod) validity of the certificate (start and end dates) |
version | (Version) of the certificate (may contain extra values) |
permissions | (UInt8 Collection) optional permissions the certificate gives |
Returns
HMAccessCertificate
Example
import HMKit
let gSerial: [UInt8] = [0x11, 0x22...0x88, 0x99]
let gPublicKey: [UInt8] = [0x12, 0x34...0xDE, 0xF0]
let pSerial: [UInt8] = [0xAA, 0xBB...0x11, 0x22]
let signature: [UInt8] = [0x09, 0x87...0xDF, 0x1B]
let validity: HMPeriod = Period(start: Date..., end: Date...)
let certificate: HMAccessCertificate? = HMAccessCertificate(gainingSerial: gSerial, gainingPublicKey: gPublicKey, providingSerial: pSerial, signature: signature, validity: validity, version: .basic, permissions: nil)
Properties
.bytes
Declaration
let bytes: [UInt8]
.validity
.version
.gainingPublicKey
Declaration
var gainingPublicKey: [UInt8] { get }
.gainingSerial
Declaration
var gainingSerial: [UInt8] { get }
.providingSerial
Declaration
var providingSerial: [UInt8] { get }
Helpers
.isValidNow
Declaration
var isValidNow: Bool { get }
Discussion
If the certificate is valid right now.
If the certificate is valid on a given date
Declaration
func isValid(on date: Date) -> Bool
Parameters
date | (Date) date to check against |
Returns
Bool
Example
import HMKit
let ac: HMAccessCertificate!
let date = Date(...)
let isValid = ac.isValid(on: date)
Conforming
Codable
Declaration
protocol Codable = Decodable & Encodable
Discussion
A type that can convert itself into and out of an external representation.
Read More
Equatable
Declaration
protocol Equatable
Discussion
A type that can be compared for value equality.
Read More
HMSigned
Declaration
protocol HMSigned
Discussion
A type that is signed with a signature and can be verified.
Read More
HMSimilar
Declaration
protocol HMSimilar
Discussion
A type that can be compared for similarity.