2
0

Fixed MP-59 Master password not recognized when no site added to mpsites file.

This commit is contained in:
Maarten Billemont 2015-06-20 11:36:31 -04:00
parent 6961236534
commit 8f1d897660
3 changed files with 11 additions and 8 deletions

View File

@ -1,10 +1,11 @@
package com.lyndir.masterpassword.gui; package com.lyndir.masterpassword.gui;
import com.google.common.base.*; import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
import com.lyndir.masterpassword.model.*; import com.lyndir.masterpassword.model.*;
import java.util.Arrays; import java.util.Arrays;
import javax.annotation.*; import javax.annotation.Nullable;
/** /**
@ -50,6 +51,7 @@ public class ModelUser extends User {
throws IncorrectMasterPasswordException { throws IncorrectMasterPasswordException {
putKey( model.authenticate( masterPassword ) ); putKey( model.authenticate( masterPassword ) );
this.masterPassword = masterPassword; this.masterPassword = masterPassword;
MPUserFileManager.get().save();
} }
@Override @Override

View File

@ -1,12 +1,10 @@
package com.lyndir.masterpassword.gui; package com.lyndir.masterpassword.gui;
import static com.lyndir.lhunath.opal.system.util.ObjectUtils.ifNotNullElse;
import static com.lyndir.lhunath.opal.system.util.StringUtils.*; import static com.lyndir.lhunath.opal.system.util.StringUtils.*;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.*; import com.google.common.util.concurrent.*;
import com.lyndir.lhunath.opal.system.util.NNSupplier;
import com.lyndir.lhunath.opal.system.util.PredicateNN; import com.lyndir.lhunath.opal.system.util.PredicateNN;
import com.lyndir.masterpassword.*; import com.lyndir.masterpassword.*;
import com.lyndir.masterpassword.gui.util.Components; import com.lyndir.masterpassword.gui.util.Components;
@ -98,10 +96,13 @@ public class PasswordFrame extends JFrame implements DocumentListener {
siteActionButton.addActionListener(new ActionListener() { siteActionButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
if (currentSite instanceof ModelSite) if (currentSite == null)
return;
else if (currentSite instanceof ModelSite)
PasswordFrame.this.user.deleteSite(currentSite); PasswordFrame.this.user.deleteSite(currentSite);
else else
PasswordFrame.this.user.addSite(currentSite); PasswordFrame.this.user.addSite(currentSite);
siteNameField.requestFocus();
updatePassword( true ); updatePassword( true );
} }

View File

@ -1,6 +1,6 @@
package com.lyndir.masterpassword.model; package com.lyndir.masterpassword.model;
import static com.lyndir.lhunath.opal.system.util.StringUtils.strf; import static com.lyndir.lhunath.opal.system.util.StringUtils.*;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -90,7 +90,7 @@ public class MPUser implements Comparable<MPUser> {
public MasterKey authenticate(final char[] masterPassword) public MasterKey authenticate(final char[] masterPassword)
throws IncorrectMasterPasswordException { throws IncorrectMasterPasswordException {
MasterKey masterKey = MasterKey.create( algorithmVersion, getFullName(), masterPassword ); MasterKey masterKey = MasterKey.create( algorithmVersion, getFullName(), masterPassword );
if (keyID == null) if (keyID == null || keyID.length == 0)
keyID = masterKey.getKeyID(); keyID = masterKey.getKeyID();
else if (!Arrays.equals( masterKey.getKeyID(), keyID )) else if (!Arrays.equals( masterKey.getKeyID(), keyID ))
throw new IncorrectMasterPasswordException( this ); throw new IncorrectMasterPasswordException( this );