Package java.security

Examples of java.security.KeyException


     * @throws KeyException thrown if there is an error constructing key
     */
    public static RSAPrivateKey buildJavaRSAPrivateKey(String base64EncodedKeythrows KeyException {
        PrivateKey key =  buildJavaPrivateKey(base64EncodedKey);
        if (! (key instanceof RSAPrivateKey)) {
            throw new KeyException("Generated key was not an RSAPrivateKey instance");
        }
        return (RSAPrivateKey) key;
    }
View Full Code Here


     * @throws KeyException thrown if there is an error constructing key
     */
    public static DSAPrivateKey buildJavaDSAPrivateKey(String base64EncodedKeythrows KeyException {
        PrivateKey key =  buildJavaPrivateKey(base64EncodedKey);
        if (! (key instanceof DSAPrivateKey)) {
            throw new KeyException("Generated key was not a DSAPrivateKey instance");
        }
        return (DSAPrivateKey) key;
    }
View Full Code Here

    public static PublicKey buildKey(KeySpec keySpec, String keyAlgorithm) throws KeyException {
        try {
            KeyFactory keyFactory = KeyFactory.getInstance(keyAlgorithm);
            return keyFactory.generatePublic(keySpec);
        } catch (NoSuchAlgorithmException e) {
            throw new KeyException(keyAlgorithm + "algorithm is not supported by the JCE", e);
        } catch (InvalidKeySpecException e) {
            throw new KeyException("Invalid key information", e);
        }
    }
View Full Code Here

  } else if (key instanceof RSAPublicKey) {
      RSAPublicKey rkey = (RSAPublicKey) key;
      exponent = new DOMCryptoBinary(rkey.getPublicExponent());
      modulus = new DOMCryptoBinary(rkey.getModulus());
  } else {
      throw new KeyException("unsupported key algorithm: " +
    key.getAlgorithm());
  }
    }
View Full Code Here

  }
    }

    public PublicKey getPublicKey() throws KeyException {
  if (publicKey == null) {
      throw new KeyException("can't convert KeyValue to PublicKey");
  } else {
            return publicKey;
  }
    }
View Full Code Here

          Constructor<?> ctor = secretKeySpecClass.getDeclaredConstructor(signature);
          secretKey = ctor.newInstance(args);
      }
      catch(Exception e)
      {
          throw new KeyException("Failed to create SecretKeySpec from session key, msg="+e.getMessage());
      }
      catch(Throwable e)
      {
         throw new KeyException("Unexpected exception during SecretKeySpec creation, msg="+e.getMessage());
      }
      return secretKey;
   }
View Full Code Here

        Constructor ctor = secretKeySpecClass.getDeclaredConstructor(signature);
        secretKey = ctor.newInstance(args);
      }
      catch(Exception e)
      {
        throw new KeyException("Failed to create SecretKeySpec from session key, msg="+e.getMessage());
      }
      catch(Throwable e)
      {
         throw new KeyException("Unexpected exception during SecretKeySpec creation, msg="+e.getMessage());
      }
      return secretKey;
   }
View Full Code Here

  } else if (key instanceof RSAPublicKey) {
      RSAPublicKey rkey = (RSAPublicKey) key;
      exponent = new DOMCryptoBinary(rkey.getPublicExponent());
      modulus = new DOMCryptoBinary(rkey.getModulus());
  } else {
      throw new KeyException("unsupported key algorithm: " +
    key.getAlgorithm());
  }
    }
View Full Code Here

  }
    }

    public PublicKey getPublicKey() throws KeyException {
  if (publicKey == null) {
      throw new KeyException("can't convert KeyValue to PublicKey");
  } else {
            return publicKey;
  }
    }
View Full Code Here

    }

    @Override
    public PublicKey getPublicKey() throws KeyException {
        if (publicKey == null) {
            throw new KeyException("can't convert KeyValue to PublicKey");
        } else {
            return publicKey;
        }
    }
View Full Code Here

TOP

Related Classes of java.security.KeyException

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.