pub struct KerberosClient {
pub client_principal: PrincipalName,
pub realm: String,
/* private fields */
}Expand description
Kerberos v5 client.
Handles AS-REQ (initial authentication) and TGS-REQ (service ticket request) flows.
Fields§
§client_principal: PrincipalNameClient principal
realm: StringRealm
Implementations§
Source§impl KerberosClient
impl KerberosClient
Sourcepub fn new(username: &str, realm: &str, password: &str) -> Self
pub fn new(username: &str, realm: &str, password: &str) -> Self
Create a new Kerberos client.
Derives a long-term key from the password using string2key.
Sourcepub fn has_valid_tgt(&self) -> bool
pub fn has_valid_tgt(&self) -> bool
Whether the client has a valid (non-expired) TGT.
Sourcepub fn session_key(&self) -> Option<&[u8]>
pub fn session_key(&self) -> Option<&[u8]>
Get the session key, if present.
Sourcepub fn request_tgt(&mut self) -> Vec<u8>
pub fn request_tgt(&mut self) -> Vec<u8>
Build an AS-REQ message to request a TGT.
Returns BER-encoded bytes ready to send to the KDC.
Sourcepub fn parse_as_rep(&mut self, _data: &[u8]) -> Result<AsRepParts, KernelError>
pub fn parse_as_rep(&mut self, _data: &[u8]) -> Result<AsRepParts, KernelError>
Parse an AS-REP message.
Extracts the TGT and encrypted part. The caller must decrypt the encrypted part using the client’s long-term key to obtain the session key.
Sourcepub fn store_tgt(
&mut self,
ticket: Ticket,
session_key: Vec<u8>,
expiry: KerberosTime,
)
pub fn store_tgt( &mut self, ticket: Ticket, session_key: Vec<u8>, expiry: KerberosTime, )
Store a TGT obtained from an AS-REP.
Sourcepub fn request_service_ticket(
&mut self,
service: &str,
hostname: &str,
) -> Result<Vec<u8>, KernelError>
pub fn request_service_ticket( &mut self, service: &str, hostname: &str, ) -> Result<Vec<u8>, KernelError>
Build a TGS-REQ message to request a service ticket.
Requires a valid TGT (obtained via request_tgt + parse_as_rep).
Sourcepub fn parse_tgs_rep(
&mut self,
_data: &[u8],
) -> Result<TgsRepParts, KernelError>
pub fn parse_tgs_rep( &mut self, _data: &[u8], ) -> Result<TgsRepParts, KernelError>
Parse a TGS-REP message.