Group
Extension

Matches 9

App-CamelPKI ( G/GR/GRM/CamelPKI/App-CamelPKI-0.07.tar.gz, GRM, 2008; MetaCPAN )
App-CamelPKI/lib/App/CamelPKI/View/JSON.pm ( view source; MetaCPAN )
package App::CamelPKI::View::JSON;

use strict;
use base 'Catalyst::View::JSON';

=head1 NAME

App::CamelPKI::View::JSON - the view used to throw data to an AJAX client
or any other RPC client.

=head
1 SYNOPSIS

=head1 DESCRIPTION

This package is a (trivial for now) subclass of L<Catalyst::View>.
It allow to send a Perl data structure to an HTTP client, using
L<JSON> encoding format.

=cut

1;
App-CamelPKI ( G/GR/GRM/CamelPKI/App-CamelPKI-0.07.tar.gz, GRM, 2008; MetaCPAN )
App-CamelPKI/lib/App/CamelPKI/Action/JSON.pm ( view source; MetaCPAN )
;
use warnings;

package App::CamelPKI::Action::JSON;

=head1 NAME

I<App::CamelPKI::Action::JSON> - Adapting the Catalyst execution
environment for JSON requests.

=head1 SYNOPSIS

In the root contro
:Action::JSON;
    sub end : ActionClass('RenderView') {
        my ($self, $c) = @_;
        App::CamelPKI::Action::JSON->finalize_errors($c);
    }

In a regular controller:

    sub my_json_control
ler : ActionClass("+App::CamelPKI::Action::JSON") {
        my ($self, $c, $request_structure) = @_;
        ...
    }


Note: the C<< MyAction("JSON") >> form documented in
L<Catalyst::Manual::Action
App-CamelPKI ( G/GR/GRM/CamelPKI/App-CamelPKI-0.07.tar.gz, GRM, 2008; MetaCPAN )
App-CamelPKI/lib/App/CamelPKI/PEM.pm ( view source; MetaCPAN )
App::CamelPKI::Error::Internal("ABSTRACT_METHOD")
        if ($class eq __PACKAGE__);

    # Some JSON objects stringify to undef!  In this case, Perl
    # converts them into the null string, with a 
App-CamelPKI ( G/GR/GRM/CamelPKI/App-CamelPKI-0.07.tar.gz, GRM, 2008; MetaCPAN )
App-CamelPKI/lib/App/CamelPKI/CertTemplate.pm ( view source; MetaCPAN )
e JSON;
    sub Bogus::Template::list_keys { qw(foo bar main) };

    my %got = Bogus::Template->App::CamelPKI::CertTemplate::normalize_opts
         (bar => [ qw( ba pa pa ) ],
         foo => JSON::
from_json('"yourself"'),
         main => "screen",
         turn => "on");
    is_deeply(\%got, {
                      foo => "yourself",
                      bar => [qw(ba pa pa)],
               
App-CamelPKI ( G/GR/GRM/CamelPKI/App-CamelPKI-0.07.tar.gz, GRM, 2008; MetaCPAN )
App-CamelPKI/lib/App/CamelPKI/Certificate.pm ( view source; MetaCPAN )
=cut

use Test::More qw(no_plan);
use Test::Group;
use File::Slurp;
use App::CamelPKI::Error;
use JSON;

my $certificate = <<"CERTIFICATE";
-----BEGIN CERTIFICATE-----
MIICsDCCAhmgAwIBAgIJANdqtXzdPS/1
#TODO: verifier pourquoi ca marche pas
#    try {
#        App::CamelPKI::Certificate->parse(JSON::from_json("null"));
#        fail;
#    } catch App::CamelPKI::Error::Internal with {
#        pass;
App-CamelPKI ( G/GR/GRM/CamelPKI/App-CamelPKI-0.07.tar.gz, GRM, 2008; MetaCPAN )
App-CamelPKI/lib/App/CamelPKI/Controller/CA.pm ( view source; MetaCPAN )
given certificate template.

Actions with name ending by C<_pem> don't use L<App::CamelPKI::View::JSON>,
but rather transmit directly their data in text/plain; this enables
operation with very basic c
App-CamelPKI ( G/GR/GRM/CamelPKI/App-CamelPKI-0.07.tar.gz, GRM, 2008; MetaCPAN )
App-CamelPKI/lib/App/CamelPKI/Controller/Test.pm ( view source; MetaCPAN )
lated).

=head2 json_helloworld

Accepts a JSON parameter which contains an associative table with keys
"nom" (meaning last name in French) and "prenom" (first name), and
returns a JSON parameter whic
For the fame of it,
"Bonjour" means "Hello" in French.)

=cut

sub json_helloworld : Local : ActionClass("+App::CamelPKI::Action::JSON") {
    my ($self, $c, $input) = @_;
    $c->stash->{salutation} 
l that the HTTP/S client is wielding (deduced from its client
certificate in L<App::CamelPKI>). A JSON request is not needed, allowing
the use of C<curl> in command-line mode for testing purposes.

=c
App-CamelPKI ( G/GR/GRM/CamelPKI/App-CamelPKI-0.07.tar.gz, GRM, 2008; MetaCPAN )
App-CamelPKI/lib/App/CamelPKI/Controller/Root.pm ( view source; MetaCPAN )
he control to the view, after having dealt with JSON errors in
collaboration with L<App::CamelPKI::Action::JSON>.

=cut

use App::CamelPKI::Action::JSON;
sub end : ActionClass('RenderView') {
    my (
                       ->isa("App::CamelPKI::Error::Privilege") };
        App::CamelPKI::Action::JSON->finalize_errors($c);
        $c->response->status($statuscode) if $statuscode;
        if ($c->r
t error, not an HTML one.  REFACTORME: code
            # copied over from App::CamelPKI::Action::JSON
            my @folded_errors = map {
                # Wrap error messages at about 75 colums fo
App-CamelPKI ( G/GR/GRM/CamelPKI/App-CamelPKI-0.07.tar.gz, GRM, 2008; MetaCPAN )
App-CamelPKI/lib/App/CamelPKI/Controller/CA/Template/Base.pm ( view source; MetaCPAN )
plate controller> is an entry point into Camel-PKI : it consists
of the code that responds to the JSON-RPC requests for issuing or
revoking certificates.  Other user-initiated Certification Authority
d2 certifyJSON($reqdetails) : Local : ActionClass("+App::CamelPKI::Action::JSON")

Requests the issuance of a number of certificates in this template
family.  $reqdetails (passed as the JSON-RPC POST 
the same call to
I<certify> throws an exception.

The response is transmitted as an C<application/json> HTTP document,
with the following structure (again in Perl syntax):

  {
     keys => [
        

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.