Code example for GeneralSecurityException

    public static SecretKey generateSecretKey(PrivateKey privateKey, PublicKey publicKey) throws NoSuchAlgorithmException, GeneralSecurityException {
        if(privateKey == null)
        	throw new GeneralSecurityException("Missing private key");
        if(publicKey == null)
        	throw new GeneralSecurityException("Missing public key");
    	KeyAgreement ka = KeyAgreement.getInstance(KEY_EXCHANGE_PROTOCOL);
        ka.doPhase(publicKey, true);
        SecretKey secretKey = ka.generateSecret(ENCRYPTION_ALGORITHM);        
        return secretKey; 
     * Get a list of the currently stored public keys, excluding your own. Hashmap with number and description 
Connect your IDE to all the code out there  Get Codota for Java