001package org.apache.commons.ssl.org.bouncycastle.asn1.isismtt.x509; 002 003import java.util.Enumeration; 004 005import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Encodable; 006import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1EncodableVector; 007import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Object; 008import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1ObjectIdentifier; 009import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1OctetString; 010import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Primitive; 011import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Sequence; 012import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1TaggedObject; 013import org.apache.commons.ssl.org.bouncycastle.asn1.DEROctetString; 014import org.apache.commons.ssl.org.bouncycastle.asn1.DERPrintableString; 015import org.apache.commons.ssl.org.bouncycastle.asn1.DERSequence; 016import org.apache.commons.ssl.org.bouncycastle.asn1.DERTaggedObject; 017import org.apache.commons.ssl.org.bouncycastle.asn1.x500.DirectoryString; 018 019/** 020 * Professions, specializations, disciplines, fields of activity, etc. 021 * 022 * <pre> 023 * ProfessionInfo ::= SEQUENCE 024 * { 025 * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, 026 * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), 027 * professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, 028 * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, 029 * addProfessionInfo OCTET STRING OPTIONAL 030 * } 031 * </pre> 032 * 033 * @see org.bouncycastle.asn1.isismtt.x509.AdmissionSyntax 034 */ 035public class ProfessionInfo 036 extends ASN1Object 037{ 038 039 /** 040 * Rechtsanw�ltin 041 */ 042 public static final ASN1ObjectIdentifier Rechtsanwltin = new ASN1ObjectIdentifier( 043 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".1"); 044 045 /** 046 * Rechtsanwalt 047 */ 048 public static final ASN1ObjectIdentifier Rechtsanwalt = new ASN1ObjectIdentifier( 049 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".2"); 050 051 /** 052 * Rechtsbeistand 053 */ 054 public static final ASN1ObjectIdentifier Rechtsbeistand = new ASN1ObjectIdentifier( 055 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".3"); 056 057 /** 058 * Steuerberaterin 059 */ 060 public static final ASN1ObjectIdentifier Steuerberaterin = new ASN1ObjectIdentifier( 061 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".4"); 062 063 /** 064 * Steuerberater 065 */ 066 public static final ASN1ObjectIdentifier Steuerberater = new ASN1ObjectIdentifier( 067 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".5"); 068 069 /** 070 * Steuerbevollm�chtigte 071 */ 072 public static final ASN1ObjectIdentifier Steuerbevollmchtigte = new ASN1ObjectIdentifier( 073 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".6"); 074 075 /** 076 * Steuerbevollm�chtigter 077 */ 078 public static final ASN1ObjectIdentifier Steuerbevollmchtigter = new ASN1ObjectIdentifier( 079 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".7"); 080 081 /** 082 * Notarin 083 */ 084 public static final ASN1ObjectIdentifier Notarin = new ASN1ObjectIdentifier( 085 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".8"); 086 087 /** 088 * Notar 089 */ 090 public static final ASN1ObjectIdentifier Notar = new ASN1ObjectIdentifier( 091 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".9"); 092 093 /** 094 * Notarvertreterin 095 */ 096 public static final ASN1ObjectIdentifier Notarvertreterin = new ASN1ObjectIdentifier( 097 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".10"); 098 099 /** 100 * Notarvertreter 101 */ 102 public static final ASN1ObjectIdentifier Notarvertreter = new ASN1ObjectIdentifier( 103 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".11"); 104 105 /** 106 * Notariatsverwalterin 107 */ 108 public static final ASN1ObjectIdentifier Notariatsverwalterin = new ASN1ObjectIdentifier( 109 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".12"); 110 111 /** 112 * Notariatsverwalter 113 */ 114 public static final ASN1ObjectIdentifier Notariatsverwalter = new ASN1ObjectIdentifier( 115 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".13"); 116 117 /** 118 * Wirtschaftspr�ferin 119 */ 120 public static final ASN1ObjectIdentifier Wirtschaftsprferin = new ASN1ObjectIdentifier( 121 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".14"); 122 123 /** 124 * Wirtschaftspr�fer 125 */ 126 public static final ASN1ObjectIdentifier Wirtschaftsprfer = new ASN1ObjectIdentifier( 127 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".15"); 128 129 /** 130 * Vereidigte Buchpr�ferin 131 */ 132 public static final ASN1ObjectIdentifier VereidigteBuchprferin = new ASN1ObjectIdentifier( 133 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".16"); 134 135 /** 136 * Vereidigter Buchpr�fer 137 */ 138 public static final ASN1ObjectIdentifier VereidigterBuchprfer = new ASN1ObjectIdentifier( 139 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".17"); 140 141 /** 142 * Patentanw�ltin 143 */ 144 public static final ASN1ObjectIdentifier Patentanwltin = new ASN1ObjectIdentifier( 145 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".18"); 146 147 /** 148 * Patentanwalt 149 */ 150 public static final ASN1ObjectIdentifier Patentanwalt = new ASN1ObjectIdentifier( 151 NamingAuthority.id_isismtt_at_namingAuthorities_RechtWirtschaftSteuern + ".19"); 152 153 private NamingAuthority namingAuthority; 154 155 private ASN1Sequence professionItems; 156 157 private ASN1Sequence professionOIDs; 158 159 private String registrationNumber; 160 161 private ASN1OctetString addProfessionInfo; 162 163 public static ProfessionInfo getInstance(Object obj) 164 { 165 if (obj == null || obj instanceof ProfessionInfo) 166 { 167 return (ProfessionInfo)obj; 168 } 169 170 if (obj instanceof ASN1Sequence) 171 { 172 return new ProfessionInfo((ASN1Sequence)obj); 173 } 174 175 throw new IllegalArgumentException("illegal object in getInstance: " 176 + obj.getClass().getName()); 177 } 178 179 /** 180 * Constructor from ASN1Sequence. 181 * <pre> 182 * ProfessionInfo ::= SEQUENCE 183 * { 184 * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, 185 * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), 186 * professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, 187 * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, 188 * addProfessionInfo OCTET STRING OPTIONAL 189 * } 190 * </pre> 191 * 192 * @param seq The ASN.1 sequence. 193 */ 194 private ProfessionInfo(ASN1Sequence seq) 195 { 196 if (seq.size() > 5) 197 { 198 throw new IllegalArgumentException("Bad sequence size: " 199 + seq.size()); 200 } 201 202 Enumeration e = seq.getObjects(); 203 204 ASN1Encodable o = (ASN1Encodable)e.nextElement(); 205 206 if (o instanceof ASN1TaggedObject) 207 { 208 if (((ASN1TaggedObject)o).getTagNo() != 0) 209 { 210 throw new IllegalArgumentException("Bad tag number: " 211 + ((ASN1TaggedObject)o).getTagNo()); 212 } 213 namingAuthority = NamingAuthority.getInstance((ASN1TaggedObject)o, true); 214 o = (ASN1Encodable)e.nextElement(); 215 } 216 217 professionItems = ASN1Sequence.getInstance(o); 218 219 if (e.hasMoreElements()) 220 { 221 o = (ASN1Encodable)e.nextElement(); 222 if (o instanceof ASN1Sequence) 223 { 224 professionOIDs = ASN1Sequence.getInstance(o); 225 } 226 else if (o instanceof DERPrintableString) 227 { 228 registrationNumber = DERPrintableString.getInstance(o).getString(); 229 } 230 else if (o instanceof ASN1OctetString) 231 { 232 addProfessionInfo = ASN1OctetString.getInstance(o); 233 } 234 else 235 { 236 throw new IllegalArgumentException("Bad object encountered: " 237 + o.getClass()); 238 } 239 } 240 if (e.hasMoreElements()) 241 { 242 o = (ASN1Encodable)e.nextElement(); 243 if (o instanceof DERPrintableString) 244 { 245 registrationNumber = DERPrintableString.getInstance(o).getString(); 246 } 247 else if (o instanceof DEROctetString) 248 { 249 addProfessionInfo = (DEROctetString)o; 250 } 251 else 252 { 253 throw new IllegalArgumentException("Bad object encountered: " 254 + o.getClass()); 255 } 256 } 257 if (e.hasMoreElements()) 258 { 259 o = (ASN1Encodable)e.nextElement(); 260 if (o instanceof DEROctetString) 261 { 262 addProfessionInfo = (DEROctetString)o; 263 } 264 else 265 { 266 throw new IllegalArgumentException("Bad object encountered: " 267 + o.getClass()); 268 } 269 } 270 271 } 272 273 /** 274 * Constructor from given details. 275 * <p> 276 * <code>professionItems</code> is mandatory, all other parameters are 277 * optional. 278 * 279 * @param namingAuthority The naming authority. 280 * @param professionItems Directory strings of the profession. 281 * @param professionOIDs DERObjectIdentfier objects for the 282 * profession. 283 * @param registrationNumber Registration number. 284 * @param addProfessionInfo Additional infos in encoded form. 285 */ 286 public ProfessionInfo(NamingAuthority namingAuthority, 287 DirectoryString[] professionItems, ASN1ObjectIdentifier[] professionOIDs, 288 String registrationNumber, ASN1OctetString addProfessionInfo) 289 { 290 this.namingAuthority = namingAuthority; 291 ASN1EncodableVector v = new ASN1EncodableVector(); 292 for (int i = 0; i != professionItems.length; i++) 293 { 294 v.add(professionItems[i]); 295 } 296 this.professionItems = new DERSequence(v); 297 if (professionOIDs != null) 298 { 299 v = new ASN1EncodableVector(); 300 for (int i = 0; i != professionOIDs.length; i++) 301 { 302 v.add(professionOIDs[i]); 303 } 304 this.professionOIDs = new DERSequence(v); 305 } 306 this.registrationNumber = registrationNumber; 307 this.addProfessionInfo = addProfessionInfo; 308 } 309 310 /** 311 * Produce an object suitable for an ASN1OutputStream. 312 * <p> 313 * Returns: 314 * <pre> 315 * ProfessionInfo ::= SEQUENCE 316 * { 317 * namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL, 318 * professionItems SEQUENCE OF DirectoryString (SIZE(1..128)), 319 * professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL, 320 * registrationNumber PrintableString(SIZE(1..128)) OPTIONAL, 321 * addProfessionInfo OCTET STRING OPTIONAL 322 * } 323 * </pre> 324 * 325 * @return a DERObject 326 */ 327 public ASN1Primitive toASN1Primitive() 328 { 329 ASN1EncodableVector vec = new ASN1EncodableVector(); 330 if (namingAuthority != null) 331 { 332 vec.add(new DERTaggedObject(true, 0, namingAuthority)); 333 } 334 vec.add(professionItems); 335 if (professionOIDs != null) 336 { 337 vec.add(professionOIDs); 338 } 339 if (registrationNumber != null) 340 { 341 vec.add(new DERPrintableString(registrationNumber, true)); 342 } 343 if (addProfessionInfo != null) 344 { 345 vec.add(addProfessionInfo); 346 } 347 return new DERSequence(vec); 348 } 349 350 /** 351 * @return Returns the addProfessionInfo. 352 */ 353 public ASN1OctetString getAddProfessionInfo() 354 { 355 return addProfessionInfo; 356 } 357 358 /** 359 * @return Returns the namingAuthority. 360 */ 361 public NamingAuthority getNamingAuthority() 362 { 363 return namingAuthority; 364 } 365 366 /** 367 * @return Returns the professionItems. 368 */ 369 public DirectoryString[] getProfessionItems() 370 { 371 DirectoryString[] items = new DirectoryString[professionItems.size()]; 372 int count = 0; 373 for (Enumeration e = professionItems.getObjects(); e.hasMoreElements();) 374 { 375 items[count++] = DirectoryString.getInstance(e.nextElement()); 376 } 377 return items; 378 } 379 380 /** 381 * @return Returns the professionOIDs. 382 */ 383 public ASN1ObjectIdentifier[] getProfessionOIDs() 384 { 385 if (professionOIDs == null) 386 { 387 return new ASN1ObjectIdentifier[0]; 388 } 389 ASN1ObjectIdentifier[] oids = new ASN1ObjectIdentifier[professionOIDs.size()]; 390 int count = 0; 391 for (Enumeration e = professionOIDs.getObjects(); e.hasMoreElements();) 392 { 393 oids[count++] = ASN1ObjectIdentifier.getInstance(e.nextElement()); 394 } 395 return oids; 396 } 397 398 /** 399 * @return Returns the registrationNumber. 400 */ 401 public String getRegistrationNumber() 402 { 403 return registrationNumber; 404 } 405}