Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateUserKey(profile, passhash string) ([]byte, error)
- type ContentKey
- type DeviceInfo
- type Encryption
- type License
- type LicenseCtrl
- func (lc *LicenseCtrl) NewStatusDoc(license *stor.LicenseInfo) *StatusDoc
- func (lc *LicenseCtrl) Register(licenseID string, device *DeviceInfo) (*StatusDoc, error)
- func (lc *LicenseCtrl) Renew(licenseID string, device *DeviceInfo, newEnd *time.Time) (*StatusDoc, error)
- func (lc *LicenseCtrl) Return(licenseID string, device *DeviceInfo) (*StatusDoc, error)
- func (lc *LicenseCtrl) Revoke(licenseID string) (*StatusDoc, error)
- type LicenseManager
- type Link
- type PotentialRights
- type StatusDoc
- type Updated
- type UserInfo
- type UserKey
- type UserRights
Constants ¶
View Source
const ( ContentType_LCP_JSON = "application/vnd.readium.lcp.license.v1.0+json" ContentType_LSD_JSON = "application/vnd.readium.license.status.v1.0+json" ContentType_TEXT_HTML = "text/html" ContentType_JSON = "application/json" ContentType_FORM_URL_ENCODED = "application/x-www-form-urlencoded" )
View Source
const ( LCP_Basic_Profile = "http://readium.org/lcp/basic-profile" LCP_10_Profile = "http://readium.org/lcp/profile-1.0" )
View Source
const SHA256_URI string = "http://www.w3.org/2001/04/xmlenc#sha256"
Variables ¶
View Source
var (
ErrLicenseNotFound = errors.New("license not found or failed to get license info")
)
View Source
var LCP_PRODUCTION_LIB = false
Functions ¶
func GenerateUserKey ¶
GenerateUserKey function prepares the user key
Types ¶
type ContentKey ¶
type Encryption ¶
type Encryption struct { Profile string `json:"profile,omitempty"` ContentKey ContentKey `json:"content_key,omitempty"` // Not used for license generation UserKey UserKey `json:"user_key"` }
type License ¶
type License struct { Provider string `json:"provider"` UUID 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"` Signature *sign.Signature `json:"signature,omitempty"` }
func NewLicense ¶
func NewLicense(config *conf.Config, cert *tls.Certificate, pubInfo *stor.Publication, licInfo *stor.LicenseInfo, userInfo *UserInfo, encryption *Encryption, passhash string) (*License, error)
NewLicense generates a license from db info, request data and config data
func (*License) CheckSignature ¶
CheckSignature verifies the signature of a license
type LicenseCtrl ¶
StatusDoc data model
func NewLicenseCtrl ¶
func NewLicenseCtrl(cf *conf.Config, st stor.Store) *LicenseCtrl
func (*LicenseCtrl) NewStatusDoc ¶
func (lc *LicenseCtrl) NewStatusDoc(license *stor.LicenseInfo) *StatusDoc
NewStatusDoc returns a Status Document
func (*LicenseCtrl) Register ¶
func (lc *LicenseCtrl) Register(licenseID string, device *DeviceInfo) (*StatusDoc, error)
Register records that a new device is using a license
func (*LicenseCtrl) Renew ¶
func (lc *LicenseCtrl) Renew(licenseID string, device *DeviceInfo, newEnd *time.Time) (*StatusDoc, error)
Renew extends the end date of a license
func (*LicenseCtrl) Return ¶
func (lc *LicenseCtrl) Return(licenseID string, device *DeviceInfo) (*StatusDoc, error)
Return forces the expiration of a license and returns a status document.
type LicenseManager ¶
type LicenseManager interface { Register(license *stor.LicenseInfo) error Renew(license *stor.LicenseInfo) error Return(license *stor.LicenseInfo) error Revoke(license *stor.LicenseInfo) error }
License management interface
type Link ¶
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"` Checksum string `json:"hash,omitempty"` }
type PotentialRights ¶
StatusDoc data model
type StatusDoc ¶
type StatusDoc struct { ID string `json:"id"` Status string `json:"status"` Message string `json:"message"` Updated Updated `json:"updated"` Links []Link `json:"links"` PotentialRights *PotentialRights `json:"potential_rights,omitempty"` Events []stor.Event `json:"events,omitempty"` }
StatusDoc data model
Click to show internal directories.
Click to hide internal directories.