Skip to content

class JsonWebKeyConverter

cangjie
public class JsonWebKeyConverter

功能:提供 SecurityKeyJsonWebKey 的双向转换能力。

成员概览

成员功能
func convertFromSecurityKey(SecurityKey)将安全密钥转换为 JWK。
func convertFromSymmetricSecurityKey(SymmetricSecurityKey, ?String)将对称密钥转换为 JWK。
func convertFromECDsaSecurityKey(ECDsaSecurityKey, ?String)将 ECDSA 密钥转换为 JWK。
func convertFromRsaSecurityKey(RsaSecurityKey, ?String)将 RSA 密钥转换为 JWK。
func convertFromSigningCredentials(SigningCredentials)将签名凭据转换为 JWK。
func convertToSecurityKey(JsonWebKey)将 JWK 转换为具体安全密钥。

func convertFromSecurityKey(SecurityKey)

cangjie
public static func convertFromSecurityKey(key: SecurityKey): JsonWebKey

功能:将安全密钥转换为 JWK。

参数:

返回值:

异常:

  • UnsupportedException - 当密钥类型不受支持时抛出。

func convertFromSymmetricSecurityKey(SymmetricSecurityKey, ?String)

cangjie
public static func convertFromSymmetricSecurityKey(key: SymmetricSecurityKey, algorithm!: ?String = None): JsonWebKey

功能:将对称密钥转换为 JWK。

参数:

  • key: SymmetricSecurityKey - 要转换的对称密钥。
  • algorithm: ?String - 可选的算法标识。

返回值:

func convertFromECDsaSecurityKey(ECDsaSecurityKey, ?String)

cangjie
public static func convertFromECDsaSecurityKey(key: ECDsaSecurityKey, algorithm!: ?String = None): JsonWebKey

功能:将 ECDSA 密钥转换为 JWK。

参数:

  • key: ECDsaSecurityKey - 要转换的 ECDSA 密钥。
  • algorithm: ?String - 可选的算法标识。

返回值:

func convertFromRsaSecurityKey(RsaSecurityKey, ?String)

cangjie
public static func convertFromRsaSecurityKey(key: RsaSecurityKey, algorithm!: ?String = None): JsonWebKey

功能:将 RSA 密钥转换为 JWK。

参数:

  • key: RsaSecurityKey - 要转换的 RSA 密钥。
  • algorithm: ?String - 可选的算法标识。

返回值:

func convertFromSigningCredentials(SigningCredentials)

cangjie
public static func convertFromSigningCredentials(signingCredentials: SigningCredentials): JsonWebKey

功能:将签名凭据转换为 JWK。

参数:

返回值:

异常:

  • UnsupportedException - 当密钥类型不受支持时抛出。

func convertToSecurityKey(JsonWebKey)

cangjie
public static func convertToSecurityKey(jsonWebKey: JsonWebKey): SecurityKey

功能:将 JWK 转换为具体安全密钥。

参数:

返回值:

异常:

  • UnsupportedException - 当 kty 不受支持时抛出。