Fixed a bug causing exceptions loading maximum security passwords.
This commit is contained in:
parent
a62ae8c757
commit
4c526d6f08
@ -120,7 +120,7 @@ public enum MPSiteType {
|
|||||||
return typeFeatures;
|
return typeFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMask() {
|
public int getType() {
|
||||||
int mask = typeIndex | typeClass.getMask();
|
int mask = typeIndex | typeClass.getMask();
|
||||||
for (MPSiteFeature typeFeature : typeFeatures)
|
for (MPSiteFeature typeFeature : typeFeatures)
|
||||||
mask |= typeFeature.getMask();
|
mask |= typeFeature.getMask();
|
||||||
@ -174,6 +174,20 @@ public enum MPSiteType {
|
|||||||
return types.build();
|
return types.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param type The type for which we look up types.
|
||||||
|
*
|
||||||
|
* @return The type registered with the given type.
|
||||||
|
*/
|
||||||
|
public static MPSiteType forType(final int type) {
|
||||||
|
|
||||||
|
for (MPSiteType siteType : values())
|
||||||
|
if (siteType.getType() == type)
|
||||||
|
return siteType;
|
||||||
|
|
||||||
|
throw logger.bug( "No type: %s", type );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mask The mask for which we look up types.
|
* @param mask The mask for which we look up types.
|
||||||
*
|
*
|
||||||
@ -181,14 +195,11 @@ public enum MPSiteType {
|
|||||||
*/
|
*/
|
||||||
public static ImmutableList<MPSiteType> forMask(final int mask) {
|
public static ImmutableList<MPSiteType> forMask(final int mask) {
|
||||||
|
|
||||||
int typeIndex = mask & 0xF, typeMask = mask & ~0xF;
|
int typeMask = mask & ~0xF;
|
||||||
|
|
||||||
ImmutableList.Builder<MPSiteType> types = ImmutableList.builder();
|
ImmutableList.Builder<MPSiteType> types = ImmutableList.builder();
|
||||||
for (MPSiteType siteType : values()) {
|
for (MPSiteType siteType : values())
|
||||||
int siteMask = siteType.getMask(), siteTypeIndex = siteMask & 0xF, siteTypeMask = siteMask & ~0xF;
|
if (((siteType.getType() & ~0xF) & typeMask) != 0)
|
||||||
if ((siteTypeMask & typeMask) != 0 && (typeIndex == 0 || siteTypeIndex == typeIndex))
|
|
||||||
types.add( siteType );
|
types.add( siteType );
|
||||||
}
|
|
||||||
|
|
||||||
return types.build();
|
return types.build();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class GUI implements UnlockFrame.SignInCallback {
|
|||||||
String upstreamRevision = upstream.readFirstLine();
|
String upstreamRevision = upstream.readFirstLine();
|
||||||
logger.inf( "Local Revision: <%s>", manifestRevision );
|
logger.inf( "Local Revision: <%s>", manifestRevision );
|
||||||
logger.inf( "Upstream Revision: <%s>", upstreamRevision );
|
logger.inf( "Upstream Revision: <%s>", upstreamRevision );
|
||||||
if (!manifestRevision.equalsIgnoreCase( upstreamRevision )) {
|
if (manifestRevision != null && !manifestRevision.equalsIgnoreCase( upstreamRevision )) {
|
||||||
logger.wrn( "You are not running the current official version. Please update from:\n"
|
logger.wrn( "You are not running the current official version. Please update from:\n"
|
||||||
+ "http://masterpasswordapp.com/masterpassword-gui.jar" );
|
+ "http://masterpasswordapp.com/masterpassword-gui.jar" );
|
||||||
JOptionPane.showMessageDialog( null, "A new version of Master Password is available.\n"
|
JOptionPane.showMessageDialog( null, "A new version of Master Password is available.\n"
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -65,7 +65,7 @@ public class MPSiteMarshaller {
|
|||||||
header.append( "# Key ID: " ).append( user.exportKeyID() ).append( '\n' );
|
header.append( "# Key ID: " ).append( user.exportKeyID() ).append( '\n' );
|
||||||
header.append( "# Version: " ).append( MasterKey.VERSION ).append( '\n' );
|
header.append( "# Version: " ).append( MasterKey.VERSION ).append( '\n' );
|
||||||
header.append( "# Algorithm: " ).append( MasterKey.ALGORITHM ).append( '\n' );
|
header.append( "# Algorithm: " ).append( MasterKey.ALGORITHM ).append( '\n' );
|
||||||
header.append( "# Default Type: " ).append( user.getDefaultType().getMask() ).append( '\n' );
|
header.append( "# Default Type: " ).append( user.getDefaultType().getType() ).append( '\n' );
|
||||||
header.append( "# Passwords: " ).append( contentMode.name() ).append( '\n' );
|
header.append( "# Passwords: " ).append( contentMode.name() ).append( '\n' );
|
||||||
header.append( "##\n" );
|
header.append( "##\n" );
|
||||||
header.append( "#\n" );
|
header.append( "#\n" );
|
||||||
@ -81,7 +81,7 @@ public class MPSiteMarshaller {
|
|||||||
rfc3339.print( site.getLastUsed() ), // lastUsed
|
rfc3339.print( site.getLastUsed() ), // lastUsed
|
||||||
site.getUses(), // uses
|
site.getUses(), // uses
|
||||||
strf( "%d:%d:%d", //
|
strf( "%d:%d:%d", //
|
||||||
site.getSiteType().getMask(), // type
|
site.getSiteType().getType(), // type
|
||||||
site.getMPVersion(), // algorithm
|
site.getMPVersion(), // algorithm
|
||||||
site.getSiteCounter() ), // counter
|
site.getSiteCounter() ), // counter
|
||||||
ifNotNullElse( site.getLoginName(), "" ), // loginName
|
ifNotNullElse( site.getLoginName(), "" ), // loginName
|
||||||
|
@ -88,7 +88,7 @@ public class MPSiteUnmarshaller {
|
|||||||
else if ("Passwords".equalsIgnoreCase( name ))
|
else if ("Passwords".equalsIgnoreCase( name ))
|
||||||
clearContent = value.equalsIgnoreCase( "visible" );
|
clearContent = value.equalsIgnoreCase( "visible" );
|
||||||
else if ("Default Type".equalsIgnoreCase( name ))
|
else if ("Default Type".equalsIgnoreCase( name ))
|
||||||
defaultType = Iterables.getOnlyElement( MPSiteType.forMask( ConversionUtils.toIntegerNN( value ) ) );
|
defaultType = MPSiteType.forType( ConversionUtils.toIntegerNN( value ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ public class MPSiteUnmarshaller {
|
|||||||
site = new MPSite( ConversionUtils.toIntegerNN( siteMatcher.group( 4 ).replace( ":", "" ) ), //
|
site = new MPSite( ConversionUtils.toIntegerNN( siteMatcher.group( 4 ).replace( ":", "" ) ), //
|
||||||
rfc3339.parseDateTime( siteMatcher.group( 1 ) ).toInstant(), //
|
rfc3339.parseDateTime( siteMatcher.group( 1 ) ).toInstant(), //
|
||||||
siteMatcher.group( 5 ), //
|
siteMatcher.group( 5 ), //
|
||||||
Iterables.getOnlyElement( MPSiteType.forMask( ConversionUtils.toIntegerNN( siteMatcher.group( 3 ) ) ) ),
|
MPSiteType.forType( ConversionUtils.toIntegerNN( siteMatcher.group( 3 ) ) ),
|
||||||
MPSite.DEFAULT_COUNTER, //
|
MPSite.DEFAULT_COUNTER, //
|
||||||
ConversionUtils.toIntegerNN( siteMatcher.group( 2 ) ), //
|
ConversionUtils.toIntegerNN( siteMatcher.group( 2 ) ), //
|
||||||
null, //
|
null, //
|
||||||
@ -137,7 +137,7 @@ public class MPSiteUnmarshaller {
|
|||||||
site = new MPSite( ConversionUtils.toIntegerNN( siteMatcher.group( 4 ).replace( ":", "" ) ), //
|
site = new MPSite( ConversionUtils.toIntegerNN( siteMatcher.group( 4 ).replace( ":", "" ) ), //
|
||||||
rfc3339.parseDateTime( siteMatcher.group( 1 ) ).toInstant(), //
|
rfc3339.parseDateTime( siteMatcher.group( 1 ) ).toInstant(), //
|
||||||
siteMatcher.group( 7 ), //
|
siteMatcher.group( 7 ), //
|
||||||
Iterables.getOnlyElement( MPSiteType.forMask( ConversionUtils.toIntegerNN( siteMatcher.group( 3 ) ) ) ),
|
MPSiteType.forType( ConversionUtils.toIntegerNN( siteMatcher.group( 3 ) ) ),
|
||||||
ConversionUtils.toIntegerNN( siteMatcher.group( 5 ).replace( ":", "" ) ), //
|
ConversionUtils.toIntegerNN( siteMatcher.group( 5 ).replace( ":", "" ) ), //
|
||||||
ConversionUtils.toIntegerNN( siteMatcher.group( 2 ) ), //
|
ConversionUtils.toIntegerNN( siteMatcher.group( 2 ) ), //
|
||||||
siteMatcher.group( 6 ), //
|
siteMatcher.group( 6 ), //
|
||||||
|
Loading…
Reference in New Issue
Block a user