Andrew J. Korty > Data-Passphrase-0.0.7 > Data::Passphrase::Ruleset

Download:
Data-Passphrase-0.0.7.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Data::Passphrase::Ruleset - ruleset for validating passphrases

SYNOPSIS ^

Specified by script file:

    my $ruleset = Data::Passphrase::Ruleset->new({
        debug => 1,
        file  => '/usr/local/etc/passphrase/rules',
    });
    
    my $passphrase_object = Data::Passphrase->new({
        ruleset => $ruleset,       # putting the filename here also works
    });

Passing rules in as Data::Passphrase::Rule objects or directly:

    my $rule = Data::Passphrase::Rule->new({
       code     => 450,
       message  => 'is too short',
       test     => 'X' x 15,
       validate => sub { $_[0] >= 15 },
    });
    
    my $ruleset = Data::Passphrase::Ruleset->new({
        rules  => [
           $rule,
           {
               code     => 452,
               message  => 'may not contain # or @',
               test     => [
                   'this passphrase contains #',
                   '@ appears in this one',
               ],
               validate => sub { $_[0] !~ /([#@])/ },
           },
        ]
    });
    
    my $passphrase_object = Data::Passphrase->new({
        ruleset => $ruleset,
    });

DESCRIPTION ^

Objects of this class represent a list of strength-checking rules used by Data::Passphrase. In addition to constructor and accessor methods, it provides a method to load rules from a Perl script.

INTERFACE ^

There is a constructor, new, which takes a reference to a hash of initial attribute settings, and accessor methods of the form get_attribute() and set_attribute(). See "Attributes".

Methods

In addition to the constructor and accessor methods, the following special method is available.

load()

    $self->load()

Load or reload rules from the Perl script specified by the file attribute. Rules are only reloaded if the script has been modified since the last time it was evaluated. Either way, after a "load()" in load(), the rules attribute will point to an up-to-date copy of the rules.

Attributes

The attributes below can be accessed via methods of the form get_attribute() and set_attribute().

debug

If TRUE, enable debugging to the Apache error log.

file

The filename of a Perl script that, when evaluated, returns a list of rules. Each rule is specified as either an Data::Passphrase::Rule object or a hash reference used to construct one.

passing_score

The lowest score a rule's validate routine can return for the passphrase to pass that rule. Defaults to 0.6.

rules

A reference to an array of rules. Each rule is specified as either an Data::Passphrase::Rule object or a hash reference used to construct one.

EXAMPLES ^

See Data::Passphrase and the included passphrase_rules file.

AUTHOR ^

Andrew J. Korty <ajk@iu.edu>

SEE ALSO ^

Data::Passphrase(3), Data::Passphrase::Rule(3)

syntax highlighting: