java.security.NoSuchAlgorithmException#getCause ( )源码实例Demo

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

源代码1 项目: julongchain   文件: GenerateKeyImpl.java
public IKey genAESKey(int size) throws CspException{

        try {
            //1.构造密钥生成器,指定为AES算法,不区分大小写
            KeyGenerator keygen = KeyGenerator.getInstance("AES");
            //2.根据ecnodeRules规则初始化密钥生成器
            //生成一个128位的随机源,根据传入的字节数组
            SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
            random.setSeed(encodeRules.getBytes());
            keygen.init(size, random);
            //3.产生原始对称密钥
            SecretKey key = keygen.generateKey();

            MessageDigest shahash = MessageDigest.getInstance("SHA-1");
            shahash.update(key.getEncoded());
            byte[] bytehash = shahash.digest();
            SymmetryKey.AESPriKey aeskey = new SymmetryKey.AESPriKey(key.getEncoded(), null, true);
            return aeskey;

        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            String err = String.format("[JC_PKCS_SOFT]:NoSuchAlgorithmException ErrMessage: %s", e.getMessage());
            throw new CspException(err, e.getCause());
        }
    }
 
源代码2 项目: jdk1.8-source-analysis   文件: CertStore.java
private static CertStore handleException(NoSuchAlgorithmException e)
        throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    Throwable cause = e.getCause();
    if (cause instanceof InvalidAlgorithmParameterException) {
        throw (InvalidAlgorithmParameterException)cause;
    }
    throw e;
}
 
源代码3 项目: jdk1.8-source-analysis   文件: Configuration.java
private static Configuration handleException(NoSuchAlgorithmException nsae)
            throws NoSuchAlgorithmException {
    Throwable cause = nsae.getCause();
    if (cause instanceof IllegalArgumentException) {
        throw (IllegalArgumentException)cause;
    }
    throw nsae;
}
 
源代码4 项目: openjdk-8   文件: Configuration.java
private static Configuration handleException(NoSuchAlgorithmException nsae)
            throws NoSuchAlgorithmException {
    Throwable cause = nsae.getCause();
    if (cause instanceof IllegalArgumentException) {
        throw (IllegalArgumentException)cause;
    }
    throw nsae;
}
 
源代码5 项目: jdk8u-jdk   文件: CertStore.java
private static CertStore handleException(NoSuchAlgorithmException e)
        throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    Throwable cause = e.getCause();
    if (cause instanceof InvalidAlgorithmParameterException) {
        throw (InvalidAlgorithmParameterException)cause;
    }
    throw e;
}
 
源代码6 项目: j2objc   文件: CertStore.java
private static CertStore handleException(NoSuchAlgorithmException e)
        throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    Throwable cause = e.getCause();
    if (cause instanceof InvalidAlgorithmParameterException) {
        throw (InvalidAlgorithmParameterException)cause;
    }
    throw e;
}
 
源代码7 项目: jdk8u_jdk   文件: CertStore.java
private static CertStore handleException(NoSuchAlgorithmException e)
        throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    Throwable cause = e.getCause();
    if (cause instanceof InvalidAlgorithmParameterException) {
        throw (InvalidAlgorithmParameterException)cause;
    }
    throw e;
}
 
源代码8 项目: TencentKona-8   文件: Configuration.java
private static Configuration handleException(NoSuchAlgorithmException nsae)
            throws NoSuchAlgorithmException {
    Throwable cause = nsae.getCause();
    if (cause instanceof IllegalArgumentException) {
        throw (IllegalArgumentException)cause;
    }
    throw nsae;
}
 
源代码9 项目: TencentKona-8   文件: Utils.java
static TerminalFactory getTerminalFactory(String provName) throws Exception {
    try {
        TerminalFactory factory = (provName == null)
                ? TerminalFactory.getInstance("PC/SC", null)
                : TerminalFactory.getInstance("PC/SC", null, provName);
        System.out.println(factory);
        return factory;
    } catch (NoSuchAlgorithmException e) {
        Throwable cause = e.getCause();
        if (cause != null && cause.getMessage().startsWith("PC/SC not available")) {
            return null;
        }
        throw e;
    }
}
 
源代码10 项目: TencentKona-8   文件: Utils.java
static CardTerminal getTerminal(String[] args, String provider) throws Exception {
    setLibrary(args);

    try {
        TerminalFactory factory = (provider == null)
                ? TerminalFactory.getInstance("PC/SC", null)
                : TerminalFactory.getInstance("PC/SC", null, provider);
        System.out.println(factory);

        List<CardTerminal> terminals = factory.terminals().list();
        System.out.println("Terminals: " + terminals);
        if (terminals.isEmpty()) {
            return null;
        }
        CardTerminal terminal = terminals.get(0);

        if (terminal.isCardPresent() == false) {
            System.out.println("*** Insert card");
            if (terminal.waitForCardPresent(20 * 1000) == false) {
                throw new Exception("no card available");
            }
        }
        System.out.println("card present: " + terminal.isCardPresent());

        return terminal;

    } catch (NoSuchAlgorithmException e) {
        Throwable cause = e.getCause();
        if (cause != null && cause.getMessage().startsWith("PC/SC not available")) {
            return null;
        }
        throw e;
    }
}
 
源代码11 项目: jdk-1.7-annotated   文件: CertStore.java
private static CertStore handleException(NoSuchAlgorithmException e)
        throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    Throwable cause = e.getCause();
    if (cause instanceof InvalidAlgorithmParameterException) {
        throw (InvalidAlgorithmParameterException)cause;
    }
    throw e;
}
 
