pub struct AsyncScramClient<S: ScramHashing, A: AsyncScramAuthClient + Sync, B: AsyncScramCbHelper> { /* 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: AsyncScramAuthClient a developes should attach a AsyncScramAuthClient
trait to his implementation where the username and password are stored or
implement one.
If a developer which to use a channel bind then developer should find out how to extract endpoint certificate from his TLS connection. i.e native_tls::TlsStream::tls_server_end_point()
Implementations§
Source§impl<S: ScramHashing, A: AsyncScramAuthClient + Sync, B: AsyncScramCbHelper> AsyncScramClient<S, A, B>
impl<S: ScramHashing, A: AsyncScramAuthClient + Sync, B: AsyncScramCbHelper> AsyncScramClient<S, A, B>
Sourcepub fn new(
scram_auth_cli: A,
scram_nonce: ScramNonce,
chan_bind_type: ChannelBindType,
chan_bind_helper: B,
ignore_exts: bool,
) -> ScramResult<AsyncScramClient<S, A, B>>
pub fn new( scram_auth_cli: A, scram_nonce: ScramNonce, chan_bind_type: ChannelBindType, chan_bind_helper: B, ignore_exts: bool, ) -> ScramResult<AsyncScramClient<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 theSCRAM
crate.
§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);
Sourcepub fn is_completed(&self) -> bool
pub fn is_completed(&self) -> bool
Checks if the client authentification was completed successfully.
Sourcepub async fn init_client(&mut self) -> ScramResultClient
pub async fn init_client(&mut self) -> ScramResultClient
Sourcepub async fn parse_response_base64<T: AsRef<[u8]>>(
&mut self,
input: T,
) -> ScramResult<ScramResultClient>
pub async 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
- The Result is returned as alias ScramResult.
-
Result::Ok is returned with ScramResultClient which contains a hint how to act on the next step.
-
Result::Err is returned in case of error.
Sourcepub async fn parse_response(
&mut self,
resp: &str,
) -> ScramResult<ScramResultClient>
pub async 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
- The Result is returned as alias ScramResult.
-
Result::Ok is returned with ScramResultClient which contains a hint how to act on the next step.
-
Result::Err is returned in case of error.