Cred

Struct Cred 

Source
pub struct Cred(/* private fields */);
Expand description

gssapi credentials.

Implementations§

Source§

impl Cred

Source

pub fn acquire( name: Option<&Name>, time_req: Option<Duration>, usage: CredUsage, desired_mechs: Option<&OidSet>, ) -> Result<Cred, Error>

Acquire gssapi credentials for name or the default name, lasting for time_req or as long as possible, for the purpose of usage, and for use with desired_mechs or the default mechanism.

Examples found in repository?
examples/krb5.rs (lines 95-97)
86fn setup_server_ctx(
87    service_name: &[u8],
88    desired_mechs: &OidSet
89) -> Result<(ServerCtx, Name), Error> {
90    println!("import name");
91    let name = Name::new(service_name, Some(&GSS_NT_HOSTBASED_SERVICE))?;
92    let cname = name.canonicalize(Some(&GSS_MECH_KRB5))?;
93    println!("canonicalize name for kerberos 5");
94    println!("server name: {}, server cname: {}", name, cname);
95    let server_cred = Cred::acquire(
96        Some(&cname), None, CredUsage::Accept, Some(desired_mechs)
97    )?;
98    println!("acquired server credentials: {:#?}", server_cred.info()?);
99    Ok((ServerCtx::new(Some(server_cred)), cname))
100}
101
102fn setup_client_ctx(
103    service_name: Name,
104    desired_mechs: &OidSet
105) -> Result<ClientCtx, Error> {
106    let client_cred = Cred::acquire(
107        None, None, CredUsage::Initiate, Some(&desired_mechs)
108    )?;
109    println!("acquired default client credentials: {:#?}", client_cred.info()?);
110    Ok(ClientCtx::new(
111        Some(client_cred), service_name, CtxFlags::GSS_C_MUTUAL_FLAG, Some(&GSS_MECH_KRB5)
112    ))
113}
Source

pub fn acquire_with_password( name: Option<&Name>, password: &str, time_req: Option<Duration>, usage: CredUsage, desired_mechs: Option<&OidSet>, ) -> Result<Cred, Error>

Source

pub fn store( &self, overwrite: bool, default: bool, usage: CredUsage, desired_mech: Option<&Oid>, ) -> Result<(OidSet, CredUsage), Error>

Store the credential into default credentials cache. See gss_store_cred.

Source

pub fn info(&self) -> Result<CredInfo, Error>

Return all the information associated with this credential

Examples found in repository?
examples/krb5.rs (line 98)
86fn setup_server_ctx(
87    service_name: &[u8],
88    desired_mechs: &OidSet
89) -> Result<(ServerCtx, Name), Error> {
90    println!("import name");
91    let name = Name::new(service_name, Some(&GSS_NT_HOSTBASED_SERVICE))?;
92    let cname = name.canonicalize(Some(&GSS_MECH_KRB5))?;
93    println!("canonicalize name for kerberos 5");
94    println!("server name: {}, server cname: {}", name, cname);
95    let server_cred = Cred::acquire(
96        Some(&cname), None, CredUsage::Accept, Some(desired_mechs)
97    )?;
98    println!("acquired server credentials: {:#?}", server_cred.info()?);
99    Ok((ServerCtx::new(Some(server_cred)), cname))
100}
101
102fn setup_client_ctx(
103    service_name: Name,
104    desired_mechs: &OidSet
105) -> Result<ClientCtx, Error> {
106    let client_cred = Cred::acquire(
107        None, None, CredUsage::Initiate, Some(&desired_mechs)
108    )?;
109    println!("acquired default client credentials: {:#?}", client_cred.info()?);
110    Ok(ClientCtx::new(
111        Some(client_cred), service_name, CtxFlags::GSS_C_MUTUAL_FLAG, Some(&GSS_MECH_KRB5)
112    ))
113}
Source

pub fn name(&self) -> Result<Name, Error>

Return the name associated with this credential

Source

pub fn proxy(&self) -> Result<Option<Name>, Error>

Return the proxy service associated with this credential

Source

pub fn lifetime(&self) -> Result<Duration, Error>

Return the lifetime of this credential

Source

pub fn usage(&self) -> Result<CredUsage, Error>

Return the allowed usage of this credential

Source

pub fn mechanisms(&self) -> Result<OidSet, Error>

Return the mechanisms this credential may be used with

Trait Implementations§

Source§

impl Clone for Cred

Source§

fn clone(&self) -> Cred

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Cred

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<*mut gss_cred_id_struct> for Cred

Source§

fn from(id: gss_cred_id_t) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Cred

§

impl RefUnwindSafe for Cred

§

impl Send for Cred

§

impl Sync for Cred

§

impl Unpin for Cred

§

impl UnwindSafe for Cred

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.