Package com.im.imjutil.exception

Examples of com.im.imjutil.exception.InstantiateException


  public HashCipher(CipherType type) {
    this.type = type;
    try {
      messageDigest = MessageDigest.getInstance(type.cipher);
    } catch (NoSuchAlgorithmException e) {
      throw new InstantiateException(Convert.toString(
          "Algoritmo nao suportado [", type.cipher, "]"), e);
    }
  }
View Full Code Here


   * do tipo {@link CipherType}.
   */
  public static final Cipher getInstance(CipherType type)
      throws InstantiateException {
    if (type == null) {
      throw new InstantiateException("O tipo passado e nulo");
    }
   
    Class<? extends Cipher> clazz = type.clazz;

    if (clazz == null) {
      throw new InstantiateException(Convert.toString(
          "Tipo de codificador nao implementado: ", type.cipher));
    }
   
    Cipher instance = null;
   
    try {
      try {
        Constructor<? extends Cipher> constructor;
        constructor = clazz.getConstructor(CipherType.class);
        instance = constructor.newInstance(type);
       
      } catch (NoSuchMethodException e) {
        instance = clazz.newInstance();
      }
    } catch (java.lang.InstantiationException e) {
      throw new InstantiateException("Erro ao instanciar o codificador",e);
     
    } catch (IllegalAccessException e) {
      throw new InstantiateException("Erro ao acessar o codificador",e);
     
    } catch (InvocationTargetException e) {
      throw new InstantiateException("Erro ao construir o codificador",e);
     
    } catch (Exception e) {
      throw new InstantiateException(Convert.toString(
          "Excecao desconhecida: ", e.getClass().getName(),
          " -> ", e.getMessage()), e);
    }
    return instance;
  }
View Full Code Here

TOP

Related Classes of com.im.imjutil.exception.InstantiateException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.