Examples of InvalidKeyException


Examples of java.security.InvalidKeyException

         {
             encoded = engineDoFinal(wrappedKey, 0, wrappedKey.length);
         }
         catch (BadPaddingException e)
         {
             throw new InvalidKeyException(e.getMessage());
         }
         catch (IllegalBlockSizeException e2)
         {
             throw new InvalidKeyException(e2.getMessage());
         }

         if (wrappedKeyType == Cipher.SECRET_KEY)
         {
             return new SecretKeySpec(encoded, wrappedKeyAlgorithm);
         }
         else if (wrappedKeyAlgorithm.equals("") && wrappedKeyType == Cipher.PRIVATE_KEY)
         {
             /*
              * The caller doesn't know the algorithm as it is part of
              * the encrypted data.
              */
             try
             {
                 PrivateKeyInfo in = PrivateKeyInfo.getInstance(encoded);

                 PrivateKey privKey = BouncyCastleProvider.getPrivateKey(in);

                 if (privKey != null)
                 {
                     return privKey;
                 }
                 else
                 {
                     throw new InvalidKeyException("algorithm " + in.getPrivateKeyAlgorithm().getAlgorithm() + " not supported");
                 }
             }
             catch (Exception e)
             {
                 throw new InvalidKeyException("Invalid key encoding.");
             }
         }
         else
         {
             try
             {
                 KeyFactory kf = KeyFactory.getInstance(wrappedKeyAlgorithm, BouncyCastleProvider.PROVIDER_NAME);

                 if (wrappedKeyType == Cipher.PUBLIC_KEY)
                 {
                     return kf.generatePublic(new X509EncodedKeySpec(encoded));
                 }
                 else if (wrappedKeyType == Cipher.PRIVATE_KEY)
                 {
                     return kf.generatePrivate(new PKCS8EncodedKeySpec(encoded));
                 }
             }
             catch (NoSuchProviderException e)
             {
                 throw new InvalidKeyException("Unknown key type " + e.getMessage());
             }
             catch (NoSuchAlgorithmException e)
             {
                 throw new InvalidKeyException("Unknown key type " + e.getMessage());
             }
             catch (InvalidKeySpecException e2)
             {
                 throw new InvalidKeyException("Unknown key type " + e2.getMessage());
             }

             throw new InvalidKeyException("Unknown key type " + wrappedKeyType);
         }
     }
View Full Code Here

Examples of org.apache.empire.db.exceptions.InvalidKeyException

    public void loadRecord(Object[] recKey)
    {
        // Check Key
        if (recKey==null || recKey.length==0)
        {   // Invalid Record key
            throw new InvalidKeyException(rowset, recKey);
        }
        // Record laden
        record.read(rowset, recKey, action.getConnection());
        // Save Record Key Info
        persistOnSession();
View Full Code Here

Examples of org.apache.empire.db.exceptions.InvalidKeyException

    {
        try {
            // Check Key
            if (recKey==null || recKey.length==0)
            {   // Invalid Record Key
                throw new InvalidKeyException(rowset, recKey);
            }
            if (newRec)
            {   // Record has not been saved yet!
                record.close();
                return true;
View Full Code Here

Examples of org.apache.empire.db.exceptions.InvalidKeyException

    {
        try {
            // Check Key
            if (recKey==null || recKey.length==0)
            {   // Invalid Record key
                throw new InvalidKeyException(rowset, recKey);
            }
            // Prepare Update
            Connection conn = action.getConnection();
            initUpdateRecord(recKey, insert, conn);
            // Set Update Fields
View Full Code Here

Examples of org.apache.empire.db.exceptions.InvalidKeyException

    { // Get the record key
        DBColumn[] keyColumns = rowset.getKeyColumns();
        if (keyColumns == null || keyColumns.length < 1)
            throw new NoPrimaryKeyException(rowset);
        if (keyValues == null || keyValues.length != keyColumns.length)
            throw new InvalidKeyException(rowset, keyValues);
        // Get Persistent record
        if (persistence==SessionPersistence.Data)
        {   // Get the record from the session
            Record rec = getRecordFromSession();
            if (rec==null || (rec instanceof DBRecord)==false)
View Full Code Here

Examples of org.jose4j.lang.InvalidKeyException

    void validateKey(Key key) throws InvalidKeyException
    {
        if (key == null)
        {
            throw new InvalidKeyException("key is null");
        }

        int length = ByteUtil.bitLength(key.getEncoded());
        if (length < minimumKeyLength)
        {
            throw new InvalidKeyException("A key of the same size as the hash output (i.e. "+minimumKeyLength+
                    " bits for "+getAlgorithmIdentifier()+
                    ") or larger MUST be used with the HMAC SHA algorithms but this key is only " + length + " bits");
        }
    }
View Full Code Here

Examples of org.thrudb.thrudoc.InvalidKeyException

  public byte[] get(String key) throws InvalidKeyException {
   
    byte[] value = bdb.get(key.getBytes());
   
    if(value == null)
      throw new InvalidKeyException();
   
    return value;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.