Skip to main content

LongTermCredentials

Struct LongTermCredentials 

Source
pub struct LongTermCredentials { /* private fields */ }
Expand description

A client’s long-term credentials for one server, and what the server’s challenges added to them. See the module documentation.

Implementations§

Source§

impl LongTermCredentials

Source

pub fn new(username: &str, password: &str) -> Result<Self>

Credentials that support the SHA-256 and MD5 password algorithms.

§Errors

RFC 8489 section 14.3: the user name is OpaqueString-processed; one the profile does not allow is refused, as is such a password (section 9.2.2).

Source

pub fn with_username_anonymity_required(self, required: bool) -> Self

With required, the user name never goes in a USERNAME attribute: a challenge whose nonce cookie does not offer username anonymity (RFC 8489 section 9.2.5, USERHASH) is refused as ChallengeError::Unusable, and nothing with the credential is sent. For a user name that reveals the user, over a transport that is not (D)TLS: RFC 8656 section 21.1.6, “If the username reveals the identity of the user, the client MUST use the USERHASH attribute … or use (D)TLS”.

Source

pub fn with_password_algorithms(self, supported: &[u16]) -> Self

Restricts the password algorithms this client accepts from a server’s PASSWORD-ALGORITHMS, for instance to SHA-256 alone (RFC 8489 section 18.5.1.1 keeps MD5 for legacy systems). Numbers other than PASSWORD_ALGORITHM_SHA256 and PASSWORD_ALGORITHM_MD5 are dropped: there is no key derivation for them.

A server that sends no PASSWORD-ALGORITHMS is an RFC 5389 server, which has MD5 only; a client that left MD5 out refuses its challenge (ChallengeError::NoSupportedAlgorithm).

Source

pub fn username(&self) -> &str

The user name, OpaqueString-processed.

Source

pub fn realm(&self) -> Option<&str>

The realm of the last challenge.

Source

pub fn nonce(&self) -> Option<&str>

The nonce of the last challenge.

Source

pub fn password_algorithm(&self) -> Option<&PasswordAlgorithm>

The password algorithm sent in PASSWORD-ALGORITHM, when the server offered a list.

Source

pub fn uses_userhash(&self) -> bool

Whether requests carry USERHASH in place of USERNAME.

Source

pub fn integrity(&self) -> Option<IntegrityAlgorithm>

The integrity attribute requests carry and responses must carry, once challenged: MESSAGE-INTEGRITY-SHA256 alone after a challenge with PASSWORD-ALGORITHMS (RFC 8489 section 9.2.5), MESSAGE-INTEGRITY otherwise.

Source

pub fn reset(&mut self)

Forgets the server’s challenge: the next request is a first request again.

Source

pub fn challenge( &mut self, request: &Message, response: &Message, crypto: &dyn RTCCrypto, ) -> Result<(), ChallengeError>

Takes the 401 (Unauthenticated) or 438 (Stale Nonce) error response to request and prepares the retry (RFC 8489 section 9.2.5).

On Ok, the realm, nonce, algorithm and key are replaced by the response’s, and the request is to be sent again in a new transaction with setter.

§Errors

The ChallengeError that says why there is no retry. The state is unchanged then.

Source

pub fn setter<'a>( &'a self, crypto: &'a dyn RTCCrypto, ) -> LongTermAuthentication<'a>

A Setter that adds the authentication attributes to a request. It goes after the request’s own attributes and ahead of FINGERPRINT.

Before the first challenge it adds nothing: the first request carries no USERNAME, USERHASH, REALM, NONCE, PASSWORD-ALGORITHMS, PASSWORD-ALGORITHM or integrity attribute (RFC 8489 section 9.2.3.1).

Source

pub fn check_response( &self, response: &Message, validator: &Validator<'_>, crypto: &dyn RTCCrypto, ) -> Result<LongTermResponse, Rejection>

Checks a response to a request that was sent with setter after a challenge, by the rules of RFC 8489 section 9.2.5. validator carries the usage’s own checks (FINGERPRINT, known attributes).

§Errors

The response is to be discarded as if it had never been received, so that the request’s retransmissions continue: Rejection::IntegrityMissing (which is what a 400 without integrity attribute gets) or Rejection::IntegrityMismatch, and, for a response whose NONCE has a cookie with the “Password algorithms” bit but which has no PASSWORD-ALGORITHMS, Rejection::IntegrityMissing as well: it is to be ignored. When every response to a request was discarded this way, the transaction’s failure is an integrity violation, not a timeout; over a reliable transport it fails at once.

Trait Implementations§

Source§

impl Debug for LongTermCredentials

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.