源代码12 项目: openjdk-8   文件: CertStore.java
private static CertStore handleException(NoSuchAlgorithmException e)
        throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    Throwable cause = e.getCause();
    if (cause instanceof InvalidAlgorithmParameterException) {
        throw (InvalidAlgorithmParameterException)cause;
    }
    throw e;
}
 
源代码13 项目: jdk8u-jdk   文件: CertStore.java
private static CertStore handleException(NoSuchAlgorithmException e)
        throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    Throwable cause = e.getCause();
    if (cause instanceof InvalidAlgorithmParameterException) {
        throw (InvalidAlgorithmParameterException)cause;
    }
    throw e;
}
 
源代码14 项目: staash   文件: TestChunking.java
public boolean compareMD5(byte[] written, byte[] read) {
	try {
		MessageDigest md = MessageDigest.getInstance(ENC1);
		byte[] wdigest = md.digest(written);
		byte[] rdigest = md.digest(read);
		return Arrays.equals(wdigest, rdigest);
	} catch (NoSuchAlgorithmException e) {
		// TODO Auto-generated catch block
		throw new RuntimeException(e.getCause());
	}
}
 
源代码15 项目: openjdk-jdk9   文件: CertStore.java
private static CertStore handleException(NoSuchAlgorithmException e)
        throws NoSuchAlgorithmException,
        InvalidAlgorithmParameterException {
    Throwable cause = e.getCause();
    if (cause instanceof InvalidAlgorithmParameterException) {
        throw (InvalidAlgorithmParameterException)cause;
    }
    throw e;
}
 
源代码16 项目: openjdk-jdk8u-backup   文件: Utils.java
static CardTerminal getTerminal(String[] args, String provider) throws Exception {
    setLibrary(args);

    try {
        TerminalFactory factory = (provider == null)
                ? TerminalFactory.getInstance("PC/SC", null)
                : TerminalFactory.getInstance("PC/SC", null, provider);
        System.out.println(factory);

        List<CardTerminal> terminals = factory.terminals().list();
        System.out.println("Terminals: " + terminals);
        if (terminals.isEmpty()) {
            return null;
        }
        CardTerminal terminal = terminals.get(0);

        if (terminal.isCardPresent() == false) {
            System.out.println("*** Insert card");
            if (terminal.waitForCardPresent(20 * 1000) == false) {
                throw new Exception("no card available");
            }
        }
        System.out.println("card present: " + terminal.isCardPresent());

        return terminal;

    } catch (NoSuchAlgorithmException e) {
        Throwable cause = e.getCause();
        if (cause != null && cause.getMessage().startsWith("PC/SC not available")) {
            return null;
        }
        throw e;
    }
}
 
源代码17 项目: openjdk-jdk9   文件: Utils.java
static CardTerminal getTerminal(String[] args, String provider) throws Exception {
    setLibrary(args);

    try {
        TerminalFactory factory = (provider == null)
                ? TerminalFactory.getInstance("PC/SC", null)
                : TerminalFactory.getInstance("PC/SC", null, provider);
        System.out.println(factory);

        List<CardTerminal> terminals = factory.terminals().list();
        System.out.println("Terminals: " + terminals);
        if (terminals.isEmpty()) {
            return null;
        }
        CardTerminal terminal = terminals.get(0);

        if (terminal.isCardPresent() == false) {
            System.out.println("*** Insert card");
            if (terminal.waitForCardPresent(20 * 1000) == false) {
                throw new Exception("no card available");
            }
        }
        System.out.println("card present: " + terminal.isCardPresent());

        return terminal;

    } catch (NoSuchAlgorithmException e) {
        Throwable cause = e.getCause();
        if (cause != null && cause.getMessage().startsWith("PC/SC not available")) {
            return null;
        }
        throw e;
    }
}
 
源代码18 项目: Bytecoder   文件: Configuration.java
private static Configuration handleException(NoSuchAlgorithmException nsae)
            throws NoSuchAlgorithmException {
    Throwable cause = nsae.getCause();
    if (cause instanceof IllegalArgumentException) {
        throw (IllegalArgumentException)cause;
    }
    throw nsae;
}
 
源代码19 项目: openjdk-jdk8u   文件: CertStore.java
private static CertStore handleException(NoSuchAlgorithmException e)
        throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
    Throwable cause = e.getCause();
    if (cause instanceof InvalidAlgorithmParameterException) {
        throw (InvalidAlgorithmParameterException)cause;
    }
    throw e;
}
 
源代码20 项目: axelor-open-suite   文件: EbicsUtils.java
/**
 * Generates a random nonce.
 *
 * <p>EBICS Specification 2.4.2 - 11.6 Generation of the transaction IDs:
 *
 * <p>Transaction IDs are cryptographically-strong random numbers with a length of 128 bits. This
 * means that the likelihood of any two bank systems using the same transaction ID at the same
 * time is sufficiently small.
 *
 * <p>Transaction IDs are generated by cryptographic pseudo-random number generators (PRNG) that
 * have been initialized with a real random number (seed). The entropy of the seed should be at
 * least 100 bits.
 *
 * @return a random nonce.
 * @throws EbicsException nonce generation fails.
 */
public static byte[] generateNonce() throws AxelorException {
  SecureRandom secureRandom;

  try {
    secureRandom = SecureRandom.getInstance("SHA1PRNG");
    return secureRandom.generateSeed(16);
  } catch (NoSuchAlgorithmException e) {
    throw new AxelorException(e.getCause(), TraceBackRepository.TYPE_FUNCTIONNAL, e.getMessage());
  }
}