Commit e9ecdbf4 authored by Yadd's avatar Yadd
Browse files

Some strictures

parent 03900f4e
...@@ -8,7 +8,7 @@ severity = 1 ...@@ -8,7 +8,7 @@ severity = 1
# Work based on a whitelist # Work based on a whitelist
only = 1 only = 1
# Our whitelist (ignores severity): # Our whitelist (ignores severity):
include = ExplicitReturnUndef GlobFunction NegativeIndices PrivateVars UselessInitialization MatchVars NumberSeparators NullStatements LongChainsOfMethodCalls UseStrict UseWarnings EndWithOne ConditionalUseStatements PackageMatchesPodName JoinedReadline UnreachableCode TrailingWhitespace InterpolationOfLiterals ImplicitNewlines CommaSeparatedStatements UnusedVariables UnusedCapture TwoArgOpen ProhibitHardTabs MismatchedOperators IndirectSyntax Modules:: BuiltinFunctions:: ClassHierarchies:: CommaSeparatedStatements QuotesAsQuotelikeOperatorDelimiters MixedBooleanOperators ProhibitBarewordFileHandles ConditionalUseStatements Modules::ProhibitAutomaticExportation ProhibitBarewordFileHandles ConditionalDeclarations include = ExplicitReturnUndef GlobFunction NegativeIndices PrivateVars UselessInitialization MatchVars NumberSeparators NullStatements LongChainsOfMethodCalls UseStrict EndWithOne ConditionalUseStatements PackageMatchesPodName JoinedReadline UnreachableCode TrailingWhitespace InterpolationOfLiterals ImplicitNewlines CommaSeparatedStatements UnusedVariables UnusedCapture TwoArgOpen ProhibitHardTabs MismatchedOperators IndirectSyntax Modules:: BuiltinFunctions:: ClassHierarchies:: CommaSeparatedStatements QuotesAsQuotelikeOperatorDelimiters MixedBooleanOperators ProhibitBarewordFileHandles ConditionalUseStatements Modules::ProhibitAutomaticExportation ProhibitBarewordFileHandles ConditionalDeclarations
#include = MixedBooleanOperators InteractiveTest UpperCaseHeredoc ReusedNames PackageVars ConditionalDeclarations SingleCharAlternation FixedStringMatches ConditionalUseStatements QuotedWordLists #include = MixedBooleanOperators InteractiveTest UpperCaseHeredoc ReusedNames PackageVars ConditionalDeclarations SingleCharAlternation FixedStringMatches ConditionalUseStatements QuotedWordLists
exclude = RequireFilenameMatchesPackage RequireVersionVar ProhibitExcessMainComplexity ProhibitStringySplit ComplexMappings StringyEval Documentation::PodSpell BuiltinFunctions::ProhibitUselessTopic exclude = RequireFilenameMatchesPackage RequireVersionVar ProhibitExcessMainComplexity ProhibitStringySplit ComplexMappings StringyEval Documentation::PodSpell BuiltinFunctions::ProhibitUselessTopic
......
...@@ -30,14 +30,14 @@ sub populate { ...@@ -30,14 +30,14 @@ sub populate {
my $self = shift; my $self = shift;
my $backend = $self->{args}->{backend}; my $backend = $self->{args}->{backend};
_load($backend); _load($backend);
$backend .= "::populate"; $backend .= '::populate';
{ {
no strict 'refs'; no strict 'refs';
$self = $self->$backend(@_); $self = $self->$backend(@_);
} }
if ( $backend =~ if ( $backend =~
/^Apache::Session::(?:(?:Postgre|Redi)s|S(?:QLite3|ybase)|(?:My|No)SQL|F(?:ile|lex)|Cassandra|Oracle|LDAP)/ /^Apache::Session::(?:(?:Postgre|Redi)s|S(?:QLite3|ybase)|(?:My|No)SQL|F(?:ile|lex)|Cassandra|Oracle|LDAP)/
and !$self->{args}->{useStorable} ) and not $self->{args}->{useStorable} )
{ {
$self->{serialize} = $self->{serialize} =
\&Lemonldap::NG::Common::Apache::Session::Serialize::JSON::serialize; \&Lemonldap::NG::Common::Apache::Session::Serialize::JSON::serialize;
...@@ -52,8 +52,8 @@ sub populate { ...@@ -52,8 +52,8 @@ sub populate {
my $generate = $self->{args}->{generateModule}; my $generate = $self->{args}->{generateModule};
eval "require $generate"; eval "require $generate";
die $@ if ($@); die $@ if ($@);
$self->{generate} = \&{ $generate . "::generate" }; $self->{generate} = \&{ $generate . '::generate' };
$self->{validate} = \&{ $generate . "::validate" }; $self->{validate} = \&{ $generate . '::validate' };
} }
if ( $self->{args}->{setId} ) { if ( $self->{args}->{setId} ) {
$self->{generate} = \&setId; $self->{generate} = \&setId;
...@@ -72,6 +72,8 @@ sub populate { ...@@ -72,6 +72,8 @@ sub populate {
return $self; return $self;
} }
1;
__END__ __END__
sub setId { sub setId {
......
...@@ -30,7 +30,7 @@ sub generate { ...@@ -30,7 +30,7 @@ sub generate {
), ),
0, $length 0, $length
); );
return;
} }
sub validate { sub validate {
...@@ -42,10 +42,10 @@ sub validate { ...@@ -42,10 +42,10 @@ sub validate {
my $session = shift; my $session = shift;
if ( $session->{data}->{_session_id} =~ /^([a-fA-F0-9]+)$/ ) { if ( $session->{data}->{_session_id} =~ /^([a-fA-F0-9]+)$/ ) {
$session->{data}->{_session_id} = $1; return $session->{data}->{_session_id} = $1;
} }
else { else {
die "Invalid session ID: " . $session->{data}->{_session_id}; die 'Invalid session ID: ' . $session->{data}->{_session_id};
} }
} }
......
...@@ -41,9 +41,10 @@ sub acquire_read_lock { ...@@ -41,9 +41,10 @@ sub acquire_read_lock {
if ( $self->cache->get($id) ) { if ( $self->cache->get($id) ) {
# got session from cache, no need to ask for locks # got session from cache, no need to ask for locks
return
} }
else { else {
$self->module->acquire_read_lock($session); return $self->module->acquire_read_lock($session);
} }
} }
...@@ -51,21 +52,21 @@ sub acquire_write_lock { ...@@ -51,21 +52,21 @@ sub acquire_write_lock {
my $self = shift; my $self = shift;
my $session = shift; my $session = shift;
$self->module->acquire_write_lock($session); return $self->module->acquire_write_lock($session);
} }
sub release_write_lock { sub release_write_lock {
my $self = shift; my $self = shift;
my $session = shift; my $session = shift;
$self->module->release_write_lock($session); return $self->module->release_write_lock($session);
} }
sub release_all_locks { sub release_all_locks {
my $self = shift; my $self = shift;
my $session = shift; my $session = shift;
$self->module->release_all_locks($session); return $self->module->release_all_locks($session);
} }
1; 1;
......
...@@ -7,14 +7,14 @@ use JSON qw(from_json to_json); ...@@ -7,14 +7,14 @@ use JSON qw(from_json to_json);
our $VERSION = '2.1.0'; our $VERSION = '2.1.0';
our @ISA = qw(Lemonldap::NG::Common::Apache::Session::Generate::SHA256); use base 'Lemonldap::NG::Common::Apache::Session::Generate::SHA256';
# PUBLIC INTERFACE # PUBLIC INTERFACE
# Constructor for Perl TIE mechanism. See perltie(3) for more. # Constructor for Perl TIE mechanism. See perltie(3) for more.
sub TIEHASH { sub TIEHASH {
my ( $class, $session_id, $args ) = @_; my ( $class, $session_id, $args ) = @_;
die "baseUrl argument is required" die 'baseUrl argument is required'
unless ( $args and $args->{baseUrl} ); unless ( $args and $args->{baseUrl} );
my $self = { my $self = {
data => { _session_id => $session_id }, data => { _session_id => $session_id },
...@@ -37,7 +37,7 @@ sub TIEHASH { ...@@ -37,7 +37,7 @@ sub TIEHASH {
$self->newSession; $self->newSession;
} }
else { else {
die "unable to create session" die 'unable to create session'
unless ( $self->newSession() ); unless ( $self->newSession() );
} }
return $self; return $self;
...@@ -65,7 +65,7 @@ sub DELETE { ...@@ -65,7 +65,7 @@ sub DELETE {
$self->{modified} = 1; $self->{modified} = 1;
delete $self->{data}->{$key}; return delete $self->{data}->{$key};
} }
sub CLEAR { sub CLEAR {
...@@ -73,7 +73,7 @@ sub CLEAR { ...@@ -73,7 +73,7 @@ sub CLEAR {
$self->{modified} = 1; $self->{modified} = 1;
$self->{data} = {}; return $self->{data} = {};
} }
sub EXISTS { sub EXISTS {
...@@ -95,7 +95,7 @@ sub NEXTKEY { ...@@ -95,7 +95,7 @@ sub NEXTKEY {
sub DESTROY { sub DESTROY {
my $self = shift; my $self = shift;
$self->save; return $self->save;
} }
sub ua { sub ua {
...@@ -207,7 +207,7 @@ sub save { ...@@ -207,7 +207,7 @@ sub save {
# Update session in cache # Update session in cache
if ( $self->{localStorage} ) { if ( $self->{localStorage} ) {
my $id = "rest" . $self->{data}->{_session_id}; my $id = 'rest' . $self->{data}->{_session_id};
if ( $self->cache->get($id) ) { if ( $self->cache->get($id) ) {
$self->cache->remove($id); $self->cache->remove($id);
} }
...@@ -236,7 +236,7 @@ sub save { ...@@ -236,7 +236,7 @@ sub save {
return $res; return $res;
} }
else { else {
print STDERR "REST server returns " . $resp->status_line; print STDERR 'REST server returns ' . $resp->status_line;
return; return;
} }
} }
...@@ -248,7 +248,7 @@ sub delete { ...@@ -248,7 +248,7 @@ sub delete {
# Remove session from cache # Remove session from cache
if ( $self->{localStorage} ) { if ( $self->{localStorage} ) {
my $id = "rest" . $self->{data}->{_session_id}; my $id = 'rest' . $self->{data}->{_session_id};
if ( $self->cache->get($id) ) { if ( $self->cache->get($id) ) {
$self->cache->remove($id); $self->cache->remove($id);
} }
...@@ -265,7 +265,7 @@ sub delete { ...@@ -265,7 +265,7 @@ sub delete {
## @method get_key_from_all_sessions() ## @method get_key_from_all_sessions()
# Not documented. # Not documented.
sub get_key_from_all_sessions() { sub get_key_from_all_sessions() {
die "Not implemented"; die 'Not implemented';
my ( $class, $args, $data ) = @_; my ( $class, $args, $data ) = @_;
my $self = bless {}, $class; my $self = bless {}, $class;
foreach (qw(baseUrl user password realm)) { foreach (qw(baseUrl user password realm)) {
...@@ -303,10 +303,10 @@ sub cache { ...@@ -303,10 +303,10 @@ sub cache {
1; 1;
__END__ __END__
=head1 NAME
=encoding utf8 =encoding utf8
=head1 NAME
Lemonldap::NG::Common::Apache::Session::REST - Perl extension written to Lemonldap::NG::Common::Apache::Session::REST - Perl extension written to
access to Lemonldap::NG Web-SSO sessions via REST. access to Lemonldap::NG Web-SSO sessions via REST.
......
...@@ -38,8 +38,7 @@ sub TIEHASH { ...@@ -38,8 +38,7 @@ sub TIEHASH {
my $session_id = shift; my $session_id = shift;
my $args = shift; my $args = shift;
my ( $proxy, $proxyOptions ); die 'proxy argument is required'
die "proxy argument is required"
unless ( $args and $args->{proxy} ); unless ( $args and $args->{proxy} );
my $self = { my $self = {
data => { _session_id => $session_id }, data => { _session_id => $session_id },
...@@ -56,7 +55,7 @@ sub TIEHASH { ...@@ -56,7 +55,7 @@ sub TIEHASH {
unless ( $self->get($session_id) ); unless ( $self->get($session_id) );
} }
else { else {
die "unable to create session" die 'unable to create session'
unless ( $self->newSession() ); unless ( $self->newSession() );
} }
return $self; return $self;
...@@ -84,7 +83,7 @@ sub DELETE { ...@@ -84,7 +83,7 @@ sub DELETE {
$self->{modified} = 1; $self->{modified} = 1;
delete $self->{data}->{$key}; return delete $self->{data}->{$key};
} }
sub CLEAR { sub CLEAR {
...@@ -92,7 +91,7 @@ sub CLEAR { ...@@ -92,7 +91,7 @@ sub CLEAR {
$self->{modified} = 1; $self->{modified} = 1;
$self->{data} = {}; return $self->{data} = {};
} }
sub EXISTS { sub EXISTS {
...@@ -114,7 +113,7 @@ sub NEXTKEY { ...@@ -114,7 +113,7 @@ sub NEXTKEY {
sub DESTROY { sub DESTROY {
my $self = shift; my $self = shift;
$self->save; return $self->save;
} }
## @method private SOAP::Lite _connect() ## @method private SOAP::Lite _connect()
...@@ -139,7 +138,7 @@ sub _soapCall { ...@@ -139,7 +138,7 @@ sub _soapCall {
my $func = shift; my $func = shift;
my $r = $self->_connect->$func(@_); my $r = $self->_connect->$func(@_);
if ( $r->fault ) { if ( $r->fault ) {
print STDERR "SOAP Error: " . $r->fault->{faultstring}; print STDERR 'SOAP Error: ' . $r->fault->{faultstring};
return (); return ();
} }
return $r->result; return $r->result;
...@@ -158,7 +157,7 @@ sub get { ...@@ -158,7 +157,7 @@ sub get {
} }
# No cache, use SOAP and set cache # No cache, use SOAP and set cache
my $r = $self->_soapCall( "getAttributes", $id ); my $r = $self->_soapCall( 'getAttributes', $id );
return 0 unless ( $r or $r->{error} ); return 0 unless ( $r or $r->{error} );
$self->{data} = $r->{attributes}; $self->{data} = $r->{attributes};
...@@ -172,11 +171,11 @@ sub get { ...@@ -172,11 +171,11 @@ sub get {
# @return User data (just the session ID) # @return User data (just the session ID)
sub newSession { sub newSession {
my $self = shift; my $self = shift;
$self->{data} = $self->_soapCall("newSession"); $self->{data} = $self->_soapCall('newSession');
# Set cache # Set cache
if ( $self->{localStorage} ) { if ( $self->{localStorage} ) {
my $id = "soap" . $self->{data}->{_session_id}; my $id = 'soap' . $self->{data}->{_session_id};
if ( $self->cache->get($id) ) { if ( $self->cache->get($id) ) {
$self->cache->remove($id); $self->cache->remove($id);
} }
...@@ -194,7 +193,7 @@ sub save { ...@@ -194,7 +193,7 @@ sub save {
# Update session in cache # Update session in cache
if ( $self->{localStorage} ) { if ( $self->{localStorage} ) {
my $id = "soap" . $self->{data}->{_session_id}; my $id = 'soap' . $self->{data}->{_session_id};
if ( $self->cache->get($id) ) { if ( $self->cache->get($id) ) {
$self->cache->remove($id); $self->cache->remove($id);
} }
...@@ -202,7 +201,7 @@ sub save { ...@@ -202,7 +201,7 @@ sub save {
} }
# SOAP # SOAP
return $self->_soapCall( "setAttributes", $self->{data}->{_session_id}, return $self->_soapCall( 'setAttributes', $self->{data}->{_session_id},
$self->{data} ); $self->{data} );
} }
...@@ -213,14 +212,14 @@ sub delete { ...@@ -213,14 +212,14 @@ sub delete {
# Remove session from cache # Remove session from cache
if ( $self->{localStorage} ) { if ( $self->{localStorage} ) {
my $id = "soap" . $self->{data}->{_session_id}; my $id = 'soap' . $self->{data}->{_session_id};
if ( $self->cache->get($id) ) { if ( $self->cache->get($id) ) {
$self->cache->remove($id); $self->cache->remove($id);
} }
} }
# SOAP # SOAP
return $self->_soapCall( "deleteSession", $self->{data}->{_session_id} ); return $self->_soapCall( 'deleteSession', $self->{data}->{_session_id} );
} }
## @method get_key_from_all_sessions() ## @method get_key_from_all_sessions()
...@@ -240,7 +239,7 @@ sub get_key_from_all_sessions() { ...@@ -240,7 +239,7 @@ sub get_key_from_all_sessions() {
my $token = Lemonldap::NG::Handler::Main->tsv->{cipher} my $token = Lemonldap::NG::Handler::Main->tsv->{cipher}
->decrypt( $self->_soapCall('getCipheredToken') ); ->decrypt( $self->_soapCall('getCipheredToken') );
if ( ref($data) eq 'CODE' ) { if ( ref($data) eq 'CODE' ) {
my $r = $self->_soapCall( "get_key_from_all_sessions", $token ); my $r = $self->_soapCall( 'get_key_from_all_sessions', $token );
my $res; my $res;
if ($r) { if ($r) {
foreach my $k ( keys %$r ) { foreach my $k ( keys %$r ) {
...@@ -248,9 +247,10 @@ sub get_key_from_all_sessions() { ...@@ -248,9 +247,10 @@ sub get_key_from_all_sessions() {
$res->{$k} = $tmp if ( defined($tmp) ); $res->{$k} = $tmp if ( defined($tmp) );
} }
} }
return;
} }
else { else {
return $self->_soapCall( "get_key_from_all_sessions", $token, $data ); return $self->_soapCall( 'get_key_from_all_sessions', $token, $data );
} }
} }
...@@ -269,10 +269,10 @@ sub cache { ...@@ -269,10 +269,10 @@ sub cache {
1; 1;
__END__ __END__
=head1 NAME
=encoding utf8 =encoding utf8
=head1 NAME
Lemonldap::NG::Common::Apache::Session::SOAP - Perl extension written to Lemonldap::NG::Common::Apache::Session::SOAP - Perl extension written to
access to Lemonldap::NG Web-SSO sessions via SOAP. access to Lemonldap::NG Web-SSO sessions via SOAP.
......
...@@ -8,23 +8,24 @@ our $VERSION = '2.1.0'; ...@@ -8,23 +8,24 @@ our $VERSION = '2.1.0';
sub serialize { sub serialize {
my $session = shift; my $session = shift;
$session->{serialized} = to_json( $session->{data}, { allow_nonref => 1 } ); return $session->{serialized} =
to_json( $session->{data}, { allow_nonref => 1 } );
} }
sub unserialize { sub unserialize {
my $session = shift; my $session = shift;
my $data = _unserialize( $session->{serialized} ); my $data = _unserialize( $session->{serialized} );
die "Session could not be unserialized" unless defined $data; die 'Session could not be unserialized' unless defined $data;
$session->{data} = $data; return $session->{data} = $data;
} }
sub unserializeBase64 { sub unserializeBase64 {
my $session = shift; my $session = shift;
my $data = _unserialize( $session->{serialized}, \&decodeThaw64 ); my $data = _unserialize( $session->{serialized}, \&decodeThaw64 );
die "Session could not be unserialized" unless defined $data; die 'Session could not be unserialized' unless defined $data;
$session->{data} = $data; return $session->{data} = $data;
} }
sub decodeThaw64 { sub decodeThaw64 {
...@@ -49,10 +50,10 @@ sub _unserialize { ...@@ -49,10 +50,10 @@ sub _unserialize {
=pod =pod
=head1 NAME
=encoding utf8 =encoding utf8