Subversion Repositories oidplus

Rev

Rev 1425 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
557 daniel-mar 1
#!/usr/bin/env php
502 daniel-mar 2
select '-- This file (wellknown_other_access.sql) contains ASN.1 and IRI names of OIDs which are either';
3
select '-- a) Root OIDs';
4
select '-- b) Unicode labels which are long arcs';
5
select '-- c) Standardized ASN.1 identifiers';
6
select '-- d) OIDs where potential users of this software can register OIDs in these arcs (e.g. an "identified organization" arc)';
7
select '-- Use the tool dev/generate_wellknown_other_access to generate this file';
8
 
9
<?php
10
 
511 daniel-mar 11
/*
12
 * OIDplus 2.0
13
 * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
14
 *
15
 * Licensed under the Apache License, Version 2.0 (the "License");
16
 * you may not use this file except in compliance with the License.
17
 * You may obtain a copy of the License at
18
 *
19
 *     http://www.apache.org/licenses/LICENSE-2.0
20
 *
21
 * Unless required by applicable law or agreed to in writing, software
22
 * distributed under the License is distributed on an "AS IS" BASIS,
23
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
 * See the License for the specific language governing permissions and
25
 * limitations under the License.
26
 */
27
 
1367 daniel-mar 28
use ViaThinkSoft\OIDplus\OIDplus;
29
 
502 daniel-mar 30
require_once __DIR__ . '/../includes/oidplus.inc.php';
1416 daniel-mar 31
require_once __DIR__ . '/ft_get_oid_data.inc.php';
502 daniel-mar 32
 
33
OIDplus::init(false);
34
if (!OIDplus::baseConfig()->exists('OIDINFO_API_URL')) {
35
	die("OIDINFO_API_URL not available (API is currently not public)\n");
36
}
37
 
38
$output = array();
39
 
40
function _is_standardized($oid, $asn1id) {
41
	$std = asn1_get_standardized_array();
42
	$x = oid_up($oid) == $oid ? '' : oid_up($oid).".";
43
	return isset( $std[$x.$asn1id]) && ($std[$x.$asn1id] == $oid);
44
}
45
 
46
function _is_long($oid) {
47
	$oid = '/'.str_replace('.', '/', $oid);
48
	return in_array($oid, iri_get_long_arcs());
49
}
50
 
51
function _process_oid($oid) {
52
	global $output;
53
 
54
	if (!isset($output[$oid])) {
55
		if ($oid == '0.0.23') {
56
			// Rec. ITU-T X.660 | ISO/IEC 9834-3, clause A.3.3.1 allows "0.0.w", although it is illegal, since no W-series exist
57
			$data = array();
58
			$data['oid'] = array();
59
			$data['oid']['identifier'] = array('w');
60
			$data['oid']['unicode-label'] = array('W');
61
		} else {
62
			$data = ft_get_oid_data($oid);
63
		}
64
 
1244 daniel-mar 65
		$output[$oid] = array();
502 daniel-mar 66
		$output[$oid]['asn1id'] = array();
67
		$output[$oid]['iri'] = array();
68
		$output[$oid]['checksum'] = array();
69
 
70
		if (isset($data['oid']['identifier'])) {
71
			foreach ($data['oid']['identifier'] as $asn1id) {
72
				$output[$oid]['checksum'][] = $oid.'|ASN1|'.$asn1id.'|'.(_is_standardized($oid, $asn1id) ? '1' : '0').'|1||';
73
				$std = _is_standardized($oid, $asn1id) ? "'1'" : "'0'";
74
				$output[$oid]['asn1id'][] = "INSERT INTO [asn1id] (oid, name, standardized, well_known) VALUES ('oid:$oid', '$asn1id', $std, '1');";
75
			}
76
		} else {
77
			//echo "select '-- Warning: Has no ASN.1 identifier: $oid';\n";
78
		}
79
		if (isset($data['oid']['unicode-label'])) {
80
			foreach ($data['oid']['unicode-label'] as $iri) {
81
				$output[$oid]['checksum'][] = $oid.'|IRI|'.$iri.'|'.(_is_long($oid) ? '1' : '0').'|1||';
82
 
83
				$std = _is_long($oid) ? "'1'" : "'0'";
84
 
85
				if (strpos($iri, '&#') !== false) {
86
					$iri = base64_encode(html_entity_decode($iri, ENT_COMPAT | ENT_HTML401, "UTF-8"));
87
					$test = base64_decode($iri);
88
					$iri = array();
89
					for ($i=0; $i<strlen($test); $i++) {
90
						$iri[] = 'chr('.ord($test[$i]).')';
91
					}
92
					$iri = implode('+',$iri);
93
				} else {
94
					$iri = "'$iri'";
95
				}
96
 
97
				$output[$oid]['iri'][] = "INSERT INTO [iri] (oid, name, longarc, well_known) VALUES ('oid:$oid', $iri, $std, '1');";
98
			}
99
		}
100
	}
101
 
102
	return $output[$oid];
103
}
104
 
