diff --git a/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/ModelUser.java b/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/ModelUser.java index 84d20393..0d721234 100755 --- a/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/ModelUser.java +++ b/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/ModelUser.java @@ -1,10 +1,11 @@ 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.lyndir.masterpassword.model.*; import java.util.Arrays; -import javax.annotation.*; +import javax.annotation.Nullable; /** @@ -50,6 +51,7 @@ public class ModelUser extends User { throws IncorrectMasterPasswordException { putKey( model.authenticate( masterPassword ) ); this.masterPassword = masterPassword; + MPUserFileManager.get().save(); } @Override diff --git a/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/PasswordFrame.java b/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/PasswordFrame.java index 2b17e313..2bb87fa8 100755 --- a/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/PasswordFrame.java +++ b/MasterPassword/Java/masterpassword-gui/src/main/java/com/lyndir/masterpassword/gui/PasswordFrame.java @@ -1,12 +1,10 @@ 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 com.google.common.collect.FluentIterable; import com.google.common.collect.Iterables; 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.masterpassword.*; import com.lyndir.masterpassword.gui.util.Components; @@ -98,12 +96,15 @@ public class PasswordFrame extends JFrame implements DocumentListener { siteActionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { - if (currentSite instanceof ModelSite) + if (currentSite == null) + return; + else if (currentSite instanceof ModelSite) PasswordFrame.this.user.deleteSite(currentSite); else PasswordFrame.this.user.addSite(currentSite); + siteNameField.requestFocus(); - updatePassword(true); + updatePassword( true ); } }); sitePanel.add( siteControls ); diff --git a/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPUser.java b/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPUser.java index 51222b2a..95348621 100755 --- a/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPUser.java +++ b/MasterPassword/Java/masterpassword-model/src/main/java/com/lyndir/masterpassword/model/MPUser.java @@ -1,6 +1,6 @@ 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.Sets; @@ -90,7 +90,7 @@ public class MPUser implements Comparable { public MasterKey authenticate(final char[] masterPassword) throws IncorrectMasterPasswordException { MasterKey masterKey = MasterKey.create( algorithmVersion, getFullName(), masterPassword ); - if (keyID == null) + if (keyID == null || keyID.length == 0) keyID = masterKey.getKeyID(); else if (!Arrays.equals( masterKey.getKeyID(), keyID )) throw new IncorrectMasterPasswordException( this );