Search in sources :

Example 1 with Importer

use of com.keepassdroid.database.load.Importer in project KeePassDX by Kunzisoft.

the class Kdb4 method testDetection.

public void testDetection() throws IOException, InvalidDBException {
    Context ctx = getContext();
    AssetManager am = ctx.getAssets();
    InputStream is = am.open("test.kdbx", AssetManager.ACCESS_STREAMING);
    Importer importer = ImporterFactory.createImporter(is);
    assertTrue(importer instanceof ImporterV4);
    is.close();
}
Also used : Context(android.content.Context) AssetManager(android.content.res.AssetManager) ByteArrayInputStream(java.io.ByteArrayInputStream) CopyInputStream(com.keepassdroid.stream.CopyInputStream) InputStream(java.io.InputStream) ImporterV4(com.keepassdroid.database.load.ImporterV4) Importer(com.keepassdroid.database.load.Importer)

Example 2 with Importer

use of com.keepassdroid.database.load.Importer in project KeePassDX by Kunzisoft.

the class Database method LoadData.

public void LoadData(Context ctx, InputStream is, String password, InputStream kfIs, UpdateStatus status, boolean debug, long roundsFix) throws IOException, InvalidDBException {
    BufferedInputStream bis = new BufferedInputStream(is);
    if (!bis.markSupported()) {
        throw new IOException("Input stream does not support mark.");
    }
    // We'll end up reading 8 bytes to identify the header. Might as well use two extra.
    bis.mark(10);
    Importer imp = ImporterFactory.createImporter(bis, debug);
    // Return to the start
    bis.reset();
    pm = imp.openDatabase(bis, password, kfIs, status, roundsFix);
    if (pm != null) {
        PwGroup root = pm.rootGroup;
        pm.populateGlobals(root);
        LoadData(ctx, pm, password, kfIs, status);
    }
    loaded = true;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) IOException(java.io.IOException) Importer(com.keepassdroid.database.load.Importer)

Aggregations

Importer (com.keepassdroid.database.load.Importer)2 Context (android.content.Context)1 AssetManager (android.content.res.AssetManager)1 ImporterV4 (com.keepassdroid.database.load.ImporterV4)1 CopyInputStream (com.keepassdroid.stream.CopyInputStream)1 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1