本文整理匯總了Golang中camlistore/org/pkg/schema.Builder.SetSigner方法的典型用法代碼示例。如果您正苦於以下問題:Golang Builder.SetSigner方法的具體用法?Golang Builder.SetSigner怎麽用?Golang Builder.SetSigner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類camlistore/org/pkg/schema.Builder
的用法示例。
在下文中一共展示了Builder.SetSigner方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: uploadAndSign
func (id *IndexDeps) uploadAndSign(m *schema.Builder) blob.Ref {
m.SetSigner(id.SignerBlobRef)
unsigned, err := m.JSON()
if err != nil {
id.Fatalf("uploadAndSignMap: " + err.Error())
}
sr := &jsonsign.SignRequest{
UnsignedJSON: unsigned,
Fetcher: id.PublicKeyFetcher,
EntityFetcher: id.EntityFetcher,
SignatureTime: id.now,
}
signed, err := sr.Sign()
if err != nil {
id.Fatalf("problem signing: " + err.Error())
}
tb := &test.Blob{Contents: signed}
_, err = id.BlobSource.ReceiveBlob(tb.BlobRef(), tb.Reader())
if err != nil {
id.Fatalf("public uploading signed blob to blob source, pre-indexing: %v, %v", tb.BlobRef(), err)
}
_, err = id.Index.ReceiveBlob(tb.BlobRef(), tb.Reader())
if err != nil {
id.Fatalf("problem indexing blob: %v\nblob was:\n%s", err, signed)
}
return tb.BlobRef()
}
示例2: Sign
func (h *Handler) Sign(bb *schema.Builder) (string, error) {
bb.SetSigner(h.pubKeyBlobRef)
unsigned, err := bb.JSON()
if err != nil {
return "", err
}
sreq := &jsonsign.SignRequest{
UnsignedJSON: unsigned,
Fetcher: h.pubKeyFetcher,
ServerMode: true,
SecretKeyringPath: h.secretRing,
}
claimTime, err := bb.Blob().ClaimDate()
if err != nil {
if !schema.IsMissingField(err) {
return "", err
}
} else {
sreq.SignatureTime = claimTime
}
if err := h.uploadPublicKey(); err != nil {
log.Printf("signing handler failed to upload public key: %v", err)
}
return sreq.Sign()
}