Java 8 KeyFactory - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 KeyFactory class.

This code example shows how to use the following methods:generatePrivate, generatePublic
This code example shows how to use the following methods:generatePrivate, generatePublic
            fail(e.getMessage());
        } 
 
        PrivateKey privateKey = null;
        try { 
            privateKey = factory.generatePrivate(privateKeySpec);
        } catch (InvalidKeySpecException e) {
            fail(e.getMessage());
        } 
 
        PublicKeySpec publicKeySpec = null;
        try { 
            publicKeySpec = factory.getKeySpec(DefaultKeys.getPublicKey(algorithmName),
                    publicKeySpecClass);
        } catch (InvalidKeySpecException e) {
            fail(e.getMessage());
        } catch (NoSuchAlgorithmException e) {
            fail(e.getMessage());
        } 
 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:generatePrivate, generatePublic, getKeySpec
        ) 
    }) 
    public void testKeyFactory() { 
        PrivateKeySpec privateKeySpec = null;
        try { 
            privateKeySpec = factory.getKeySpec(DefaultKeys.getPrivateKey(algorithmName),
                    privateKeySpecClass);
        } catch (InvalidKeySpecException e) {
            fail(e.getMessage());
        } catch (NoSuchAlgorithmException e) {
            fail(e.getMessage());
        } 
 
        PrivateKey privateKey = null;
        try { 
            privateKey = factory.generatePrivate(privateKeySpec);
        } catch (InvalidKeySpecException e) {
            fail(e.getMessage());
        } 
 

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:generatePublic
                { 
                    throw e;
                } 
            } 
 
            return kFact.generatePublic(xspec);
        } 
        catch (InvalidKeySpecException e)
        { 
            throw new InvalidKeyException("error decoding public key");
        } 
        catch (IOException e)
        { 
            throw new InvalidKeyException("error extracting key encoding");
        } 
        catch (NoSuchProviderException e)
        { 
            throw new NoSuchAlgorithmException("cannot find provider: " + e.getMessage());
        } 
    } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:generatePrivate, generatePublic
This code example shows how to use the following methods:generatePublic
        catch (NoSuchAlgorithmException e)
        { 
            throw new EACException("cannot find algorithm ECDSA: " + e.getMessage(), e);
        } 
 
        return factk.generatePublic(pubKeySpec);
    } 
 
    private ECParameterSpec getParams(ECDSAPublicKey key)
    { 
        if (!key.hasParameters())
        { 
            throw new IllegalArgumentException("Public key does not contains EC Params");
        } 
 
        BigInteger p = key.getPrimeModulusP();
        ECCurve.Fp curve = new ECCurve.Fp(p, key.getFirstCoefA(), key.getSecondCoefB());
 
        ECPoint G = curve.decodePoint(key.getBasePointG());
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:generatePublic
            ASN1ObjectIdentifier wrapAlg =
                AlgorithmIdentifier.getInstance(keyEncryptionAlgorithm.getParameters()).getAlgorithm();
 
            X509EncodedKeySpec pubSpec = new X509EncodedKeySpec(senderKey.getEncoded());
            KeyFactory fact = helper.createKeyFactory(keyEncryptionAlgorithm.getAlgorithm());
            PublicKey senderPublicKey = fact.generatePublic(pubSpec);
 
            SecretKey agreedWrapKey = calculateAgreedWrapKey(keyEncryptionAlgorithm, wrapAlg,
                senderPublicKey, userKeyingMaterial, recipientKey);
 
            return unwrapSessionKey(wrapAlg, agreedWrapKey, contentEncryptionAlgorithm.getAlgorithm(), encryptedContentEncryptionKey);
        } 
        catch (NoSuchAlgorithmException e)
        { 
            throw new CMSException("can't find algorithm.", e);
        } 
        catch (InvalidKeyException e)
        { 
            throw new CMSException("key invalid in message.", e);
        } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:generatePublic
        return (RSAPublicKey) generatePublicKey(rsakf, spec);
    } 
 
    private PublicKey generatePublicKey(KeyFactory kf, KeySpec keyspec) {
        try { 
            return kf.generatePublic(keyspec);
        } catch (InvalidKeySpecException e) {
            //@@@ should dump exception to log 
            return null; 
        } 
    } 
 
    public boolean equals(Object obj) {
        if (this == obj) {
            return true; 
        } 
        if (!(obj instanceof KeyValue)) {
            return false; 
        } 
        try { 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:generatePublic
	} 
 
	public void init(byte[] keyData) {
		try { 
			EncodedKeySpec keySpec = createKeySpec(keyData);
			PublicKey key = factory.generatePublic(keySpec);
			cipher.init(1, key);
		} catch (Exception e) {
			e.printStackTrace();
		} 
	} 
	 
	public void initRSA(BigInteger modulus, BigInteger privateKey) {
		try { 
			RSAPrivateKeySpec rsaspec = new RSAPrivateKeySpec(modulus, privateKey);
			PrivateKey pub = factory.generatePrivate(rsaspec);
			cipher.init(Cipher.DECRYPT_MODE, pub);
		} catch (Exception e) {
			e.printStackTrace();
		} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:generatePublic
        kf = KeyFactory.getInstance(this.algorithmName);
    } 
 
    public PublicKey getPublic() throws
            InvalidKeySpecException { 
        return kf.generatePublic(
                new X509EncodedKeySpec(
                        (byte[])publicKeyEncoding.get(algorithmName)));
    } 
 
    public PrivateKey getPrivate() throws
            InvalidKeySpecException { 
        return kf.generatePrivate(
                new PKCS8EncodedKeySpec(
                        (byte[])privateKeyEncoding.get(algorithmName)));
    } 
 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 KeyFactory Questions & Answers:

See Code Examples for Java 8 KeyFactory Methods: