license

package
v0.0.0-...-99fd3eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLinks map[string]string
View Source
var ErrNotFound = errors.New("License not found")

Functions

func CreateDefaultLinks() error

CreateDefaultLinks inits the global var DefaultLinks from config data

func EncryptLicenseFields

func EncryptLicenseFields(l *License, c index.Content) error

EncryptLicenseFields sets the content key, encrypted user info and key check

func GenerateUserKey

func GenerateUserKey(key UserKey) []byte

GenerateUserKey function prepares the user key

func Initialize

func Initialize(contentID string, l *License)

Initialize sets a license id and issued date, contentID,

func SetLicenseLinks(l *License, c index.Content) error

SetLicenseLinks sets publication and status links l.ContentID must have been set before the call

func SetLicenseProfile

func SetLicenseProfile(l *License)

SetLicenseProfile sets the license profile from config

func SignLicense

func SignLicense(l *License, cert *tls.Certificate) error

SignLicense signs a license using the server certificate

Types

type ContentKey

type ContentKey struct {
	Key
	Value []byte `json:"encrypted_value,omitempty"`
}

type Encryption

type Encryption struct {
	Profile    string     `json:"profile,omitempty"`
	ContentKey ContentKey `json:"content_key"`
	UserKey    UserKey    `json:"user_key"`
}

type EncryptionProfile

type EncryptionProfile int

EncryptionProfile is an enum of possible encryption profiles

const (
	BasicProfile EncryptionProfile = iota
	V1Profile
)

Declare typed constants for Encryption Profile

func (EncryptionProfile) String

func (profile EncryptionProfile) String() string

type Key

type Key struct {
	Algorithm string `json:"algorithm,omitempty"`
}

type License

type License struct {
	Provider   string          `json:"provider"`
	ID         string          `json:"id"`
	Issued     time.Time       `json:"issued"`
	Updated    *time.Time      `json:"updated,omitempty"`
	Encryption Encryption      `json:"encryption"`
	Links      []Link          `json:"links,omitempty"`
	User       UserInfo        `json:"user"`
	Rights     *UserRights     `json:"rights,omitempty"`
	Signature  *sign.Signature `json:"signature,omitempty"`
	ContentID  string          `json:"-"`
}

type LicenseReport

type LicenseReport struct {
	Provider  string      `json:"provider"`
	ID        string      `json:"id"`
	Issued    time.Time   `json:"issued"`
	Updated   *time.Time  `json:"updated,omitempty"`
	User      UserInfo    `json:"user,omitempty"`
	Rights    *UserRights `json:"rights"`
	ContentID string      `json:"-"`
}
type Link struct {
	Rel       string `json:"rel"`
	Href      string `json:"href"`
	Type      string `json:"type,omitempty"`
	Title     string `json:"title,omitempty"`
	Profile   string `json:"profile,omitempty"`
	Templated bool   `json:"templated,omitempty"`
	Size      int64  `json:"length,omitempty"`
	//Digest    []byte `json:"hash,omitempty"`
	Checksum string `json:"hash,omitempty"`
}

type Store

type Store interface {
	//List() func() (License, error)
	List(ContentID string, page int, pageNum int) func() (LicenseReport, error)
	ListAll(page int, pageNum int) func() (LicenseReport, error)
	UpdateRights(l License) error
	Update(l License) error
	UpdateLsdStatus(id string, status int32) error
	Add(l License) error
	Get(id string) (License, error)
}

func NewSqlStore

func NewSqlStore(db *sql.DB) (Store, error)

NewSqlStore

type UserInfo

type UserInfo struct {
	ID        string   `json:"id"`
	Email     string   `json:"email,omitempty"`
	Name      string   `json:"name,omitempty"`
	Encrypted []string `json:"encrypted,omitempty"`
}

type UserKey

type UserKey struct {
	Key
	Hint     string `json:"text_hint,omitempty"`
	Check    []byte `json:"key_check,omitempty"`
	Value    []byte `json:"value,omitempty"`     //Used for license generation
	HexValue string `json:"hex_value,omitempty"` //Used for license generation
}

type UserRights

type UserRights struct {
	Print *int32     `json:"print,omitempty"`
	Copy  *int32     `json:"copy,omitempty"`
	Start *time.Time `json:"start,omitempty"`
	End   *time.Time `json:"end,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL