Package java.security.spec

Examples of java.security.spec.InvalidKeySpecException


                  return JDKKeyFactory.createPrivateKeyFromDERStream(
                              new ByteArrayInputStream(((PKCS8EncodedKeySpec)keySpec).getEncoded()));
              }
              catch (Exception e)
              {
                  throw new InvalidKeySpecException(e.toString());
              }
          }
          else if (keySpec instanceof ECPrivateKeySpec)
          {
              return new JCEECPrivateKey(algorithm, (ECPrivateKeySpec)keySpec);
          }
 
          throw new InvalidKeySpecException("Unknown KeySpec type.");
      }
View Full Code Here


                  return JDKKeyFactory.createPublicKeyFromDERStream(
                              new ByteArrayInputStream(((X509EncodedKeySpec)keySpec).getEncoded()));
              }
              catch (Exception e)
              {
                  throw new InvalidKeySpecException(e.toString());
              }
          }
          else if (keySpec instanceof ECPublicKeySpec)
          {
              return new JCEECPublicKey(algorithm, (ECPublicKeySpec)keySpec);
          }
 
          throw new InvalidKeySpecException("Unknown KeySpec type.");
      }
View Full Code Here

      throw (RuntimeException)failure;
  }
  if (failure instanceof InvalidKeySpecException) {
      throw (InvalidKeySpecException)failure;
  }
  throw new InvalidKeySpecException
    ("Could not generate public key", failure);
    }
View Full Code Here

      throw (RuntimeException)failure;
  }
  if (failure instanceof InvalidKeySpecException) {
      throw (InvalidKeySpecException)failure;
  }
  throw new InvalidKeySpecException
    ("Could not generate private key", failure);
    }
View Full Code Here

      throw (RuntimeException)failure;
  }
  if (failure instanceof InvalidKeySpecException) {
      throw (InvalidKeySpecException)failure;
  }
  throw new InvalidKeySpecException
    ("Could not get key spec", failure);
    }
View Full Code Here

        } catch (InvalidKeyException e) {
            throw new InvalidKeyException("InvalidKeyException due to invalid passPhrase: " + Arrays.toString(passPhrase));
        } catch (NoSuchAlgorithmException e) {
            throw new NoSuchAlgorithmException("NoSuchAlgorithmException while using algorithm: " + algorithm);
        } catch (InvalidKeySpecException e) {
            throw new InvalidKeySpecException("Invalid Key generated while using passPhrase: " + Arrays.toString(passPhrase));
        }
        return secretKey;
    }
View Full Code Here

        else if (keySpec instanceof RSAPrivateKeySpec)
        {
            return new BCRSAPrivateKey((RSAPrivateKeySpec)keySpec);
        }

        throw new InvalidKeySpecException("Unknown KeySpec type: " + keySpec.getClass().getName());
    }
View Full Code Here

        if (keySpec instanceof SecretKeySpec)
        {
            return (SecretKey)keySpec;
        }

        throw new InvalidKeySpecException("Invalid KeySpec");
    }
View Full Code Here

            }

            return new BCPBEKey(this.algName, this.algOid, scheme, digest, keySize, ivSize, pbeSpec, param);
        }

        throw new InvalidKeySpecException("Invalid KeySpec");
    }
View Full Code Here

            {
                PBEKeySpec pbeSpec = (PBEKeySpec)keySpec;

                if (pbeSpec.getSalt() == null)
                {
                    throw new InvalidKeySpecException("missing required salt");
                }

                if (pbeSpec.getIterationCount() <= 0)
                {
                    throw new InvalidKeySpecException("positive iteration count required: "
                        + pbeSpec.getIterationCount());
                }

                if (pbeSpec.getKeyLength() <= 0)
                {
                    throw new InvalidKeySpecException("positive key length required: "
                        + pbeSpec.getKeyLength());
                }

                if (pbeSpec.getPassword().length == 0)
                {
                    throw new IllegalArgumentException("password empty");
                }

                int digest = SHA1;
                int keySize = pbeSpec.getKeyLength();
                int ivSize = -1;    // JDK 1,2 and earlier does not understand simplified version.
                CipherParameters param = PBE.Util.makePBEMacParameters(pbeSpec, scheme, digest, keySize);

                return new BCPBEKey(this.algName, this.algOid, scheme, digest, keySize, ivSize, pbeSpec, param);
            }

            throw new InvalidKeySpecException("Invalid KeySpec");
        }
View Full Code Here

TOP

Related Classes of java.security.spec.InvalidKeySpecException

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.