Java 8 GeneralSecurityException - 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 GeneralSecurityException class.

This code example shows how to use the following methods:getMessage
signature.setParameter(sigParams.getParameterSpec(PSSParameterSpec.class));
                } 
                catch (GeneralSecurityException e)
                { 
                    throw new SignatureException("Exception extracting parameters: " + e.getMessage());
                } 
            } 
        } 
    } 
     
    static String getSignatureName(
        AlgorithmIdentifier sigAlgId) 
    { 
        DEREncodable params = sigAlgId.getParameters();
         
        if (params != null && !derNull.equals(params))
        { 
            // BEGIN android-removed 
            // if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS)) 
7
CodeRank
This code example shows how to use the following methods:getMessage
signature.setParameter(sigParams.getParameterSpec(PSSParameterSpec.class));
                } 
                catch (GeneralSecurityException e)
                { 
                    throw new SignatureException("Exception extracting parameters: " + e.getMessage());
                } 
            } 
        } 
    } 
     
    static String getSignatureName(
        AlgorithmIdentifier sigAlgId) 
    { 
        DEREncodable params = sigAlgId.getParameters();
         
        if (params != null && !derNull.equals(params))
        { 
            // BEGIN android-removed 
            // if (sigAlgId.getObjectId().equals(PKCSObjectIdentifiers.id_RSASSA_PSS)) 
6
CodeRank
This code example shows how to use the following methods:getMessage
 
            return keyEncryptionCipher.wrap(contentEncryptionKeySpec);
        } 
        catch (GeneralSecurityException e)
        { 
            throw new CMSException("cannot process content encryption key: " + e.getMessage(), e);
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getMessage
 
            return mac.doFinal(data);
        } 
        catch (GeneralSecurityException e)
        { 
            throw new CRMFException("failure in setup: " + e.getMessage(), e);
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getCause, getMessage
     * Test for <code>GeneralSecurityException(String, Throwable)</code> 
     * constructor Assertion: constructs GeneralSecurityException when 
     * <code>cause</code> is not null <code>msg</code> is null 
     */ 
    public void testGeneralSecurityException08() { 
        GeneralSecurityException tE = new GeneralSecurityException(null, tCause);
        if (tE.getMessage() != null) {
            String toS = tCause.toString();
            String getM = tE.getMessage();
            assertTrue("getMessage() must should ".concat(toS), (getM
                    .indexOf(toS) != -1));
        } 
        assertNotNull("getCause() must not return null", tE.getCause());
        assertEquals("getCause() must return ".concat(tCause.toString()), tE
                .getCause(), tCause);
    } 
 
    /** 
     * Test for <code>GeneralSecurityException(String, Throwable)</code> 
     * constructor Assertion: constructs GeneralSecurityException when 
6
CodeRank
This code example shows how to use the following methods:getMessage
 
            return keyEncryptionCipher.unwrap(encryptedContentEncryptionKey, contentEncryptionAlgorithm.getAlgorithm().getId(), Cipher.SECRET_KEY);
        } 
        catch (GeneralSecurityException e)
        { 
            throw new CMSException("cannot process content encryption key: " + e.getMessage(), e);
        } 
    } 
 
    public int getPasswordConversionScheme() 
    { 
        return schemeID;
    } 
 
    public char[] getPassword() 
    { 
        return password;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
                storeValidator(validator);
            } 
            else { 
                rawKey = loadKeyData();
                if (!checkKeyValid(rawKey, loadValidator())) {
                    throw new GeneralSecurityException("Stored key is incorrect or corrupt.");
                } 
            } 
            return new SecretKeySpec(rawKey, getAlgorithm());
        } finally { 
            zeroFill(rawKey);
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getMessage
cipher.init(Cipher.ENCRYPT_MODE, encKey, params, random);
            } 
            catch (GeneralSecurityException e)
            { 
                throw new CRMFException("unable to initialize cipher: " + e.getMessage(), e);
            } 
 
            // 
            // If params are null we try and second guess on them as some providers don't provide 
            // algorithm parameter generation explicity but instead generate them under the hood. 
            // 
            if (params == null)
            { 
                params = cipher.getParameters();
            } 
 
            algorithmIdentifier = helper.getAlgorithmIdentifier(encryptionOID, params);
        } 
 
6
CodeRank
This code example shows how to use the following methods:printStackTrace
 
    public void setEncryptedSharedKey(byte[] encryptedSharedKey) {
      try { 
        sharedKey = decryptSharedKey(encryptedSharedKey, keyPair.getPrivate());
      } catch (GeneralSecurityException e) {
        e.printStackTrace();
      } 
    } 
 
    public String getLoginHash(String name) throws NoSuchAlgorithmException, UnsupportedEncodingException {
      return new BigInteger(loginHash(name, keyPair.getPublic(), sharedKey)).toString(16);
    } 
 
    public byte[] getPublicKey() { 
      return keyPair.getPublic().getEncoded();
    } 
 
    public boolean checkChallengeToken(byte[] challengeTokenResponse) {
      try { 
        return Arrays.equals(encrypt(keyPair.getPrivate(), challengeTokenResponse, 2), challengeToken);
6
CodeRank
This code example shows how to use the following methods:getMessage
 
            return keyEncryptionCipher.wrap(contentEncryptionKeySpec);
        } 
        catch (GeneralSecurityException e)
        { 
            throw new OperatorException("cannot wrap key: " + e.getMessage(), e);
        } 
    } 
 
    private static AlgorithmIdentifier determineKeyEncAlg(SecretKey key)
    { 
        String algorithm = key.getAlgorithm();
 
        if (algorithm.startsWith("DES"))
        { 
            return new AlgorithmIdentifier(new ASN1ObjectIdentifier( 
                    "1.2.840.113549.1.9.16.3.6"), DERNull.INSTANCE); 
        } 
        else if (algorithm.startsWith("RC2"))
        { 
6
CodeRank
This code example shows how to use the following methods:
     *             if false, validate the input against existing key data 
     * 
     */ 
    public void feedUserInput(char [] input, boolean init)
        throws IOException, GeneralSecurityException { 
        throw new GeneralSecurityException("User input is not required.");
    } 
     
    public boolean isInitialized() { 
        return validatorFile.isFile() && paramsFile.isFile();
    } 
 
    /**  
     * resets cipher internally.  Prior state information  
     * (initialization vectors, validators) will be destroyed.  
     * isInitialized will return false following this call. 
     */ 
    public void reset() throws IOException { 
        localKey = null;
        FileUtils.forceDelete(paramsFile);
5
CodeRank
This code example shows how to use the following methods:
   *  
   * @throws GeneralSecurityException 
   */ 
  public static byte[] hmacSha1(byte[] key, byte[] in) throws GeneralSecurityException {
    if (key.length < MIN_HMAC_KEY_LEN) {
      throw new GeneralSecurityException("HMAC key should be at least "
          + MIN_HMAC_KEY_LEN + " bytes.");
    } 
    Mac hmac = Mac.getInstance(HMAC_TYPE);
    Key hmacKey = new SecretKeySpec(key, HMAC_TYPE);
    hmac.init(hmacKey);
    hmac.update(in);
    return hmac.doFinal();
  } 
   
  /** 
   * Verifies an HMAC SHA1 hash.  Throws if the verification fails. 
   *  
   * @param key 
   * @param in 
5
CodeRank
This code example shows how to use the following methods:getMessage
	private CertificateCreator createCertificateCreator() throws ProxySSLInitializationException { 
		try { 
			certificateStore = new CertificateStore(storeDirectory, "foo");
			return new CertificateCreator(certificateStore);
		} catch (GeneralSecurityException e) {
			throw new ProxySSLInitializationException("Failed to create certificate creator: "+ e.getMessage(), e);
		} catch (IOException e) {
			throw new ProxySSLInitializationException("I/O error creating certificate creator: "+ e.getMessage(), e);
		} 
	} 
 
	private SSLContext createContextForName(String name) throws GeneralSecurityException {
		final HostCertificateData hostCertificateData = certificateCreator.createCertificateDataFor(name);
		final X509KeyManager km = new VegaX509KeyManager(hostCertificateData);
		final SSLContext ctx = SSLContext.getInstance("SSLv3");
		ctx.init(new KeyManager[] {km}, null, null);
		return ctx;
	} 
} 
5
CodeRank
This code example shows how to use the following methods:
            CertificateFactory cf = CertificateFactory.getInstance("X.509");
            X509Certificate cert = (X509Certificate)cf.generateCertificate(fis);
            cert.checkValidity();
            String cn = CertUtil.getSubjectValue(cert, "CN");
            if (!keyName.equals(cn))
                throw new GeneralSecurityException("CN mismatch: " + cn);
            return cert.getPublicKey();
        } finally { 
            try { if (fis != null) fis.close(); } catch (IOException foo) {}
        } 
    } 
 
    public void setKey(String keyName, String scope, PublicKey key) {}
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
signature.setParameter(sigParams.getParameterSpec(PSSParameterSpec.class));
                } 
                catch (GeneralSecurityException e)
                { 
                    throw new SignatureException("Exception extracting parameters: " + e.getMessage());
                } 
            } 
        } 
    } 
     
    static String getSignatureName(
        AlgorithmIdentifier sigAlgId) 
    { 
        ASN1Encodable params = sigAlgId.getParameters();
         
        if (params != null && !derNull.equals(params))
        { 
            if (sigAlgId.getAlgorithm().equals(PKCSObjectIdentifiers.id_RSASSA_PSS))
            { 
5
CodeRank
This code example shows how to use the following methods:getMessage
 
            return mac.doFinal(data);
        } 
        catch (GeneralSecurityException e)
        { 
            throw new CRMFException("failure in setup: " + e.getMessage(), e);
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
 
            return keyEncryptionCipher.wrap(contentEncryptionKeySpec);
        } 
        catch (GeneralSecurityException e)
        { 
            throw new CMSException("cannot process content encryption key: " + e.getMessage(), e);
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
cipher.init(Cipher.ENCRYPT_MODE, encKey, params, random);
            } 
            catch (GeneralSecurityException e)
            { 
                throw new CRMFException("unable to initialize cipher: " + e.getMessage(), e);
            } 
 
            // 
            // If params are null we try and second guess on them as some providers don't provide 
            // algorithm parameter generation explicity but instead generate them under the hood. 
            // 
            if (params == null)
            { 
                params = cipher.getParameters();
            } 
 
            algorithmIdentifier = helper.getAlgorithmIdentifier(encryptionOID, params);
        } 
 
5
CodeRank
This code example shows how to use the following methods:getMessage
            // Validate certification path 
            CertPathValidator.getInstance("PKIX").validate(buildResult.getCertPath(),pbParams);
        } 
        catch (GeneralSecurityException gse)
        { 
            LOG.debug(gse);
            throw new CertificateException("Unable to validate certificate: " + gse.getMessage(), gse);
        } 
    } 
 
    public KeyStore getTrustStore()
    { 
        return _trustStore;
    } 
 
    public Collection<? extends CRL> getCrls()
    { 
        return _crls;
    } 
 
5
CodeRank
This code example shows how to use the following methods:getMessage
 
            return keyEncryptionCipher.wrap(contentEncryptionKeySpec);
        } 
        catch (GeneralSecurityException e)
        { 
            throw new OperatorException("cannot wrap key: " + e.getMessage(), e);
        } 
    } 
 
    private static AlgorithmIdentifier determineKeyEncAlg(SecretKey key)
    { 
        String algorithm = key.getAlgorithm();
 
        if (algorithm.startsWith("DES"))
        { 
            return new AlgorithmIdentifier(new ASN1ObjectIdentifier( 
                    "1.2.840.113549.1.9.16.3.6"), DERNull.INSTANCE); 
        } 
        else if (algorithm.startsWith("RC2"))
        { 
5
CodeRank
This code example shows how to use the following methods:getMessage
            { 
                throw new CMSException("unable to initialize cipher: " + e.getMessage(), e);
            } 
            catch (GeneralSecurityException e)
            { 
                throw new CMSException("unable to initialize cipher: " + e.getMessage(), e);
            } 
 
            // 
            // If params are null we try and second guess on them as some providers don't provide 
            // algorithm parameter generation explicity but instead generate them under the hood. 
            // 
            if (params == null)
            { 
                params = cipher.getParameters();
            } 
 
            algorithmIdentifier = helper.getAlgorithmIdentifier(encryptionOID, params);
        } 
 
5
CodeRank
This code example shows how to use the following methods:getMessage
            throw new AuthSSLInitializationError("Unsupported algorithm exception: " + e.getMessage());
        } catch (KeyStoreException e) {
            LOGGER.error(e.getMessage(), e);
            throw new AuthSSLInitializationError("Keystore exception: " + e.getMessage());
        } catch (GeneralSecurityException e) {
            LOGGER.error(e.getMessage(), e);
            throw new AuthSSLInitializationError("Key management exception: " + e.getMessage());
        } catch (IOException e) {
            LOGGER.error(e.getMessage(), e);
            throw new AuthSSLInitializationError("I/O error reading keystore/truststore file: " + e.getMessage());
        } 
    } 
 
     public SSLContext getSSLContext() {
        if (this.sslcontext == null) {
            this.sslcontext = createSSLContext();
        } 
        return this.sslcontext;
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
        try 
        { 
            return generate(); 
        } catch (GeneralSecurityException e)
        { 
            throw new RuntimeOperatorException("exception obtaining signature: " + e.getMessage(), e);
        } 
    } 
 
    @Override 
    public boolean verify(byte[] signature)
    { 
        return this.signer.verifySignature(signature);
    } 
 
    @Override 
    public boolean verify(byte[] signature, byte[] input) throws GeneralSecurityException
    { 
        update(input);
        return verify(signature);
5
CodeRank
This code example shows how to use the following methods:getMessage
                throw new CredentialException("Key encrypted, password required"); 
            } else { 
                try { 
                    this.opensslKey.decrypt(password);
                } catch (GeneralSecurityException exp) {
                    throw new CredentialException(exp.getMessage(), exp);
                } 
            } 
        } 
        return this.opensslKey.getPrivateKey();
 
    } 
 
    public boolean isEncryptedKey() { 
        return this.opensslKey.isEncrypted();
    } 
 
    /** 
     * Reads Base64 encoded data from the stream and returns its decoded value. The reading continues until 
     * the "END" string is found in the data. Otherwise, returns null. 
5
CodeRank
This code example shows how to use the following methods:getMessage
		if (ssl) {
			if (this.sslSocketFactory == null) {
				try { 
					sslSocketFactory = SocketUtil.getSSLSocketFactory(props);
				} catch (GeneralSecurityException e) {
					 throw new CommunicationException(e, e.getMessage());
				} 
			} 
			socket = sslSocketFactory.getSocket();
		} else { 
			socket = new Socket();
		} 
		if (receiveBufferSize > 0) {
			socket.setReceiveBufferSize(receiveBufferSize);
		} 
		if (sendBufferSize > 0) {
			socket.setSendBufferSize(sendBufferSize);
		} 
	    socket.setTcpNoDelay(!conserveBandwidth); // enable Nagle's algorithm to conserve bandwidth
	    socket.connect(address);
5
CodeRank
This code example shows how to use the following methods:getMessage
			KeyFactory keyFactory = KeyFactory.getInstance("RSA");
 
			publicKey = keyFactory.generatePublic(keySpec);
		} catch (GeneralSecurityException ex) {
 
			throw new Xdi2RuntimeException("Invalid RSA public key " + string + ": " + ex.getMessage(), ex);
		} 
 
		return publicKey;
	} 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
		try { 
 
			publicKey = Keys.getSignaturePublicKey(senderXdiEntity);
		} catch (GeneralSecurityException ex) {
 
			if (log.isWarnEnabled()) log.warn("Invalid signature public key: " + ex.getMessage(), ex);
 
			return null; 
		} 
 
		// done 
 
		return publicKey;
	} 
 
	/* 
	 * Getters and setters 
	 */ 
 
	public Graph getPublicKeyGraph() { 
5
CodeRank
This code example shows how to use the following methods:getMessage
            save(bitmap_thumbnail, photo + "_thumb", QUALITY, newKey);
        } catch (IOException e) {
            Log.e("ERROR WHILE CONVERTING PHOTO", e.getMessage());
            new RuntimeException(e.getMessage());
        } catch (GeneralSecurityException e) {
            Log.e("ERROR WHILE CONVERTING PHOTO", e.getMessage());
            new RuntimeException(e.getMessage());
        } 
    } 
 
    protected Bitmap decodeStreamToBitMap(InputStream inputStream){
        return BitmapFactory.decodeStream(inputStream);
    } 
} 
5
CodeRank
This code example shows how to use the following methods:getMessage
            boolean worked = false;
            try { 
                cert = CertificateLoadUtil
                        .loadCertificate(testCert2.getAbsoluteFilename());
            } catch (GeneralSecurityException e) {
                String err = e.getMessage();
                if (err != null &&
                        err.indexOf("BEGIN CERTIFICATE") != -1) {
                    worked = true;
                } 
            } 
 
            assertTrue(worked);
        } 
    } 
 
    @Test 
    public void testLoadCrl() throws Exception { 
 
        this.testCrl1.copyFileToTemp();
5
CodeRank
This code example shows how to use the following methods:getMessage
 
            return new Fingerprints( 
                    FingerprintUtils.getFingerprint(keyProvider.getCertificate(), "MD5"),
                    FingerprintUtils.getFingerprint(keyProvider.getCertificate(), "SHA1"));
        } catch (GeneralSecurityException e) {
            setErrorMessage(e.getMessage());
        } catch (IOException e) {
            setErrorMessage(e.getMessage());
        } catch (KeytoolException e) {
            setErrorMessage(e.getMessage());
        } catch (AndroidLocationException e) {
            setErrorMessage(e.getMessage());
        } 
        return null; 
    } 
 
    /* 
     * (non-Javadoc) 
     * 
     * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) 
5
CodeRank

Related Java 8 GeneralSecurityException Questions & Answers:

See Code Examples for Java 8 GeneralSecurityException Methods: