Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrConflict represents unique identifier violation. ErrConflict = errors.New("entity already exists") // ErrNotFound represents non-existing entity request. ErrNotFound = errors.New("entity does not exist") // ErrMalformedEntity represents malformed entity specification. ErrMalformedEntity = errors.New("malformed entity data") ErrUnauthorizedAccess = errors.New("unauthorized access") // ErrExpired represents expired license error. ErrExpired = errs.New("the license is expired") // ErrIssuedAt represents invalid issue date. ErrIssuedAt = errs.New("invalid issue date") )
View Source
var ErrLicenseValidation = errors.New("license validation failed")
ErrLicenseValidation wraps an error in case of unsuccessfull validation.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface { // Validate validates service. Validate([]byte) ([]byte, error) // Load reads License from the location. Load() error // Save saves License to file. Save() error // Do runs the Agent. Do() }
Agent represents licensing agent. Licensing Agent is a service that handles License locally.
type Crypto ¶
type Crypto interface { // Encrypt encrypts license before storing in file. Encrypt([]byte) ([]byte, error) // Descrypt decrypts license retrieved from file or cloud. Decrypt([]byte) ([]byte, error) }
Crypto provides an interface for reading and storing of the License.
type IdentityProvider ¶
IdentityProvider specifies an API for generating unique identifiers.
type License ¶
type License struct { ID string `json:"id"` Key string `json:"key"` Issuer string `json:"issuer"` DeviceID string `json:"device_id"` Active bool `json:"active"` CreatedAt time.Time `json:"created_at"` ExpiresAt time.Time `json:"expires_at"` UpdatedBy string `json:"updated_by"` UpdatedAt time.Time `json:"updated_at"` Services []string `json:"services"` Plan map[string]interface{} `json:"plan"` Signature []byte `json:"signature"` }
License represents single license object.
type Repository ¶
type Repository interface { // Save stores a License. Save(ctx context.Context, l License) (string, error) // Retrieve the License by given ID that belongs to the given owner. Retrieve(ctx context.Context, issuer, id string) (License, error) // RetrieveByID retrives the license by device ID. RetrieveByDeviceID(ctx context.Context, deviceID string) (License, error) // Update an existing License. Update(ctx context.Context, l License) error // Remove a License with the given ID that belongs to the given owner. Remove(ctx context.Context, issuer, id string) error // ChangeActive a License with the given ID // that belongs to the given issuer. ChangeActive(ctx context.Context, token, id string, active bool) error }
Repository specifies a License persistence API.
type Service ¶
type Service interface { // Create adds License that belongs to the // user identified by the provided token. Create(ctx context.Context, token string, l License) (string, error) // Retrieve retrieves the License by given ID that belongs to // the user identified by the provided token. Retrieve(ctx context.Context, token, id string) (License, error) // RetrieveByDeviceID retrieves the License by given ID. RetrieveByDeviceID(ctx context.Context, deviceID string) ([]byte, error) // Fetch retrieves License using license ID and Key. Fetch(ctx context.Context, key, id string) ([]byte, error) // Update updates an existing License that's issued // by the given issuer. Update(ctx context.Context, token string, l License) error // Remove removes a License with the given ID // that belongs to the given issuer. Remove(ctx context.Context, token, id string) error // ChangeActive a License with the given ID // that belongs to the given issuer. ChangeActive(ctx context.Context, token, id string, active bool) error // Validate checks if the license is valid for the given service name. Validate(ctx context.Context, svcName, deviceID string, payload []byte) error }
Service represents licensing service API specification.
Click to show internal directories.
Click to hide internal directories.