1 7 8 9 package org.enhydra.oyster.cms; 10 11 import org.enhydra.oyster.exception.SMIMEException; 12 import org.enhydra.oyster.der.DERSetPr; 13 import org.enhydra.oyster.der.DERObjectIdentifier; 14 import org.enhydra.oyster.der.DERIA5String; 15 import org.enhydra.oyster.der.DERSequence; 16 import org.enhydra.oyster.der.DERPrintableString; 17 18 26 public class RelativeDistinguishedName extends DERSetPr { 27 28 31 private int enable = 1; 32 33 37 public RelativeDistinguishedName () throws SMIMEException 38 { 39 } 40 41 56 public RelativeDistinguishedName (String id0, String typeConstruction0, String value0) throws SMIMEException 57 { 58 this.setAttributeTypeAndValue(id0, typeConstruction0, value0); 59 enable = 2; 60 } 61 62 73 public RelativeDistinguishedName (int[] arrayID0, String value0) throws SMIMEException 74 { 75 this.setAttributeTypeAndValue(arrayID0, value0); 76 enable = 3; 77 } 78 79 89 public void setAttributeTypeAndValue (String id0, String typeConstruction0, String value0) throws SMIMEException { 90 if (enable == 4) 91 throw new SMIMEException(this, 1023); 92 else if (enable != 1) 93 throw new SMIMEException(this, 1024); 94 DERSequence seq = new DERSequence(); 95 DERObjectIdentifier attribID = new DERObjectIdentifier(id0, typeConstruction0); 96 seq.addContent(attribID.getDEREncoded()); 97 if (id0.equalsIgnoreCase("EMAILADDRESS") | id0.equalsIgnoreCase("1.2.840.113549.1.9.1")) { 98 DERIA5String atribString = new DERIA5String(value0); 99 seq.addContent(atribString.getDEREncoded()); 100 } 101 else { 102 DERPrintableString atribString = new DERPrintableString(value0); 103 seq.addContent(atribString.getDEREncoded()); 104 } 105 super.addContent(seq.getDEREncoded()); 106 enable = 4; 107 } 108 109 118 public void setAttributeTypeAndValue (int[] arrayID0, String value0) throws SMIMEException { 119 if (enable == 4) 120 throw new SMIMEException(this, 1023); 121 else if (enable != 1) 122 throw new SMIMEException(this, 1024); 123 DERObjectIdentifier attribID = new DERObjectIdentifier(arrayID0); 124 DERPrintableString atribString = new DERPrintableString(value0); 125 DERSequence seq = new DERSequence(); 126 seq.addContent(attribID.getDEREncoded()); 127 seq.addContent(atribString.getDEREncoded()); 128 super.addContent(seq.getDEREncoded()); 129 enable = 4; 130 } 131 } 132 133 134 135 | Popular Tags |