| 1 | package VOMS::Lite::Audit; | ||
| 2 | |||
| 3 | use 5.004; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use VOMS::Lite::ASN1Helper qw(Hex ASN1Index ASN1Unwrap ASN1Wrap); | ||
| 7 | |||
| 8 | require Exporter; | ||
| 9 | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | ||
| 10 | @ISA = qw(Exporter); | ||
| 11 | |||
| 12 | $VERSION = '0.20'; | ||
| 13 | |||
| 14 | sub Create { | ||
| 15 | my ($location,$critical) = @_; | ||
| 16 | # SEQ{OID{1.3.6.1.4.1.18141.3.100.5.1 }.[CRITICAL].OS{URL}} # NB Critical is not generally used | ||
| 17 | if ( $location !~ m#^https?://.*# ) { return ""; } | ||
| 18 | my $Audit=ASN1Wrap('30','060c2b06010401818d5d03640501'. | ||
| 19 | ($critical?"01010f":""). | ||
| 20 | ASN1Wrap('04',Hex($location))); | ||
| 21 | $Audit =~ s/(..)/pack('C',hex($&))/ge; | ||
| 22 | return $Audit; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub Examine { | ||
| 26 | my $decoded=$_[0]; | ||
| 27 | if ( $decoded !~ /^\x30/ ) { return { Errors => ["Expecting Sequence (0x30...)"] }; } | ||
| 28 | if ( ASN1Unwrap($decoded) =~ /^\x06\x0c\x2b\x06\x01\x04\x01\x81\x8d\x5d\x03\x64\x05\x01((?:\x01\x01[^\0])?)(\x04.*)$/ ) { | ||
| 29 | my $URL=ASN1Unwrap($2); | ||
| 30 | if ( $URL !~ /^https?:\/\//) { return { Errors => ["Badly encoded Audit URL"] }; } | ||
| 31 | return { URL=>$URL, critical => (($1=="")?0:1) }; | ||
| 32 | } | ||
| 33 | return { Errors => ["Not an Audit Extension"] }; | ||
| 34 | } | ||
| 35 | |||
| 36 | ################################################################ | ||
| 37 | |||
| 38 | 1; | ||
| 39 | __END__ |