github.com/vnforks/kid/v5@v5.22.1-0.20200408055009-b89d99c65676/model/system.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See LICENSE.txt for license information. 3 4 package model 5 6 import ( 7 "encoding/json" 8 "io" 9 "math/big" 10 ) 11 12 const ( 13 SYSTEM_DIAGNOSTIC_ID = "DiagnosticId" 14 SYSTEM_RAN_UNIT_TESTS = "RanUnitTests" 15 SYSTEM_LAST_SECURITY_TIME = "LastSecurityTime" 16 SYSTEM_ACTIVE_LICENSE_ID = "ActiveLicenseId" 17 SYSTEM_LAST_COMPLIANCE_TIME = "LastComplianceTime" 18 SYSTEM_ASYMMETRIC_SIGNING_KEY = "AsymmetricSigningKey" 19 SYSTEM_POST_ACTION_COOKIE_SECRET = "PostActionCookieSecret" 20 SYSTEM_INSTALLATION_DATE_KEY = "InstallationDate" 21 ) 22 23 type System struct { 24 Name string `json:"name"` 25 Value string `json:"value"` 26 } 27 28 func (o *System) ToJson() string { 29 b, _ := json.Marshal(o) 30 return string(b) 31 } 32 33 func SystemFromJson(data io.Reader) *System { 34 var o *System 35 json.NewDecoder(data).Decode(&o) 36 return o 37 } 38 39 type SystemPostActionCookieSecret struct { 40 Secret []byte `json:"key,omitempty"` 41 } 42 43 type SystemAsymmetricSigningKey struct { 44 ECDSAKey *SystemECDSAKey `json:"ecdsa_key,omitempty"` 45 } 46 47 type SystemECDSAKey struct { 48 Curve string `json:"curve"` 49 X *big.Int `json:"x"` 50 Y *big.Int `json:"y"` 51 D *big.Int `json:"d,omitempty"` 52 } 53 54 // ServerBusyState provides serialization for app.Busy. 55 type ServerBusyState struct { 56 Busy bool `json:"busy"` 57 Expires int64 `json:"expires"` 58 Expires_ts string `json:"expires_ts,omitempty"` 59 } 60 61 func (sbs *ServerBusyState) ToJson() string { 62 b, _ := json.Marshal(sbs) 63 return string(b) 64 } 65 66 func ServerBusyStateFromJson(r io.Reader) *ServerBusyState { 67 var sbs *ServerBusyState 68 json.NewDecoder(r).Decode(&sbs) 69 return sbs 70 }