1 4 7 package javax.xml.crypto.dsig.keyinfo; 8 9 import java.math.BigInteger ; 10 import java.security.KeyException ; 11 import java.security.NoSuchAlgorithmException ; 12 import java.security.NoSuchProviderException ; 13 import java.security.Provider ; 14 import java.security.PublicKey ; 15 import java.security.Security ; 16 import java.security.cert.X509CRL ; 17 import java.util.List ; 18 import javax.xml.crypto.MarshalException; 19 import javax.xml.crypto.NoSuchMechanismException; 20 import javax.xml.crypto.URIDereferencer; 21 import javax.xml.crypto.XMLStructure; 22 import javax.xml.crypto.dom.DOMStructure; 23 import javax.xml.crypto.dsig.*; 24 25 import sun.security.jca.*; 26 import sun.security.jca.GetInstance.Instance; 27 28 86 public abstract class KeyInfoFactory { 87 88 private String mechanismType; 89 private Provider provider; 90 91 94 protected KeyInfoFactory() {} 95 96 123 public static KeyInfoFactory getInstance(String mechanismType) { 124 if (mechanismType == null) { 125 throw new NullPointerException ("mechanismType cannot be null"); 126 } 127 Instance instance; 128 try { 129 instance = GetInstance.getInstance 130 ("KeyInfoFactory", null, mechanismType); 131 } catch (NoSuchAlgorithmException nsae) { 132 throw new NoSuchMechanismException(nsae); 133 } 134 KeyInfoFactory factory = (KeyInfoFactory) instance.impl; 135 factory.mechanismType = mechanismType; 136 factory.provider = instance.provider; 137 return factory; 138 } 139 140 161 public static KeyInfoFactory getInstance(String mechanismType, 162 Provider provider) { 163 if (mechanismType == null) { 164 throw new NullPointerException ("mechanismType cannot be null"); 165 } else if (provider == null) { 166 throw new NullPointerException ("provider cannot be null"); 167 } 168 169 Instance instance; 170 try { 171 instance = GetInstance.getInstance 172 ("KeyInfoFactory", null, mechanismType, provider); 173 } catch (NoSuchAlgorithmException nsae) { 174 throw new NoSuchMechanismException(nsae); 175 } 176 KeyInfoFactory factory = (KeyInfoFactory) instance.impl; 177 factory.mechanismType = mechanismType; 178 factory.provider = instance.provider; 179 return factory; 180 } 181 182 207 public static KeyInfoFactory getInstance(String mechanismType, 208 String provider) throws NoSuchProviderException { 209 if (mechanismType == null) { 210 throw new NullPointerException ("mechanismType cannot be null"); 211 } else if (provider == null) { 212 throw new NullPointerException ("provider cannot be null"); 213 } else if (provider.length() == 0) { 214 throw new NoSuchProviderException (); 215 } 216 217 Instance instance; 218 try { 219 instance = GetInstance.getInstance 220 ("KeyInfoFactory", null, mechanismType, provider); 221 } catch (NoSuchAlgorithmException nsae) { 222 throw new NoSuchMechanismException(nsae); 223 } 224 KeyInfoFactory factory = (KeyInfoFactory) instance.impl; 225 factory.mechanismType = mechanismType; 226 factory.provider = instance.provider; 227 return factory; 228 } 229 230 250 public static KeyInfoFactory getInstance() { 251 return getInstance("DOM"); 252 } 253 254 261 public final String getMechanismType() { 262 return mechanismType; 263 } 264 265 270 public final Provider getProvider() { 271 return provider; 272 } 273 274 287 public abstract KeyInfo newKeyInfo(List content); 288 289 306 public abstract KeyInfo newKeyInfo(List content, String id); 307 308 315 public abstract KeyName newKeyName(String name); 316 317 326 public abstract KeyValue newKeyValue(PublicKey key) throws KeyException ; 327 328 340 public abstract PGPData newPGPData(byte[] keyId); 341 342 367 public abstract PGPData newPGPData(byte[] keyId, byte[] keyPacket, 368 List other); 369 370 390 public abstract PGPData newPGPData(byte[] keyPacket, List other); 391 392 402 public abstract RetrievalMethod newRetrievalMethod(String uri); 403 404 421 public abstract RetrievalMethod newRetrievalMethod(String uri, String type, 422 List transforms); 423 424 446 public abstract X509Data newX509Data(List content); 447 448 463 public abstract X509IssuerSerial newX509IssuerSerial 464 (String issuerName, BigInteger serialNumber); 465 466 474 public abstract boolean isFeatureSupported(String feature); 475 476 482 public abstract URIDereferencer getURIDereferencer(); 483 484 499 public abstract KeyInfo unmarshalKeyInfo(XMLStructure xmlStructure) 500 throws MarshalException; 501 } 502 | Popular Tags |