105
// ---
106
 
107
$interesting_oids = array();
108
 
109
foreach (asn1_get_standardized_array() as $tmp => $oid) {
110
	$interesting_oids[] = $oid;
111
}
112
 
113
foreach (iri_get_long_arcs() as $tmp => $oid) {
114
	$oid = substr(str_replace('/', '.', $oid),1);
115
	$interesting_oids[] = $oid;
116
}
117
 
118
// ----------------------------------------------------------------
119
 
120
$interesting_oids[] = '0'; // itu-t
121
	$interesting_oids[] = '0.2'; // telecom operators
122
	$interesting_oids[] = '0.3'; // network-operator
123
	$interesting_oids[] = '0.4'; // identified-organization
124
		$interesting_oids[] = '0.4.0'; // etsi
125
			$interesting_oids[] = '0.4.0.127'; // reserved
126
				$interesting_oids[] = '0.4.0.127.0'; // etsi-identified-organization
127
$interesting_oids[] = '1'; // iso
128
	$interesting_oids[] = '1.1'; // registration-authority
129
		$interesting_oids[] = '1.1.19785'; // cbeff
130
			$interesting_oids[] = '1.1.19785.0'; // organization
131
	$interesting_oids[] = '1.2'; // member-body
132
		// country_getter defines the country OIDs
133
		//$interesting_oids[] = '1.2.158'; // tw
134
			$interesting_oids[] = '1.2.158.1'; // organization
135
		//$interesting_oids[] = '1.2.276'; // de
136
			$interesting_oids[] = '1.2.276.0'; // din-certco
137
		//$interesting_oids[] = '1.2.344'; // hk
138
			$interesting_oids[] = '1.2.344.1'; // organization
139
		//$interesting_oids[] = '1.2.616'; // pl
140
			$interesting_oids[] = '1.2.616.1'; // organization
141
		//$interesting_oids[] = '1.2.826'; // gb
142
			$interesting_oids[] = '1.2.826.0'; // national
143
				$interesting_oids[] = '1.2.826.0.1'; // eng-ltd
144
					$interesting_oids[] = '1.2.826.0.1.3680043'; // Medical Connections ( https://www.medicalconnections.co.uk/FreeUID/ )
145
		//$interesting_oids[] = '1.2.840'; // us
146
			$interesting_oids[] = '1.2.840.1'; // organization
147
				$interesting_oids[] = '1.2.840.113556'; // microsoft
148
					$interesting_oids[] = '1.2.840.113556.1'; // Microsoft Active Directory
149
						$interesting_oids[] = '1.2.840.113556.1.8000'; // companies
1425 daniel-mar 150
							$interesting_oids[] = '1.2.840.113556.1.8000.2554'; // customer usage (UUID-to-OID)
502 daniel-mar 151
					$interesting_oids[] = '1.2.840.113556.2'; // DICOM
152
	$interesting_oids[] = '1.3'; // identified-organization
153
		$interesting_oids[] = '1.3.6'; // dod
154
			$interesting_oids[] = '1.3.6.1'; // internet
155
				$interesting_oids[] = '1.3.6.1.2'; // mgmt
156
					$interesting_oids[] = '1.3.6.1.2.1'; // mib-2
157
						$interesting_oids[] = '1.3.6.1.4'; // private
158
							$interesting_oids[] = '1.3.6.1.4.1'; // enterprise
159
								$interesting_oids[] = '1.3.6.1.4.1.19376'; // Integrating the Healthcare Enterprise International
160
									$interesting_oids[] = '1.3.6.1.4.1.19376.3'; // Organizations (not in Repo!)
161
									$interesting_oids[] = '1.3.6.1.4.1.19376.3.276'; // IHE Deutschland
1462 daniel-mar 162
										$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1'; // OID für das OID Konzept Version 1
163
											$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4'; // Identifikation des ID-Pools für Institutionen (Organisationen, Einheiten, etc.)
164
													$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.1'; // Krankenhäuser
165
													$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.2'; // Praxen niedergelassener Ärzte
502 daniel-mar 166
													$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.3'; // Systeme
1462 daniel-mar 167
								$interesting_oids[] = '1.3.6.1.4.1.12798'; // Members of Internet-Käyttäjät Ikuisesti (IKI)
502 daniel-mar 168
									$interesting_oids[] = '1.3.6.1.4.1.12798.1'; // member
169
								$interesting_oids[] = '1.3.6.1.4.1.37476'; // ViaThinkSoft
