Format-specific marshalling.
This commit is contained in:
parent
11185725d1
commit
10698284d2
@ -126,7 +126,7 @@ public class MPFileUserManager extends MPUserManager {
|
||||
throws IOException {
|
||||
return new OutputStreamWriter( new FileOutputStream( getUserFile( user ) ), Charsets.UTF_8 );
|
||||
}
|
||||
}.write( new MPFlatMarshaller().marshall( user, masterKey, MPMarshaller.ContentMode.PROTECTED ) );
|
||||
}.write( user.getFormat().marshaller().marshall( user, masterKey, MPMarshaller.ContentMode.PROTECTED ) );
|
||||
}
|
||||
catch (final IOException e) {
|
||||
logger.err( e, "Unable to save sites for user: %s", user );
|
||||
|
@ -36,7 +36,7 @@ public class MPFlatMarshaller implements MPMarshaller {
|
||||
@Nonnull
|
||||
@Override
|
||||
public String marshall(final MPFileUser user, final MPMasterKey masterKey, final ContentMode contentMode)
|
||||
throws MPInvalidatedException {
|
||||
throws MPInvalidatedException, MPMarshalException {
|
||||
StringBuilder content = new StringBuilder();
|
||||
content.append( "# Master Password site export\n" );
|
||||
content.append( "# " ).append( contentMode.description() ).append( '\n' );
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package com.lyndir.masterpassword.model;
|
||||
|
||||
import com.lyndir.masterpassword.MPInvalidatedException;
|
||||
import com.lyndir.masterpassword.MPMasterKey;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@ -29,8 +30,8 @@ public class MPJSONMarshaller implements MPMarshaller {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String marshall(final MPFileUser user, final MPMasterKey masterKey, final ContentMode contentMode) {
|
||||
// TODO
|
||||
return null;
|
||||
public String marshall(final MPFileUser user, final MPMasterKey masterKey, final ContentMode contentMode)
|
||||
throws MPInvalidatedException, MPMarshalException {
|
||||
throw new MPMarshalException( "Not yet implemented" );
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public interface MPMarshaller {
|
||||
|
||||
@Nonnull
|
||||
String marshall(MPFileUser user, MPMasterKey masterKey, ContentMode contentMode)
|
||||
throws MPInvalidatedException;
|
||||
throws MPInvalidatedException, MPMarshalException;
|
||||
|
||||
enum ContentMode {
|
||||
PROTECTED( "Export of site names and stored passwords (unless device-private) encrypted with the master key." ),
|
||||
|
Loading…
Reference in New Issue
Block a user