Add sender key capability

This commit is contained in:
Ehren Kret
2021-05-12 18:08:22 -05:00
parent e9a3d52d7f
commit bfd2c32d4e
11 changed files with 79 additions and 18 deletions

View File

@@ -231,6 +231,10 @@ public class ProfileController {
Optional<ProfileKeyCredentialResponse> credential = getProfileCredential(credentialRequest, profile, uuid);
final UserCapabilities userCapabilities = new UserCapabilities(
accountProfile.get().isGroupsV2Supported(),
accountProfile.get().isGv1MigrationSupported(),
accountProfile.get().isSenderKeySupported());
return Optional.of(new Profile(name,
about,
aboutEmoji,
@@ -239,7 +243,7 @@ public class ProfileController {
accountProfile.get().getIdentityKey(),
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
new UserCapabilities(accountProfile.get().isGroupsV2Supported(), accountProfile.get().isGv1MigrationSupported()),
userCapabilities,
username.orElse(null),
null,
credential.orElse(null)));
@@ -271,6 +275,10 @@ public class ProfileController {
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
}
final UserCapabilities userCapabilities = new UserCapabilities(
accountProfile.get().isGroupsV2Supported(),
accountProfile.get().isGv1MigrationSupported(),
accountProfile.get().isSenderKeySupported());
return new Profile(accountProfile.get().getProfileName(),
null,
null,
@@ -279,7 +287,7 @@ public class ProfileController {
accountProfile.get().getIdentityKey(),
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
new UserCapabilities(accountProfile.get().isGroupsV2Supported(), accountProfile.get().isGv1MigrationSupported()),
userCapabilities,
username,
accountProfile.get().getUuid(),
null);
@@ -346,6 +354,10 @@ public class ProfileController {
username = usernamesManager.get(accountProfile.get().getUuid());
}
final UserCapabilities userCapabilities = new UserCapabilities(
accountProfile.get().isGroupsV2Supported(),
accountProfile.get().isGv1MigrationSupported(),
accountProfile.get().isSenderKeySupported());
return new Profile(accountProfile.get().getProfileName(),
null,
null,
@@ -354,7 +366,7 @@ public class ProfileController {
accountProfile.get().getIdentityKey(),
UnidentifiedAccessChecksum.generateFor(accountProfile.get().getUnidentifiedAccessKey()),
accountProfile.get().isUnrestrictedUnidentifiedAccess(),
new UserCapabilities(accountProfile.get().isGroupsV2Supported(), accountProfile.get().isGv1MigrationSupported()),
userCapabilities,
username.orElse(null),
null,
null);

View File

@@ -14,11 +14,15 @@ public class UserCapabilities {
@JsonProperty("gv1-migration")
private boolean gv1Migration;
@JsonProperty
private boolean senderKey;
public UserCapabilities() {}
public UserCapabilities(boolean gv2, boolean gv1Migration) {
public UserCapabilities(boolean gv2, boolean gv1Migration, final boolean senderKey) {
this.gv2 = gv2;
this.gv1Migration = gv1Migration;
this.senderKey = senderKey;
}
public boolean isGv2() {
@@ -28,4 +32,8 @@ public class UserCapabilities {
public boolean isGv1Migration() {
return gv1Migration;
}
public boolean isSenderKey() {
return senderKey;
}
}

View File

@@ -145,6 +145,12 @@ public class Account implements Principal {
.allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isGv1Migration());
}
public boolean isSenderKeySupported() {
return devices.stream()
.filter(Device::isEnabled)
.allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isSenderKey());
}
public boolean isEnabled() {
return getMasterDevice().map(Device::isEnabled).orElse(false);
}

View File

@@ -273,15 +273,20 @@ public class Device {
@JsonProperty("gv1-migration")
private boolean gv1Migration;
@JsonProperty
private boolean senderKey;
public DeviceCapabilities() {}
public DeviceCapabilities(boolean gv2, final boolean gv2_2, final boolean gv2_3, boolean storage, boolean transfer, boolean gv1Migration) {
public DeviceCapabilities(boolean gv2, final boolean gv2_2, final boolean gv2_3, boolean storage, boolean transfer,
boolean gv1Migration, final boolean senderKey) {
this.gv2 = gv2;
this.gv2_2 = gv2_2;
this.gv2_3 = gv2_3;
this.storage = storage;
this.transfer = transfer;
this.gv1Migration = gv1Migration;
this.senderKey = senderKey;
}
public boolean isGv2() {
@@ -307,5 +312,9 @@ public class Device {
public boolean isGv1Migration() {
return gv1Migration;
}
public boolean isSenderKey() {
return senderKey;
}
}
}