Search in sources :

Example 1 with ImporterV4

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

the class Kdb4 method testComposite.

public void testComposite() throws IOException, InvalidDBException {
    Context ctx = getContext();
    AssetManager am = ctx.getAssets();
    InputStream is = am.open("keyfile.kdbx", AssetManager.ACCESS_STREAMING);
    ImporterV4 importer = new ImporterV4();
    importer.openDatabase(is, "12345", TestUtil.getKeyFileInputStream(ctx, TestUtil.getSdPath("key")));
    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)

Example 2 with ImporterV4

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

the class Kdb4 method testCompositeBinary.

public void testCompositeBinary() throws IOException, InvalidDBException {
    Context ctx = getContext();
    AssetManager am = ctx.getAssets();
    InputStream is = am.open("keyfile-binary.kdbx", AssetManager.ACCESS_STREAMING);
    ImporterV4 importer = new ImporterV4();
    importer.openDatabase(is, "12345", TestUtil.getKeyFileInputStream(ctx, TestUtil.getSdPath("key-binary")));
    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)

Example 3 with ImporterV4

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

the class Kdb4 method testSaving.

private void testSaving(String inputFile, String password, String outputFile) throws IOException, InvalidDBException, PwDbOutputException {
    Context ctx = getContext();
    AssetManager am = ctx.getAssets();
    InputStream is = am.open(inputFile, AssetManager.ACCESS_STREAMING);
    ImporterV4 importer = new ImporterV4();
    PwDatabaseV4 db = importer.openDatabase(is, password, null);
    is.close();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    PwDbV4Output output = (PwDbV4Output) PwDbOutput.getInstance(db, bos);
    output.output();
    byte[] data = bos.toByteArray();
    FileOutputStream fos = new FileOutputStream(TestUtil.getSdPath(outputFile), false);
    InputStream bis = new ByteArrayInputStream(data);
    bis = new CopyInputStream(bis, fos);
    importer = new ImporterV4();
    db = importer.openDatabase(bis, password, null);
    bis.close();
    fos.close();
}
Also used : Context(android.content.Context) PwDbV4Output(com.keepassdroid.database.save.PwDbV4Output) AssetManager(android.content.res.AssetManager) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) CopyInputStream(com.keepassdroid.stream.CopyInputStream) InputStream(java.io.InputStream) ImporterV4(com.keepassdroid.database.load.ImporterV4) FileOutputStream(java.io.FileOutputStream) CopyInputStream(com.keepassdroid.stream.CopyInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PwDatabaseV4(com.keepassdroid.database.PwDatabaseV4)

Example 4 with ImporterV4

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

the class Kdb4 method testKeyfile.

public void testKeyfile() throws IOException, InvalidDBException {
    Context ctx = getContext();
    AssetManager am = ctx.getAssets();
    InputStream is = am.open("key-only.kdbx", AssetManager.ACCESS_STREAMING);
    ImporterV4 importer = new ImporterV4();
    importer.openDatabase(is, "", TestUtil.getKeyFileInputStream(ctx, TestUtil.getSdPath("key")));
    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)

Example 5 with ImporterV4

use of com.keepassdroid.database.load.ImporterV4 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)

Aggregations

Context (android.content.Context)9 AssetManager (android.content.res.AssetManager)9 ImporterV4 (com.keepassdroid.database.load.ImporterV4)9 InputStream (java.io.InputStream)9 CopyInputStream (com.keepassdroid.stream.CopyInputStream)7 ByteArrayInputStream (java.io.ByteArrayInputStream)7 PwDatabaseV4 (com.keepassdroid.database.PwDatabaseV4)2 Importer (com.keepassdroid.database.load.Importer)1 PwDbV4Output (com.keepassdroid.database.save.PwDbV4Output)1 SprEngineV4 (com.keepassdroid.utils.SprEngineV4)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileOutputStream (java.io.FileOutputStream)1