| 1 | # -*- Mode: Perl; indent-tabs-mode: nil; -*- | ||
| 2 | |||
| 3 | package Wombat::Deploy::LoginConfig; | ||
| 4 | |||
| 5 | =pod | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Wombat::Deploy::LoginConfig - login-config deployment descriptor element | ||
| 10 | class | ||
| 11 | |||
| 12 | =head1 SYNOPSIS | ||
| 13 | |||
| 14 | =head1 DESCRIPTION | ||
| 15 | |||
| 16 | Representation of a login configuration object for a web application, | ||
| 17 | as specified in a I<login-config> element in the deployment | ||
| 18 | descriptor. | ||
| 19 | |||
| 20 | =cut | ||
| 21 | |||
| 22 | use fields qw(authMethod errorPage loginPage realmName); | ||
| 23 | use strict; | ||
| 24 | use warnings; | ||
| 25 | |||
| 26 | use URI::Escape (); | ||
| 27 | |||
| 28 | =pod | ||
| 29 | |||
| 30 | =head1 CONSTRUCTOR | ||
| 31 | |||
| 32 | =over | ||
| 33 | |||
| 34 | =item new() | ||
| 35 | |||
| 36 | Construct and return a B<Wombat::Deploy::LoginConfig> instance, | ||
| 37 | initializing fields appropriately. | ||
| 38 | |||
| 39 | =back | ||
| 40 | |||
| 41 | B<Parameters:> | ||
| 42 | |||
| 43 | =over | ||
| 44 | |||
| 45 | =item $authMethod | ||
| 46 | |||
| 47 | the authentication method | ||
| 48 | |||
| 49 | =item $realmName | ||
| 50 | |||
| 51 | the realm name | ||
| 52 | |||
| 53 | =item $loginPage | ||
| 54 | |||
| 55 | the URI of the login page | ||
| 56 | |||
| 57 | =item $errorPage | ||
| 58 | |||
| 59 | the URI of the error page | ||
| 60 | |||
| 61 | =back | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | sub new { | ||
| 66 | my $self = shift; | ||
| 67 | my $authMethod = shift; | ||
| 68 | my $realmName = shift; | ||
| 69 | my $loginPage = shift; | ||
| 70 | my $errorPage = shift; | ||
| 71 | |||
| 72 | $self = fields::new($self) unless ref $self; | ||
| 73 | |||
| 74 | $self->{authMethod} = $authMethod; | ||
| 75 | $self->{errorPage} = $errorPage; | ||
| 76 | $self->{loginPage} = $loginPage; | ||
| 77 | $self->{realmName} = $realmName; | ||
| 78 | |||
| 79 | return $self; | ||
| 80 | } | ||
| 81 | |||
| 82 | =pod | ||
| 83 | |||
| 84 | =head1 ACCESSOR METHODS | ||
| 85 | |||
| 86 | =over | ||
| 87 | |||
| 88 | =item getAuthMethod() | ||
| 89 | |||
| 90 | Return the authentication method to use for application login. | ||
| 91 | |||
| 92 | =cut | ||
| 93 | |||
| 94 | sub getAuthMethod { | ||
| 95 | my $self = shift; | ||
| 96 | |||
| 97 | return $self->{authMethod}; | ||
| 98 | } | ||
| 99 | |||
| 100 | =pod | ||
| 101 | |||
| 102 | =item setAuthMethod($authMethod) | ||
| 103 | |||
| 104 | Set the authentication method to use for application login. Must be | ||
| 105 | one of I<BASIC>, I<DIGEST>, I<FORM>, or I<CLIENT-CERT>. | ||
| 106 | |||
| 107 | B<Parameters:> | ||
| 108 | |||
| 109 | =over | ||
| 110 | |||
| 111 | =item $authMethod | ||
| 112 | |||
| 113 | the authentication method | ||
| 114 | |||
| 115 | =back | ||
| 116 | |||
| 117 | =cut | ||
| 118 | |||
| 119 | sub setAuthMethod { | ||
| 120 | my $self = shift; | ||
| 121 | my $authMethod = shift; | ||
| 122 | |||
| 123 | $self->{authMethod} = $authMethod; | ||
| 124 | |||
| 125 | return 1; | ||
| 126 | } | ||
| 127 | |||
| 128 | =pod | ||
| 129 | |||
| 130 | =item getErrorPage() | ||
| 131 | |||
| 132 | Return the URI of the error page for form login. | ||
| 133 | |||
| 134 | =cut | ||
| 135 | |||
| 136 | sub getErrorPage { | ||
| 137 | my $self = shift; | ||
| 138 | |||
| 139 | return $self->{errorPage}; | ||
| 140 | } | ||
| 141 | |||
| 142 | =pod | ||
| 143 | |||
| 144 | =item setErrorPage($errorPage) | ||
| 145 | |||
| 146 | Set the URI of the error page for form login. The URI must be | ||
| 147 | specified relative to the context (ie beginning with a '/'). | ||
| 148 | |||
| 149 | B<Parameters:> | ||
| 150 | |||
| 151 | =over | ||
| 152 | |||
| 153 | =item $errorPage | ||
| 154 | |||
| 155 | the error page URI | ||
| 156 | |||
| 157 | =back | ||
| 158 | |||
| 159 | =cut | ||
| 160 | |||
| 161 | sub setErrorPage { | ||
| 162 | my $self = shift; | ||
| 163 | my $errorPage = shift; | ||
| 164 | |||
| 165 | $self->{errorPage} = URI::Escape::uri_unescape($errorPage); | ||
| 166 | |||
| 167 | return 1; | ||
| 168 | } | ||
| 169 | |||
| 170 | =pod | ||
| 171 | |||
| 172 | =item getLoginPage() | ||
| 173 | |||
| 174 | Return the URI of the login page for form login. | ||
| 175 | |||
| 176 | =cut | ||
| 177 | |||
| 178 | sub getLoginPage { | ||
| 179 | my $self = shift; | ||
| 180 | |||
| 181 | return $self->{loginPage}; | ||
| 182 | } | ||
| 183 | |||
| 184 | =pod | ||
| 185 | |||
| 186 | =item setLoginPage($loginPage) | ||
| 187 | |||
| 188 | Set the URI of the login page for form login. The URI must be | ||
| 189 | specified relative to the context (ie beginning with a '/'). | ||
| 190 | |||
| 191 | B<Parameters:> | ||
| 192 | |||
| 193 | =over | ||
| 194 | |||
| 195 | =item $loginPage | ||
| 196 | |||
| 197 | the login page URI | ||
| 198 | |||
| 199 | =back | ||
| 200 | |||
| 201 | =cut | ||
| 202 | |||
| 203 | sub setLoginPage { | ||
| 204 | my $self = shift; | ||
| 205 | my $loginPage = shift; | ||
| 206 | |||
| 207 | $self->{loginPage} = URI::Escape::uri_unescape($loginPage); | ||
| 208 | |||
| 209 | return 1; | ||
| 210 | } | ||
| 211 | |||
| 212 | =pod | ||
| 213 | |||
| 214 | =item getRealmName() | ||
| 215 | |||
| 216 | Return the name of the realm in which users will be authenticated. | ||
| 217 | |||
| 218 | =cut | ||
| 219 | |||
| 220 | sub getRealmName { | ||
| 221 | my $self = shift; | ||
| 222 | |||
| 223 | return $self->{realmName}; | ||
| 224 | } | ||
| 225 | |||
| 226 | =pod | ||
| 227 | |||
| 228 | =item setRealmName($realmName) | ||
| 229 | |||
| 230 | Set the name of the realm in which users will be authenticated. | ||
| 231 | |||
| 232 | B<Parameters:> | ||
| 233 | |||
| 234 | =over | ||
| 235 | |||
| 236 | =item $realmName | ||
| 237 | |||
| 238 | the name of the realm | ||
| 239 | |||
| 240 | =back | ||
| 241 | |||
| 242 | =cut | ||
| 243 | |||
| 244 | sub setRealmName { | ||
| 245 | my $self = shift; | ||
| 246 | my $realmName = shift; | ||
| 247 | |||
| 248 | $self->{realmName} = $realmName; | ||
| 249 | |||
| 250 | return 1; | ||
| 251 | } | ||
| 252 | |||
| 253 | =pod | ||
| 254 | |||
| 255 | =cut | ||
| 256 | |||
| 257 | 1; | ||
| 258 | __END__ |