Package java.security

Examples of java.security.NoSuchAlgorithmException


                throw new InvalidKeyException(
                        Messages.getString("crypto.29")); //$NON-NLS-1$
            }
            return new PKCS8EncodedKeySpec(decryptedData);
        } catch (NoSuchPaddingException e) {
            throw new NoSuchAlgorithmException(e.getMessage());
        } catch (InvalidAlgorithmParameterException e) {
            throw new NoSuchAlgorithmException(e.getMessage());
        } catch (IllegalStateException e) {
            throw new InvalidKeyException(e.getMessage());
        } catch (IllegalBlockSizeException e) {
            throw new InvalidKeyException(e.getMessage());
        } catch (BadPaddingException e) {
View Full Code Here


                throw new InvalidKeyException(
                        Messages.getString("crypto.29")); //$NON-NLS-1$
            }
            return new PKCS8EncodedKeySpec(decryptedData);
        } catch (NoSuchPaddingException e) {
            throw new NoSuchAlgorithmException(e.getMessage());
        } catch (InvalidAlgorithmParameterException e) {
            throw new NoSuchAlgorithmException(e.getMessage());
        } catch (IllegalStateException e) {
            throw new InvalidKeyException(e.getMessage());
        } catch (IllegalBlockSizeException e) {
            throw new InvalidKeyException(e.getMessage());
        } catch (BadPaddingException e) {
View Full Code Here

                throw new InvalidKeyException(
                        Messages.getString("crypto.29")); //$NON-NLS-1$
            }
            return new PKCS8EncodedKeySpec(decryptedData);
        } catch (NoSuchPaddingException e) {
            throw new NoSuchAlgorithmException(e.getMessage());
        } catch (InvalidAlgorithmParameterException e) {
            throw new NoSuchAlgorithmException(e.getMessage());
        } catch (IllegalStateException e) {
            throw new InvalidKeyException(e.getMessage());
        } catch (IllegalBlockSizeException e) {
            throw new InvalidKeyException(e.getMessage());
        } catch (BadPaddingException e) {
View Full Code Here

     */
    private static synchronized Cipher getCipher(String transformation, Provider provider)
            throws NoSuchAlgorithmException, NoSuchPaddingException {

        if (transformation == null || "".equals(transformation)) { //$NON-NLS-1$
            throw new NoSuchAlgorithmException(Messages.getString("crypto.17", //$NON-NLS-1$
                    transformation));
        }

        String[] transf = checkTransformation(transformation);

        boolean needSetPadding = false;
        boolean needSetMode = false;
        if (transf[1] == null && transf[2] == null) { // "algorithm"
            if (provider == null) {
                engine.getInstance(transf[0], null);
            } else {
                engine.getInstance(transf[0], provider, null);
            }
        } else {
            String[] searhOrder = {
                    transf[0] + "/" + transf[1] + "/" + transf[2], // "algorithm/mode/padding" //$NON-NLS-1$ //$NON-NLS-2$
                    transf[0] + "/" + transf[1], // "algorithm/mode" //$NON-NLS-1$
                    transf[0] + "//" + transf[2], // "algorithm//padding" //$NON-NLS-1$
                    transf[0] // "algorithm"
            };
            int i;
            for (i = 0; i < searhOrder.length; i++) {
                try {
                    if (provider == null) {
                        engine.getInstance(searhOrder[i], null);
                    } else {
                        engine.getInstance(searhOrder[i], provider, null);
                    }
                    break;
                } catch (NoSuchAlgorithmException e) {
                    if ( i == searhOrder.length-1) {
                        throw new NoSuchAlgorithmException(transformation);
                    }
                }
            }
            switch (i) {
            case 1: // "algorithm/mode"
                needSetPadding = true;
                break;
            case 2: // "algorithm//padding"
                needSetMode = true;
                break;
            case 3: // "algorithm"
                needSetPadding = true;
                needSetMode = true;
            }
        }
        CipherSpi cspi;
        try {
            cspi = (CipherSpi) engine.spi;
        } catch (ClassCastException e) {
            throw new NoSuchAlgorithmException(e);
        }
        Cipher c = new Cipher(cspi, engine.provider, transformation);
        if (needSetMode) {
            c.spiImpl.engineSetMode(transf[1]);
        }
View Full Code Here

        StringTokenizer st;
        int i = 0;
        for (st = new StringTokenizer(transformation, "/"); st //$NON-NLS-1$
                .hasMoreElements();) {
            if (i > 2) {
                throw new NoSuchAlgorithmException(Messages.getString("crypto.17", //$NON-NLS-1$
                        transformation));
            }
            transf[i] = st.nextToken();
            if (transf[i] != null) {
                transf[i] = transf[i].trim();
                if ("".equals(transf[i])) { //$NON-NLS-1$
                    transf[i] = null;
                }
                i++;
            }
        }
        if (transf[0] == null) {
            throw new NoSuchAlgorithmException(Messages.getString("crypto.17", //$NON-NLS-1$
                    transformation));
        }
        if (!(transf[1] == null && transf[2] == null)
                && (transf[1] == null || transf[2] == null)) {
            throw new NoSuchAlgorithmException(Messages.getString("crypto.17", //$NON-NLS-1$
                    transformation));
        }
        return transf;
    }
View Full Code Here

        super();
        TrustManagerFactory factory = TrustManagerFactory.getInstance("SunX509");
        factory.init(keystore);
        TrustManager[] trustmanagers = factory.getTrustManagers();
        if (trustmanagers.length == 0) {
            throw new NoSuchAlgorithmException("SunX509 trust manager not supported");
        }
        this.standardTrustManager = (X509TrustManager)trustmanagers[0];
    }
View Full Code Here

        if ("CRC".equals(algorithm)) {
            checksum = new CRC32();
        } else if ("ADLER".equals(algorithm)) {
            checksum = new Adler32();
        } else {
            throw new BuildException(new NoSuchAlgorithmException());
        }
    }
View Full Code Here

        super();
        TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        factory.init(keystore);
        TrustManager[] trustmanagers = factory.getTrustManagers();
        if (trustmanagers.length == 0) {
            throw new NoSuchAlgorithmException("no trust manager found");
        }
        this.standardTrustManager = (X509TrustManager)trustmanagers[0];
    }
View Full Code Here

  
   public void setEncryptedPassword(String algorithm,final String value)
      throws SQLException,NoSuchAlgorithmException
   {
      if (!algorithm.equals("md5")) {
         throw new NoSuchAlgorithmException("Algorithm "+algorithm+" is not supported.");
      }
      DBConnection connection = db.getConnection();
      try {
         connection.deleteById(AuthDB.DELETE_AUTHENTICATION_BY_USER, id);
         connection.create(AuthDB.CREATE_AUTHENTICATION, -1,new DBUpdateHandler() {
View Full Code Here

                ts.mechanism = mechanismType;
                ts.provider = instance.provider;
                return ts;
            }
        }
        throw new NoSuchAlgorithmException
            (algorithm + " algorithm and " + mechanismType
                 + " mechanism not available");
    }
View Full Code Here

TOP

Related Classes of java.security.NoSuchAlgorithmException

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.