170
									$interesting_oids[] = '1.3.6.1.4.1.37476.9000'; // freeoid
171
								$interesting_oids[] = '1.3.6.1.4.1.37553'; // frdlweb
172
									$interesting_oids[] = '1.3.6.1.4.1.37553.8'; // WEID
173
										$interesting_oids[] = '1.3.6.1.4.1.37553.8.8'; // private
174
										$interesting_oids[] = '1.3.6.1.4.1.37553.8.9'; // ns
175
											$interesting_oids[] = '1.3.6.1.4.1.37553.8.9.17704'; // dns
176
											$interesting_oids[] = '1.3.6.1.4.1.37553.8.9.1439221'; // uuid
1425 daniel-mar 177
								$interesting_oids[] = '1.3.6.1.4.1.54392'; // Waterjuice
178
# Is not on oid-info.com, but has no alphanum/unicode ID anyway
179
#									$interesting_oids[] = '1.3.6.1.4.1.54392.1'; // Waterjuice "UUID-to-OID" (2x64 bits)
180
#									$interesting_oids[] = '1.3.6.1.4.1.54392.2'; // Waterjuice "UUID-to-OID" (4x32 bits)
181
#									$interesting_oids[] = '1.3.6.1.4.1.54392.3'; // Waterjuice "UUID-to-OID" (8x16 bits)
182
#									$interesting_oids[] = '1.3.6.1.4.1.54392.4'; // Waterjuice FreeOID "old"
183
#									$interesting_oids[] = '1.3.6.1.4.1.54392.5'; // Waterjuice FreeOID "new"
184
								$interesting_oids[] = '1.3.6.1.4.1.61117'; // R74n
185
									$interesting_oids[] = '1.3.6.1.4.1.61117.9000'; // R74n FreeOID
502 daniel-mar 186
$interesting_oids[] = '2'; // joint-iso-itu-t
187
	$interesting_oids[] = '2.16'; // country
188
		// country_getter defines the country OIDs
189
		//$interesting_oids[] = '2.16.158'; // tw
190
			$interesting_oids[] = '2.16.158.1'; // organization
191
		//$interesting_oids[] = '2.16.344'; // hk
192
			$interesting_oids[] = '2.16.344.1'; // organization
193
		//$interesting_oids[] = '2.16.616'; // pl
194
			$interesting_oids[] = '2.16.616.1'; // organization
195
		//$interesting_oids[] = '2.16.840'; // us
196
			$interesting_oids[] = '2.16.840.1'; // organization
197
				$interesting_oids[] = '2.16.840.1.113883'; // hl7
198
					$interesting_oids[] = '2.16.840.1.113883.3'; // externalUseRoots
199
					$interesting_oids[] = '2.16.840.1.113883.6'; // externalCodeSystems
200
					$interesting_oids[] = '2.16.840.1.113883.13'; // externalValueSets
201
	$interesting_oids[] = '2.23'; // international-organizations
202
	$interesting_oids[] = '2.25'; // uuid
203
	$interesting_oids[] = '2.40'; // upu
204
		$interesting_oids[] = '2.40.2'; // member-body
205
		$interesting_oids[] = '2.40.3'; // identified-organization
206
	$interesting_oids[] = '2.49'; // alerting
207
		$interesting_oids[] = '2.49.0'; // wmo
208
			$interesting_oids[] = '2.49.0.0'; // authority (Countries)
209
				// country_getter defines the country OIDs beneath 2.49.0.0
210
			$interesting_oids[] = '2.49.0.1'; // country-msg
211
				// country_getter defines the country OIDs beneath 2.49.0.1
212
			$interesting_oids[] = '2.49.0.2'; // org
213
			$interesting_oids[] = '2.49.0.3'; // org-msg
214
 
215
// ----------------------------------------------------------------
216
 
217
$interesting_oids = array_unique($interesting_oids);
218
natsort($interesting_oids);
219
 
220
$output = array();
221
foreach ($interesting_oids as $oid) {
222
	_process_oid($oid);
223
}
224
 
225
$check_sum = '';
226
foreach ($output as $oid => $data) {
227
	if (count($data['asn1id']) + count($data['iri']) == 0) continue;
228
 
229
	echo "select '-- $oid';\n";
230
	foreach ($data['asn1id'] as $line_asn1) {
231
		echo "$line_asn1\n";
232
	}
233
	foreach ($data['iri'] as $line_iri) {
234
		echo "$line_iri\n";
235
	}
236
	foreach ($data['checksum'] as $chunk) {
237
		$check_sum .= $chunk;
238
	}
239
	echo "\n";
240
}
241
echo "select '-- Generator \"generate_wellknown_other_access\" checksum ".dechex(crc32($check_sum))."';\n";