Complete security questions model.
This commit is contained in:
@@ -27,7 +27,7 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* @author lhunath, 2018-05-14
|
||||
*/
|
||||
public interface MPSite extends Comparable<MPSite> {
|
||||
public interface MPSite<Q extends MPQuestion> extends Comparable<MPSite<Q>> {
|
||||
|
||||
// - Meta
|
||||
|
||||
@@ -61,7 +61,11 @@ public interface MPSite extends Comparable<MPSite> {
|
||||
|
||||
// - Relations
|
||||
|
||||
MPUser<? extends MPSite> getUser();
|
||||
MPUser<? extends MPSite<?>> getUser();
|
||||
|
||||
Collection<? extends MPQuestion> getQuestions();
|
||||
void addQuestion(Q question);
|
||||
|
||||
void deleteQuestion(Q question);
|
||||
|
||||
Collection<Q> getQuestions();
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* @author lhunath, 14-12-16
|
||||
*/
|
||||
public abstract class MPBasicSite implements MPSite {
|
||||
public abstract class MPBasicSite<Q extends MPQuestion> implements MPSite<Q> {
|
||||
|
||||
private String name;
|
||||
private MPAlgorithm algorithm;
|
||||
@@ -41,7 +41,7 @@ public abstract class MPBasicSite implements MPSite {
|
||||
private MPResultType resultType;
|
||||
private MPResultType loginType;
|
||||
|
||||
private final Collection<MPFileQuestion> questions = new LinkedHashSet<>();
|
||||
private final Collection<Q> questions = new LinkedHashSet<>();
|
||||
|
||||
protected MPBasicSite(final String name, final MPAlgorithm algorithm) {
|
||||
this( name, algorithm, null, null, null );
|
||||
@@ -139,7 +139,17 @@ public abstract class MPBasicSite implements MPSite {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<? extends MPQuestion> getQuestions() {
|
||||
public void addQuestion(final Q question) {
|
||||
questions.add( question );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteQuestion(final Q question) {
|
||||
questions.remove( question );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Q> getQuestions() {
|
||||
return Collections.unmodifiableCollection( questions );
|
||||
}
|
||||
|
||||
@@ -150,11 +160,11 @@ public abstract class MPBasicSite implements MPSite {
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
return (this == obj) || ((obj instanceof MPSite) && Objects.equals( getName(), ((MPSite) obj).getName() ));
|
||||
return (this == obj) || ((obj instanceof MPSite) && Objects.equals( getName(), ((MPSite<?>) obj).getName() ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull final MPSite o) {
|
||||
public int compareTo(@NotNull final MPSite<Q> o) {
|
||||
return getName().compareTo( o.getName() );
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,7 @@ package com.lyndir.masterpassword.model.impl;
|
||||
|
||||
import com.google.common.primitives.UnsignedInteger;
|
||||
import com.lyndir.masterpassword.*;
|
||||
import com.lyndir.masterpassword.model.MPSite;
|
||||
import com.lyndir.masterpassword.model.MPUser;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -30,7 +31,7 @@ import org.joda.time.ReadableInstant;
|
||||
/**
|
||||
* @author lhunath, 14-12-05
|
||||
*/
|
||||
public class MPFileSite extends MPBasicSite {
|
||||
public class MPFileSite extends MPBasicSite<MPFileQuestion> {
|
||||
|
||||
private final MPFileUser user;
|
||||
|
||||
@@ -60,7 +61,8 @@ public class MPFileSite extends MPBasicSite {
|
||||
@Nullable final MPResultType resultType, @Nullable final String resultState,
|
||||
@Nullable final MPResultType loginType, @Nullable final String loginState,
|
||||
@Nullable final String url, final int uses, final ReadableInstant lastUsed) {
|
||||
super( name, (algorithm == null)? user.getAlgorithm(): algorithm, counter, resultType, loginType );
|
||||
super( name, (algorithm == null)? user.getAlgorithm(): algorithm, counter,
|
||||
(resultType == null)? user.getDefaultType(): resultType, loginType );
|
||||
|
||||
this.user = user;
|
||||
this.resultState = resultState;
|
||||
@@ -144,7 +146,7 @@ public class MPFileSite extends MPBasicSite {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MPUser<? extends com.lyndir.masterpassword.model.MPSite> getUser() {
|
||||
public MPFileUser getUser() {
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
@@ -191,26 +191,27 @@ public class MPJSONFile extends MPJSONAnyObject {
|
||||
String full_name;
|
||||
String last_used;
|
||||
@Nullable
|
||||
String key_id;
|
||||
@Nullable
|
||||
MPAlgorithm.Version algorithm;
|
||||
@Nullable
|
||||
String key_id;
|
||||
@Nullable
|
||||
MPResultType default_type;
|
||||
}
|
||||
|
||||
|
||||
public static class Site extends MPJSONAnyObject {
|
||||
|
||||
@Nullable
|
||||
MPResultType type;
|
||||
long counter;
|
||||
MPAlgorithm.Version algorithm;
|
||||
@Nullable
|
||||
MPResultType type;
|
||||
@Nullable
|
||||
String password;
|
||||
@Nullable
|
||||
String login_name;
|
||||
@Nullable
|
||||
MPResultType login_type;
|
||||
@Nullable
|
||||
String login_name;
|
||||
|
||||
int uses;
|
||||
@Nullable
|
||||
String last_used;
|
||||
|
Reference in New Issue
Block a user