Documentation ¶
Index ¶
- Constants
- Variables
- func VersionNumber() string
- type ArmorEnvelope
- type License
- type LicenseClass
- type LicenseDatastore
- type LicenseKey
- type LicenseKeyExtra
- type LicenseKeyPairType
- type LicenseType
- type SQLite3Datastore
- func (s *SQLite3Datastore) DeleteLicense(id LicenseKey) error
- func (s *SQLite3Datastore) GetLicense(id LicenseKey) (*License, error)
- func (s *SQLite3Datastore) GetLicenseList() (keys []LicenseKey, err error)
- func (s *SQLite3Datastore) GetLicenseListByParent(parent LicenseKey) (keys []LicenseKey, err error)
- func (s *SQLite3Datastore) SetupDatabase(dbpath string) error
- func (s *SQLite3Datastore) StoreLicense(license *License) error
Constants ¶
const ARMOR_MAGIC = "HADES-ARMOR"
const ARMOR_VERSION = 1
const VERSION_MAJOR = 0
const VERSION_MINOR = 1
const VERSION_PATCH = 0
Variables ¶
var ArmorHeader = strings.Repeat("-", 25) + " BEGIN LICENSE " + strings.Repeat("-", 24)
var KEYPAIR_ECDSA = LicenseKeyPairType("ECDSA-2048")
var LICENSE_CLIENT = LicenseClass("CLIENT")
var LICENSE_ENDUSER = LicenseType("ENDUSER")
var LICENSE_MASTER = LicenseClass("MASTER")
var LICENSE_PRODUCER = LicenseType("PRODUCER")
var LICENSE_PRODUCT = LicenseType("PRODUCT")
var LICENSE_VERSION = LicenseType("VERSION")
Functions ¶
func VersionNumber ¶
func VersionNumber() string
Types ¶
type ArmorEnvelope ¶
type License ¶
type License struct { ID LicenseKey ParentID LicenseKey Type LicenseType Class LicenseClass Created time.Time Metadata map[string]string KeyPairType LicenseKeyPairType PrivateKey []byte PublicKey []byte }
type LicenseClass ¶
type LicenseClass string
A license's class (master, client) essentially specifies what the license is to be used for, in broad terms. A master license is that of a software producer or program, and is used to sign other master licenses and client licenses and there can only be one master license for a given thing (software producer, program, program version, etc.). A client license, in turn has no key pair, can't be used for signing other licenses, and is the only license class a Hades-protected program can load.
type LicenseDatastore ¶
type LicenseDatastore interface { SetupDatabase(url string) error GetLicense(LicenseKey) (*License, error) GetLicenseList() (*[]LicenseKey, error) GetLicenseListByParent(LicenseKey) (*License, error) StoreLicense(*License) error DeleteLicense(LicenseKey) error }
LicenseDatastore is an interface designed to make the license database easily replaceable so the license server and the CLI application can use different database engines based on their different use cases. Plus, this way I get to change my mind about the datastore later on without having to make a lot of changes.
type LicenseKey ¶
type LicenseKey []byte
Key format is as follows, in NAME(BYTES) format: CHECKSUM(4): truncated SHA-1 hash of parent keys (producer, product,
version) and the current key with the CHECKSUM field zeroed out. Inclusion of the parent keys is mandatory if they exist.
EXTRA-1(2): available for custom use. EXTRA-2(2): available for custom use. EXTRA-3(2): available for custom use. RANDOM(6): this is the key proper, so to speak. It makes a given key unique. Please note that unused EXTRA fields can be used to increase the key space.
func LicenseKeyFromString ¶
func LicenseKeyFromString(k string) (key LicenseKey, err error)
func NewLicenseKey ¶
func NewLicenseKey(extra1, extra2, extra3 LicenseKeyExtra, parents ...LicenseKey) (LicenseKey, error)
func (LicenseKey) Bytes ¶
func (k LicenseKey) Bytes() []byte
func (LicenseKey) IsValid ¶
func (k LicenseKey) IsValid() bool
func (LicenseKey) String ¶
func (k LicenseKey) String() string
type LicenseKeyExtra ¶
type LicenseKeyExtra []byte
func (LicenseKeyExtra) IsValid ¶
func (k LicenseKeyExtra) IsValid() bool
type LicenseType ¶
type LicenseType string
A license's type specifies what the licence is intended to represent (a producer, a product, etc.) All but LICENSE_CLIENT are master licenses.
type SQLite3Datastore ¶
type SQLite3Datastore struct {
// contains filtered or unexported fields
}
SQLite3Datastore implements LicenseDatastore for SQLite3-based storage.
func (*SQLite3Datastore) DeleteLicense ¶
func (s *SQLite3Datastore) DeleteLicense(id LicenseKey) error
func (*SQLite3Datastore) GetLicense ¶
func (s *SQLite3Datastore) GetLicense(id LicenseKey) (*License, error)
func (*SQLite3Datastore) GetLicenseList ¶
func (s *SQLite3Datastore) GetLicenseList() (keys []LicenseKey, err error)
func (*SQLite3Datastore) GetLicenseListByParent ¶
func (s *SQLite3Datastore) GetLicenseListByParent(parent LicenseKey) (keys []LicenseKey, err error)
func (*SQLite3Datastore) SetupDatabase ¶
func (s *SQLite3Datastore) SetupDatabase(dbpath string) error
func (*SQLite3Datastore) StoreLicense ¶
func (s *SQLite3Datastore) StoreLicense(license *License) error