aboutsummaryrefslogtreecommitdiff
path: root/potpourri/oob-translate.xsl
blob: c78f052f2ed624aef2fd0af2aa59665f4b0457d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!-- -*- SGML -*-
  - $Id$
  -
  - Copyright (C) 2015-2016  Parsons Government Services ("PARSONS")
  -
  - Permission to use, copy, modify, and distribute this software for any
  - purpose with or without fee is hereby granted, provided that the above
  - copyright notices and this permission notice appear in all copies.
  -
  - THE SOFTWARE IS PROVIDED "AS IS" AND PARSONS DISCLAIMS ALL
  - WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  - WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL
  - PARSONS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
  - CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  - OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 -->
<!--
  - Translate between old "myrpki" XML and current IETF standards
  - track out-of-band-setup protocol XML.  Well, partially.  Much of
  - the old protocol is either irrelevant or can't be translated due
  - to embedded signatures, but the subset that other implementations
  - support is small enough that we can fake something workable.
  -->

<xsl:transform xmlns:xsl    = "http://www.w3.org/1999/XSL/Transform"
	       version      = "1.0"
	       xmlns:myrpki = "http://www.hactrn.net/uris/rpki/myrpki/"
	       xmlns:oob    = "http://www.hactrn.net/uris/rpki/rpki-setup/"
	       exclude-result-prefixes = "myrpki oob">

  <xsl:output omit-xml-declaration = "yes"
	      indent               = "yes"
	      method               = "xml"
	      encoding             = "US-ASCII"/>

  <!-- Versions of the respective protocols -->

  <xsl:param name = "myrpki-version"  select = "2"/>
  <xsl:param name = "oob-version"     select = "1"/>

  <!-- Old-style identity to new-style child_request -->

  <xsl:template match = "/myrpki:identity">
    <oob:child_request version      = "{$oob-version}" 
		       child_handle = "{@handle}">
      <oob:child_bpki_ta>
	<xsl:value-of select = "myrpki:bpki_ta"/>
      </oob:child_bpki_ta>
    </oob:child_request>
  </xsl:template>

  <!-- New-style child_request to old style identity -->

  <xsl:template match = "/oob:child_request">
    <myrpki:identity version = "{$myrpki-version}" 
		     handle  = "{@child_handle}">
      <myrpki:bpki_ta>
	<xsl:value-of select = "oob:child_bpki_ta"/>
      </myrpki:bpki_ta>
    </myrpki:identity>
  </xsl:template>

  <!-- Old-style parent response to new-style parent_response -->
  <!-- Referrals are not translatable due to embedded signatures -->

  <xsl:template match = "/myrpki:parent">
    <oob:parent_response version       = "{$oob-version}"
			 service_uri   = "{@service_uri}"
			 child_handle  = "{@child_handle}"
			 parent_handle = "{@parent_handle}">
      <oob:parent_bpki_ta>
	<xsl:value-of select = "myrpki:bpki_resource_ta"/>
      </oob:parent_bpki_ta>
      <xsl:if test = "repository[@type = 'offer']">
	<oob:offer/>
      </xsl:if>
    </oob:parent_response>
  </xsl:template>

  <!-- New-style parent_response to old-style parent response -->
  <!-- Referrals are not translatable due to embedded signatures -->

  <xsl:template match = "/oob:parent_response">
    <myrpki:parent version       = "{$myrpki-version}"
		   service_uri   = "{@service_uri}"
		   child_handle  = "{@child_handle}"
		   parent_handle = "{@parent_handle}">
      <myrpki:bpki_resource_ta>
	<xsl:value-of select = "oob:parent_bpki_ta"/>
      </myrpki:bpki_resource_ta>
      <myrpki:bpki_child_ta/>
      <myrpki:repository type = "none"/>
    </myrpki:parent>
  </xsl:template>

</xsl:transform>