| 1 | package OAuth::Lite2::Agent::Strict; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use parent 'OAuth::Lite2::Agent'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use OAuth::Lite2::Client::Error; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | =head1 NAME | ||||||||||
| 10 | |||||||||||
| 11 | OAuth::Lite2::Agent::Strict - Preset User Agent class for strict SSL | ||||||||||
| 12 | |||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||
| 14 | |||||||||||
| 15 | my $client = OAuth::Lite2::Client::WebApp->new( | ||||||||||
| 16 | ..., # other params | ||||||||||
| 17 | agent => OAuth::Lite2::Client::Agent::Strict->new( | ||||||||||
| 18 | https_version => $https_version, | ||||||||||
| 19 | ..., # https parameters | ||||||||||
| 20 | ), | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||
| 24 | |||||||||||
| 25 | This module is one of preset user-agent class. | ||||||||||
| 26 | This is useful when you want check the SSL strictly. | ||||||||||
| 27 | |||||||||||
| 28 | =head1 METHODS | ||||||||||
| 29 | |||||||||||
| 30 | =head2 request ($req) | ||||||||||
| 31 | |||||||||||
| 32 | Append to the behavior of parent class, this method verify the SSL, | ||||||||||
| 33 | and if it fails, it throws the exception. | ||||||||||
| 34 | |||||||||||
| 35 | =cut | ||||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | sub request { | ||||||||
|
Subroutine
request: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||
| 38 | 0 | my ($self, $req) = @_; | |||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | OAuth::Lite2::Client::Error::InsecureRequest->throw( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | message => sprintf q{request url should start with https, but found "%s"}, $req->uri) | ||||||||||
| 42 | unless $req->uri =~ /^https/; | ||||||||||
| 43 | |||||||||||
| 44 | 0 | ▶ | local $ENV{HTTPS_DEBUG} = $self->{https_debug} if $self->{https_debug}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 0 | ▶ | local $ENV{HTTPS_CA_FILE} = $self->{https_ca_file} if $self->{https_ca_file}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | 0 | ▶ | local $ENV{HTTPS_CA_DIR} = $self->{https_ca_dir} if $self->{https_ca_dir}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | ▶ | local $ENV{HTTPS_CERT_FILE} = $self->{https_cert_file} if $self->{https_cert_file}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 0 | ▶ | local $ENV{HTTPS_KEY_FILE} = $self->{https_key_file} if $self->{https_key_file}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 0 | ▶ | local $ENV{HTTPS_VERSION} = $self->{https_version} if $self->{https_version}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | ▶ | local $ENV{HTTPS_PROXY} = $self->{https_proxy} if $self->{https_proxy}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 0 | ▶ | local $ENV{HTTPS_PROXY_USERNAME} = $self->{https_proxy_username} if $self->{https_proxy_username}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | ▶ | local $ENV{HTTPS_PROXY_PASSWORD} = $self->{https_proxy_password} if $self->{https_proxy_password}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | |||||||||||
| 54 | 0 | my $res = $self->SUPER::request($req); | |||||||||
| 55 | |||||||||||
| 56 | 0 | ▶ | OAuth::Lite2::Client::Error::InsecureResponse->throw( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | message => "SSL Warning: Unauthorized access to blocked host" | ||||||||||
| 58 | ) if $res->header('Client-SSL-Warning'); | ||||||||||
| 59 | |||||||||||
| 60 | 0 | return $res; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 1 | 1; | |||||||||
| 64 | |||||||||||
| 65 | =head1 SEE ALSO | ||||||||||
| 66 | |||||||||||
| 67 | L<OAuth::Lite2::Client::Agent>, | ||||||||||
| 68 | L<OAuth::Lite2::Client::Agent::Dump> | ||||||||||
| 69 | |||||||||||
| 70 | =head1 AUTHOR | ||||||||||
| 71 | |||||||||||
| 72 | Lyo Kato, C<lyo.kato _at_ gmail.com> | ||||||||||
| 73 | |||||||||||
| 74 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 75 | |||||||||||
| 76 | This library is free software; you can redistribute it and/or modify | ||||||||||
| 77 | it under the same terms as Perl itself, either Perl version 5.8.8 or, | ||||||||||
| 78 | at your option, any later version of Perl 5 you may have available. | ||||||||||
| 79 | |||||||||||
| 80 | =cut | ||||||||||