| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | Authen::Passphrase::Clear - cleartext passphrases | ||||||||||
| 4 | |||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||
| 6 | |||||||||||
| 7 | use Authen::Passphrase::Clear; | ||||||||||
| 8 | |||||||||||
| 9 | $ppr = Authen::Passphrase::Clear->new("passphrase"); | ||||||||||
| 10 | |||||||||||
| 11 | if($ppr->match($passphrase)) { ... | ||||||||||
| 12 | |||||||||||
| 13 | $passphrase = $ppr->passphrase; | ||||||||||
| 14 | |||||||||||
| 15 | $userPassword = $ppr->as_rfc2307; | ||||||||||
| 16 | |||||||||||
| 17 | =head1 DESCRIPTION | ||||||||||
| 18 | |||||||||||
| 19 | An object of this class is a passphrase recogniser that accepts | ||||||||||
| 20 | some particular passphrase which it knows. This is a subclass of | ||||||||||
| 21 | L<Authen::Passphrase>, and this document assumes that the reader is | ||||||||||
| 22 | familiar with the documentation for that class. | ||||||||||
| 23 | |||||||||||
| 24 | I<Warning:> Storing a passphrase in cleartext, as this class does, | ||||||||||
| 25 | is a very bad idea. It means that anyone who sees the passphrase file | ||||||||||
| 26 | immediately knows all the passphrases. Do not use this unless you really | ||||||||||
| 27 | know what you're doing. | ||||||||||
| 28 | |||||||||||
| 29 | =cut | ||||||||||
| 30 | |||||||||||
| 31 | package Authen::Passphrase::Clear; | ||||||||||
| 32 | |||||||||||
| 33 | 2 | ▶ | { use 5.006; } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 34 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 35 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 36 | |||||||||||
| 37 | 2 | ▶ | use Authen::Passphrase 0.003; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 38 | 2 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 39 | |||||||||||
| 40 | 2 | our $VERSION = "0.009"; | |||||||||
| 41 | |||||||||||
| 42 | 2 | ▶ | use parent "Authen::Passphrase"; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | |||||||||||
| 44 | # An object of this class is a blessed scalar containing the passphrase. | ||||||||||
| 45 | |||||||||||
| 46 | =head1 CONSTRUCTORS | ||||||||||
| 47 | |||||||||||
| 48 | =over | ||||||||||
| 49 | |||||||||||
| 50 | =item Authen::Passphrase::Clear->new(PASSPHRASE) | ||||||||||
| 51 | |||||||||||
| 52 | Returns a passphrase recogniser object that stores the specified | ||||||||||
| 53 | passphrase in cleartext and accepts only that passphrase. | ||||||||||
| 54 | |||||||||||
| 55 | =cut | ||||||||||
| 56 | |||||||||||
| 57 | 6 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 58 | 6 | my($class, $passphrase) = @_; | |||||||||
| 59 | 6 | $passphrase = "$passphrase"; | |||||||||
| 60 | 6 | return bless(\$passphrase, $class); | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | =item Authen::Passphrase::Clear->from_rfc2307(USERPASSWORD) | ||||||||||
| 64 | |||||||||||
| 65 | Generates a cleartext passphrase recogniser from the supplied RFC2307 | ||||||||||
| 66 | encoding. The string must consist of "B<{CLEARTEXT}>" (case insensitive) | ||||||||||
| 67 | followed by the passphrase. | ||||||||||
| 68 | |||||||||||
| 69 | =cut | ||||||||||
| 70 | |||||||||||
| 71 | 2 | ▶ | sub from_rfc2307 { | ||||||||
|
Subroutine
from_rfc2307: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||
| 72 | 2 | my($class, $userpassword) = @_; | |||||||||
| 73 | 2 | ▶ | if($userpassword =~ /\A\{(?i:cleartext)\}/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | 1 | ▶ | $userpassword =~ /\A\{.*?\}([!-~]*)\z/ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | or croak "malformed {CLEARTEXT} data"; | ||||||||||
| 76 | 1 | my $text = $1; | |||||||||
| 77 | 1 | return $class->new($text); | |||||||||
| 78 | } | ||||||||||
| 79 | 1 | return $class->SUPER::from_rfc2307($userpassword); | |||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | =back | ||||||||||
| 83 | |||||||||||
| 84 | =head1 METHODS | ||||||||||
| 85 | |||||||||||
| 86 | =over | ||||||||||
| 87 | |||||||||||
| 88 | =item $ppr->match(PASSPHRASE) | ||||||||||
| 89 | |||||||||||
| 90 | =item $ppr->passphrase | ||||||||||
| 91 | |||||||||||
| 92 | =item $ppr->as_rfc2307 | ||||||||||
| 93 | |||||||||||
| 94 | These methods are part of the standard L<Authen::Passphrase> interface. | ||||||||||
| 95 | The L</passphrase> method trivially works. | ||||||||||
| 96 | |||||||||||
| 97 | =cut | ||||||||||
| 98 | |||||||||||
| 99 | 25 | ▶ | sub match { | ||||||||
|
Subroutine
match: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 100 | 25 | my($self, $passphrase) = @_; | |||||||||
| 101 | 25 | return $passphrase eq $$self; | |||||||||
| 102 | } | ||||||||||
| 103 | |||||||||||
| 104 | 6 | ▶ | sub passphrase { ${$_[0]} } | ||||||||
|
Subroutine
passphrase: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 105 | |||||||||||
| 106 | 5 | ▶ | sub as_rfc2307 { | ||||||||
|
Subroutine
as_rfc2307: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 107 | 5 | my($self) = @_; | |||||||||
| 108 | 5 | ▶ | croak "can't put this passphrase into an RFC 2307 string" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 109 | if $$self =~ /[^!-~]/; | ||||||||||
| 110 | 5 | return "{CLEARTEXT}".$$self; | |||||||||
| 111 | } | ||||||||||
| 112 | |||||||||||
| 113 | =back | ||||||||||
| 114 | |||||||||||
| 115 | =head1 SEE ALSO | ||||||||||
| 116 | |||||||||||
| 117 | L<Authen::Passphrase> | ||||||||||
| 118 | |||||||||||
| 119 | =head1 AUTHOR | ||||||||||
| 120 | |||||||||||
| 121 | Andrew Main (Zefram) <zefram@fysh.org> | ||||||||||
| 122 | |||||||||||
| 123 | =head1 COPYRIGHT | ||||||||||
| 124 | |||||||||||
| 125 | Copyright (C) 2006, 2007, 2009, 2010, 2012 | ||||||||||
| 126 | Andrew Main (Zefram) <zefram@fysh.org> | ||||||||||
| 127 | |||||||||||
| 128 | =head1 LICENSE | ||||||||||
| 129 | |||||||||||
| 130 | This module is free software; you can redistribute it and/or modify it | ||||||||||
| 131 | under the same terms as Perl itself. | ||||||||||
| 132 | |||||||||||
| 133 | =cut | ||||||||||
| 134 | |||||||||||
| 135 | 2 | 1; | |||||||||