encryptorAPIDB.go 2.6 KB
Newer Older
T
tanggen 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
// Copyright (C) 2020 Finogeeks Co., Ltd
//
// This program is free software: you can redistribute it and/or  modify
// it under the terms of the GNU Affero General Public License, version 3,
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

package model

import (
	"context"

	"github.com/finogeeks/ligase/model/dbtypes"
)

type EncryptorAPIDatabase interface {
	//NewDatabase(driver, createAddr, address, topic string, useAsync bool) (interface{}, error)

	WriteDBEvent(ctx context.Context, update *dbtypes.DBEvent) error

	RecoverCache()

	InsertDeviceKey(
		ctx context.Context,
		deviceID, userID, keyInfo, al, sig, identifier string,
	) (err error)

	InsertOneTimeKey(
		ctx context.Context,
		deviceID, userID, keyID, keyInfo, al, sig, identifier string,
	) (err error)

	OnInsertDeviceKey(
		ctx context.Context,
		deviceID, userID, keyInfo, al, sig, identifier string,
	) (err error)

	OnInsertOneTimeKey(
		ctx context.Context,
		deviceID, userID, keyID, keyInfo, al, sig, identifier string,
	) (err error)

	DeleteOneTimeKey(
		ctx context.Context,
		deviceID, userID, keyID, algorithm string,
	) (err error)

	OnDeleteOneTimeKey(
		ctx context.Context,
		deviceID, userID, keyID, algorithm string,
	) (err error)

	DeleteMacOneTimeKey(
		ctx context.Context,
		deviceID, userID, identifier string,
	) (err error)

	OnDeleteMacOneTimeKey(
		ctx context.Context,
		deviceID, userID, identifier string,
	) (err error)

	InsertAl(
		ctx context.Context, uid, device, als, identifier string,
	) (err error)

	OnInsertAl(
		ctx context.Context, uid, device, als, identifier string,
	) (err error)

	DeleteDeviceKeys(
		ctx context.Context, deviceID, userID string,
	) error

	DeleteMacKeys(
		ctx context.Context, deviceID, userID, identifier string,
	) error

	OnDeleteAl(
		ctx context.Context,
		userID, deviceID string,
	) error

	OnDeleteMacAl(
		ctx context.Context,
		userID, deviceID, identifier string,
	) error

	OnDeleteDeviceKey(
		ctx context.Context,
		deviceID, userID string,
	) error

	OnDeleteMacDeviceKey(
		ctx context.Context,
		deviceID, userID, identifier string,
	) error

	OnDeleteDeviceOneTimeKey(
		ctx context.Context,
		deviceID, userID string,
	) error

	DeleteDeviceOneTimeKey(
		ctx context.Context, deviceID, userID string,
	) error
}