This file can be downloaded as part of milnlicence.tbz.

//  LCLicenceCore.h
//  LicenceCore -
//  Copyright © Graham Miln. All rights reserved.
//  This package is subject to the terms of the Artistic License 2.0.
//  If a copy of the Artistic-2.0 was not distributed with this file, you can
//  obtain one at

@import Foundation;
@import Security;
#import "LCLicence.h"

// KVO Keys
extern NSString* LCLicenceCoreKeyLicences;
extern NSString* LCLicenceCoreKeyIsLicensed;

/** LCLicenceCore manages and evaluates licence certificates. */
@interface LCLicenceCore : NSObject
@property(strong,readonly) NSArray<LCLicence*>* licences; /**< Known licences. KVO suitable. */
@property(assign,readonly) BOOL isLicensed; /**< Is at least one licence trusted. */

/** Return a singleton instance of the licence core. */
+ (instancetype)sharedCore;

/** Set trusted anchor certificates. */
- (NSError*)setTrustedAnchors:(NSArray<NSData*>*)somePEMs;

/** Trust licences that are pending; resets to NO when all licences are evaluated or when licences is empty.
 trustPending is provided to deal with long evaluation times and application launch. Default is NO. */
- (void)setTrustPending:(BOOL)inTrust;

/** Add an encoded licence. */
- (void)addLicenceWithData:(NSData*)someData format:(SecExternalFormat)inFormat;

/** Add a licence certificate. */
- (void)addLicenceCertificate:(SecCertificateRef)aCertificate;

/** Remove every licence. Does not affect underlying storage or ongoing evaluations. */
- (void)removeAll;