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>
impl<S: ScramHashing, A: ScramAuthClient, B: ScramCbHelper> SyncScramClient<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<SyncScramClient<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<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 theSCRAM
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);
Sourcepub fn is_completed(&self) -> bool
pub fn is_completed(&self) -> bool
Checks if the client authentification was completed successfully.
Sourcepub fn init_client(&mut self) -> ScramResultClient
pub fn init_client(&mut self) -> ScramResultClient
Sourcepub fn parse_response_base64<T: AsRef<[u8]>>(
&mut self,
input: T,
) -> ScramResult<ScramResultClient>
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
- 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 fn parse_response(&mut self, resp: &str) -> ScramResult<ScramResultClient>
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
- 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.