Example usage for org.apache.commons.lang SerializationUtils deserialize

List of usage examples for org.apache.commons.lang SerializationUtils deserialize

Introduction

In this page you can find the example usage for org.apache.commons.lang SerializationUtils deserialize.

Prototype

public static Object deserialize(byte[] objectData) 

Source Link

Document

Deserializes a single Object from an array of bytes.

Usage

From source file:com.github.seqware.queryengine.plugins.runners.hbasemr.MRHBasePluginRunner.java

public static Class transferConfiguration(JobContext context, JobRunParameterInterface inter) {
    Configuration conf = context.getConfiguration();
    String[] strings = conf.getStrings(MRHBasePluginRunner.EXT_PARAMETERS);
    Logger.getLogger(PluginRunnerMapper.class.getName())
            .info("QEMapper configured with: host: "
                    + Constants.Term.HBASE_PROPERTIES.getTermValue(Map.class).toString() + " namespace: "
                    + Constants.Term.NAMESPACE.getTermValue(String.class));
    final String mapParameter = strings[SETTINGS_MAP];
    if (mapParameter != null && !mapParameter.isEmpty()) {
        Map<String, String> settingsMap = (Map<String, String>) ((Object[]) SerializationUtils
                .deserialize(Base64.decodeBase64(mapParameter)))[EXTERNAL_PARAMETERS];
        if (settingsMap != null) {
            Logger.getLogger(FeatureSetCountPlugin.class.getName())
                    .info("Settings map retrieved with " + settingsMap.size() + " entries");
            Constants.setSETTINGS_MAP(settingsMap);
        }/*from   w w  w. j  a  v  a2s .co  m*/
    }

    Logger.getLogger(PluginRunnerMapper.class.getName())
            .info("QEMapper configured with: host: "
                    + Constants.Term.HBASE_PROPERTIES.getTermValue(Map.class).toString() + " namespace: "
                    + Constants.Term.NAMESPACE.getTermValue(String.class));
    final String externalParameters = strings[EXTERNAL_PARAMETERS];
    if (externalParameters != null && !externalParameters.isEmpty()) {
        inter.setExt_parameters(
                (Object[]) SerializationUtils.deserialize(Base64.decodeBase64(externalParameters)));
    }
    final String internalParameters = strings[INTERNAL_PARAMETERS];
    if (internalParameters != null && !internalParameters.isEmpty()) {
        inter.setInt_parameters(
                (Object[]) SerializationUtils.deserialize(Base64.decodeBase64(internalParameters)));
    }
    final String sourceSets = strings[NUM_AND_SOURCE_FEATURE_SETS];
    if (sourceSets != null && !sourceSets.isEmpty()) {
        List<FeatureSet> sSets = convertBase64StrToFeatureSets(sourceSets);
        inter.setSourceSets(sSets);
    }
    final String destSetParameter = strings[DESTINATION_FEATURE_SET];
    if (destSetParameter != null && !destSetParameter.isEmpty()) {
        inter.setDestSet(SWQEFactory.getSerialization().deserialize(Base64.decodeBase64(destSetParameter),
                FeatureSet.class));
    }
    final String pluginParameter = strings[PLUGIN_CLASS];
    if (pluginParameter != null && !pluginParameter.isEmpty()) {
        Object deserialize = SerializationUtils.deserialize(Base64.decodeBase64(pluginParameter));
        Class plugin = (Class) deserialize;
        return plugin;
    }
    throw new RuntimeException("Could not determine plugin to run");
}

From source file:com.ephesoft.dcma.da.common.ExecuteUpdatePatch.java

private Map<String, BatchClass> readBatchClassSerializeFile() {
    FileInputStream fileInputStream = null;
    Map<String, BatchClass> newBatchClassMap = null;
    File serializedFile = null;//from  ww w . ja v a2 s. c  o  m
    try {
        String batchClassFilePath = dbPatchFolderLocation + File.separator
                + DataAccessConstant.BATCH_CLASS_UPDATE + SERIALIZATION_EXT;
        serializedFile = new File(batchClassFilePath);
        fileInputStream = new FileInputStream(serializedFile);
        newBatchClassMap = (Map<String, BatchClass>) SerializationUtils.deserialize(fileInputStream);
        updateFile(serializedFile, batchClassFilePath);
    } catch (IOException e) {
        LOG.info(DataAccessConstant.ERROR_DURING_READING_THE_SERIALIZED_FILE);
    } catch (Exception e) {
        LOG.error(DataAccessConstant.ERROR_DURING_DE_SERIALIZING_THE_PROPERTIES_FOR_DATABASE_UPGRADE, e);
    } finally {
        try {
            if (fileInputStream != null) {
                fileInputStream.close();
            }
        } catch (Exception e) {
            if (serializedFile != null) {
                LOG.error(DataAccessConstant.PROBLEM_CLOSING_STREAM_FOR_FILE + serializedFile.getName());
            }
        }
    }

    return newBatchClassMap;
}

