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