当前位置: 首页>>代码示例>>Golang>>正文


Golang JsonWebKey.UnmarshalJSON方法代码示例

本文整理汇总了Golang中github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/letsencrypt/go-jose.JsonWebKey.UnmarshalJSON方法的典型用法代码示例。如果您正苦于以下问题:Golang JsonWebKey.UnmarshalJSON方法的具体用法?Golang JsonWebKey.UnmarshalJSON怎么用?Golang JsonWebKey.UnmarshalJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/letsencrypt/go-jose.JsonWebKey的用法示例。


在下文中一共展示了JsonWebKey.UnmarshalJSON方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GetRegistration

func (sa *MockSA) GetRegistration(id int64) (core.Registration, error) {
	if id == 100 {
		// Tag meaning "Missing"
		return core.Registration{}, errors.New("missing")
	}
	if id == 101 {
		// Tag meaning "Malformed"
		return core.Registration{}, nil
	}

	keyJSON := []byte(test1KeyPublicJSON)
	var parsedKey jose.JsonWebKey
	parsedKey.UnmarshalJSON(keyJSON)

	return core.Registration{ID: id, Key: parsedKey, Agreement: agreementURL}, nil
}
开发者ID:tomclegg,项目名称:boulder,代码行数:16,代码来源:web-front-end_test.go

示例2: GetRegistrationByKey

func (sa *MockSA) GetRegistrationByKey(jwk jose.JsonWebKey) (core.Registration, error) {
	var test1KeyPublic jose.JsonWebKey
	var test2KeyPublic jose.JsonWebKey
	test1KeyPublic.UnmarshalJSON([]byte(test1KeyPublicJSON))
	test2KeyPublic.UnmarshalJSON([]byte(test2KeyPublicJSON))

	if core.KeyDigestEquals(jwk, test1KeyPublic) {
		return core.Registration{ID: 1, Key: jwk, Agreement: agreementURL}, nil
	}

	if core.KeyDigestEquals(jwk, test2KeyPublic) {
		// No key found
		return core.Registration{ID: 2}, sql.ErrNoRows
	}

	// Return a fake registration. Make sure to fill the key field to avoid marshaling errors.
	return core.Registration{ID: 1, Key: test1KeyPublic, Agreement: agreementURL}, nil
}
开发者ID:tomclegg,项目名称:boulder,代码行数:18,代码来源:web-front-end_test.go


注:本文中的github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/letsencrypt/go-jose.JsonWebKey.UnmarshalJSON方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。