1 7 8 9 package org.enhydra.oyster.cms; 10 11 import org.enhydra.oyster.exception.SMIMEException; 12 import org.enhydra.oyster.der.DERSet; 13 import org.enhydra.oyster.der.DERSequence; 14 import org.enhydra.oyster.der.DERInteger; 15 16 22 public class CapabilitiesAttribute extends Attribute { 23 24 31 public CapabilitiesAttribute (String [] capabilities0) throws SMIMEException 32 { 33 super("ID_SMIMECAPABILITIES", "NAME_STRING"); 34 DERSet capabilSet = new DERSet(); 35 DERSequence capabilSequ = new DERSequence(); 36 for (int i = 0; i != capabilities0.length; i++) { 37 if (capabilities0[i] == null) 38 continue; 39 else if (capabilities0[i].equalsIgnoreCase("RC2_CBC_40") | capabilities0[i].equalsIgnoreCase("RC2_CBC_64") | capabilities0[i].equalsIgnoreCase("RC2_CBC_128")) { 40 AlgorithmIdentifier rc2 = new AlgorithmIdentifier("RC2_CBC", "NAME_STRING"); 41 Integer keyLeng = new Integer (capabilities0[i].substring(9)); 42 rc2.addParamToAlgorithmId((new DERInteger(keyLeng.intValue())).getDEREncoded()); 43 capabilSequ.addContent(rc2.getDEREncoded()); 44 } 45 else if (capabilities0[i].equalsIgnoreCase("DES_EDE3_CBC") | capabilities0[i].equalsIgnoreCase("DES")) { 46 AlgorithmIdentifier desede3 = new AlgorithmIdentifier(capabilities0[i], "NAME_STRING"); 47 desede3.addNullToAlgorithmId(); 48 capabilSequ.addContent(desede3.getDEREncoded()); 49 } 50 else if (capabilities0[i].equalsIgnoreCase("MD2_WITH_RSA") | capabilities0[i].equalsIgnoreCase("MD5_WITH_RSA") | capabilities0[i].equalsIgnoreCase("SHA1_WITH_RSA") | capabilities0[i].equalsIgnoreCase("SHA1_WITH_DSA") | capabilities0[i].equalsIgnoreCase("RSA")) { 51 AlgorithmIdentifier rsa = new AlgorithmIdentifier(capabilities0[i], "NAME_STRING"); 52 capabilSequ.addContent(rsa.getDEREncoded()); 53 } 54 else 55 throw new SMIMEException(this, 1020); 56 } 57 capabilSet.addContent(capabilSequ.getDEREncoded()); 58 super.addContent(capabilSet.getDEREncoded()); 59 } 60 } 61 62 63 64 | Popular Tags |