Subversion Repositories oidplus

Rev

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

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