Subversion Repositories oidplus

Rev

Rev 1244 | Rev 1416 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
783 daniel-mar 1
#!/usr/bin/env php
2
-- This file (wellknown_other_oracle.sql) contains ASN.1 and IRI names of OIDs which are either
3
-- a) Root OIDs
4
-- b) Unicode labels which are long arcs
5
-- c) Standardized ASN.1 identifiers
6
-- d) OIDs where potential users of this software can register OIDs in these arcs (e.g. an "identified organization" arc)
7
-- Use the tool dev/generate_wellknown_other_oracle to generate this file
8
 
9
<?php
10
 
11
/*
12
 * OIDplus 2.0
13
 * Copyright 2019 - 2022 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
 
783 daniel-mar 30
require_once __DIR__ . '/../includes/oidplus.inc.php';
31
 
32
OIDplus::init(false);
33
if (!OIDplus::baseConfig()->exists('OIDINFO_API_URL')) {
34
	die("OIDINFO_API_URL not available (API is currently not public)\n");
35
}
36
 
37
$output = array();
38
 
39
function _is_standardized($oid, $asn1id) {
40
	$std = asn1_get_standardized_array();
41
	$x = oid_up($oid) == $oid ? '' : oid_up($oid).".";
42
	return isset( $std[$x.$asn1id]) && ($std[$x.$asn1id] == $oid);
43
}
44
 
45
function _is_long($oid) {
46
	$oid = '/'.str_replace('.', '/', $oid);
47
	return in_array($oid, iri_get_long_arcs());
48
}
49
 
50
function _process_oid($oid) {
51
	global $output;
52
 
53
	if (!isset($output[$oid])) {
54
		if ($oid == '0.0.23') {
55
			// 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
56
			$data = array();
57
			$data['oid'] = array();
58
			$data['oid']['identifier'] = array('w');
59
			$data['oid']['unicode-label'] = array('W');
60
		} else {
61
			$data = ft_get_oid_data($oid);
62
		}
63
 
1244 daniel-mar 64
		$output[$oid] = array();
783 daniel-mar 65
		$output[$oid]['asn1id'] = array();
66
		$output[$oid]['iri'] = array();
67
		$output[$oid]['checksum'] = array();
68
 
69
		if (isset($data['oid']['identifier'])) {
70
			foreach ($data['oid']['identifier'] as $asn1id) {
71
				$output[$oid]['checksum'][] = $oid.'|ASN1|'.$asn1id.'|'.(_is_standardized($oid, $asn1id) ? '1' : '0').'|1||';
72
				$std = _is_standardized($oid, $asn1id) ? "'1'" : "'0'";
73
				$output[$oid]['asn1id'][] = "INSERT INTO \"ASN1ID\" (oid, name, standardized, well_known) VALUES ('oid:$oid', '$asn1id', $std, '1');";
74
			}
75
		} else {
76
			//echo "-- Warning: Has no ASN.1 identifier: $oid\n";
77
		}
78
		if (isset($data['oid']['unicode-label'])) {
79
			foreach ($data['oid']['unicode-label'] as $iri) {
80
				$output[$oid]['checksum'][] = $oid.'|IRI|'.$iri.'|'.(_is_long($oid) ? '1' : '0').'|1||';
81
 
82
				$std = _is_long($oid) ? "'1'" : "'0'";
83
 
84
				if (strpos($iri, '&#') !== false) {
85
					$iri = "utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('".base64_encode(html_entity_decode($iri, ENT_COMPAT | ENT_HTML401, "UTF-8"))."')))";
86
				} else {
87
					$iri = "'$iri'";
88
				}
89
 
90
				$output[$oid]['iri'][] = "INSERT INTO \"IRI\" (oid, name, longarc, well_known) VALUES ('oid:$oid', $iri, $std, '1');";
91
			}
92
		}
93
	}
94
 
95
	return $output[$oid];
96
}
97
 
98
// ---
99
 
100
$interesting_oids = array();
101
 
102
foreach (asn1_get_standardized_array() as $tmp => $oid) {
103
	$interesting_oids[] = $oid;
104
}
105
 
106
foreach (iri_get_long_arcs() as $tmp => $oid) {
107
	$oid = substr(str_replace('/', '.', $oid),1);
108
	$interesting_oids[] = $oid;
109
}
110
 
111
// ----------------------------------------------------------------
112
 
113
$interesting_oids[] = '0'; // itu-t
114
	$interesting_oids[] = '0.2'; // telecom operators
115
	$interesting_oids[] = '0.3'; // network-operator
116
	$interesting_oids[] = '0.4'; // identified-organization
117
		$interesting_oids[] = '0.4.0'; // etsi
118
			$interesting_oids[] = '0.4.0.127'; // reserved
119
				$interesting_oids[] = '0.4.0.127.0'; // etsi-identified-organization
120
$interesting_oids[] = '1'; // iso
121
	$interesting_oids[] = '1.1'; // registration-authority
122
		$interesting_oids[] = '1.1.19785'; // cbeff
123
			$interesting_oids[] = '1.1.19785.0'; // organization
124
	$interesting_oids[] = '1.2'; // member-body
125
		// country_getter defines the country OIDs
126
		//$interesting_oids[] = '1.2.158'; // tw
127
			$interesting_oids[] = '1.2.158.1'; // organization
128
		//$interesting_oids[] = '1.2.276'; // de
129
			$interesting_oids[] = '1.2.276.0'; // din-certco
130
		//$interesting_oids[] = '1.2.344'; // hk
131
			$interesting_oids[] = '1.2.344.1'; // organization
132
		//$interesting_oids[] = '1.2.616'; // pl
133
			$interesting_oids[] = '1.2.616.1'; // organization
134
		//$interesting_oids[] = '1.2.826'; // gb
135
			$interesting_oids[] = '1.2.826.0'; // national
136
				$interesting_oids[] = '1.2.826.0.1'; // eng-ltd
137
					$interesting_oids[] = '1.2.826.0.1.3680043'; // Medical Connections ( https://www.medicalconnections.co.uk/FreeUID/ )
138
		//$interesting_oids[] = '1.2.840'; // us
139
			$interesting_oids[] = '1.2.840.1'; // organization
140
				$interesting_oids[] = '1.2.840.113556'; // microsoft
141
					$interesting_oids[] = '1.2.840.113556.1'; // Microsoft Active Directory
142
						$interesting_oids[] = '1.2.840.113556.1.8000'; // companies
143
							$interesting_oids[] = '1.2.840.113556.1.8000.2554'; // customer usage
144
					$interesting_oids[] = '1.2.840.113556.2'; // DICOM
145
	$interesting_oids[] = '1.3'; // identified-organization
146
		$interesting_oids[] = '1.3.6'; // dod
147
			$interesting_oids[] = '1.3.6.1'; // internet
148
				$interesting_oids[] = '1.3.6.1.2'; // mgmt
149
					$interesting_oids[] = '1.3.6.1.2.1'; // mib-2
150
						$interesting_oids[] = '1.3.6.1.4'; // private
151
							$interesting_oids[] = '1.3.6.1.4.1'; // enterprise
152
								$interesting_oids[] = '1.3.6.1.4.1.19376'; // Integrating the Healthcare Enterprise International
153
									$interesting_oids[] = '1.3.6.1.4.1.19376.3'; // Organizations (not in Repo!)
154
									$interesting_oids[] = '1.3.6.1.4.1.19376.3.276'; // IHE Deutschland
155
										$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1'; // OID für das OID Konzept Version 1
156
											$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4'; // Identifikation des ID-Pools für Institutionen (Organisationen, Einheiten, etc.)
157
													$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.1'; // Krankenhäuser
158
													$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.2'; // Praxen niedergelassener Ärzte
159
													$interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.3'; // Systeme
160
								$interesting_oids[] = '1.3.6.1.4.1.12798'; // Members of Internet-Käyttäjät Ikuisesti (IKI)
161
									$interesting_oids[] = '1.3.6.1.4.1.12798.1'; // member
162
								$interesting_oids[] = '1.3.6.1.4.1.37476'; // ViaThinkSoft
163
									$interesting_oids[] = '1.3.6.1.4.1.37476.9000'; // freeoid
164
								$interesting_oids[] = '1.3.6.1.4.1.37553'; // frdlweb
165
									$interesting_oids[] = '1.3.6.1.4.1.37553.8'; // WEID
166
										$interesting_oids[] = '1.3.6.1.4.1.37553.8.8'; // private
167
										$interesting_oids[] = '1.3.6.1.4.1.37553.8.9'; // ns
168
											$interesting_oids[] = '1.3.6.1.4.1.37553.8.9.17704'; // dns
169
											$interesting_oids[] = '1.3.6.1.4.1.37553.8.9.1439221'; // uuid
170
$interesting_oids[] = '2'; // joint-iso-itu-t
171
	$interesting_oids[] = '2.16'; // country
172
		// country_getter defines the country OIDs
173
		//$interesting_oids[] = '2.16.158'; // tw
174
			$interesting_oids[] = '2.16.158.1'; // organization
175
		//$interesting_oids[] = '2.16.344'; // hk
176
			$interesting_oids[] = '2.16.344.1'; // organization
177
		//$interesting_oids[] = '2.16.616'; // pl
178
			$interesting_oids[] = '2.16.616.1'; // organization
179
		//$interesting_oids[] = '2.16.840'; // us
180
			$interesting_oids[] = '2.16.840.1'; // organization
181
				$interesting_oids[] = '2.16.840.1.113883'; // hl7
182
					$interesting_oids[] = '2.16.840.1.113883.3'; // externalUseRoots
183
					$interesting_oids[] = '2.16.840.1.113883.6'; // externalCodeSystems
184
					$interesting_oids[] = '2.16.840.1.113883.13'; // externalValueSets
185
	$interesting_oids[] = '2.23'; // international-organizations
186
	$interesting_oids[] = '2.25'; // uuid
187
	$interesting_oids[] = '2.40'; // upu
188
		$interesting_oids[] = '2.40.2'; // member-body
189
		$interesting_oids[] = '2.40.3'; // identified-organization
190
	$interesting_oids[] = '2.49'; // alerting
191
		$interesting_oids[] = '2.49.0'; // wmo
192
			$interesting_oids[] = '2.49.0.0'; // authority (Countries)
193
				// country_getter defines the country OIDs beneath 2.49.0.0
194
			$interesting_oids[] = '2.49.0.1'; // country-msg
195
				// country_getter defines the country OIDs beneath 2.49.0.1
196
			$interesting_oids[] = '2.49.0.2'; // org
197
			$interesting_oids[] = '2.49.0.3'; // org-msg
198
 
199
// ----------------------------------------------------------------
200
 
201
$interesting_oids = array_unique($interesting_oids);
202
natsort($interesting_oids);
203
 
204
$output = array();
205
foreach ($interesting_oids as $oid) {
206
	_process_oid($oid);
207
}
208
 
209
$check_sum = '';
210
foreach ($output as $oid => $data) {
211
	if (count($data['asn1id']) + count($data['iri']) == 0) continue;
212
 
213
	echo "-- $oid\n";
214
	foreach ($data['asn1id'] as $line_asn1) {
215
		echo "$line_asn1\n";
216
	}
217
	foreach ($data['iri'] as $line_iri) {
218
		echo "$line_iri\n";
219
	}
220
	foreach ($data['checksum'] as $chunk) {
221
		$check_sum .= $chunk;
222
	}
223
	echo "\n";
224
}
225
echo '-- Generator "generate_wellknown_other_oracle" checksum '.dechex(crc32($check_sum))."\n";
226
 
227
# ---
228
 
229
function ft_get_oid_data($oid) {
230
	$url = OIDplus::baseConfig()->getValue('OIDINFO_API_URL') . '&oid='.urlencode($oid);
231
	$cont_json = @file_get_contents($url);
232
	if (!$cont_json) {
233
		sleep(5);
1244 daniel-mar 234
		$cont_json = @file_get_contents($url);
235
		if (!$cont_json) return false;
783 daniel-mar 236
	}
237
	$data = json_decode($cont_json,true);
238
 
239
	return $data;
240
}