Documentation

Index

Constants

View Source
const (
	LicenseTypeUnknown = iota
	LicenseTypeCloud
	LicenseTypeOnPremise
)

    Various license types

    Variables

    This section is empty.

    Functions

    func New

    func New() (string, string)

      New generates a new license and master key. This uses the most up-to-date version of the license to generate a new one.

      Types

      type Cipher

      type Cipher interface {
      	DecryptKey(buffer []byte) (security.Key, error)
      	EncryptKey(k security.Key) (string, error)
      }

        Cipher represents a cipher used by the license type.

        type License

        type License interface {
        	fmt.Stringer
        	NewMasterKey(id uint16) (security.Key, error)
        	Cipher() (Cipher, error)
        	Contract() uint32
        	Signature() uint32
        	Master() uint32
        }

          License represents an abstract license.

          func Parse

          func Parse(data string) (License, error)

            Parse parses a valid license of any version.

            type V1

            type V1 struct {
            	EncryptionKey string    // Gets or sets the encryption key.
            	User          uint32    // Gets or sets the contract id.
            	Sign          uint32    // Gets or sets the signature of the contract.
            	Expires       time.Time // Gets or sets the expiration date for the license.
            	Type          uint32    // Gets or sets the license type.
            }

              V1 represents a legacy v1 license.

              func NewV1

              func NewV1() *V1

                NewV1 generates a new legacy v1 license.

                func (*V1) Cipher

                func (l *V1) Cipher() (Cipher, error)

                  Cipher creates a new cipher for the licence

                  func (*V1) Contract

                  func (l *V1) Contract() uint32

                    Contract retuns the contract ID of the license.

                    func (*V1) Master

                    func (l *V1) Master() uint32

                      Master returns the secret key index.

                      func (*V1) NewMasterKey

                      func (l *V1) NewMasterKey(id uint16) (key security.Key, err error)

                        NewMasterKey generates a new master key.

                        func (*V1) Signature

                        func (l *V1) Signature() uint32

                          Signature returns the signature of the license.

                          func (*V1) String

                          func (l *V1) String() string

                            String converts the license to string.

                            type V2

                            type V2 struct {
                            	EncryptionKey  []byte // Gets or sets the encryption key.
                            	EncryptionSalt []byte // Gets or sets the encryption key.
                            	User           uint32 // Gets or sets the contract id.
                            	Sign           uint32 // Gets or sets the signature of the contract.
                            	Index          uint32 // Gets or sets the current master.
                            }

                              V2 represents a v2 license.

                              func NewV2

                              func NewV2() *V2

                                NewV2 generates a new v2 license.

                                func (*V2) Cipher

                                func (l *V2) Cipher() (Cipher, error)

                                  Cipher creates a new cipher for the licence

                                  func (*V2) Contract

                                  func (l *V2) Contract() uint32

                                    Contract retuns the contract ID of the license.

                                    func (*V2) Master

                                    func (l *V2) Master() uint32

                                      Master returns the secret key index.

                                      func (*V2) NewMasterKey

                                      func (l *V2) NewMasterKey(id uint16) (key security.Key, err error)

                                        NewMasterKey generates a new master key.

                                        func (*V2) Signature

                                        func (l *V2) Signature() uint32

                                          Signature returns the signature of the license.

                                          func (*V2) String

                                          func (l *V2) String() string

                                            String converts the license to string.

                                            type V3

                                            type V3 struct {
                                            	EncryptionKey  []byte // Gets or sets the encryption key.
                                            	EncryptionSalt []byte // Gets or sets the encryption key.
                                            	User           uint32 // Gets or sets the contract id.
                                            	Sign           uint32 // Gets or sets the signature of the contract.
                                            	Index          uint32 // Gets or sets the current master.
                                            }

                                              V3 represents a v3 license.

                                              func NewV3

                                              func NewV3() *V3

                                                NewV3 generates a new v2 license.

                                                func (*V3) Cipher

                                                func (l *V3) Cipher() (Cipher, error)

                                                  Cipher creates a new cipher for the licence

                                                  func (*V3) Contract

                                                  func (l *V3) Contract() uint32

                                                    Contract retuns the contract ID of the license.

                                                    func (*V3) Master

                                                    func (l *V3) Master() uint32

                                                      Master returns the secret key index.

                                                      func (*V3) NewMasterKey

                                                      func (l *V3) NewMasterKey(id uint16) (key security.Key, err error)

                                                        NewMasterKey generates a new master key.

                                                        func (*V3) Signature

                                                        func (l *V3) Signature() uint32

                                                          Signature returns the signature of the license.

                                                          func (*V3) String

                                                          func (l *V3) String() string

                                                            String converts the license to string.