sed together with WWW::LetsEncrypt::JWK as parents
will create a JSON Web Key that implements all the functions needed for signing
JSON Web Signature objects.
=head2 Attributes
'alg' a scalar attrib
pan-meta/issues/28
# but this is the current v2.0 spec - regexp lifted from Test::CPAN::Meta::JSON::Version
$self->log_fatal('invalid syntax for optional feature name \'' . $self->name . '\''
se strict;
use warnings;
use Encode qw(encode_utf8);
use MIME::Base64 qw(encode_base64url);
use JSON;
use Moose;
has 'payload' => (
is => 'rw',
isa => 'HashRef',
default => sub { return
eaders if %{$self->headers};
return encode_json($output);
}
sub _serialize_hash {
my ($hash_ref) = @_;
return encode_base64url(encode_utf8(encode_json($hash_ref)));
}
__PACKAGE__->meta->make_imm
({
item1 => 'a',
});
IOFunction($JWS->serialize());
=head1 DESCRIPTION
A (mostly) implemented JSON Web Signature object as per the RFC specification.
This object's implementation follows the JWS R
ally, modulo lazy fetching of references.
That means that when a parsed schema is rendered out to JSON, it should look
the same as the original document.
Probably the sane way to do this would be to
WebService::FritzBox;
# ABSTRACT: Interface to FritzBox devices
use Digest::MD5 qw/md5_hex/;
use JSON::MaybeXS;
use LWP::UserAgent;
use Log::Log4perl;
use Moose;
use MooseX::Params::Validate;
use Try
ata = decode_json( $response->decoded_content );
# It's just an array with one element...
$data = $data->[0];
}catch{
$self->log->logdie( "Could not decode json: $_" );
warnings;
use Carp ();
use Digest::SHA qw(hmac_sha256_hex);
use Exporter qw(import);
use JSON::XS qw(decode_json);
our @EXPORT_OK = qw( create_signature is_signature_valid );
our $SIG_VALID_FOR_SEC
$time ||= time;
my $req_time = ref($params) ? $params->{time}
: decode_json($params)->{time};
return if not $req_time;
return if $req_time < ($time - $SIG_VALID_FOR
package Test::Mojo::More;
use Mojo::Base 'Test::Mojo';
use Test::More;
use Mojo::JSON::Pointer;
use Mojo::Message::Request;
use Mojolicious;
use Mojolicious::Controller;
use Mojo::Transaction::HTTP;
} );
$t = $t->flash_is( '/error/message', 'error message' );
Check flash the given JSON Pointer with Mojo::JSON::Pointer.
=cut
sub flash_is {
my ($self, $key, $value, $desc) = @_;
my ( $flash,
deeply',
_pointer( $flash, $path ? "/$path" : "" ),
$value,
$desc || "flash exact match for JSON Pointer \"$key\"",
);
}
=head2 C<flash_has>
$t = $t->flash_has( '/error' );
$t = $t->flas
N
B<WebService::Pandora> is a module to communicate with the Pandora (L<http://www.pandora.com>) JSON API.
The API is not officially published, and has a few oddities, but was reverse engineered and
cify anything if package is os-independent
dependencies:
- perl-YAML > 0.5
- perl-JSON
files:
bin: /usr/local/bin # directory-based mapping. RPM will install C
=> '/usr/local/bin' },
dependencies => [
'perl-YAML > 0.5',
'perl-JSON'
],
os => 'el6',
user => 'apache',
group => 'apache',
or() );
=head1 DESCRIPTION
B<WebService::Pandora::Method> is a module which queries the Pandora JSON API using the
B<LWP::UserAgent> and B<HTTP::Request> libraries. It is used by the main B<WebServ
dule for all of the webservice methods it exposes. It handles all of the encryption,
decryption, JSON conversion, and the Pandora API oddities for you.
=head1 CONSTRUCTOR
=head2 new
Creates a new
iven. The method can
then be B<execute()>ed, returning a decrypted hashref representation of the JSON string returned
by the Pandora API method.
$method = WebService::Pandora::Method->new( name =>
y $auth = encode_base64($self->api_key.':x', '');
my $headers = { Accept => 'application/json', 'Authorization' => "Basic $auth" };
my $response = $ua->request('GET', $full_url, { headers
y $auth = encode_base64($self->api_key.':x', '');
my $headers = { Accept => 'application/json', 'Authorization' => "Basic $auth" };
my $response = $ua->request('POST', $full_url, { header
use Moo 2.000000;
use HTTP::Tiny 0.045;
use Try::Tiny 0.13;
use JSON::MaybeXS 1.003003 qw/ decode_json /;
with 'WebService::BambooHR::UserAgent';
use WebService::BambooHR::Employee;
.qq{\n</fields>\n</report>\n};
my $response = $self->_post('reports/custom?format=json', $body);
my $json = $response->{content};
# Workaround for a issues in BambooHR:
# - if
r field '1610' you get back '1610.0'
$json =~ s/"employmentStatus":/"status":/g;
$json =~ s/"1610.0":/"1610":/g;
my $report = decode_json($json);
return map { WebService::BambooHR::
ice::Pandora::Method;
use strict;
use warnings;
use WebService::Pandora::Cryptor;
use URI;
use JSON;
use HTTP::Request;
use LWP::UserAgent;
use Data::Dumper;
### constructor ###
sub new {
my
= LWP::UserAgent->new( timeout => $self->{'timeout'} );
# create and store json object
$self->{'json'} = JSON->new();
return $self;
}
### getters/setters ###
sub error {
my ( $se
.' );
return;
}
# craft the json data accordingly
my $json_data = {};
if ( defined( $self->{'userAuthToken'} ) ) {
$json_data->{'userAuthToken'} = $self->{'userAuthT
use strict;
use warnings;
use Role::Tiny;
use Test::More;
use Test::Deep qw( cmp_deeply );
sub json_deeply {
my ( $t, $ptr, $expect, $desc ) = @_;
# Pointer is an optional argument
if
a simple scalar (did you mean to use json_is()?)"
if !ref $expect;
$desc ||= qq{deeply match JSON Pointer "$ptr"};
my $given = $t->tx->res->json( $ptr );
local $Test::Builder::
t::Builder::Level + 1;
my $result = cmp_deeply( $given, $expect, $desc )
or diag "Got JSON: ", explain $given;
return $t->success( $result );
}
sub text_deeply {
my ( $t, $sel, $
e::Pandora::Method;
use WebService::Pandora::Cryptor;
use WebService::Pandora::Partner::iOS;
use JSON;
use Data::Dumper;
our $VERSION = '0.4';
### constructor ###
sub new {
my $caller = shift
deExtendedAttributes'};
$includeExtendedAttributes = ( $includeExtendedAttributes ) ? JSON::true() : JSON::false();
# make sure they provided a stationToken argument
if ( !defined( $stat
Positive must be specified.' );
return;
}
$isPositive = ( $isPositive ) ? JSON::true() : JSON::false();
# create the station.addFeedback method w/ appropriate params
my $meth
::Cryptor> is used to encrypt and decrypt the data sent to and from
the Pandora JSON API. Some methods require the JSON to be sent using the Blowfish
algorithm in ECB mode. Some of the attributes re
is passed
a true value for the B<encrypt> boolean, it uses this module to do so for the submitted
JSON data.
=head1 CONSTRUCTOR
=head2 new
Creates a B<WebService::Pandora::Cryptor> object with the
encrypted string of the JSON data given that the Pandora
API expects, using the provided B<encryption_key> specified in the constructor.
$encrypted = $cryptor->encrypt( $json_str );
=head2 decrypt
to use when encrypting the JSON data being sent to the
Pandora API method.
=item decryption_key =E<gt> STRING [required]
The decryption key to use when decrypting the JSON data send back from the
Pa
DATE
our $VERSION = '0.03'; # VERSION
use 5.010001;
use strict;
use warnings;
use JSON::MaybeXS;
my $json = JSON::MaybeXS->new->allow_nonref;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK
2";
}
} else {
return $json->encode("$str");
}
}
sub decode_js_string {
my $str = shift;
if ($str =~ /\A"/o) {
$json->decode($str);
} elsif ($str =~ /\A'/o
JavaScript literal representation using double
quotes (C<">). This is currently implemented using JSON encoding.
If C<$mode> is set to 1, will produce literal representation using single quotes
(C<'>
om log4perl
http_post = (rwp) if true, use http post method instead of get
post_json = (rwp) set json content to be post
ssl = (ro) if 'on', use https (default is 'off')
ssl_v
define if it's xa datasource, yes/no (default is 'no')
=cut
has [qw/url log json_data resource_url http_post post_json /] => ( is => 'rwp' );
has [qw/username password/]
croak "post_json not set"
unless $self->post_json;
my $req = HTTP::Request->new(POST => $self->url);
$req->content_type ('application/json');
$req->
->http_post) {
$self->_set_post_json('{"operation":"read-attribute","name":"server-state","json.pretty":1}');
$self->log->debug($self->post_json);
}
else {
$self->_set_
resource_url('/?operation=attribute&name=server-state&json.pretty');
$self->log->debug($self->resource_url);
}
$self->get_api_response();
}
=head2 get_jvm_usage
return jvm usag
et_resource_url('/core-service/platform-mbean/type/memory?operation=resource&include-runtime=true&json.pretty');
$self->log->debug($self->resource_url);
$self->get_api_response();
}
=hea