model

package
v0.0.0-...-7fc488a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2019 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaimDB

func ClaimDB() *kvdb.BoltDB

ClaimDB - get claim status db

func GetClaims

func GetClaims(c Claims, id string) error

GetClaims - get claims from database

func GetIdentity

func GetIdentity(i Identity, id string) error

GetIdentity - get publickey from database

func GetPublicKey

func GetPublicKey(pk PublicKey, id string) error

GetPublicKey - get publickey from database

func IdentityDataBase

func IdentityDataBase() kvdb.KVMethods

IdentityDataBase - kv database of identity

func SetClaims

func SetClaims(c Claims, id string) error

SetClaims - set claims to database

func SetIdentity

func SetIdentity(id string, i Identity) error

SetIdentity - set publickey from database

func SetPublicKey

func SetPublicKey(id string, pk PublicKey) error

SetPublicKey - set publickey from database

Types

type ClaimContent

type ClaimContent struct {
	Scope    map[string]interface{} `json:"scp,omitempty"`
	Contents map[string]interface{} `json:"cnt,omitempty"`
}

ClaimContent - Content of Claim

func FindContent

func FindContent(page uint, check func(k, v []byte) (*ClaimContent, error)) ([]*ClaimContent, error)

FindContent - find some claim content

func NewContent

func NewContent(scope, content map[string]interface{}) (*ClaimContent, string, error)

NewContent - Create a claim content

func (*ClaimContent) Get

func (c *ClaimContent) Get(id string) error

Get - get content from database

func (*ClaimContent) ID

func (c *ClaimContent) ID() string

ID - get id from content

func (*ClaimContent) Marshal

func (c *ClaimContent) Marshal() ([]byte, error)

Marshal - convert json content to string ([]byte)

func (*ClaimContent) Set

func (c *ClaimContent) Set() error

Set - set content to database

func (*ClaimContent) Unmarshal

func (c *ClaimContent) Unmarshal(data []byte) error

Unmarshal - convert json string ([]byte) to content

type ClaimHeader

type ClaimHeader struct {
	Type      string `json:"typ"`
	Subject   string `json:"sub"`
	Issuer    string `json:"iss"`
	Arguments string `json:"arg,omitempty"`
	Algorithm string `json:"alg,omitempty"`
}

ClaimHeader - header of claim. content of header identify the one claim to the others so ID of claim is symbol of this content

func FindHeader

func FindHeader(page uint, check func(k, v []byte) (*ClaimHeader, error)) ([]*ClaimHeader, error)

FindHeader - find some claim header

func NewHeader

func NewHeader(t, subject, issuer string) (*ClaimHeader, string, error)

NewHeader - Create a claim header

func (*ClaimHeader) Get

func (hd *ClaimHeader) Get(id string) error

Get - get claimheader from database

func (*ClaimHeader) ID

func (hd *ClaimHeader) ID() string

ID - get id from header

func (*ClaimHeader) Marshal

func (hd *ClaimHeader) Marshal() ([]byte, error)

Marshal - convert json claimheader to string ([]byte)

func (*ClaimHeader) Set

func (hd *ClaimHeader) Set() error

Set - set claimheader from database

func (*ClaimHeader) Unmarshal

func (hd *ClaimHeader) Unmarshal(data []byte) error

Unmarshal - convert json string ([]byte) to claimheader

type Claims

type Claims interface {
	Value
	ID() string
	Get(id string) error
	Set() error
	Hdr() (*ClaimHeader, error)
	Cont() (*ClaimContent, error)
}

Claims - For a type to be a Claims object

type Identity

type Identity interface {
	Value
}

Identity - interface for any identity and document convert to/from value

type PublicKey

type PublicKey interface {
	Value
}

PublicKey - interface for any publickey convert to/from value

type StandardClaim

type StandardClaim struct {
	Header  *ClaimHeader  `json:"header"`
	Content *ClaimContent `json:"content"`
	Claim   Claims        `json:"status"`
}

StandardClaim - Basic elements for claim

func (*StandardClaim) Get

func (s *StandardClaim) Get(c Claims, id string) error

Get - get status from database

func (*StandardClaim) Marshal

func (s *StandardClaim) Marshal() ([]byte, error)

Marshal - convert json status to string ([]byte)

func (*StandardClaim) Set

func (s *StandardClaim) Set() error

Set - set status to database

func (*StandardClaim) Unmarshal

func (s *StandardClaim) Unmarshal(data []byte) error

Unmarshal - convert json string ([]byte) to status

type Value

type Value interface {
	Marshal() ([]byte, error)
	Unmarshal(data []byte) error // this method need Unmarshal data to interface.

}

Value - interface for any convert to/from value Warning - Value interface need be a point implement because Unmarshal will return data into interface object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL