summaryrefslogtreecommitdiffstats
path: root/utils/license.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2016-02-04 13:00:03 -0500
committerJoramWilander <jwawilander@gmail.com>2016-02-04 13:35:44 -0500
commite45282deaa1d78d7ff3a125e9fd11e3fdc120b07 (patch)
treec116beae6abed1b703c481dfd63df36d689a8af5 /utils/license.go
parent7e8389cd0538fb6aff3931fb23714158d3f24449 (diff)
downloadchat-e45282deaa1d78d7ff3a125e9fd11e3fdc120b07.tar.gz
chat-e45282deaa1d78d7ff3a125e9fd11e3fdc120b07.tar.bz2
chat-e45282deaa1d78d7ff3a125e9fd11e3fdc120b07.zip
Move license storage to database
Diffstat (limited to 'utils/license.go')
-rw-r--r--utils/license.go37
1 files changed, 4 insertions, 33 deletions
diff --git a/utils/license.go b/utils/license.go
index 0d1cd597c..b773a163e 100644
--- a/utils/license.go
+++ b/utils/license.go
@@ -1,19 +1,15 @@
-// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package utils
import (
- "bytes"
"crypto"
"crypto/rsa"
"crypto/sha512"
"crypto/x509"
"encoding/base64"
"encoding/pem"
- "io"
- "os"
- "path/filepath"
"strconv"
"strings"
@@ -22,10 +18,6 @@ import (
"github.com/mattermost/platform/model"
)
-const (
- LICENSE_FILENAME = "active.dat"
-)
-
var IsLicensed bool = false
var License *model.License = &model.License{}
var ClientLicense map[string]string = make(map[string]string)
@@ -41,18 +33,8 @@ NxpC+5KFhU+xSeeklNqwCgnlOyZ7qSTxmdJHb+60SwuYnnGIYzLJhY4LYDr4J+KR
1wIDAQAB
-----END PUBLIC KEY-----`)
-func LoadLicense() {
- file, err := os.Open(LicenseLocation())
- if err != nil {
- l4g.Warn(T("utils.license.load_license.open_find.warn"))
- return
- }
- defer file.Close()
-
- buf := bytes.NewBuffer(nil)
- io.Copy(buf, file)
-
- if success, licenseStr := ValidateLicense(buf.Bytes()); success {
+func LoadLicense(licenseBytes []byte) {
+ if success, licenseStr := ValidateLicense(licenseBytes); success {
license := model.LicenseFromJson(strings.NewReader(licenseStr))
SetLicense(license)
return
@@ -74,21 +56,10 @@ func SetLicense(license *model.License) bool {
return false
}
-func LicenseLocation() string {
- return filepath.Dir(CfgFileName) + "/" + LICENSE_FILENAME
-}
-
-func RemoveLicense() bool {
+func RemoveLicense() {
License = &model.License{}
IsLicensed = false
ClientLicense = getClientLicense(License)
-
- if err := os.Remove(LicenseLocation()); err != nil {
- l4g.Error(T("utils.license.remove_license.unable.error"), err.Error())
- return false
- }
-
- return true
}
func ValidateLicense(signed []byte) (bool, string) {