本文整理汇总了Golang中euphoria/io/heim/proto/security.Capability.CapabilityID方法的典型用法代码示例。如果您正苦于以下问题:Golang Capability.CapabilityID方法的具体用法?Golang Capability.CapabilityID怎么用?Golang Capability.CapabilityID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类euphoria/io/heim/proto/security.Capability
的用法示例。
在下文中一共展示了Capability.CapabilityID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: decryptRoomKey
func decryptRoomKey(clientKey *security.ManagedKey, capability security.Capability) (
*security.ManagedKey, error) {
if clientKey.Encrypted() {
return nil, security.ErrKeyMustBeDecrypted
}
iv, err := base64.URLEncoding.DecodeString(capability.CapabilityID())
if err != nil {
return nil, err
}
roomKeyJSON := capability.EncryptedPayload()
if err := clientKey.BlockCrypt(iv, clientKey.Plaintext, roomKeyJSON, false); err != nil {
return nil, err
}
roomKey := &security.ManagedKey{
KeyType: security.AES128,
}
if err := json.Unmarshal(clientKey.Unpad(roomKeyJSON), &roomKey.Plaintext); err != nil {
return nil, err
}
return roomKey, nil
}
示例2: Save
func (cs *capabilities) Save(ctx scope.Context, account proto.Account, c security.Capability) error {
cs.Lock()
defer cs.Unlock()
if cs.capabilities == nil {
cs.capabilities = map[string]security.Capability{}
cs.accounts = map[string]proto.Account{}
}
cid := c.CapabilityID()
cs.capabilities[cid] = c
cs.accounts[cid] = account
return nil
}
示例3: Save
func (rmc *RoomManagerCapabilities) Save(
ctx scope.Context, account proto.Account, c security.Capability) error {
capRow := &Capability{
ID: c.CapabilityID(),
NonceBytes: c.Nonce(),
EncryptedPrivateData: c.EncryptedPayload(),
PublicData: c.PublicPayload(),
}
rmCapRow := &RoomManagerCapability{
Room: rmc.Room.Name,
CapabilityID: c.CapabilityID(),
Granted: time.Now(),
}
if account != nil {
capRow.AccountID = account.ID().String()
rmCapRow.AccountID = account.ID().String()
}
return rmc.Executor.Insert(capRow, rmCapRow)
}