otifications::JSON;
use strict;
use Mouse;
use JSON qw(from_json to_json);
our $VERSION = '2.19.0';
sub newNotification {
my ( $self, $jsonString, $defaultCond ) = @_;
my $json;
$defaul
tCond ||= '';
eval { $json = from_json( $jsonString, { allow_nonref => 1 } ) };
if ( my $err = $@ ) {
eval { $self->logger->error("Unable to decode JSON file: $err") };
return
0;
}
my @notifs;
$json = [$json] unless ( ref($json) eq 'ARRAY' );
foreach my $notif (@$json) {
my @data;
$notif->{reference} =~ s/_/-/g; # Remove underscores (#21
::Session::Serialize::JSON;
use strict;
use JSON qw(to_json from_json);
our $VERSION = '2.19.0';
sub serialize {
my $session = shift;
$session->{serialized} = to_json( $session->{data}, {
);
}
sub _unserialize {
my ( $serialized, $next ) = @_;
my $tmp;
eval { $tmp = from_json( $serialized, { allow_nonref => 1 } ) };
if ($@) {
eval {
require Storabl
Serialize::JSON - Use JSON to zip up data
=head1 SYNOPSIS
use Lemonldap::NG::Common::Apache::Session::Serialize::JSON;
$zipped = Lemonldap::NG::Common::Apache::Session::Serialize::JSON::serialize
package Lemonldap::NG::Common::Conf::Serializer;
use strict;
use utf8;
use Encode;
use JSON;
use Lemonldap::NG::Common::Conf::Constants;
our $VERSION = '2.0.12';
BEGIN {
*Lemonldap::NG::Common:
y $v = $conf->{$k};
# 1.Hash ref
if ( ref($v) ) {
$fields->{$k} = to_json($v);
}
else {
$fields->{$k} = $v;
}
}
return $fields
}
$conf->{$k} = (
$v =~ /./
? eval { from_json( $v, { allow_nonref => 1 } ) }
: {}
);
if ($@) {
mmon::Conf::Constants;
use Lemonldap::NG::Common::Util qw/display2F getPSessionID/;
use JSON qw(from_json to_json);
our $VERSION = '2.21.0';
has sessionTypes => ( is => 'rw' );
# Boolean value to t
return $session->error
? $self->sendError( $req, $session->error, 200 )
: $self->sendJSONresponse( $req, { result => 1 } );
}
sub deleteOIDCConsent {
my ( $self, $req ) = @_;
my
ts;
if ( $session->data->{_oidcConsents} ) {
$_oidcConsents = eval {
from_json( $session->data->{_oidcConsents}, { allow_nonref => 1 } );
};
if ($@) {
package Lemonldap::NG::Common::Conf::Wrapper;
use strict;
use JSON;
our $VERSION = '2.0.3';
sub TIEHASH {
my ( $class, $conf, $overrides ) = @_;
my %h = %$overrides;
foreach ( keys %h )
{
if ( $h{$_} =~ /^[\[\{]/ ) {
my $tmp = eval { JSON::from_json( $h{$_} ) };
if ($@) {
print STDERR "Wrapper: unable to compile $_ key, skipping\n";
package Lemonldap::NG::Common::PSGI::Request;
use strict;
use Mouse;
use JSON;
use Plack::Request;
use URI::Escape;
our $VERSION = '2.19.0';
our @ISA = ('Plack::Request');
# http :/
->{$k} = $v;
}
sub wantJSON {
return 1
if ( defined $_[0]->accept
and $_[0]->accept =~ m#(?:application|text)/json# );
return 0;
}
# JSON parser
sub jsonBodyToObj {
my $sel
f = shift;
return $self->{json_body} if ( $self->{json_body} );
unless ( $self->content_type =~ /application\/json/ ) {
$self->error('Data is not JSON');
return undef;
}
Header getJWTPayload getJWTSignature getJWTSignedData)
; # symbols to export on request
use JSON;
use MIME::Base64 qw/encode_base64 decode_base64/;
our $VERSION = '2.21.0';
# Gets the Access T
json whether or not to decode as JSON
# @return JSON string
sub getJWTPart {
my ( $jwt, $part ) = @_;
my @jwt_parts = split( /\./, $jwt );
return undef unless @jwt_parts > 1;
my $json
_hash;
eval { $json_hash = from_json( decode_base64url( $jwt_parts[$part] ) ); };
return undef if ($@);
return $json_hash;
}
# Return the JWT data that has to be signed by the OP
# @param
he::Session;
use base qw(Apache::Session);
use Lemonldap::NG::Common::Apache::Session::Serialize::JSON;
use Lemonldap::NG::Common::Apache::Session::Store;
use Lemonldap::NG::Common::Apache::Session::L
p::NG::Common::Apache::Session::Serialize::JSON::serialize;
$self->{unserialize} =
\&Lemonldap::NG::Common::Apache::Session::Serialize::JSON::unserialize;
if ( $backend =~ /^
$self->{unserialize} =
\&Lemonldap::NG::Common::Apache::Session::Serialize::JSON::unserializeBase64;
}
}
if ( $self->{args}->{generateModule} ) {
my $gene
package Lemonldap::NG::Common::Conf::RESTServer;
use strict;
use JSON 'from_json';
use Mouse;
use Lemonldap::NG::Common::Conf::Constants;
use Lemonldap::NG::Common::Conf::ReConstants;
our $VERSION =
ontent (for SAML/OIDC metadata)
# 31 - Complex subnodes
# ----------------
## @method PSGI-JSON-response complexNodesRoot($req, $query, $tpl)
# Respond to root requests for virtual hosts and SA
m $query Configuration root key
#@param $tpl Javascript template to use (see JS/JSON generator script)
#@return PSGI JSON response
sub complexNodesRoot {
my ( $self, $req, $query, $tpl ) = @_;
se Mouse;
use HTTP::Status;
use JSON;
use Lemonldap::NG::Common::PSGI::Constants;
use Lemonldap::NG::Common::PSGI::Request;
our $VERSION = '2.22.0';
our $_json = JSON->new->allow_nonref;
# PROPERTI
ses methods
sub sendJSONresponse {
my ( $self, $req, $j, %args ) = @_;
$args{code} ||= 200;
$args{headers} ||= [ $req->spliceHdrs ];
my $type = 'application/json; charset=utf-8';
args{pretty} ) {
# This avoids changing the settings of the $_json reference
$j = to_json(
$j,
{
allow_
::Conf::Backends::File;
use strict;
use Lemonldap::NG::Common::Conf::Constants; #inherits
use JSON;
use Encode;
our $VERSION = '2.20.2';
our $initDone;
sub Lemonldap::NG::Common::Conf::_lock {
Common::Conf::_file {
my ( $self, $cfgNum ) = @_;
return "$self->{dirName}/lmConf-$cfgNum.json";
}
sub prereq {
my $self = shift;
unless ( $self->{dirName} ) {
$Lemonldap::NG:
ed: $! \n";
$self->unlock;
return UNKNOWN_ERROR;
}
binmode(FILE);
my $json_options = {
allow_nonref => 1,
(
$self->{prettyPrint}
? (
package Lemonldap::NG::Common::Session;
use strict;
use Exporter 'import';
use Digest::SHA;
use JSON;
use Lemonldap::NG::Common::Apache::Session;
use Lemonldap::NG::Common::Apache::Session::Generate
:Common::Safelib;
use strict;
use Encode;
use MIME::Base64;
use Lemonldap::NG::Common::IPv6;
use JSON::XS;
use Net::CIDR;
use Digest::SHA;
use Date::Parse;
our $VERSION = '2.20.0';
# Set here all t
uri$attribute/;
}
my $json = JSON::XS->new;
sub has2f_internal {
my ( $session, $type ) = @_;
return 0 unless $session->{_2fDevices};
my $_2fDevices = eval { $json->decode( $session->{_
package Lemonldap::NG::Common::CliSessions;
use strict;
use Mouse;
use JSON;
use Lemonldap::NG::Common::Conf;
use Lemonldap::NG::Common::Logger::Std;
use Lemonldap::NG::Common::Apache::Session;
use L
ile} );
return { %$res, %$localConf };
},
);
sub _to_json {
my $self = shift;
my $obj = shift;
return to_json( $obj, { pretty => 1, canonical => 1 } );
}
sub _search {
m
_}->{_session_id} . "\n" } keys %{$res};
}
else {
print $o $self->_to_json( [ values %{$res} ] );
}
}
return 0;
}
sub backup {
my $self = shift;
m
::Common::Cli;
use strict;
use JSON;
use Mouse;
use Lemonldap::NG::Common::Conf;
use Lemonldap::NG::Common::EmailTransport;
use constant booleanOptions => qr/^(?:json)$/;
our $VERSION = '2.22.0';
$res);
return $res;
},
);
has cfgNum => (
is => 'rw',
isa => 'Int',
);
has json => ( is => 'rw' );
sub info {
my ($self) = @_;
my $conf =
$self->confAccess->getCo
->{cfgDate} ||= 0;
$conf->{cfgLog} ||= "No log provided";
if ( $self->json ) {
print JSON->new->pretty->allow_nonref->encode( {
num => $conf->{cfgNum},
package Lemonldap::NG::Common::Notifications;
use strict;
use Mouse;
use JSON qw(to_json);
our $VERSION = '2.21.0';
extends 'Lemonldap::NG::Common::Module';
sub import {
if ( $_[1] eq 'XML' )
s 'Lemonldap::NG::Common::Notifications::JSON',
'Lemonldap::NG::Common::Module';
}
}
has extension => (
is => 'rw',
default => 'json'
);
has notifField => (
is =>
l = ( $1 eq 'Pending' ? $self->getAll() : $self->getExisting() );
$all = { map { $_ => to_json( $all->{$_} ) } keys %$all };
return ( $forAll ? { %$all, %$forAll } : $all );
}
:UserAgent;
use JSON qw(from_json to_json);
our $VERSION = '2.18.0';
#parameter baseUrl, user, password, realm, lwpOpts
BEGIN {
*Lemonldap::NG::Common::Conf::getJson = \&getJson;
*Lemonldap
sub getJson {
my $self = shift;
my $url = shift;
my $resp = $self->ua->get( $self->base . $url, @_ );
if ( $resp->is_success ) {
my $res;
eval { $res = from_json( $res
ented for now';
return undef;
}
sub lastCfg {
my $self = shift;
my $res = $self->getJson('latest') or return;
return $res->{cfgNum};
}
# lock and unlock must not be requested by the
package Lemonldap::NG::Common::Conf::Backends::CDBI;
use strict;
use utf8;
use JSON;
use Lemonldap::NG::Common::Conf::Backends::_DBI;
our $VERSION = '2.22.0';
our @ISA = qw(Lemonldap::NG::Common
my $cfgNum = $fields->{cfgNum};
my $req;
my $lastCfg = $self->lastCfg;
$fields = to_json($fields);
my $query =
$lastCfg == $cfgNum
? "UPDATE $self->{dbiTable} SET data=?
;
return 0;
}
my $r;
if ( $row->[0] =~ /^\s*\{/s ) {
eval { $r = from_json( $row->[0], { allow_nonref => 1 } ); };
}
else { # Old format
require Storable
ommon::Session;
use Lemonldap::NG::Common::Safelib;
use Lemonldap::NG::Common::PSGI::Request;
use JSON;
use Mouse;
use Time::HiRes;
use POSIX qw(strftime);
use constant defaultLogger => 'Lemonldap::N
s logLevel => ( is => 'rw' );
has force => ( is => 'rw' );
has audit => ( is => 'rw' );
has json => ( is => 'rw' );
has conf => (
is => 'ro',
default => sub {
my $ca = L
)
);
}
my $log = "Session purge completed: ";
if ( $self->json ) {
$log .= to_json($return_stats);
}
else {
my @logentries;
for my $type ( "to
package Lemonldap::NG::Common::Logger::Loki;
use strict;
use JSON;
use Lemonldap::NG::Common::UserAgent;
use Sys::Hostname;
use Time::HiRes qw(time);
our $VERSION = '2.22.0';
sub new {
my ( $cl
t:3100/loki/api/v1/push';
$self->{label} = $conf->{lokiLabel} || 'llng';
$self->{j} = JSON->new->canonical;
$self->{ua} = Lemonldap::NG::Common::UserAgent->new($conf)
unless $
( $self->{proxy} ? ( Host => $self->{host} ) : () ),
'Content-Type' => 'application/json',
(
$self->{authorization}
? ( 'Authorization' => $se