2021-12-03 22:04:09 +00:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
2021-12-05 00:00:32 +00:00
|
|
|
"crypto/ecdsa"
|
|
|
|
"crypto/x509"
|
2021-12-03 22:04:09 +00:00
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"gitea.benny.dog/torjus/ezshare/pb"
|
|
|
|
)
|
|
|
|
|
|
|
|
var ErrNoSuchFile = fmt.Errorf("no such file")
|
|
|
|
|
|
|
|
type FileStore interface {
|
|
|
|
GetFile(id string) (*pb.File, error)
|
|
|
|
StoreFile(file *pb.File) (string, error)
|
|
|
|
DeleteFile(id string) error
|
2021-12-04 10:30:42 +00:00
|
|
|
ListFiles() ([]*pb.ListFilesResponse_ListFileInfo, error)
|
2021-12-03 22:04:09 +00:00
|
|
|
}
|
2021-12-05 00:00:32 +00:00
|
|
|
|
|
|
|
type CertificateStore interface {
|
|
|
|
GetCertificate(id string) (*x509.Certificate, error)
|
|
|
|
StoreCertificate(id string, cert *x509.Certificate) error
|
|
|
|
GetKey(id string) (*ecdsa.PrivateKey, error)
|
|
|
|
StoreKey(id string, key *ecdsa.PrivateKey) error
|
|
|
|
ListCertificates() ([]string, error)
|
|
|
|
}
|
2021-12-05 10:08:09 +00:00
|
|
|
|
|
|
|
type UserStore interface {
|
|
|
|
StoreUser(user *pb.User) error
|
|
|
|
GetUser(id string) (*pb.User, error)
|
2021-12-05 11:39:28 +00:00
|
|
|
GetUserByUsername(username string) (*pb.User, error)
|
2021-12-05 10:08:09 +00:00
|
|
|
ListUsers() ([]string, error)
|
|
|
|
}
|