From source file:info.raack.appliancelabeler.data.JDBCDatabase.java

public Map<String, Map<String, OAuthConsumerToken>> getOAuthTokensForAllUsers() {
    try {//w  w  w .  j a  v a 2s . c  o  m
        List<UserOAuthTokenCarrier> carriers = jdbcTemplate.query(queryForAllUserOAuthTokens,
                new RowMapper<UserOAuthTokenCarrier>() {

                    public UserOAuthTokenCarrier mapRow(ResultSet rs, int arg1) throws SQLException {
                        UserOAuthTokenCarrier token = new UserOAuthTokenCarrier();
                        token.userId = rs.getString("user_id");
                        Blob blob = rs.getBlob("spring_oauth_serialized_token_map");
                        Object tokenObject = SerializationUtils.deserialize(blob.getBinaryStream());
                        Map<String, OAuthConsumerToken> tokens = (Map<String, OAuthConsumerToken>) tokenObject;
                        token.tokens = tokens;

                        return token;
                    }
                });

        Map<String, Map<String, OAuthConsumerToken>> tokens = new HashMap<String, Map<String, OAuthConsumerToken>>();
        for (UserOAuthTokenCarrier carrier : carriers) {
            tokens.put(carrier.userId, carrier.tokens);
        }

        return tokens;
    } catch (Exception e) {
        throw new RuntimeException("Error while getting user tokens", e);
    }
}

From source file:com.ephesoft.dcma.da.common.ExecuteUpdatePatch.java

private void readPluginSerializeFile() {
    FileInputStream fileInputStream = null;
    File serializedFile = null;//from w  ww  .j ava2 s.  c o  m
    try {
        String pluginFilePath = dbPatchFolderLocation + File.separator + DataAccessConstant.PLUGIN_UPDATE
                + SERIALIZATION_EXT;
        serializedFile = new File(pluginFilePath);
        fileInputStream = new FileInputStream(serializedFile);
        batchClassNameVsBatchClassPluginMap = (Map<String, List<BatchClassPlugin>>) SerializationUtils
                .deserialize(fileInputStream);
        updateFile(serializedFile, pluginFilePath);
    } catch (IOException e) {
        LOG.info(DataAccessConstant.ERROR_DURING_READING_THE_SERIALIZED_FILE);
    } catch (Exception e) {
        LOG.error(DataAccessConstant.ERROR_DURING_DE_SERIALIZING_THE_PROPERTIES_FOR_DATABASE_UPGRADE, e);
    } finally {
        try {
            if (fileInputStream != null) {
                fileInputStream.close();
            }
        } catch (Exception e) {
            if (serializedFile != null) {
                LOG.error(DataAccessConstant.PROBLEM_CLOSING_STREAM_FOR_FILE + serializedFile.getName());
            }
        }
    }
}

From source file:com.ephesoft.dcma.da.common.ExecuteUpdatePatch.java

private List<BatchClassScannerConfiguration> readScannerConfigSerializeFile() {
    FileInputStream fileInputStream = null;
    List<BatchClassScannerConfiguration> newScannerConfigsList = null;
    File serializedFile = null;/*ww w .j a va 2s.  co m*/
    try {
        String scannerConfigFilePath = dbPatchFolderLocation + File.separator
                + DataAccessConstant.SCANNER_CONFIG_UPDATE + SERIALIZATION_EXT;
        serializedFile = new File(scannerConfigFilePath);
        fileInputStream = new FileInputStream(serializedFile);
        newScannerConfigsList = (List<BatchClassScannerConfiguration>) SerializationUtils
                .deserialize(fileInputStream);
        updateFile(serializedFile, scannerConfigFilePath);
    } catch (IOException e) {
        LOG.info(DataAccessConstant.ERROR_DURING_READING_THE_SERIALIZED_FILE);
    } catch (Exception e) {
        LOG.error(DataAccessConstant.ERROR_DURING_DE_SERIALIZING_THE_PROPERTIES_FOR_DATABASE_UPGRADE, e);
    } finally {
        try {
            if (fileInputStream != null) {
                fileInputStream.close();
            }
        } catch (Exception e) {
            if (serializedFile != null) {
                LOG.error(DataAccessConstant.PROBLEM_CLOSING_STREAM_FOR_FILE + serializedFile.getName());
            }
        }
    }
    return newScannerConfigsList;

}

