PolicyBuilder

Struct PolicyBuilder 

Source
pub struct PolicyBuilder { /* private fields */ }
Expand description

Utility to create a policy

let kadm = kadmin::KAdmin::builder().with_ccache(None, None).unwrap();
let polname = String::from("mynewpol");
let password_max_life = Some(Duration::from_secs(365 * 24 * 60 * 60));
let policy = Policy::builder(&polname)
    .password_max_life(password_max_life)
    .create(&kadm)
    .unwrap();
assert_eq!(policy.password_max_life(), password_max_life);

Implementations§

Source§

impl PolicyBuilder

Source

pub fn password_min_life(self, password_min_life: Option<Duration>) -> Self

Set the minimum lifetime of a password

Pass None to clear it. Defaults to not set

Source

pub fn password_max_life(self, password_max_life: Option<Duration>) -> Self

Set the maximum lifetime of a password

Pass None to clear it. Defaults to not set

Source

pub fn password_min_length(self, password_min_length: c_long) -> Self

Set the minimum length of a password

Defaults to not set

Source

pub fn password_min_classes(self, password_min_classes: c_long) -> Self

Set the minimum number of character classes required in a password. The five character classes are lower case, upper case, numbers, punctuation, and whitespace/unprintable characters

Defaults to not set

Source

pub fn password_history_num(self, password_history_num: c_long) -> Self

Set the number of past keys kept for a principal. May be ignored if used with other database modules such as the MIT krb5 LDAP KDC database module

Defaults to not set

Source

pub fn password_max_fail(self, password_max_fail: krb5_kvno) -> Self

Set the number of authentication failures before the principal is locked. Authentication failures are only tracked for principals which require preauthentication. The counter of failed attempts resets to 0 after a successful attempt to authenticate. A value of 0 disables lock‐out

Defaults to not set

Source

pub fn password_failcount_interval( self, password_failcount_interval: Option<Duration>, ) -> Self

Set the allowable time between authentication failures. If an authentication failure happens after this duration has elapsed since the previous failure, the number of authentication failures is reset to 1.

Setting this to None means forever. Defaults to not set

Source

pub fn password_lockout_duration( self, password_lockout_duration: Option<Duration>, ) -> Self

Set the duration for which the principal is locked from authenticating if too many authentication failures occur without the specified failure count interval elapsing.

Setting this to None means the principal remains locked out until it is administratively unlocked. Defaults to not set

Source

pub fn attributes(self, attributes: krb5_flags) -> Self

Set policy attributes

Source

pub fn max_life(self, max_life: Option<Duration>) -> Self

Set the maximum ticket life

Source

pub fn max_renewable_life(self, max_renewable_life: Option<Duration>) -> Self

Set the maximum renewable ticket life

Source

pub fn allowed_keysalts(self, allowed_keysalts: Option<KeySalts>) -> Self

Set the allowed keysalts

Pass None to clear it. Defaults to not set

Source

pub fn tl_data(self, tl_data: TlData) -> Self

Add new TL-data

Source

pub fn new(name: &str) -> Self

Construct a new PolicyBuilder for a policy with name

Source

pub fn name(self, name: &str) -> Self

Set the name of the policy

Source

pub fn create<K: KAdminImpl>(&self, kadmin: &K) -> Result<Policy>

Create the policy

Trait Implementations§

Source§

impl Clone for PolicyBuilder

Source§

fn clone(&self) -> PolicyBuilder

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 PolicyBuilder

Source§

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

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

impl Default for PolicyBuilder

Source§

fn default() -> PolicyBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.