App-CamelPKI

 view release on metacpan or  search on metacpan

inc/My/Module/Build.pm  view on Meta::CPAN

$builder->create_build_script();
1;
REMAINDER
ok($sample_Build_PL =~ s/^(.*##.*remainder.*)$/$remainder/m,
   "Substitution 2 in synopsis");
write_file("$fakemoduledir/Build.PL", $sample_Build_PL);

mkdir("$fakemoduledir/lib");
mkdir("$fakemoduledir/lib/Fake");

=begin this_pod_is_not_mine

=cut

my $fakemodule = <<'FAKE_MODULE';
#!perl -w

# (C) DOMQ

use strict;
package Fake::Module;

inc/My/Module/Build.pm  view on Meta::CPAN

package Fake::Module::Ancillary::Class;

1;

__END__

package This::Package::Should::Not::Be::Reported::In::METAyml;

FAKE_MODULE

=end this_pod_is_not_mine

=cut

write_file("$fakemoduledir/lib/Fake/Module.pm", $fakemodule);

mkdir("$fakemoduledir/$_") foreach
    (qw(inc inc/My inc/My/Module
        lib/My lib/My/Private lib/My/Private/Stuff));

use FindBin qw($Bin $Script);

lib/App/CamelPKI/CADB.pm  view on Meta::CPAN

        if (@_ % 2);
    my ($self, $cert, %infos) = @_;

    my $dercert = $cert->serialize(-format => "DER");

    throw App::CamelPKI::Error::Database("Certificate already entered")
        if $self->{dbix}->resultset("Certificate")
            ->search({der => $dercert})->count;
    my $certid = $self->{dbix}->resultset("Certificate")->create
        ({der => $dercert, serial => $cert->get_serial,
          not_before => $cert->get_notBefore,
          not_after  => $cert->get_notAfter,
         })->id;
    foreach my $key (keys %infos) {
        foreach my $val (ref($infos{$key}) eq "ARRAY" ? @{$infos{$key}} :
                         ($infos{$key})) {
            $self->{dbix}->resultset("CertInfo")
                ->create({certid => $certid,
                          key => $key,
                          val => $val});
        }
    }

lib/App/CamelPKI/CADB.pm  view on Meta::CPAN

                   ( defined($v) ? ("infos${qualifier}.val" => $v) : () ),
                 });
        } elsif ($k eq "-certificate") {
            throw App::CamelPKI::Error::Internal("INCORRECT_ARGS")
                unless eval { $v->isa("App::CamelPKI::Certificate") };
            $cursor = $cursor->search
                ( { der => $v->serialize(-format => "DER") } );
        } elsif ($k eq "-initially_valid_at") {
            $v = App::CamelPKI::Time->parse($v);
            $cursor = $cursor->search
                ( { not_before => { "<=", $v->zulu },
                    not_after => { " >=", $v->zulu }} );
        } elsif ($k eq "-serial") {
        	$cursor = $cursor->search
                ( { serial => { "=", $v } } );
        } elsif ($k eq "-revoked") {
            if (! defined($v)) {
                # no-op
            } elsif ($v) {
                # Only revoked certificates
                $cursor = $cursor->search
                     # Yes, { "!=", undef } correctly translates to "IS

lib/App/CamelPKI/CADB.pm  view on Meta::CPAN

     # Fields that follow are de-normalisations on the "der" field,
     # to allow searchs.

     # The serial number, on a hexadecimal textual form, used by
     # Crypt::OpenSSL::CA (ie "0x1234deadbeef").
     serial => {data_type => "text",
                is_nullable => 0,
               },
     # Dates of validity for the certificate, in "zulu" format with
     # 4 digit for the year date.
     not_before => { data_type => "text",
                     is_nullable => 0 },
     not_after  => { data_type => "text",
                     is_nullable => 0 },
    );

__PACKAGE__->set_primary_key("certid");
__PACKAGE__->has_many("infos",
                      "App::CamelPKI::CADB::_Schema::CertInfo", "certid");

=head2 App::CamelPKI::CADB::_Schema::Sequence

This class represents the "sequences" table, which contains one line

lib/App/CamelPKI/Controller/Certificate.pm  view on Meta::CPAN

sub show_by_serial : Local{
	my ($self, $c) = @_;
	my $serial;
	foreach my $part (@{$c->request->arguments}){
		$serial .= $part;
	}
	my $cert = $c->model("CA")->instance->get_certificate_by_serial($serial);
	if ($cert) {
		$c->stash->{cert}->{serial} = $cert->get_serial;
		$c->stash->{cert}->{subject} = $cert->get_subject_DN->to_string;
		$c->stash->{cert}->{not_before} = $cert->get_notBefore;
		$c->stash->{cert}->{not_after} = $cert->get_notAfter;
		$c->stash->{cert}->{public_key} = $cert->get_public_key->serialize;
		$c->stash->{cert}->{issuer} = $cert->get_issuer_DN->to_string;
		$c->stash->{cert}->{subject_key_id} = $cert->get_subject_keyid;
		$c->stash->{cert}->{status} = 
			$c->model("CA")->instance->issue_crl->is_member($cert) ?
				"Revoked" : "Valid" ;
		$c->stash->{template} = 'certificate/info.tt2';
	} else {
		$c->stash->{message} = "The certificate with serial : \"$serial\" doesn't exists.";
		$c->stash->{template} = 'message.tt2';

root/certificate/info.tt2  view on Meta::CPAN

	<td>Subject DN</td>
	<td>[% cert.subject %]</td>
</tr><tr>
	<td>Subject Key Id</td>
	<td>[% cert.subject_key_id %]</td>
</tr><tr>
	<td>Issuer DN</td>
	<td>[% cert.issuer %]</td>
</tr><tr>
	<td>Not Before</td>
	<td>[% cert.not_before %]</td>
<tr></tr>
</tr><tr>
	<td>Not After</td>
	<td>[% cert.not_after %]</td>
<tr></tr>
</tr><tr>
	<td>Public Key</td>
	<td>[% cert.public_key %]</td>
<tr></tr>
</table>

t/lib/App/CamelPKI/Test.pm  view on Meta::CPAN

    my @keyids = keys %App::CamelPKI::Test::test_rootca_certs;
    foreach my $id (@keyids) {
        certificate_chain_ok
            ($App::CamelPKI::Test::test_entity_certs{$id},
           [ $App::CamelPKI::Test::test_rootca_certs{$id} ]);
        certificate_chain_ok
            ($App::CamelPKI::Test::test_entity_certs{"${id}_sha256"},
             [ $App::CamelPKI::Test::test_rootca_certs{$id} ]);
    }

    my ($snippet_ok, $snippet_not_ok) =
        map { My::Tests::Below->pod_code_snippet($_) }
            (qw(certificate_chain_ok certificate_chain_notok));
    my $out = run_perl(<<"SCRIPT");
use Test::More qw(no_plan);
use App::CamelPKI::Test qw(certificate_chain_ok
       %test_rootca_certs %test_self_signed_certs %test_entity_certs);
foreach my \$key (qw(${\join(" ", @keyids)})) {
    $snippet_ok
    $snippet_not_ok
}
SCRIPT
    for my $i (0..$#keyids) {
        my $success = 2 * $i + 1;
        my $failure = 2 * $i + 2;
        like($out, qr/^ok $success/m);
        like($out, qr/^not ok $failure/m);
    }
};



( run in 1.034 second using v1.01-cache-2.11-cpan-cc502c75498 )