SyncScramClient

Struct SyncScramClient 

Source
pub struct SyncScramClient<S: ScramHashing, A: ScramAuthClient, B: ScramCbHelper> { /* private fields */ }
Expand description

§A Scram Client

S: ScramHashing a developer should manually preprogram the ScramHashing for every supported by their’s program types of auth.
A: ScramAuthClient a developes should attach a ScramAuthClient trait to his implementation where the username and password are stored or implement one.

If code which uses this crate supports channel binding then the code uses this crate should find out how to extract endpoint certificate from TLS connection. i.e native_tls::TlsStream::tls_server_end_point()

Implementations§

Source§

impl<S: ScramHashing, A: ScramAuthClient, B: ScramCbHelper> SyncScramClient<S, A, B>

Source

pub fn new( scram_auth_cli: A, scram_nonce: ScramNonce, chan_bind_type: ChannelBindType, chan_bind_helper: B, ignore_exts: bool, ) -> ScramResult<SyncScramClient<S, A, B>>

Creates a new client instance with borrowed arguments. Sets all fields to default instance.

§Arguments
  • scram_auth_cli - an authentification instance which implements ScramAuthClient

  • scram_nonce - a client scram nonce ScramNonce

  • chan_bind_type - picks the channel bound ChannelBindType. It is responsibility of the developer to correctly set the chan binding type.

  • chan_bind_helper - a data type which implements a traint ScramCbHelper which contains functions for realization which are designed to provide the channel bind data to the SCRAM crate.

  • ignore_exts - if set to true ignores the unsupported extensions which may be found after the main data. Otherwise, the error will be generated reporting unexpected data.

§Examples
let cbt = ChannelBindType::None;

let ac = AuthClient::new(username, password);
let nonce = ScramNonce::Plain(&client_nonce_dec);

let scram_res = SyncScramClient::<ScramSha256, &AuthClient, &AuthClient>::new(&ac, nonce, cbt, &ac);
Source

pub fn is_completed(&self) -> bool

Checks if the client authentification was completed successfully.

Source

pub fn init_client(&mut self) -> ScramResultClient

Initializes the SCRAM negoatiation from client

§Arguments
  • to_base64 - when set to true, the generated response will be encoded to base64.
§Returns
  • base64 encoded or plain string with formed message
Source

pub fn parse_response_base64<T: AsRef<[u8]>>( &mut self, input: T, ) -> ScramResult<ScramResultClient>

Decodes the response from server which is in base64 encoded and performes parsing and result computation.

§Arguments
  • input - a base64 encoded response from server
§Returns
Source

pub fn parse_response(&mut self, resp: &str) -> ScramResult<ScramResultClient>

Performes parsing of the response from server and result computation.
It is assumed that resp is UTF-8 valid sequences

§Arguments
  • resp - A response from client as ref str.

  • to_base64 - if set to true, will encode response into base64.

§Returns
Source§

impl<'cc, S: ScramHashing + 'cc, A: ScramAuthClient + 'cc, B: ScramCbHelper + 'cc> SyncScramClient<S, A, B>

Source

pub fn make_dyn(self) -> Box<dyn ScramClientDyn + 'cc>

Trait Implementations§

Source§

impl<S: Debug + ScramHashing, A: Debug + ScramAuthClient, B: Debug + ScramCbHelper> Debug for SyncScramClient<S, A, B>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S: ScramHashing, A: ScramAuthClient, B: ScramCbHelper> ScramClientDyn for SyncScramClient<S, A, B>

Auto Trait Implementations§

§

impl<S, A, B> Freeze for SyncScramClient<S, A, B>
where A: Freeze, B: Freeze,

§

impl<S, A, B> RefUnwindSafe for SyncScramClient<S, A, B>

§

impl<S, A, B> Send for SyncScramClient<S, A, B>
where A: Send, B: Send, S: Send,

§

impl<S, A, B> Sync for SyncScramClient<S, A, B>
where A: Sync, B: Sync, S: Sync,

§

impl<S, A, B> Unpin for SyncScramClient<S, A, B>
where A: Unpin, B: Unpin, S: Unpin,

§

impl<S, A, B> UnwindSafe for SyncScramClient<S, A, B>
where A: UnwindSafe, B: UnwindSafe, S: UnwindSafe,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.