From source file:com.ephesoft.dcma.da.common.ExecuteUpdatePatch.java

private Map<String, List<BatchClassPluginConfig>> readPluginConfigSerializeFile() {
    FileInputStream fileInputStream = null;
    Map<String, List<BatchClassPluginConfig>> newPluginConfigsMap = null;
    File serializedFile = null;/*from  ww  w  . j av a  2s.  co  m*/
    try {
        String pluginConfigFilePath = dbPatchFolderLocation + File.separator
                + DataAccessConstant.PLUGIN_CONFIG_UPDATE + SERIALIZATION_EXT;
        serializedFile = new File(pluginConfigFilePath);
        fileInputStream = new FileInputStream(serializedFile);
        newPluginConfigsMap = (Map<String, List<BatchClassPluginConfig>>) SerializationUtils
                .deserialize(fileInputStream);
        updateFile(serializedFile, pluginConfigFilePath);
    } catch (IOException e) {
        LOG.info(DataAccessConstant.ERROR_DURING_READING_THE_SERIALIZED_FILE);
    } catch (Exception e) {
        LOG.error(DataAccessConstant.ERROR_DURING_DE_SERIALIZING_THE_PROPERTIES_FOR_DATABASE_UPGRADE, e);
    } finally {
        try {
            if (fileInputStream != null) {
                fileInputStream.close();
            }
        } catch (Exception e) {
            if (serializedFile != null) {
                LOG.error(DataAccessConstant.PROBLEM_CLOSING_STREAM_FOR_FILE + serializedFile.getName());
            }
        }
    }
    return newPluginConfigsMap;
}

From source file:com.ephesoft.dcma.imp.FolderImporter.java

private List<BatchClassField> readBatchClassFieldSerializeFile(final String sFinalFolder) {
    FileInputStream fileInputStream = null;
    List<BatchClassField> batchClassFieldList = null;
    File serializedFile = null;//from ww  w  . ja v a 2 s  . c  o  m
    try {
        final String serializedFilePath = sFinalFolder + File.separator
                + IFolderImporterConstants.BCF_SER_FILE_NAME + IFolderImporterConstants.SERIALIZATION_EXT;
        serializedFile = new File(serializedFilePath);
        fileInputStream = new FileInputStream(serializedFile);
        batchClassFieldList = (List<BatchClassField>) SerializationUtils.deserialize(fileInputStream);
        // updateFile(serializedFile, serializedFilePath);
    } catch (final IOException e) {
        LOGGER.info("Error during reading the serialized file. ");
    } catch (final Exception e) {
        LOGGER.error("Error during de-serializing the properties for Database Upgrade: ", e);
    } finally {
        try {
            if (fileInputStream != null) {
                fileInputStream.close();
            }
        } catch (final Exception e) {
            if (serializedFile != null) {
                LOGGER.error("Problem closing stream for file :" + serializedFile.getName());
            }
        }
    }

    return batchClassFieldList;
}

From source file:com.ephesoft.dcma.da.common.ExecuteUpdatePatch.java

private Map<String, List<BatchClassModuleConfig>> readModuleConfigSerializeFile() {
    FileInputStream fileInputStream = null;
    Map<String, List<BatchClassModuleConfig>> newModuleConfigsMap = null;
    File serializedFile = null;//from  w  w w  . j  av a 2 s .  c o m
    try {
        String moduleConfigFilePath = dbPatchFolderLocation + File.separator
                + DataAccessConstant.MODULE_CONFIG_UPDATE + SERIALIZATION_EXT;
        serializedFile = new File(moduleConfigFilePath);
        fileInputStream = new FileInputStream(serializedFile);
        newModuleConfigsMap = (Map<String, List<BatchClassModuleConfig>>) SerializationUtils
                .deserialize(fileInputStream);
        updateFile(serializedFile, moduleConfigFilePath);
    } catch (IOException e) {
        LOG.info(DataAccessConstant.ERROR_DURING_READING_THE_SERIALIZED_FILE);
    } catch (Exception e) {
        LOG.error(DataAccessConstant.ERROR_DURING_DE_SERIALIZING_THE_PROPERTIES_FOR_DATABASE_UPGRADE, e);
    } finally {
        try {
            if (fileInputStream != null) {
                fileInputStream.close();
            }
        } catch (Exception e) {
            if (serializedFile != null) {
                LOG.error(DataAccessConstant.PROBLEM_CLOSING_STREAM_FOR_FILE + serializedFile.getName());
            }
        }
    }
    return newModuleConfigsMap;
}

