Initial Java JSON serialization/deserialization.
This commit is contained in:
@@ -18,10 +18,14 @@
|
||||
|
||||
package com.lyndir.masterpassword.gui.model;
|
||||
|
||||
import static com.lyndir.lhunath.opal.system.util.ObjectUtils.ifNotNullElse;
|
||||
|
||||
import com.google.common.primitives.UnsignedInteger;
|
||||
import com.lyndir.masterpassword.MPAlgorithm;
|
||||
import com.lyndir.masterpassword.MPResultType;
|
||||
import com.lyndir.masterpassword.model.MPSite;
|
||||
import com.lyndir.masterpassword.model.MPUser;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
@@ -29,19 +33,28 @@ import com.lyndir.masterpassword.model.MPSite;
|
||||
*/
|
||||
public class IncognitoSite extends MPSite {
|
||||
|
||||
private final IncognitoUser user;
|
||||
|
||||
private String siteName;
|
||||
private UnsignedInteger siteCounter;
|
||||
private MPResultType resultType;
|
||||
private MPResultType loginType;
|
||||
private MPAlgorithm algorithm;
|
||||
|
||||
public IncognitoSite(final String siteName, final UnsignedInteger siteCounter, final MPResultType resultType,
|
||||
public IncognitoSite(final IncognitoUser user, final String siteName, final UnsignedInteger siteCounter, final MPResultType resultType,
|
||||
final MPAlgorithm algorithm) {
|
||||
this.user = user;
|
||||
this.siteName = siteName;
|
||||
this.siteCounter = siteCounter;
|
||||
this.resultType = resultType;
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MPUser<?> getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSiteName() {
|
||||
return siteName;
|
||||
@@ -62,6 +75,16 @@ public class IncognitoSite extends MPSite {
|
||||
this.resultType = resultType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MPResultType getLoginType() {
|
||||
return loginType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoginType(@Nullable final MPResultType loginType) {
|
||||
this.loginType = ifNotNullElse( loginType, getAlgorithm().mpw_default_login_type() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MPAlgorithm getAlgorithm() {
|
||||
return algorithm;
|
||||
|
@@ -86,9 +86,8 @@ public class IncognitoAuthenticationPanel extends AuthenticationPanel<IncognitoU
|
||||
return new PasswordFrame<IncognitoUser, IncognitoSite>( Preconditions.checkNotNull( getSelectedUser() ) ) {
|
||||
@Override
|
||||
protected IncognitoSite createSite(final IncognitoUser user, final String siteName, final UnsignedInteger siteCounter,
|
||||
final MPResultType resultType,
|
||||
final MPAlgorithm algorithm) {
|
||||
return new IncognitoSite( siteName, siteCounter, resultType, algorithm );
|
||||
final MPResultType resultType, final MPAlgorithm algorithm) {
|
||||
return new IncognitoSite( user, siteName, siteCounter, resultType, algorithm );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -147,7 +147,7 @@ public abstract class PasswordFrame<U extends MPUser<S>, S extends MPSite> exten
|
||||
siteCounterField = Components.spinner( siteCounterModel ) );
|
||||
sitePanel.add( siteSettings );
|
||||
resultTypeField.setFont( Res.valueFont().deriveFont( resultTypeField.getFont().getSize2D() ) );
|
||||
resultTypeField.setSelectedItem( user.getAlgorithm().mpw_default_type() );
|
||||
resultTypeField.setSelectedItem( user.getAlgorithm().mpw_default_password_type() );
|
||||
resultTypeField.addItemListener( new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(final ItemEvent e) {
|
||||
|
Reference in New Issue
Block a user