Ver a proveniência

add endpoints and string resources for device types

tags/v0.9.14
Jonathan Cobb há 4 anos
ascendente
cometimento
551558011a
9 ficheiros alterados com 58 adições e 16 eliminações
  1. +1
    -0
      bubble-server/src/main/java/bubble/ApiConstants.java
  2. +2
    -1
      bubble-server/src/main/java/bubble/dao/device/DeviceDAO.java
  3. +20
    -8
      bubble-server/src/main/java/bubble/model/device/BubbleDeviceType.java
  4. +2
    -2
      bubble-server/src/main/java/bubble/model/device/Device.java
  5. +6
    -0
      bubble-server/src/main/java/bubble/resources/account/AccountsResource.java
  6. +2
    -0
      bubble-server/src/main/java/bubble/resources/account/DevicesResource.java
  7. +6
    -0
      bubble-server/src/main/java/bubble/resources/account/MeResource.java
  8. +18
    -4
      bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties
  9. +1
    -1
      bubble-web

+ 1
- 0
bubble-server/src/main/java/bubble/ApiConstants.java Ver ficheiro

@@ -146,6 +146,7 @@ public class ApiConstants {
public static final String EP_TAGS = "/tags";
public static final String EP_NODES = "/nodes";
public static final String EP_DEVICES = "/devices";
public static final String EP_DEVICE_TYPES = "/deviceTypes";
public static final String EP_MODEL = "/model";
public static final String EP_VPN = "/vpn";
public static final String EP_IPS = "/ips";


+ 2
- 1
bubble-server/src/main/java/bubble/dao/device/DeviceDAO.java Ver ficheiro

@@ -19,7 +19,8 @@ import java.io.File;
import java.util.List;

import static bubble.ApiConstants.HOME_DIR;
import static bubble.model.device.Device.*;
import static bubble.model.device.Device.UNINITIALIZED_DEVICE_LIKE;
import static bubble.model.device.Device.newUninitializedDevice;
import static org.cobbzilla.util.io.FileUtil.abs;
import static org.cobbzilla.util.io.FileUtil.touch;



+ 20
- 8
bubble-server/src/main/java/bubble/model/device/BubbleDeviceType.java Ver ficheiro

@@ -9,22 +9,34 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import static bubble.ApiConstants.enumFromString;

@AllArgsConstructor
public enum BubbleDeviceType {

uninitialized (null),
windows (CertType.cer),
macosx (CertType.pem),
ios (CertType.pem),
android (CertType.cer),
linux (CertType.crt),
firefox (CertType.crt),
other (null);
uninitialized (null, false),
windows (CertType.cer, true),
macosx (CertType.pem, true),
ios (CertType.pem, true),
android (CertType.cer, true),
linux (CertType.crt, true),
firefox (CertType.crt, false),
other (null, true);

@Getter private CertType certType;
@Getter private boolean selectable;

@JsonCreator public static BubbleDeviceType fromString (String v) { return enumFromString(BubbleDeviceType.class, v); }

@Getter(lazy=true) private static final List<BubbleDeviceType> selectableTypes = initSelectable();
private static List<BubbleDeviceType> initSelectable() {
return Arrays.stream(values())
.filter(BubbleDeviceType::isSelectable)
.collect(Collectors.toList());
}

}

+ 2
- 2
bubble-server/src/main/java/bubble/model/device/Device.java Ver ficheiro

@@ -41,8 +41,8 @@ import static org.cobbzilla.wizard.model.crypto.EncryptedTypes.ENC_PAD;
})
public class Device extends IdentifiableBase implements HasAccount {

public static final String[] CREATE_FIELDS = { UUID, "name", "enabled", "totpKey" };
public static final String[] UPDATE_FIELDS = { "name", "enabled", "deviceType" };
public static final String[] CREATE_FIELDS = { UUID, "name", "enabled", "totpKey", "deviceType" };
public static final String[] UPDATE_FIELDS = { "name", "enabled" };

public static final String UNINITIALIZED_DEVICE = "__uninitialized_device__";
public static final String UNINITIALIZED_DEVICE_LIKE = UNINITIALIZED_DEVICE+"%";


+ 6
- 0
bubble-server/src/main/java/bubble/resources/account/AccountsResource.java Ver ficheiro

@@ -15,6 +15,7 @@ import bubble.model.account.message.AccountMessage;
import bubble.model.account.message.AccountMessageType;
import bubble.model.account.message.ActionTarget;
import bubble.model.cloud.BubbleNetwork;
import bubble.model.device.BubbleDeviceType;
import bubble.resources.app.AppsResource;
import bubble.resources.bill.AccountPaymentMethodsResource;
import bubble.resources.bill.AccountPaymentsResource;
@@ -515,6 +516,11 @@ public class AccountsResource {
return configuration.subResource(DevicesResource.class, c.account);
}

@GET @Path("/{id}"+EP_DEVICE_TYPES)
public Response getDeviceTypes(@Context ContainerRequest ctx) {
return ok(BubbleDeviceType.getSelectableTypes());
}

@Path("/{id}"+EP_ROLES)
public AnsibleRolesResource getAnsibleRoles(@Context ContainerRequest ctx,
@PathParam("id") String id) {


+ 2
- 0
bubble-server/src/main/java/bubble/resources/account/DevicesResource.java Ver ficheiro

@@ -9,6 +9,7 @@ import bubble.model.account.Account;
import bubble.model.device.Device;
import bubble.server.BubbleConfiguration;
import bubble.service.cloud.DeviceIdService;
import lombok.extern.slf4j.Slf4j;
import org.glassfish.jersey.server.ContainerRequest;
import org.springframework.beans.factory.annotation.Autowired;

@@ -24,6 +25,7 @@ import static bubble.ApiConstants.*;
import static org.cobbzilla.util.daemon.ZillaRuntime.empty;
import static org.cobbzilla.wizard.resources.ResourceUtil.*;

@Slf4j
public class DevicesResource extends AccountOwnedResource<Device, DeviceDAO> {

@Autowired protected BubbleConfiguration configuration;


+ 6
- 0
bubble-server/src/main/java/bubble/resources/account/MeResource.java Ver ficheiro

@@ -15,6 +15,7 @@ import bubble.model.account.AuthenticatorRequest;
import bubble.model.account.message.AccountMessage;
import bubble.model.account.message.AccountMessageType;
import bubble.model.account.message.ActionTarget;
import bubble.model.device.BubbleDeviceType;
import bubble.resources.app.AppsResource;
import bubble.resources.bill.AccountPaymentMethodsResource;
import bubble.resources.bill.AccountPaymentsResource;
@@ -340,6 +341,11 @@ public class MeResource {
return configuration.subResource(DevicesResource.class, caller);
}

@GET @Path(EP_DEVICE_TYPES)
public Response getDeviceTypes(@Context ContainerRequest ctx) {
return ok(BubbleDeviceType.getSelectableTypes());
}

@Path(EP_REFERRAL_CODES)
public ReferralCodesResource getReferralCodes(@Context ContainerRequest ctx) {
final Account caller = userPrincipal(ctx);


+ 18
- 4
bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties Ver ficheiro

@@ -398,12 +398,15 @@ msg_node_state_unknown_error=unknown error
loading_devices=Loading devices...
table_title_devices=Devices
label_field_device_name=Name
label_field_device_type=Type
label_field_device_certificate=Certificate
label_field_device_enabled=Enabled?
label_field_device_vpn_config=VPN
label_field_device_ctime=Added
label_device_ctime_format={{MMM}} {{d}}, {{YYYY}} / {{h}}:{{m}}{{a}}
message_device_vpn_show_config=Show VPN connection info
message_device_vpn_download_conf=Download vpn.conf file
message_device_certificate=Download certificate
button_label_close_device_vpn_config=Close
message_no_devices=No Devices
form_title_add_device=Add Device
@@ -411,6 +414,17 @@ button_label_add_device=Add
button_label_remove_device=Remove
button_label_remove_device_icon=fa fa-trash-alt

# Device types
device_type_uninitialized=Uninitialized
device_type_windows=Windows
device_type_macosx=Mac OS X
device_type_ios=iOS
device_type_android=Android
device_type_linux=Linux
device_type_other=Other
# should never be seen...
device_type_firefox=Firefox

# Apps and MITM control
form_title_mitm=App Control Master Switch
message_mitm_enabled=Enabled
@@ -419,12 +433,12 @@ button_label_mitm_enable=Enable
button_label_mitm_disable=Disable

message_download_ca_cert=Download Certificate
message_os_macosx=Apple Mac OS X
message_os_ios=Apple iOS
message_os_windows=Microsoft Windows
message_os_macosx=Mac OS X
message_os_ios=iOS
message_os_windows=Windows
message_os_android=Android
message_os_linux=Linux
message_os_firefox=Firefox Browser (desktop)
message_os_firefox=Firefox (desktop)

loading_apps=Loading apps...
table_title_apps=Apps


+ 1
- 1
bubble-web

@@ -1 +1 @@
Subproject commit f5c2a0bdce5e4a9e8d610b1512c7ba4aa8e75828
Subproject commit 0a779b9aa415328d8925955eee639c460c17a7e1

Carregando…
Cancelar
Guardar