From source file:at.gv.egovernment.moa.id.storage.AuthenticationSessionStoreage.java

private static AuthenticationSession decryptSession(AuthenticatedSessionStore dbsession) throws BuildException {
    EncryptedData encdata = new EncryptedData(dbsession.getSession(), dbsession.getIv());
    byte[] decrypted = SessionEncrytionUtil.getInstance().decrypt(encdata);

    return (AuthenticationSession) SerializationUtils.deserialize(decrypted);

}

From source file:ch.zhaw.ficore.p2abc.services.user.UserServiceGUI.java

/**
 * This is the entry point for the User to obtain a credential from an
 * issuer. This method will display a webpage asking for the required data
 * and will direct the User to obtainCredential2
 * /*from   w  w  w .j  a v a 2  s. c o  m*/
 * @return Response
 */
@GET
@Path("/obtainCredential/")
public Response obtainCredential() {
    try {
        Html html = UserGUI.getHtmlPramble("Obtain Credential [1]", request);
        Div mainDiv = new Div().setCSSClass("mainDiv");
        html.appendChild(UserGUI.getBody(mainDiv));
        mainDiv.appendChild(new H2().appendChild(new Text("Obtain Credential")));
        mainDiv.appendChild(new P().setCSSClass("info")
                .appendChild(new Text("Please enter the information required to obtain the credential. "
                        + "If the the Issuer field is blank please add an alias for an URL first via the Profile page.")));
        Form f = new Form("./obtainCredential2");
        f.setMethod("post");

        Table tbl = new Table();
        Tr row = null;
        f.appendChild(tbl);

        row = new Tr();
        row.appendChild(new Td().appendChild(new Label().appendChild(new Text("Username:"))));
        row.appendChild(new Td().appendChild(new Input().setType("text").setName("un")));
        tbl.appendChild(row);

        row = new Tr();
        row.appendChild(new Td().appendChild(new Label().appendChild(new Text("Password:"))));
        row.appendChild(new Td().appendChild(new Input().setType("password").setName("pw")));
        tbl.appendChild(row);

        row = new Tr();
        row.appendChild(new Td().appendChild(new Label().appendChild(new Text("Issuer:"))));
        // row.appendChild(new Td().appendChild(new Input().setType("text")
        // .setName("is")));
        Select s = new Select().setName("is");

        row.appendChild(new Td().appendChild(s));
        // .setName("is")));

        List<String> keys = urlStorage.keysAsStrings();
        List<byte[]> values = urlStorage.values();
        List<String> urls = new ArrayList<String>();

        for (byte[] b : values) {
            urls.add((String) SerializationUtils.deserialize(b));
        }

        for (int i = 0; i < keys.size(); i++) {
            Option o = new Option().appendChild(new Text(keys.get(i))).setValue(urls.get(i));
            s.appendChild(o);
        }

        tbl.appendChild(row);

        row = new Tr();
        row.appendChild(new Td().appendChild(new Label().appendChild(new Text("Credential specification:"))));
        Select sel = new Select().setName("cs");
        row.appendChild(new Td().appendChild(sel));
        tbl.appendChild(row);

        Context initCtx = new InitialContext();
        Context envCtx = (Context) initCtx.lookup("java:/comp/env");

        boolean enabled = (Boolean) envCtx.lookup("cfg/userGui/keyrockEnabled");

        String enableString = enabled ? "yes" : "no";
        f.appendChild(new Input().setType("hidden").setName("oauth").setValue(enableString));

        f.appendChild(new Input().setType("submit").setValue("Obtain"));

        mainDiv.appendChild(f);

        Settings settings = (Settings) RESTHelper
                .getRequest(ServicesConfiguration.getUserServiceURL() + "getSettings/", Settings.class);

        List<CredentialSpecification> credSpecs = settings.credentialSpecifications;

        for (CredentialSpecification credSpec : credSpecs) {
            URI uri = credSpec.getSpecificationUID();
            sel.appendChild(new Option().appendChild(new Text(uri.toString())));
        }

        return Response.ok(html.write()).build();
    } catch (Exception e) {
        log.catching(e);
        return log.exit(Response.status(Response.Status.BAD_REQUEST)
                .entity(UserGUI.errorPage(ExceptionDumper.dumpExceptionStr(e, log), request).write()).build());
    }
}