Package org.broadinstitute.gatk.utils.exceptions

Examples of org.broadinstitute.gatk.utils.exceptions.ReviewedGATKException


    public static SecureRandom createRandomnessSource ( String randAlgorithm ) {
        try {
            return SecureRandom.getInstance(randAlgorithm);
        }
        catch ( NoSuchAlgorithmException e ) {
            throw new ReviewedGATKException(String.format("Could not find an implementation of the requested random-number generation algorithm %s", randAlgorithm), e);
        }
    }
View Full Code Here


            KeySpec keySpec = new X509EncodedKeySpec(rawKey);
            KeyFactory keyFactory = KeyFactory.getInstance(encryptionAlgorithm);
            return keyFactory.generatePublic(keySpec);
        }
        catch ( NoSuchAlgorithmException e ) {
            throw new ReviewedGATKException(String.format("Could not find an implementation of the requested encryption algorithm %s", encryptionAlgorithm), e);
        }
        catch ( InvalidKeySpecException e ) {
            throw new ReviewedGATKException("Unable to use X.509 key specification to decode the given key", e);
        }
    }
View Full Code Here

            KeySpec keySpec = new PKCS8EncodedKeySpec(rawKey);
            KeyFactory keyFactory = KeyFactory.getInstance(encryptionAlgorithm);
            return keyFactory.generatePrivate(keySpec);
        }
        catch ( NoSuchAlgorithmException e ) {
            throw new ReviewedGATKException(String.format("Could not find an implementation of the requested encryption algorithm %s", encryptionAlgorithm), e);
        }
        catch ( InvalidKeySpecException e ) {
            throw new ReviewedGATKException("Unable to use the PKCS #8 key specification to decode the given key", e);
        }
    }
View Full Code Here

     */
    public static PublicKey loadGATKDistributedPublicKey() {
        InputStream publicKeyInputStream = ClassLoader.getSystemResourceAsStream(GATK_DISTRIBUTED_PUBLIC_KEY_FILE_NAME);

        if ( publicKeyInputStream == null ) {
            throw new ReviewedGATKException(String.format("Could not locate the GATK public key %s in the classpath",
                                                           GATK_DISTRIBUTED_PUBLIC_KEY_FILE_NAME));
        }

        return readPublicKey(publicKeyInputStream);
    }
View Full Code Here

            Cipher cipher = Cipher.getInstance(key.getAlgorithm());
            cipher.init(cipherMode, key);
            return cipher.doFinal(data);
        }
        catch ( NoSuchAlgorithmException e ) {
            throw new ReviewedGATKException(String.format("Could not find an implementation of the requested algorithm %s",
                                             key.getAlgorithm()), e);
        }
        catch ( InvalidKeyException e ) {
            throw new ReviewedGATKException("Key is invalid", e);
        }
        catch ( GeneralSecurityException e ) {
            throw new ReviewedGATKException("Error during encryption", e);
        }
    }
View Full Code Here

     * @param readBufferSize Number of bytes to read in at one time
     * @return The contents of the file as a byte array
     */
    public static byte[] readFileIntoByteArray ( File source, int readBufferSize ) {
        if ( source == null ) {
            throw new ReviewedGATKException("Source file was null");
        }

        byte[] fileContents;

        try {
View Full Code Here

     * @param readBufferSize Number of bytes to read in at one time
     * @return The contents of the stream as a byte array
     */
    public static byte[] readStreamIntoByteArray ( InputStream in, int readBufferSize ) {
        if ( in == null ) {
            throw new ReviewedGATKException("Input stream was null");
        }
        else if ( readBufferSize <= 0 ) {
            throw new ReviewedGATKException("Read buffer size must be > 0");
        }

        // Use a fixed-size buffer for each read, but a dynamically-growing buffer
        // to hold the accumulated contents of the file/stream:
        byte[] readBuffer = new byte[readBufferSize];
View Full Code Here

     * @param bytes Data to write
     * @param destination File to write the data to
     */
    public static void writeByteArrayToFile ( byte[] bytes, File destination ) {
        if ( destination == null ) {
            throw new ReviewedGATKException("Destination file was null");
        }

        try {
            writeByteArrayToStream(bytes, new FileOutputStream(destination));
        }
View Full Code Here

     * @param bytes Data to write
     * @param out Stream to write the data to
     */
    public static void writeByteArrayToStream ( byte[] bytes, OutputStream out ) {
        if ( bytes == null || out == null ) {
            throw new ReviewedGATKException("Data to write or output stream was null");
        }

        try {
            try {
                out.write(bytes);
View Full Code Here

     * @param gzipFile GZIP-format file whose uncompressed size to determine
     * @return The uncompressed size (in bytes) of the GZIP file
     */
    public static int getGZIPFileUncompressedSize ( File gzipFile ) {
        if ( gzipFile == null ) {
            throw new ReviewedGATKException("GZIP file to examine was null");
        }

        try {
            // The GZIP ISIZE field holds the uncompressed size of the compressed data.
            // It occupies the last 4 bytes of any GZIP file:
View Full Code Here

TOP

Related Classes of org.broadinstitute.gatk.utils.exceptions.ReviewedGATKException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.