java.security.Provider.Service#supportsParameter ( )源码实例Demo

下面列出了java.security.Provider.Service#supportsParameter ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-8   文件: SupportsParameter.java
private static void checkSupports(Service s, Key key, boolean r) throws Exception {
    if (s.supportsParameter(key) != r) {
        throw new Exception("Result mismatch");
    }
    System.out.println("Passed");
}
 
源代码2 项目: dragonwell8_jdk   文件: Signature.java
private void chooseProvider(int type, Key key, SecureRandom random)
        throws InvalidKeyException {
    synchronized (lock) {
        if (sigSpi != null) {
            init(sigSpi, type, key, random);
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            if (firstService != null) {
                s = firstService;
                firstService = null;
            } else {
                s = serviceIterator.next();
            }
            // if provider says it does not support this key, ignore it
            if (s.supportsParameter(key) == false) {
                continue;
            }
            // if instance is not a SignatureSpi, ignore it
            if (isSpi(s) == false) {
                continue;
            }
            try {
                SignatureSpi spi = newInstance(s);
                init(spi, type, key, random);
                provider = s.getProvider();
                sigSpi = spi;
                firstService = null;
                serviceIterator = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        String k = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + k, lastException);
    }
}
 
源代码3 项目: dragonwell8_jdk   文件: Cipher.java
private void chooseProvider(int initType, int opmode, Key key,
        AlgorithmParameterSpec paramSpec,
        AlgorithmParameters params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    synchronized (lock) {
        if (spi != null) {
            implInit(spi, initType, opmode, key, paramSpec, params, random);
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            CipherSpi thisSpi;
            if (firstService != null) {
                s = firstService;
                thisSpi = firstSpi;
                firstService = null;
                firstSpi = null;
            } else {
                s = serviceIterator.next();
                thisSpi = null;
            }
            // if provider says it does not support this key, ignore it
            if (s.supportsParameter(key) == false) {
                continue;
            }
            if (JceSecurity.canUseProvider(s.getProvider()) == false) {
                continue;
            }
            Transform tr = getTransform(s, transforms);
            if (tr == null) {
                // should never happen
                continue;
            }
            if (tr.supportsModePadding(s) == S_NO) {
                continue;
            }
            try {
                if (thisSpi == null) {
                    thisSpi = (CipherSpi)s.newInstance(null);
                }
                tr.setModePadding(thisSpi);
                initCryptoPermission();
                implInit(thisSpi, initType, opmode, key, paramSpec,
                                                    params, random);
                provider = s.getProvider();
                this.spi = thisSpi;
                firstService = null;
                serviceIterator = null;
                transforms = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                // SecurityException from crypto permission check
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof InvalidAlgorithmParameterException) {
            throw (InvalidAlgorithmParameterException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        String kName = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + kName, lastException);
    }
}
 
源代码4 项目: jdk8u_jdk   文件: Signature.java
private void chooseProvider(int type, Key key,
        AlgorithmParameterSpec params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    synchronized (lock) {
        if (sigSpi != null) {
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            if (firstService != null) {
                s = firstService;
                firstService = null;
            } else {
                s = serviceIterator.next();
            }
            // if provider says it does not support this key, ignore it
            if (key != null && s.supportsParameter(key) == false) {
                continue;
            }
            // if instance is not a SignatureSpi, ignore it
            if (isSpi(s) == false) {
                continue;
            }
            try {
                SignatureSpi spi = newInstance(s);
                tryOperation(spi, type, key, params, random);
                provider = s.getProvider();
                sigSpi = spi;
                firstService = null;
                serviceIterator = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        if (lastException instanceof InvalidAlgorithmParameterException) {
            throw (InvalidAlgorithmParameterException)lastException;
        }

        String k = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + k, lastException);
    }
}
 
源代码5 项目: TencentKona-8   文件: Signature.java
private void chooseProvider(int type, Key key, SecureRandom random)
        throws InvalidKeyException {
    synchronized (lock) {
        if (sigSpi != null) {
            init(sigSpi, type, key, random);
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            if (firstService != null) {
                s = firstService;
                firstService = null;
            } else {
                s = serviceIterator.next();
            }
            // if provider says it does not support this key, ignore it
            if (s.supportsParameter(key) == false) {
                continue;
            }
            // if instance is not a SignatureSpi, ignore it
            if (isSpi(s) == false) {
                continue;
            }
            try {
                SignatureSpi spi = newInstance(s);
                init(spi, type, key, random);
                provider = s.getProvider();
                sigSpi = spi;
                firstService = null;
                serviceIterator = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        String k = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + k, lastException);
    }
}
 
源代码6 项目: jdk8u_jdk   文件: SupportsParameter.java
private static void checkSupports(Service s, Key key, boolean r) throws Exception {
    if (s.supportsParameter(key) != r) {
        throw new Exception("Result mismatch");
    }
    System.out.println("Passed");
}
 
源代码7 项目: TencentKona-8   文件: SupportsParameter.java
private static void checkSupports(Service s, Key key, boolean r) throws Exception {
    if (s.supportsParameter(key) != r) {
        throw new Exception("Result mismatch");
    }
    System.out.println("Passed");
}
 
源代码8 项目: jdk8u60   文件: Signature.java
private void chooseProvider(int type, Key key, SecureRandom random)
        throws InvalidKeyException {
    synchronized (lock) {
        if (sigSpi != null) {
            init(sigSpi, type, key, random);
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            if (firstService != null) {
                s = firstService;
                firstService = null;
            } else {
                s = serviceIterator.next();
            }
            // if provider says it does not support this key, ignore it
            if (s.supportsParameter(key) == false) {
                continue;
            }
            // if instance is not a SignatureSpi, ignore it
            if (isSpi(s) == false) {
                continue;
            }
            try {
                SignatureSpi spi = newInstance(s);
                init(spi, type, key, random);
                provider = s.getProvider();
                sigSpi = spi;
                firstService = null;
                serviceIterator = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        String k = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + k, lastException);
    }
}
 
源代码9 项目: jdk8u60   文件: Cipher.java
private void chooseProvider(int initType, int opmode, Key key,
        AlgorithmParameterSpec paramSpec,
        AlgorithmParameters params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    synchronized (lock) {
        if (spi != null) {
            implInit(spi, initType, opmode, key, paramSpec, params, random);
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            CipherSpi thisSpi;
            if (firstService != null) {
                s = firstService;
                thisSpi = firstSpi;
                firstService = null;
                firstSpi = null;
            } else {
                s = serviceIterator.next();
                thisSpi = null;
            }
            // if provider says it does not support this key, ignore it
            if (s.supportsParameter(key) == false) {
                continue;
            }
            if (JceSecurity.canUseProvider(s.getProvider()) == false) {
                continue;
            }
            Transform tr = getTransform(s, transforms);
            if (tr == null) {
                // should never happen
                continue;
            }
            if (tr.supportsModePadding(s) == S_NO) {
                continue;
            }
            try {
                if (thisSpi == null) {
                    thisSpi = (CipherSpi)s.newInstance(null);
                }
                tr.setModePadding(thisSpi);
                initCryptoPermission();
                implInit(thisSpi, initType, opmode, key, paramSpec,
                                                    params, random);
                provider = s.getProvider();
                this.spi = thisSpi;
                firstService = null;
                serviceIterator = null;
                transforms = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                // SecurityException from crypto permission check
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof InvalidAlgorithmParameterException) {
            throw (InvalidAlgorithmParameterException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        String kName = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + kName, lastException);
    }
}
 
源代码10 项目: openjdk-jdk9   文件: SupportsParameter.java
private static void checkSupports(Service s, Key key, boolean r) throws Exception {
    if (s.supportsParameter(key) != r) {
        throw new Exception("Result mismatch");
    }
    System.out.println("Passed");
}
 
源代码11 项目: jdk8u-jdk   文件: Signature.java
private void chooseProvider(int type, Key key, SecureRandom random)
        throws InvalidKeyException {
    synchronized (lock) {
        if (sigSpi != null) {
            init(sigSpi, type, key, random);
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            if (firstService != null) {
                s = firstService;
                firstService = null;
            } else {
                s = serviceIterator.next();
            }
            // if provider says it does not support this key, ignore it
            if (s.supportsParameter(key) == false) {
                continue;
            }
            // if instance is not a SignatureSpi, ignore it
            if (isSpi(s) == false) {
                continue;
            }
            try {
                SignatureSpi spi = newInstance(s);
                init(spi, type, key, random);
                provider = s.getProvider();
                sigSpi = spi;
                firstService = null;
                serviceIterator = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        String k = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + k, lastException);
    }
}
 
源代码12 项目: jdk8u-dev-jdk   文件: SupportsParameter.java
private static void checkSupports(Service s, Key key, boolean r) throws Exception {
    if (s.supportsParameter(key) != r) {
        throw new Exception("Result mismatch");
    }
    System.out.println("Passed");
}
 
源代码13 项目: openjdk-8-source   文件: Cipher.java
private void chooseProvider(int initType, int opmode, Key key,
        AlgorithmParameterSpec paramSpec,
        AlgorithmParameters params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    synchronized (lock) {
        if (spi != null) {
            implInit(spi, initType, opmode, key, paramSpec, params, random);
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            CipherSpi thisSpi;
            if (firstService != null) {
                s = firstService;
                thisSpi = firstSpi;
                firstService = null;
                firstSpi = null;
            } else {
                s = serviceIterator.next();
                thisSpi = null;
            }
            // if provider says it does not support this key, ignore it
            if (s.supportsParameter(key) == false) {
                continue;
            }
            if (JceSecurity.canUseProvider(s.getProvider()) == false) {
                continue;
            }
            Transform tr = getTransform(s, transforms);
            if (tr == null) {
                // should never happen
                continue;
            }
            if (tr.supportsModePadding(s) == S_NO) {
                continue;
            }
            try {
                if (thisSpi == null) {
                    thisSpi = (CipherSpi)s.newInstance(null);
                }
                tr.setModePadding(thisSpi);
                initCryptoPermission();
                implInit(thisSpi, initType, opmode, key, paramSpec,
                                                    params, random);
                provider = s.getProvider();
                this.spi = thisSpi;
                firstService = null;
                serviceIterator = null;
                transforms = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                // SecurityException from crypto permission check
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof InvalidAlgorithmParameterException) {
            throw (InvalidAlgorithmParameterException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        String kName = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + kName, lastException);
    }
}
 
源代码14 项目: openjdk-jdk8u   文件: SupportsParameter.java
private static void checkSupports(Service s, Key key, boolean r) throws Exception {
    if (s.supportsParameter(key) != r) {
        throw new Exception("Result mismatch");
    }
    System.out.println("Passed");
}
 
源代码15 项目: jdk8u-jdk   文件: Signature.java
private void chooseProvider(int type, Key key, SecureRandom random)
        throws InvalidKeyException {
    synchronized (lock) {
        if (sigSpi != null) {
            init(sigSpi, type, key, random);
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            if (firstService != null) {
                s = firstService;
                firstService = null;
            } else {
                s = serviceIterator.next();
            }
            // if provider says it does not support this key, ignore it
            if (s.supportsParameter(key) == false) {
                continue;
            }
            // if instance is not a SignatureSpi, ignore it
            if (isSpi(s) == false) {
                continue;
            }
            try {
                SignatureSpi spi = newInstance(s);
                init(spi, type, key, random);
                provider = s.getProvider();
                sigSpi = spi;
                firstService = null;
                serviceIterator = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        String k = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + k, lastException);
    }
}
 
源代码16 项目: openjdk-jdk8u-backup   文件: Cipher.java
private void chooseProvider(int initType, int opmode, Key key,
        AlgorithmParameterSpec paramSpec,
        AlgorithmParameters params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    synchronized (lock) {
        if (spi != null) {
            implInit(spi, initType, opmode, key, paramSpec, params, random);
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            CipherSpi thisSpi;
            if (firstService != null) {
                s = firstService;
                thisSpi = firstSpi;
                firstService = null;
                firstSpi = null;
            } else {
                s = serviceIterator.next();
                thisSpi = null;
            }
            // if provider says it does not support this key, ignore it
            if (s.supportsParameter(key) == false) {
                continue;
            }
            if (JceSecurity.canUseProvider(s.getProvider()) == false) {
                continue;
            }
            Transform tr = getTransform(s, transforms);
            if (tr == null) {
                // should never happen
                continue;
            }
            if (tr.supportsModePadding(s) == S_NO) {
                continue;
            }
            try {
                if (thisSpi == null) {
                    thisSpi = (CipherSpi)s.newInstance(null);
                }
                tr.setModePadding(thisSpi);
                initCryptoPermission();
                implInit(thisSpi, initType, opmode, key, paramSpec,
                                                    params, random);
                provider = s.getProvider();
                this.spi = thisSpi;
                firstService = null;
                serviceIterator = null;
                transforms = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                // SecurityException from crypto permission check
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof InvalidAlgorithmParameterException) {
            throw (InvalidAlgorithmParameterException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        String kName = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + kName, lastException);
    }
}
 
源代码17 项目: openjdk-8   文件: Cipher.java
private void chooseProvider(int initType, int opmode, Key key,
        AlgorithmParameterSpec paramSpec,
        AlgorithmParameters params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    synchronized (lock) {
        if (spi != null) {
            implInit(spi, initType, opmode, key, paramSpec, params, random);
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            CipherSpi thisSpi;
            if (firstService != null) {
                s = firstService;
                thisSpi = firstSpi;
                firstService = null;
                firstSpi = null;
            } else {
                s = serviceIterator.next();
                thisSpi = null;
            }
            // if provider says it does not support this key, ignore it
            if (s.supportsParameter(key) == false) {
                continue;
            }
            if (JceSecurity.canUseProvider(s.getProvider()) == false) {
                continue;
            }
            Transform tr = getTransform(s, transforms);
            if (tr == null) {
                // should never happen
                continue;
            }
            if (tr.supportsModePadding(s) == S_NO) {
                continue;
            }
            try {
                if (thisSpi == null) {
                    thisSpi = (CipherSpi)s.newInstance(null);
                }
                tr.setModePadding(thisSpi);
                initCryptoPermission();
                implInit(thisSpi, initType, opmode, key, paramSpec,
                                                    params, random);
                provider = s.getProvider();
                this.spi = thisSpi;
                firstService = null;
                serviceIterator = null;
                transforms = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                // SecurityException from crypto permission check
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof InvalidAlgorithmParameterException) {
            throw (InvalidAlgorithmParameterException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        String kName = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + kName, lastException);
    }
}
 
源代码18 项目: hottub   文件: SupportsParameter.java
private static void checkSupports(Service s, Key key, boolean r) throws Exception {
    if (s.supportsParameter(key) != r) {
        throw new Exception("Result mismatch");
    }
    System.out.println("Passed");
}
 
源代码19 项目: Bytecoder   文件: Cipher.java
private void chooseProvider(int initType, int opmode, Key key,
        AlgorithmParameterSpec paramSpec,
        AlgorithmParameters params, SecureRandom random)
        throws InvalidKeyException, InvalidAlgorithmParameterException {
    synchronized (lock) {
        if (spi != null) {
            implInit(spi, initType, opmode, key, paramSpec, params, random);
            return;
        }
        Exception lastException = null;
        while ((firstService != null) || serviceIterator.hasNext()) {
            Service s;
            CipherSpi thisSpi;
            if (firstService != null) {
                s = firstService;
                thisSpi = firstSpi;
                firstService = null;
                firstSpi = null;
            } else {
                s = serviceIterator.next();
                thisSpi = null;
            }
            // if provider says it does not support this key, ignore it
            if (s.supportsParameter(key) == false) {
                continue;
            }
            if (JceSecurity.canUseProvider(s.getProvider()) == false) {
                continue;
            }
            Transform tr = getTransform(s, transforms);
            if (tr == null) {
                // should never happen
                continue;
            }
            if (tr.supportsModePadding(s) == S_NO) {
                continue;
            }
            try {
                if (thisSpi == null) {
                    thisSpi = (CipherSpi)s.newInstance(null);
                }
                tr.setModePadding(thisSpi);
                initCryptoPermission();
                implInit(thisSpi, initType, opmode, key, paramSpec,
                                                    params, random);
                provider = s.getProvider();
                this.spi = thisSpi;
                firstService = null;
                serviceIterator = null;
                transforms = null;
                return;
            } catch (Exception e) {
                // NoSuchAlgorithmException from newInstance()
                // InvalidKeyException from init()
                // RuntimeException (ProviderException) from init()
                // SecurityException from crypto permission check
                if (lastException == null) {
                    lastException = e;
                }
            }
        }
        // no working provider found, fail
        if (lastException instanceof InvalidKeyException) {
            throw (InvalidKeyException)lastException;
        }
        if (lastException instanceof InvalidAlgorithmParameterException) {
            throw (InvalidAlgorithmParameterException)lastException;
        }
        if (lastException instanceof RuntimeException) {
            throw (RuntimeException)lastException;
        }
        String kName = (key != null) ? key.getClass().getName() : "(null)";
        throw new InvalidKeyException
            ("No installed provider supports this key: "
            + kName, lastException);
    }
}
 
源代码20 项目: jdk8u-jdk   文件: SupportsParameter.java
private static void checkSupports(Service s, Key key, boolean r) throws Exception {
    if (s.supportsParameter(key) != r) {
        throw new Exception("Result mismatch");
    }
    System.out.println("Passed");
}