pub struct Jwk { /* private fields */ }Expand description
JSON Web Key.
Implementations§
Source§impl Jwk
impl Jwk
Sourcepub fn from_params(params: impl Into<JwkParams>) -> Jwk
pub fn from_params(params: impl Into<JwkParams>) -> Jwk
Creates a new Jwk from the given params.
Sourcepub fn set_kty(&mut self, value: impl Into<JwkType>)
pub fn set_kty(&mut self, value: impl Into<JwkType>)
Sets a value for the key type parameter (kty).
Removes any previously set params.
Sourcepub fn set_use(&mut self, value: impl Into<JwkUse>)
pub fn set_use(&mut self, value: impl Into<JwkUse>)
Sets a value for the key use parameter (use).
Sourcepub fn key_ops(&self) -> Option<&[JwkOperation]>
pub fn key_ops(&self) -> Option<&[JwkOperation]>
Returns the value for the key operations parameter (key_ops).
Sourcepub fn set_key_ops(
&mut self,
value: impl IntoIterator<Item = impl Into<JwkOperation>>,
)
pub fn set_key_ops( &mut self, value: impl IntoIterator<Item = impl Into<JwkOperation>>, )
Sets values for the key operations parameter (key_ops).
Sourcepub fn set_alg(&mut self, value: impl Into<String>)
pub fn set_alg(&mut self, value: impl Into<String>)
Sets a value for the algorithm property (alg).
Sourcepub fn set_kid(&mut self, value: impl Into<String>)
pub fn set_kid(&mut self, value: impl Into<String>)
Sets a value for the key ID property (kid).
Sourcepub fn set_x5u(&mut self, value: impl Into<Url>)
pub fn set_x5u(&mut self, value: impl Into<Url>)
Sets a value for the X.509 URL property (x5u).
Sourcepub fn x5c(&self) -> Option<&[String]>
pub fn x5c(&self) -> Option<&[String]>
Returns the value of the X.509 certificate chain property (x5c).
Sourcepub fn set_x5c(&mut self, value: impl IntoIterator<Item = impl Into<String>>)
pub fn set_x5c(&mut self, value: impl IntoIterator<Item = impl Into<String>>)
Sets values for the X.509 certificate chain property (x5c).
Sourcepub fn x5t(&self) -> Option<&str>
pub fn x5t(&self) -> Option<&str>
Returns the value of the X.509 certificate SHA-1 thumbprint property (x5t).
Sourcepub fn set_x5t(&mut self, value: impl Into<String>)
pub fn set_x5t(&mut self, value: impl Into<String>)
Sets a value for the X.509 certificate SHA-1 thumbprint property (x5t).
Sourcepub fn x5t_s256(&self) -> Option<&str>
pub fn x5t_s256(&self) -> Option<&str>
Returns the value of the X.509 certificate SHA-256 thumbprint property (x5t#S256).
Sourcepub fn set_x5t_s256(&mut self, value: impl Into<String>)
pub fn set_x5t_s256(&mut self, value: impl Into<String>)
Sets a value for the X.509 certificate SHA-256 thumbprint property (x5t#S256).
Sourcepub fn params_mut(&mut self) -> &mut JwkParams
pub fn params_mut(&mut self) -> &mut JwkParams
Returns a mutable reference to the custom JWK properties.
Sourcepub fn set_params(&mut self, params: impl Into<JwkParams>) -> Result<(), Error>
pub fn set_params(&mut self, params: impl Into<JwkParams>) -> Result<(), Error>
Sets the value of the custom JWK properties.
The passed params must be appropriate for the key type (kty), an error is returned otherwise.
If you want to set params unchecked, use set_params_unchecked.
Sourcepub fn set_params_unchecked(&mut self, value: impl Into<JwkParams>)
pub fn set_params_unchecked(&mut self, value: impl Into<JwkParams>)
Sets the value of the custom JWK properties.
Does not check whether the passed params are appropriate for the set key type (kty).
Sourcepub fn try_ec_params(&self) -> Result<&JwkParamsEc, Error>
pub fn try_ec_params(&self) -> Result<&JwkParamsEc, Error>
Returns the JwkParamsEc in this JWK if it is of type Ec.
Sourcepub fn try_ec_params_mut(&mut self) -> Result<&mut JwkParamsEc, Error>
pub fn try_ec_params_mut(&mut self) -> Result<&mut JwkParamsEc, Error>
Returns a mutable reference to the JwkParamsEc in this JWK if it is of type Ec.
Sourcepub fn try_rsa_params(&self) -> Result<&JwkParamsRsa, Error>
pub fn try_rsa_params(&self) -> Result<&JwkParamsRsa, Error>
Returns the JwkParamsRsa in this JWK if it is of type Rsa.
Sourcepub fn try_rsa_params_mut(&mut self) -> Result<&mut JwkParamsRsa, Error>
pub fn try_rsa_params_mut(&mut self) -> Result<&mut JwkParamsRsa, Error>
Returns a mutable reference to the JwkParamsRsa in this JWK if it is of type Rsa.
Sourcepub fn try_oct_params(&self) -> Result<&JwkParamsOct, Error>
pub fn try_oct_params(&self) -> Result<&JwkParamsOct, Error>
Returns the JwkParamsOct in this JWK if it is of type Oct.
Sourcepub fn try_oct_params_mut(&mut self) -> Result<&mut JwkParamsOct, Error>
pub fn try_oct_params_mut(&mut self) -> Result<&mut JwkParamsOct, Error>
Returns a mutable reference to the JwkParamsOct in this JWK if it is of type Oct.
Sourcepub fn try_okp_params(&self) -> Result<&JwkParamsOkp, Error>
pub fn try_okp_params(&self) -> Result<&JwkParamsOkp, Error>
Returns the JwkParamsOkp in this JWK if it is of type Okp.
Sourcepub fn try_okp_params_mut(&mut self) -> Result<&mut JwkParamsOkp, Error>
pub fn try_okp_params_mut(&mut self) -> Result<&mut JwkParamsOkp, Error>
Returns a mutable reference to the JwkParamsOkp in this JWK if it is of type Okp.
Sourcepub fn try_akp_params(&self) -> Result<&JwkParamsAkp, Error>
pub fn try_akp_params(&self) -> Result<&JwkParamsAkp, Error>
Returns the JwkParamsAkp in this JWK if it is of type Akp.
Sourcepub fn try_akp_params_mut(&mut self) -> Result<&mut JwkParamsAkp, Error>
pub fn try_akp_params_mut(&mut self) -> Result<&mut JwkParamsAkp, Error>
Returns a mutable reference to the JwkParamsAkp in this JWK if it is of type Akp.
Sourcepub fn thumbprint_sha256_b64(&self) -> String
pub fn thumbprint_sha256_b64(&self) -> String
Creates a Thumbprint of the JSON Web Key according to RFC7638.
SHA2-256 is used as the hash function H.
The thumbprint is returned as a base64url-encoded string.
Sourcepub fn thumbprint_sha256(&self) -> [u8; 32]
pub fn thumbprint_sha256(&self) -> [u8; 32]
Creates a Thumbprint of the JSON Web Key according to RFC7638.
SHA2-256 is used as the hash function H.
The thumbprint is returned as an unencoded array of bytes.
Sourcepub fn thumbprint_hash_input(&self) -> String
pub fn thumbprint_hash_input(&self) -> String
Creates the JSON string of the JSON Web Key according to RFC7638, which is used as the input for the JWK thumbprint hashing procedure. This can be used as input for a custom hash function.
Sourcepub fn check_alg(&self, expected: impl AsRef<str>) -> Result<(), Error>
pub fn check_alg(&self, expected: impl AsRef<str>) -> Result<(), Error>
Checks if the alg claim of the JWK is equal to expected.
Sourcepub fn try_ec_curve(&self) -> Result<EcCurve, Error>
pub fn try_ec_curve(&self) -> Result<EcCurve, Error>
Returns the EcCurve of this JWK if it is of type Ec.
Sourcepub fn try_ed_curve(&self) -> Result<EdCurve, Error>
pub fn try_ed_curve(&self) -> Result<EdCurve, Error>
Returns the EdCurve of this JWK if it is of type Okp.
Sourcepub fn try_ecx_curve(&self) -> Result<EcxCurve, Error>
pub fn try_ecx_curve(&self) -> Result<EcxCurve, Error>
Returns the EcxCurve of this JWK if it is of type Okp.
Sourcepub fn is_public(&self) -> bool
pub fn is_public(&self) -> bool
Returns true if all private key components of the key are unset, false otherwise.
Sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Returns true if all private key components of the key are set, false otherwise.
Sourcepub fn to_public(&self) -> Option<Jwk>
pub fn to_public(&self) -> Option<Jwk>
Returns a clone of the Jwk with all private key components unset.
The None variant is returned when kty = oct as this key type is not considered public by this library.
Sourcepub fn strip_private(&mut self)
pub fn strip_private(&mut self)
Removes all private key components. In the case of JwkParams::Oct, this method does nothing.
Sourcepub fn into_public(self) -> Option<Jwk>
pub fn into_public(self) -> Option<Jwk>
Returns this key with all private key components unset. In the case of JwkParams::Oct, this method returns None.
Trait Implementations§
Source§impl AsRef<Jwk> for PostQuantumJwk
impl AsRef<Jwk> for PostQuantumJwk
Source§impl AsRef<Jwk> for TraditionalJwk
impl AsRef<Jwk> for TraditionalJwk
Source§impl<'de> Deserialize<'de> for Jwk
impl<'de> Deserialize<'de> for Jwk
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Jwk, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Jwk, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<PostQuantumJwk> for Jwk
impl From<PostQuantumJwk> for Jwk
Source§fn from(value: PostQuantumJwk) -> Jwk
fn from(value: PostQuantumJwk) -> Jwk
Source§impl From<TraditionalJwk> for Jwk
impl From<TraditionalJwk> for Jwk
Source§fn from(value: TraditionalJwk) -> Jwk
fn from(value: TraditionalJwk) -> Jwk
Source§impl FromIterator<Jwk> for JwkSet
impl FromIterator<Jwk> for JwkSet
Source§impl Serialize for Jwk
impl Serialize for Jwk
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl TryFrom<Jwk> for PostQuantumJwk
impl TryFrom<Jwk> for PostQuantumJwk
Source§impl TryFrom<Jwk> for TraditionalJwk
impl TryFrom<Jwk> for TraditionalJwk
impl Eq for Jwk
impl StructuralPartialEq for Jwk
Auto Trait Implementations§
impl Freeze for Jwk
impl RefUnwindSafe for Jwk
impl Send for Jwk
impl Sync for Jwk
impl Unpin for Jwk
impl UnwindSafe for Jwk
Blanket Implementations§
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> ConvertTo<T> for Twhere
T: Send,
impl<T> ConvertTo<T> for Twhere
T: Send,
fn convert(self) -> Result<T, Error>
fn convert_unchecked(self) -> T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Source§impl<T> FromJson for Twhere
T: for<'de> Deserialize<'de>,
impl<T> FromJson for Twhere
T: for<'de> Deserialize<'de>,
Source§fn from_json(json: &(impl AsRef<str> + ?Sized)) -> Result<Self, Error>
fn from_json(json: &(impl AsRef<str> + ?Sized)) -> Result<Self, Error>
Self from a string of JSON text.Source§fn from_json_slice(json: &(impl AsRef<[u8]> + ?Sized)) -> Result<Self, Error>
fn from_json_slice(json: &(impl AsRef<[u8]> + ?Sized)) -> Result<Self, Error>
Self from bytes of JSON text.Source§fn from_json_value(json: Value) -> Result<Self, Error>
fn from_json_value(json: Value) -> Result<Self, Error>
Self from a serde_json::Value.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a Request§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> ToJson for Twhere
T: Serialize,
impl<T> ToJson for Twhere
T: Serialize,
Source§fn to_json_value(&self) -> Result<Value, Error>
fn to_json_value(&self) -> Result<Value, Error>
self as a serde_json::Value.