Search in sources :

Example 41 with ObjectInputStream

use of java.io.ObjectInputStream in project tdi-studio-se by Talend.

the class JetSkeletonManager method deserializeAlreadyChecked.

@SuppressWarnings("unchecked")
private void deserializeAlreadyChecked() throws Exception {
    alreadyCheckedSkeleton = new HashMap<String, Long>();
    File file = getSerializationFilePath();
    if (!file.exists()) {
        return;
    }
    BufferedInputStream bufferedInputStream = null;
    try {
        bufferedInputStream = new BufferedInputStream(new FileInputStream(file));
        ObjectInputStream objectIn = new ObjectInputStream(bufferedInputStream);
        alreadyCheckedSkeleton = (Map<String, Long>) objectIn.readObject();
    } catch (Exception e) {
        throw e;
    } finally {
        try {
            bufferedInputStream.close();
        } catch (Exception e) {
        // ignore me even if i'm null
        }
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) IFile(org.eclipse.core.resources.IFile) File(java.io.File) FileInputStream(java.io.FileInputStream) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ObjectInputStream(java.io.ObjectInputStream)

Example 42 with ObjectInputStream

use of java.io.ObjectInputStream in project android_frameworks_base by ResurrectionRemix.

the class SerializedFrame method deserializeObjectValue.

private final Object deserializeObjectValue() {
    try {
        InputStream inputStream = mByteOutputStream.getInputStream();
        ObjectInputStream objectStream = new ObjectInputStream(inputStream);
        return objectStream.readObject();
    } catch (IOException e) {
        throw new RuntimeException("Could not deserialize object in " + this + "!", e);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException("Unable to deserialize object of unknown class in " + this + "!", e);
    }
}
Also used : ObjectInputStream(java.io.ObjectInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) ObjectInputStream(java.io.ObjectInputStream)

Example 43 with ObjectInputStream

use of java.io.ObjectInputStream in project opennms by OpenNMS.

the class JCEKSSecureCredentialsVault method fromBase64EncodedByteArray.

private static <T extends Serializable> T fromBase64EncodedByteArray(byte[] bytes) throws IOException, ClassNotFoundException {
    byte[] decodedBytes = Base64.decodeBase64(bytes);
    ByteArrayInputStream bais = new ByteArrayInputStream(decodedBytes);
    ObjectInputStream in = new ObjectInputStream(bais);
    @SuppressWarnings("unchecked") T o = (T) in.readObject();
    in.close();
    return o;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 44 with ObjectInputStream

use of java.io.ObjectInputStream in project OpenAM by OpenRock.

the class SessionService method decrypt.

/**
     * This method is used to decrypt the InternalSession object, after
     * obtaining from HttpSession.
     *
     * @param strEncrypted Object to be decrypted
     */
private InternalSession decrypt(String strEncrypted) {
    if (strEncrypted == null)
        return null;
    String strDecrypted;
    byte[] byteDecrypted = null;
    ByteArrayInputStream byteIn;
    ObjectInputStream objInStream;
    Object tempObject = null;
    try {
        // decrypt string
        strDecrypted = AccessController.doPrivileged(new DecodeAction(strEncrypted, Crypt.getHardcodedKeyEncryptor()));
        // convert string to byte
        byteDecrypted = Base64.decode(strDecrypted);
        // convert byte to object using streams
        byteIn = new ByteArrayInputStream(byteDecrypted);
        objInStream = new ObjectInputStream(byteIn);
        tempObject = objInStream.readObject();
    } catch (Exception e) {
        sessionDebug.message("Error in decrypting the Internal Session object" + e.getMessage());
        return null;
    }
    if (tempObject == null) {
        return null;
    }
    return (InternalSession) tempObject;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DecodeAction(com.sun.identity.security.DecodeAction) DelegationException(com.sun.identity.delegation.DelegationException) SSOException(com.iplanet.sso.SSOException) InterruptedIOException(java.io.InterruptedIOException) IdRepoException(com.sun.identity.idm.IdRepoException) ConnectException(java.net.ConnectException) SessionException(com.iplanet.dpro.session.SessionException) CoreTokenException(org.forgerock.openam.cts.exceptions.CoreTokenException) ObjectInputStream(java.io.ObjectInputStream)

Example 45 with ObjectInputStream

use of java.io.ObjectInputStream in project screenbird by adamhub.

the class FileUtil method readObjectDataFromFile.

public static Object readObjectDataFromFile(String name) {
    Object obj = new Object();
    try {
        FileInputStream fin = new FileInputStream(Settings.SCREEN_CAPTURE_DIR + name);
        ObjectInputStream ois = new ObjectInputStream(fin);
        obj = ois.readObject();
        ois.close();
    } catch (ClassNotFoundException e) {
        log(e);
    } catch (IOException e) {
        log(e);
    }
    return obj;
}
Also used : IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

ObjectInputStream (java.io.ObjectInputStream)2159 ByteArrayInputStream (java.io.ByteArrayInputStream)1406 ObjectOutputStream (java.io.ObjectOutputStream)970 ByteArrayOutputStream (java.io.ByteArrayOutputStream)807 IOException (java.io.IOException)752 Test (org.junit.Test)458 FileInputStream (java.io.FileInputStream)339 File (java.io.File)197 InputStream (java.io.InputStream)157 ArrayList (java.util.ArrayList)90 BufferedInputStream (java.io.BufferedInputStream)84 Serializable (java.io.Serializable)66 FileNotFoundException (java.io.FileNotFoundException)64 FileOutputStream (java.io.FileOutputStream)63 HashMap (java.util.HashMap)63 Socket (java.net.Socket)49 Map (java.util.Map)48 ObjectInput (java.io.ObjectInput)45 GZIPInputStream (java.util.zip.GZIPInputStream)44 List (java.util.List)37