1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::key_pair::KeyPair;

pub struct UserInfo {
    pub(crate) auth_type: AuthType,
    pub(crate) username: String,
    pub(crate) password: String,
    pub(crate) key_pair: KeyPair
}

impl UserInfo {

    pub fn from_key_pair<S: ToString>(user_name: S, key_pair: KeyPair) -> Self {
        UserInfo {
            auth_type: AuthType::PublicKey,
            username: user_name.to_string(),
            password: "".to_string(),
            key_pair
        }
    }

    pub fn from_password<S: ToString>(user_name: S, password: S) -> Self {
        UserInfo {
            auth_type: AuthType::Password,
            username: user_name.to_string(),
            password: password.to_string(),
            key_pair: KeyPair::new()
        }
    }

}


pub enum AuthType {
    Password,
    PublicKey
}