All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.xml.crypto.dsig.keyinfo.KeyInfoFactory Maven / Gradle / Ivy

The newest version!
/*     */ package javax.xml.crypto.dsig.keyinfo;
/*     */ 
/*     */ import java.lang.reflect.InvocationTargetException;
/*     */ import java.lang.reflect.Method;
/*     */ import java.math.BigInteger;
/*     */ import java.security.AccessController;
/*     */ import java.security.KeyException;
/*     */ import java.security.NoSuchProviderException;
/*     */ import java.security.PrivilegedAction;
/*     */ import java.security.Provider;
/*     */ import java.security.PublicKey;
/*     */ import java.security.Security;
/*     */ import java.util.List;
/*     */ import javax.xml.crypto.MarshalException;
/*     */ import javax.xml.crypto.NoSuchMechanismException;
/*     */ import javax.xml.crypto.URIDereferencer;
/*     */ import javax.xml.crypto.XMLStructure;
/*     */ 
/*     */ public abstract class KeyInfoFactory
/*     */ {
/*     */   private String mechanismType;
/*     */   private Provider provider;
/*     */   private static Class cl;
/*  91 */   private static final Class[] getImplParams = { String.class, String.class, Provider.class };
/*     */ 
/*  98 */   private static Method getImplMethod = (Method)AccessController.doPrivileged(new PrivilegedAction()
/*     */   {
/*     */     public Object run() {
/* 101 */       Method m = null;
/*     */       try {
/* 103 */         m = KeyInfoFactory.cl.getDeclaredMethod("getImpl", KeyInfoFactory.getImplParams);
/* 104 */         if (m != null)
/* 105 */           m.setAccessible(true); 
/*     */       } catch (NoSuchMethodException nsme) {  }
/*     */ 
/* 107 */       return m;
/*     */     }
/*     */   });
/*     */ 
/*     */   public static KeyInfoFactory getInstance(String mechanismType)
/*     */   {
/* 145 */     if (mechanismType == null) {
/* 146 */       throw new NullPointerException("mechanismType cannot be null");
/*     */     }
/*     */ 
/* 149 */     return findInstance(mechanismType, null);
/*     */   }
/*     */ 
/*     */   private static KeyInfoFactory findInstance(String mechanismType, Provider provider)
/*     */   {
/* 155 */     if (getImplMethod == null) {
/* 156 */       throw new NoSuchMechanismException("Cannot find " + mechanismType + " mechanism type");
/*     */     }
/*     */ 
/* 160 */     Object[] objs = null;
/*     */     try {
/* 162 */       objs = (Object[])getImplMethod.invoke(null, new Object[] { mechanismType, "KeyInfoFactory", provider });
/*     */     }
/*     */     catch (IllegalAccessException iae) {
/* 165 */       throw new NoSuchMechanismException("Cannot find " + mechanismType + " mechanism type", iae);
/*     */     }
/*     */     catch (InvocationTargetException ite) {
/* 168 */       throw new NoSuchMechanismException("Cannot find " + mechanismType + " mechanism type", ite);
/*     */     }
/*     */ 
/* 172 */     KeyInfoFactory factory = (KeyInfoFactory)objs[0];
/* 173 */     factory.mechanismType = mechanismType;
/* 174 */     factory.provider = ((Provider)objs[1]);
/* 175 */     return factory;
/*     */   }
/*     */ 
/*     */   public static KeyInfoFactory getInstance(String mechanismType, Provider provider)
/*     */   {
/* 201 */     if (mechanismType == null)
/* 202 */       throw new NullPointerException("mechanismType cannot be null");
/* 203 */     if (provider == null) {
/* 204 */       throw new NullPointerException("provider cannot be null");
/*     */     }
/*     */ 
/* 207 */     return findInstance(mechanismType, provider);
/*     */   }
/*     */ 
/*     */   public static KeyInfoFactory getInstance(String mechanismType, String provider)
/*     */     throws NoSuchProviderException
/*     */   {
/* 237 */     if (mechanismType == null)
/* 238 */       throw new NullPointerException("mechanismType cannot be null");
/* 239 */     if (provider == null) {
/* 240 */       throw new NullPointerException("provider cannot be null");
/*     */     }
/*     */ 
/* 243 */     Provider prov = Security.getProvider(provider);
/* 244 */     if (prov == null) {
/* 245 */       throw new NoSuchProviderException("cannot find provider named " + provider);
/*     */     }
/*     */ 
/* 249 */     return findInstance(mechanismType, prov);
/*     */   }
/*     */ 
/*     */   public static KeyInfoFactory getInstance()
/*     */   {
/* 273 */     return getInstance("DOM");
/*     */   }
/*     */ 
/*     */   public final String getMechanismType()
/*     */   {
/* 284 */     return this.mechanismType;
/*     */   }
/*     */ 
/*     */   public final Provider getProvider()
/*     */   {
/* 293 */     return this.provider;
/*     */   }
/*     */ 
/*     */   public abstract KeyInfo newKeyInfo(List paramList);
/*     */ 
/*     */   public abstract KeyInfo newKeyInfo(List paramList, String paramString);
/*     */ 
/*     */   public abstract KeyName newKeyName(String paramString);
/*     */ 
/*     */   public abstract KeyValue newKeyValue(PublicKey paramPublicKey)
/*     */     throws KeyException;
/*     */ 
/*     */   public abstract PGPData newPGPData(byte[] paramArrayOfByte);
/*     */ 
/*     */   public abstract PGPData newPGPData(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2, List paramList);
/*     */ 
/*     */   public abstract PGPData newPGPData(byte[] paramArrayOfByte, List paramList);
/*     */ 
/*     */   public abstract RetrievalMethod newRetrievalMethod(String paramString);
/*     */ 
/*     */   public abstract RetrievalMethod newRetrievalMethod(String paramString1, String paramString2, List paramList);
/*     */ 
/*     */   public abstract X509Data newX509Data(List paramList);
/*     */ 
/*     */   public abstract X509IssuerSerial newX509IssuerSerial(String paramString, BigInteger paramBigInteger);
/*     */ 
/*     */   public abstract boolean isFeatureSupported(String paramString);
/*     */ 
/*     */   public abstract URIDereferencer getURIDereferencer();
/*     */ 
/*     */   public abstract KeyInfo unmarshalKeyInfo(XMLStructure paramXMLStructure)
/*     */     throws MarshalException;
/*     */ 
/*     */   static
/*     */   {
/*     */     try
/*     */     {
/*  96 */       cl = Class.forName("javax.xml.crypto.dsig.XMLDSigSecurity");
/*     */     }
/*     */     catch (ClassNotFoundException cnfe)
/*     */     {
/*     */     }
/*     */   }
/*     */ }

/* Location:           E:\HYN\Java\trunk\ref\lib-dep\xmldsig\xmldsig.jar
 * Qualified Name:     javax.xml.crypto.dsig.keyinfo.KeyInfoFactory
 * JD-Core Version:    0.6.2
 */




© 2015 - 2024 Weber Informatics LLC | Privacy Policy