@@ -13,18 +13,19 @@ use super::Authenticate;
1313use log:: error;
1414use parsec_interface:: requests:: request:: RequestAuth ;
1515use parsec_interface:: requests:: { ResponseStatus , Result } ;
16+ use parsec_interface:: secrecy:: ExposeSecret ;
1617use std:: str;
1718
1819#[ derive( Copy , Clone , Debug ) ]
1920pub struct DirectAuthenticator ;
2021
2122impl Authenticate for DirectAuthenticator {
2223 fn authenticate ( & self , auth : & RequestAuth ) -> Result < ApplicationName > {
23- if auth. is_empty ( ) {
24+ if auth. buffer . expose_secret ( ) . is_empty ( ) {
2425 error ! ( "The direct authenticator does not expect empty authentication values." ) ;
2526 Err ( ResponseStatus :: AuthenticationError )
2627 } else {
27- match str:: from_utf8 ( auth. bytes ( ) ) {
28+ match str:: from_utf8 ( auth. buffer . expose_secret ( ) ) {
2829 Ok ( str) => Ok ( ApplicationName ( String :: from ( str) ) ) ,
2930 Err ( _) => {
3031 error ! ( "Error parsing the authentication value as a UTF-8 string." ) ;
@@ -47,7 +48,7 @@ mod test {
4748 let authenticator = DirectAuthenticator { } ;
4849
4950 let app_name = "app_name" . to_string ( ) ;
50- let req_auth = RequestAuth :: from_bytes ( app_name. clone ( ) . into_bytes ( ) ) ;
51+ let req_auth = RequestAuth :: new ( app_name. clone ( ) . into_bytes ( ) ) ;
5152
5253 let auth_name = authenticator
5354 . authenticate ( & req_auth)
@@ -60,7 +61,7 @@ mod test {
6061 fn failed_authentication ( ) {
6162 let authenticator = DirectAuthenticator { } ;
6263 let status = authenticator
63- . authenticate ( & RequestAuth :: from_bytes ( vec ! [ 0xff ; 5 ] ) )
64+ . authenticate ( & RequestAuth :: new ( vec ! [ 0xff ; 5 ] ) )
6465 . expect_err ( "Authentication should have failed" ) ;
6566
6667 assert_eq ! ( status, ResponseStatus :: AuthenticationError ) ;
@@ -70,7 +71,7 @@ mod test {
7071 fn empty_auth ( ) {
7172 let authenticator = DirectAuthenticator { } ;
7273 let status = authenticator
73- . authenticate ( & RequestAuth :: from_bytes ( Vec :: new ( ) ) )
74+ . authenticate ( & RequestAuth :: new ( Vec :: new ( ) ) )
7475 . expect_err ( "Empty auth should have failed" ) ;
7576
7677 assert_eq ! ( status, ResponseStatus :: AuthenticationError ) ;
0 commit comments