當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Builder.SetSigner方法代碼示例

本文整理匯總了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()
}
開發者ID:stevearm,項目名稱:camlistore,代碼行數:27,代碼來源:tests.go

示例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()
}
開發者ID:rfistman,項目名稱:camlistore,代碼行數:25,代碼來源:sig.go


注:本文中的camlistore/org/pkg/schema.Builder.SetSigner方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。