use of org.teiid.core.util.ObjectInputStreamWithClassloader in project teiid by teiid.
the class BasicCryptor method unsealObject.
public synchronized Object unsealObject(Object object) throws CryptoException {
if (useSealedObject) {
if (!(object instanceof SealedObject)) {
return object;
}
SealedObject so = (SealedObject) object;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
if (cl != classLoader) {
Thread.currentThread().setContextClassLoader(BasicCryptor.class.getClassLoader());
}
return so.getObject(decryptCipher);
} catch (Exception e) {
try {
initDecryptCipher();
} catch (CryptoException err) {
// shouldn't happen
}
throw new CryptoException(CorePlugin.Event.TEIID10006, CorePlugin.Util.gs(CorePlugin.Event.TEIID10006, e.getClass().getName(), e.getMessage()));
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
if (!(object instanceof byte[])) {
return object;
}
byte[] bytes = (byte[]) object;
bytes = decrypt(bytes);
try {
ObjectInputStream ois = new ObjectInputStreamWithClassloader(new ByteArrayInputStream(bytes), classLoader);
return ois.readObject();
} catch (Exception e) {
throw new CryptoException(CorePlugin.Event.TEIID10006, CorePlugin.Util.gs(CorePlugin.Event.TEIID10006, e.getClass().getName(), e.getMessage()));
}
}
Aggregations