From 6acbb9ce64bacf07cd6a0fd0a26aa16a3d32d6fa Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Wed, 20 Jun 2007 14:33:26 +0000 Subject: Checkpoint svn path=/scripts/PLAN; revision=672 --- scripts/PLAN | 6 + scripts/up-down-schema.rnc | 80 +++++++++++++ scripts/up-down-schema.rng | 272 +++++++++++++++++++++++++++++++++++++++++++++ scripts/xml-parse-test.pl | 31 +++++- 4 files changed, 387 insertions(+), 2 deletions(-) create mode 100644 scripts/up-down-schema.rnc create mode 100644 scripts/up-down-schema.rng (limited to 'scripts') diff --git a/scripts/PLAN b/scripts/PLAN index 073317ef..13f9de93 100644 --- a/scripts/PLAN +++ b/scripts/PLAN @@ -18,6 +18,12 @@ Rough plan for initial prototype RE. Log everything as we go and use Data::Dumper to log content of Perl data structures. + APNIC is specifying schema in RNC (RelaxNG Compact) syntax, xmllint + wants RNG (RelaxNG XML) syntax, so use /usr/ports/textproc/trang to + convert: + + $ trang foo.rnc foo.rng + 3) Whack (2) into something that does this over minimal HTTP. 4) [to be continued...] diff --git a/scripts/up-down-schema.rnc b/scripts/up-down-schema.rnc new file mode 100644 index 00000000..41921b21 --- /dev/null +++ b/scripts/up-down-schema.rnc @@ -0,0 +1,80 @@ +# $Id$ +# +# RelaxNG (Compact Syntax) Scheme for up-down protocol, extracted +# from APNIC Wiki. +# +# libxml2 (including xmllint) only groks the XML syntax of RelaxNG, +# so run this through a converter like /usr/ports/textproc/trang to get +# XML syntax: +# +# $ trang up-down-schema.rnc up-down-schema.rng + + default namespace = "http://www.apnic.net/specs/rescerts/up-down/" + + grammar { + start = element message { + attribute version { xsd:positiveInteger { maxInclusive="1" } }, + attribute sender { xsd:token { maxLength="1024" } }, + attribute recipient { xsd:token { maxLength="1024" } }, + attribute msg_ref { xsd:positiveInteger { maxInclusive="999999999999999" } }, + payload + } + + payload |= attribute type { "list" }, list_request + payload |= attribute type { "list_response"}, list_response + payload |= attribute type { "issue" }, issue_request + payload |= attribute type { "issue_response"}, issue_response + payload |= attribute type { "revoke" }, revoke_request + payload |= attribute type { "revoke_response"}, revoke_response + payload |= attribute type { "error_response"}, error_response + + list_request = empty + list_response = class* + + class = element class { + attribute class_name { xsd:token { maxLength="1024" } }, + attribute cert_url { xsd:anyURI { maxLength="1024" } }, + attribute cert_ski { xsd:token { maxLength="1024" } }, + attribute resource_set_as { xsd:string { maxLength="512000" } }, + attribute resource_set_ipv4 { xsd:string { maxLength="512000" } }, + attribute resource_set_ipv6 { xsd:string { maxLength="512000" } }, + attribute suggested_sia_head { xsd:string { maxLength="1024" } }?, + element certificate { + attribute cert_url { xsd:anyURI { maxLength="1024" } }, + attribute cert_ski { xsd:token { maxLength="1024" } }, + attribute cert_aki { xsd:token { maxLength="1024" } }, + attribute cert_serial { xsd:positiveInteger }, + attribute resource_set_as { xsd:string { maxLength="512000" } }, + attribute resource_set_ipv4 { xsd:string { maxLength="512000" } }, + attribute resource_set_ipv6 { xsd:string { maxLength="512000" } }, + attribute req_resource_set_as { xsd:string { maxLength="512000" } }?, + attribute req_resource_set_ipv4 { xsd:string { maxLength="512000" } }?, + attribute req_resource_set_ipv6 { xsd:string { maxLength="512000" } }?, + attribute status { "undersize" | "match" | "oversize" }, + xsd:base64Binary { maxLength="512000" } + }*, + element issuer { xsd:base64Binary { maxLength="512000" } } + } + + issue_request = element request { + attribute class_name { xsd:token { maxLength="1024" } }, + attribute req_resource_set_as { xsd:string { maxLength="512000" } }?, + attribute req_resource_set_ipv4 { xsd:string { maxLength="512000" } }?, + attribute req_resource_set_ipv6 { xsd:string { maxLength="512000" } }?, + xsd:base64Binary { maxLength="512000" } + } + issue_response = class + + revoke_request = revocation + revoke_response = revocation + + revocation = element key { + attribute class_name { xsd:token { maxLength="1024" } }, + attribute ski { xsd:token { maxLength="1024" } } + } + + error_response = + element status { xsd:positiveInteger { maxInclusive="999999999999999" } }, + element last_msg_processed { xsd:positiveInteger { maxInclusive="999999999999999" } }?, + element description { attribute xml:lang { xsd:language }, xsd:string { maxLength="1024" } }? + } diff --git a/scripts/up-down-schema.rng b/scripts/up-down-schema.rng new file mode 100644 index 00000000..749d98e8 --- /dev/null +++ b/scripts/up-down-schema.rng @@ -0,0 +1,272 @@ + + + + + + + 1 + + + + + 1024 + + + + + 1024 + + + + + 999999999999999 + + + + + + + + list + + + + + + list_response + + + + + + issue + + + + + + issue_response + + + + + + revoke + + + + + + revoke_response + + + + + + error_response + + + + + + + + + + + + + + + + 1024 + + + + + 1024 + + + + + 1024 + + + + + 512000 + + + + + 512000 + + + + + 512000 + + + + + + 1024 + + + + + + + + 1024 + + + + + 1024 + + + + + 1024 + + + + + + + + 512000 + + + + + 512000 + + + + + 512000 + + + + + + 512000 + + + + + + + 512000 + + + + + + + 512000 + + + + + + undersize + match + oversize + + + + 512000 + + + + + + 512000 + + + + + + + + + 1024 + + + + + + 512000 + + + + + + + 512000 + + + + + + + 512000 + + + + + 512000 + + + + + + + + + + + + + + + + + 1024 + + + + + 1024 + + + + + + + + 999999999999999 + + + + + + 999999999999999 + + + + + + + + + + 1024 + + + + + diff --git a/scripts/xml-parse-test.pl b/scripts/xml-parse-test.pl index 4811177a..0a7256b0 100755 --- a/scripts/xml-parse-test.pl +++ b/scripts/xml-parse-test.pl @@ -9,6 +9,25 @@ use strict; use XML::Simple; use Data::Dumper; use IPC::Open2; +use Getopt::Long; + +my %opt; + +if (0) { + my $usage = "Use The Source, Luke"; + die($usage) + unless GetOptions(\%opt, qw(encode! decode! schema=s key=s cert=s dir=s)) + and $opt{encode} + $opt{decode} == 1; + die($usage) + if $opt{encode} and !$opt{cert} || !$opt{key}; + die($usage) + if $opt{decode} and !$opt{schema} || !$opt{dir}; +} else { + $opt{dir} = "biz-certs"; + $opt{cert} = "biz-certs/Alice-EE.cer"; + $opt{key} = "biz-certs/Alice-EE.key"; + $opt{schema} = "up-down-schema.rng"; +} sub run2 { my $arg = shift; @@ -46,6 +65,13 @@ sub decode { return join('', @res); } +sub relaxng { + my $xml = shift; + my $schema = shift; + my @res = run2($xml, qw(xmllint --relaxng), $schema, q(-)); + return join('', @res); +} + my $xs = XML::Simple->new(KeepRoot => 1, ForceArray => [qw(list_class)], KeyAttr => [qw(header)], @@ -131,11 +157,12 @@ my @xml = (' for my $xml (@xml) { print("1: ", $xml, "\n"); print("2: ", Dumper($xs->XMLin($xml)), "\n"); - my $cms = encode($xml, "biz-certs/Alice-EE.cer", "biz-certs/Alice-EE.key"); + my $cms = encode($xml, $opt{cert}, $opt{key}); print("3: ", $cms, "\n"); - $xml = decode($cms, "biz-certs"); + $xml = decode($cms, $opt{dir}); print("4: ", $xml, "\n"); print("5: ", Dumper($xs->XMLin($xml)), "\n"); + print("6: ", relaxng($xml, $opt{schema}), "\n"); # my $x = $xs->XMLin($xml); # my $t = $xs->XMLout($x); -- cgit v1.2.3