100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
User and asset provisioning WIP (currently in testing)
Rich Turnerca82502babab
diff --git a/manager/src/main/java/org/openremote/manager/provisioning/ProvisioningResourceImpl.java b/manager/src/main/java/org/openremote/manager/provisioning/ProvisioningResourceImpl.javanew file mode 100644index 000000000..f003cf081--- /dev/null+++ b/manager/src/main/java/org/openremote/manager/provisioning/ProvisioningResourceImpl.java@@ -0,0 +1,56 @@+/*+ * Copyright 2021, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.manager.provisioning;++import org.openremote.manager.security.ManagerIdentityService;+import org.openremote.model.http.RequestParams;+import org.openremote.model.provisioning.ProvisioningConfig;+import org.openremote.model.provisioning.ProvisioningResource;++public class ProvisioningResourceImpl implements ProvisioningResource {++ protected final ProvisioningService provisioningService;+ protected final ManagerIdentityService identityService;++ public ProvisioningResourceImpl(ProvisioningService provisioningService, ManagerIdentityService identityService) {+ this.provisioningService = provisioningService;+ this.identityService = identityService;+ }++ @Override+ public ProvisioningConfig<?> getProvisioningConfigs() {+ return null;+ }++ @Override+ public long createProvisioningConfig(ProvisioningConfig<?> provisioningConfig) {+ return 0;+ }++ @Override+ public void updateProvisioningConfig(RequestParams requestParams, Long id, ProvisioningConfig<?> provisioningConfig) {++ }++ @Override+ public void deleteProvisioningConfig(RequestParams requestParams, Long id) {++ }+}diff --git a/manager/src/main/java/org/openremote/manager/provisioning/ProvisioningService.java b/manager/src/main/java/org/openremote/manager/provisioning/ProvisioningService.javanew file mode 100644index 000000000..a53c4915e--- /dev/null+++ b/manager/src/main/java/org/openremote/manager/provisioning/ProvisioningService.java@@ -0,0 +1,110 @@+/*+ * Copyright 2021, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.manager.provisioning;++import org.apache.commons.io.IOUtils;+import org.openremote.container.persistence.PersistenceService;+import org.openremote.manager.security.ManagerIdentityService;+import org.openremote.manager.web.ManagerWebService;+import org.openremote.model.Container;+import org.openremote.model.ContainerService;+import org.openremote.model.asset.impl.WeatherAsset;+import org.openremote.model.provisioning.ProvisioningConfig;+import org.openremote.model.provisioning.X509ProvisioningConfig;+import org.openremote.model.provisioning.X509ProvisioningData;+import org.openremote.model.provisioning.X509ProvisioningMessage;+import org.openremote.model.security.ClientRole;+import org.openremote.model.util.ValueUtil;++import java.io.ByteArrayInputStream;+import java.io.IOException;+import java.io.InputStream;+import java.nio.charset.StandardCharsets;+import java.security.cert.CertificateException;+import java.security.cert.CertificateFactory;+import java.security.cert.X509Certificate;+import java.util.Collections;+import java.util.List;+import java.util.logging.Logger;++public class ProvisioningService implements ContainerService {++ protected static final Logger LOG = Logger.getLogger(ProvisioningService.class.getName());+ protected PersistenceService persistenceService;+ protected ManagerIdentityService identityService;+ protected CertificateFactory certificateFactory;++ @Override+ public int getPriority() {+ return 0;+ }++ @Override+ public void init(Container container) throws Exception {+ persistenceService = container.getService(PersistenceService.class);+ identityService = container.getService(ManagerIdentityService.class);+++ container.getService(ManagerWebService.class).getApiSingletons().add(+ new ProvisioningResourceImpl(this, identityService)+ );+ }++ @Override+ public void start(Container container) throws Exception {++ }++ @Override+ public void stop(Container container) throws Exception {++ }++ public List<ProvisioningConfig<?>> getProvisioningConfigs() {+ String caPemStr = null;+ try {+ caPemStr = IOUtils.toString(getClass().getResource("/org/openremote/test/provisioning/ca_long.pem"), StandardCharsets.UTF_8);+ } catch (IOException e) {+ e.printStackTrace();+ }+ return Collections.singletonList(+ new X509ProvisioningConfig().setData(+ new X509ProvisioningData()+ .setCACertPEM(caPemStr)+ ).setAssetTemplate(+ ValueUtil.asJSON(+ new WeatherAsset("Weather Asset")+ ).orElse("")+ ).setRealm("building")+ .setRestrictedUser(true)+ .setUserRoles(new ClientRole[] {+ ClientRole.WRITE_ASSETS,+ ClientRole.READ_ASSETS+ })+ );+//+// return persistenceService.doReturningTransaction(entityManager ->+// entityManager.createQuery(+// "select pc from " + ProvisioningConfig.class + " pc " ++// "order by pc.name desc",+// ProvisioningConfig.class)+// .getResultList());+ }+}diff --git a/manager/src/main/java/org/openremote/manager/provisioning/UserAssetProvisioningMQTTHandler.java b/manager/src/main/java/org/openremote/manager/provisioning/UserAssetProvisioningMQTTHandler.javaindex bb7b222e3..e705bbae5 100644--- a/manager/src/main/java/org/openremote/manager/provisioning/UserAssetProvisioningMQTTHandler.java+++ b/manager/src/main/java/org/openremote/manager/provisioning/UserAssetProvisioningMQTTHandler.java@@ -23,12 +23,36 @@ import io.moquette.broker.subscriptions.Topic;import io.moquette.interception.messages.InterceptPublishMessage;import io.moquette.interception.messages.InterceptSubscribeMessage;import io.moquette.interception.messages.InterceptUnsubscribeMessage;+import io.netty.handler.codec.mqtt.MqttQoS;+import org.openremote.container.timer.TimerService;+import org.openremote.container.util.UniqueIdentifierGenerator;+import org.openremote.manager.asset.AssetStorageService;import org.openremote.manager.mqtt.MQTTHandler;+import org.openremote.manager.mqtt.MqttBrokerService;import org.openremote.manager.mqtt.MqttConnection;+import org.openremote.manager.security.ManagerIdentityService;+import org.openremote.manager.security.ManagerKeycloakIdentityProvider;+import org.openremote.model.Container;+import org.openremote.model.asset.Asset;+import org.openremote.model.asset.UserAsset;+import org.openremote.model.provisioning.*;+import org.openremote.model.security.ClientRole;+import org.openremote.model.security.User;import org.openremote.model.syslog.SyslogCategory;+import org.openremote.model.util.TextUtil;+import org.openremote.model.util.ValueUtil;+import java.nio.charset.StandardCharsets;+import java.security.cert.CertificateException;+import java.security.cert.CertificateExpiredException;+import java.security.cert.CertificateNotYetValidException;+import java.security.cert.X509Certificate;+import java.util.Arrays;+import java.util.Date;+import java.util.logging.Level;import java.util.logging.Logger;+import static org.openremote.model.Constants.RESTRICTED_USER_REALM_ROLE;import static org.openremote.model.syslog.SyslogCategory.API;/**@@ -38,12 +62,58 @@ import static org.openremote.model.syslog.SyslogCategory.API;public class UserAssetProvisioningMQTTHandler extends MQTTHandler {protected static final Logger LOG = SyslogCategory.getLogger(API, UserAssetProvisioningMQTTHandler.class);- public static final String TOP_LEVEL_TOPIC = "provisioning";- //protected ProvisioningService provisioningService;+ public static final String PROVISIONING_TOKEN = "provisioning";+ public static final String REQUEST_TOKEN = "request";+ public static final String RESPONSE_TOKEN = "response";+ public static final String UNIQUE_ID_PLACEHOLDER = "%UNIQUE_ID%";+ protected ProvisioningService provisioningService;+ protected TimerService timerService;+ protected MqttBrokerService brokerService;+ protected AssetStorageService assetStorageService;+ protected ManagerKeycloakIdentityProvider identityProvider;+ protected boolean isKeycloak;++ @Override+ public void start(Container container) throws Exception {+ super.start(container);+ provisioningService = container.getService(ProvisioningService.class);+ timerService = container.getService(TimerService.class);+ brokerService = container.getService(MqttBrokerService.class);+ assetStorageService = container.getService(AssetStorageService.class);+ ManagerIdentityService identityService = container.getService(ManagerIdentityService.class);++ if (!identityService.isKeycloakEnabled()) {+ LOG.warning("MQTT connections are not supported when not using Keycloak identity provider");+ isKeycloak = false;+ } else {+ isKeycloak = true;+ identityProvider = (ManagerKeycloakIdentityProvider) identityService.getIdentityProvider();+ }+ }++ @Override+ public boolean handlesTopic(Topic topic) {+ // Skip standard checks+ return topicMatches(topic);+ }++ @Override+ public boolean checkCanSubscribe(MqttConnection connection, Topic topic) {+ // Skip standard checks+ return canSubscribe(connection, topic);+ }++ @Override+ public boolean checkCanPublish(MqttConnection connection, Topic topic) {+ // Skip standard checks+ return canPublish(connection, topic);+ }@Overridepublic boolean topicMatches(Topic topic) {- return false;+ return isProvisioningTopic(topic)+ && topic.getTokens().size() == 3+ && (isRequestTopic(topic) || isResponseTopic(topic));}@Override@@ -53,25 +123,19 @@ public class UserAssetProvisioningMQTTHandler extends MQTTHandler {@Overridepublic boolean canSubscribe(MqttConnection connection, Topic topic) {- if (!TOP_LEVEL_TOPIC.equals(topic.headToken().toString())) {+ if (!isKeycloak) {+ LOG.fine("Identity provider is not keycloak");return false;}- // client/UNIQUE_ID/connect/response--// topic.getTokens().size() ==-// if (Arrays.stream(this.realms).noneMatch(realm -> realm.equals(connection.getRealm()))) {-// LOG.info("realm mismatch");-// return false;-// }-// return true;-- return false;+ return isResponseTopic(topic)+ && !TOKEN_MULTI_LEVEL_WILDCARD.equals(topicTokenIndexToString(topic, 1))+ && !TOKEN_SINGLE_LEVEL_WILDCARD.equals(topicTokenIndexToString(topic, 1));}@Overridepublic void doSubscribe(MqttConnection connection, Topic topic, InterceptSubscribeMessage msg) {-+ // Nothing to do here as we'll publish to this topic in response to client messages}@Override@@ -81,11 +145,248 @@ public class UserAssetProvisioningMQTTHandler extends MQTTHandler {@Overridepublic boolean canPublish(MqttConnection connection, Topic topic) {- return false;+ if (!isKeycloak) {+ LOG.fine("Identity provider is not keycloak");+ return false;+ }++ return isRequestTopic(topic)+ && !TOKEN_MULTI_LEVEL_WILDCARD.equals(topicTokenIndexToString(topic, 1))+ && !TOKEN_SINGLE_LEVEL_WILDCARD.equals(topicTokenIndexToString(topic, 1));}@Overridepublic void doPublish(MqttConnection connection, Topic topic, InterceptPublishMessage msg) {+ String payloadContent = msg.getPayload().toString(StandardCharsets.UTF_8);++ ProvisioningMessage provisioningMessage = ValueUtil.parse(payloadContent, ProvisioningMessage.class)+ .orElseGet(() -> {+ LOG.fine("Failed to parse message from client: topic=" + topic + ", connection=" + connection);+ brokerService.publishMessage(getResponseTopic(topic), new ErrorResponseMessage(ErrorResponseMessage.Error.MESSAGE_INVALID), MqttQoS.AT_MOST_ONCE);+ return null;+ });++ if (provisioningMessage == null) {+ return;+ }++ if (provisioningMessage instanceof X509ProvisioningMessage) {+ processX509ProvisioningMessage(connection, topic, (X509ProvisioningMessage)provisioningMessage);+ }+ }++ protected static boolean isProvisioningTopic(Topic topic) {+ return PROVISIONING_TOKEN.equals(topicTokenIndexToString(topic, 0));+ }++ protected static boolean isRequestTopic(Topic topic) {+ return REQUEST_TOKEN.equals(topicTokenIndexToString(topic, 2));+ }++ protected static boolean isResponseTopic(Topic topic) {+ return RESPONSE_TOKEN.equals(topicTokenIndexToString(topic, 2));+ }++ protected String getResponseTopic(Topic topic) {+ return PROVISIONING_TOKEN + "/" + topicTokenIndexToString(topic, 1) + "/" + RESPONSE_TOKEN;+ }++ protected void processX509ProvisioningMessage(MqttConnection connection, Topic topic, X509ProvisioningMessage provisioningMessage) {++ if (TextUtil.isNullOrEmpty(provisioningMessage.getCert())) {+ LOG.fine("Certificate is missing from X509 provisioning message: topic=" + topic + ", connection=" + connection);+ brokerService.publishMessage(getResponseTopic(topic), new ErrorResponseMessage(ErrorResponseMessage.Error.CERTIFICATE_INVALID), MqttQoS.AT_MOST_ONCE);+ return;+ }++ // Parse client cert+ X509Certificate clientCertificate;+ try {+ clientCertificate = ProvisioningUtil.getX509Certificate(provisioningMessage.getCert());+ } catch (CertificateException e) {+ LOG.log(Level.INFO, "Failed to parse client X.509 certificate: topic=" + topic + ", connection=" + connection, e);+ brokerService.publishMessage(getResponseTopic(topic), new ErrorResponseMessage(ErrorResponseMessage.Error.CERTIFICATE_INVALID), MqttQoS.AT_MOST_ONCE);+ return;+ }++ X509ProvisioningConfig matchingConfig = getMatchingX509ProvisioningConfig(connection, clientCertificate);++ if (matchingConfig == null) {+ LOG.fine("No matching provisioning config found for client certificate: topic=" + topic + ", connection=" + connection);+ brokerService.publishMessage(getResponseTopic(topic), new ErrorResponseMessage(ErrorResponseMessage.Error.UNAUTHORIZED), MqttQoS.AT_MOST_ONCE);+ return;+ }++ // Validate unique ID+ String certUniqueId = ProvisioningUtil.getSubjectCN(clientCertificate.getSubjectX500Principal());+ String uniqueId = topicTokenIndexToString(topic, 1);++ if (TextUtil.isNullOrEmpty(certUniqueId)) {+ LOG.info("Client X.509 certificate missing unique ID in subject CN: topic=" + topic + ", connection=" + connection);+ brokerService.publishMessage(getResponseTopic(topic), new ErrorResponseMessage(ErrorResponseMessage.Error.UNIQUE_ID_MISMATCH), MqttQoS.AT_MOST_ONCE);+ return;+ }++ if (TextUtil.isNullOrEmpty(uniqueId) || !certUniqueId.equals(uniqueId)) {+ LOG.info("Client X.509 certificate unique ID doesn't match topic unique ID: topic=" + topic + ", connection=" + connection);+ brokerService.publishMessage(getResponseTopic(topic), new ErrorResponseMessage(ErrorResponseMessage.Error.UNIQUE_ID_MISMATCH), MqttQoS.AT_MOST_ONCE);+ return;+ }++ String realm = matchingConfig.getRealm();++ // Get/create service user+ String serviceUsername = "PS-" + uniqueId;+ User serviceUser;++ try {+ serviceUser = identityProvider.getUserByUsername(realm, User.SERVICE_ACCOUNT_PREFIX + serviceUsername);++ if (serviceUser != null) {+ if (!serviceUser.getEnabled()) {+ LOG.info("Client service user has been disabled: topic=" + topic + ", connection=" + connection);+ brokerService.publishMessage(getResponseTopic(topic), new ErrorResponseMessage(ErrorResponseMessage.Error.USER_DISABLED), MqttQoS.AT_MOST_ONCE);+ return;+ }+ } else {+ serviceUser = createClientServiceUser(realm, serviceUsername, matchingConfig);+ }+ } catch (Exception e) {+ LOG.log(Level.WARNING, "Failed to retrieve/create service user: topic=" + topic + ", connection=" + connection, e);+ brokerService.publishMessage(getResponseTopic(topic), new ErrorResponseMessage(ErrorResponseMessage.Error.SERVER_ERROR), MqttQoS.AT_MOST_ONCE);+ return;+ }++ Asset<?> asset;++ // Prepend realm name to unique ID to generate asset ID to further improve uniqueness+ String assetId = UniqueIdentifierGenerator.generateId(matchingConfig.getRealm() + uniqueId);+ LOG.fine("Client unique ID '" + uniqueId + "' mapped to asset ID '" + assetId + "': topic=" + topic + ", connection=" + connection);++ try {+ // Look for existing asset+ asset = assetStorageService.find(assetId);++ if (asset != null) {+ LOG.finer("Client asset found: topic=" + topic + ", connection=" + connection + ", assetId=" + assetId);++ if (!matchingConfig.getRealm().equals(asset.getRealm())) {+ LOG.info("Client asset realm mismatch : topic=" + topic + ", connection=" + connection + ", assetId=" + assetId);+ brokerService.publishMessage(getResponseTopic(topic), new ErrorResponseMessage(ErrorResponseMessage.Error.ASSET_ERROR), MqttQoS.AT_MOST_ONCE);+ return;+ }+ } else {+ asset = createClientAsset(realm, assetId, uniqueId, serviceUser, matchingConfig);+ }+ } catch (Exception e) {+ LOG.log(Level.WARNING, "Failed to retrieve/create asset: topic=" + topic + ", connection=" + connection + ", config=" + matchingConfig, e);+ brokerService.publishMessage(getResponseTopic(topic), new ErrorResponseMessage(ErrorResponseMessage.Error.SERVER_ERROR), MqttQoS.AT_MOST_ONCE);+ return;+ }++ LOG.fine("Client successfully initialised: topic=" + topic + ", connection=" + connection);++ // Update connection with service user credentials+ connection.setCredentials(serviceUser.getUsername(), serviceUser.getSecret());+ brokerService.publishMessage(getResponseTopic(topic), new SuccessResponseMessage(realm, asset), MqttQoS.AT_MOST_ONCE);+ }++ protected X509ProvisioningConfig getMatchingX509ProvisioningConfig(MqttConnection connection, X509Certificate clientCertificate) {+ return provisioningService+ .getProvisioningConfigs()+ .stream()+ .filter(config -> config instanceof X509ProvisioningConfig)+ .map(config -> (X509ProvisioningConfig)config)+ .filter(config -> {+ try {+ X509Certificate caCertificate = config.getCertificate();+ if (caCertificate != null) {+ if (!caCertificate.getSubjectX500Principal().getName().equals(clientCertificate.getIssuerX500Principal().getName())) {+ LOG.fine("Client certificate issuer matches provisioning config CA certificate subject: connection=" + connection + ", config=" + config);+ Date now = Date.from(timerService.getNow());++ try {+ clientCertificate.verify(caCertificate.getPublicKey());+ LOG.fine("Client certificate verified against CA certificate: connection=" + connection + ", config=" + config);++ if (!config.getData().isIgnoreExpiryDate()) {+ LOG.fine("Validating client certificate validity: connection=" + connection + ", timestamp=" + now);+ clientCertificate.checkValidity(now);+ }++ return true;+ } catch (CertificateExpiredException | CertificateNotYetValidException e) {+ LOG.log(Level.INFO, "Client certificate failed validity check: connection=" + connection + ", timestamp=" + now, e);+ } catch (Exception e) {+ LOG.log(Level.INFO, "Client certificate failed verification against CA certificate: connection=" + connection + ", config=" + config, e);+ }+ }+ }+ } catch (Exception e) {+ LOG.log(Level.WARNING, "Failed to extract certificate from provisioning config: config=" + config, e);+ }+ return false;+ })+ .findFirst()+ .orElse(null);+ }++ protected User createClientServiceUser(String realm, String username, ProvisioningConfig<?> provisioningConfig) {+ LOG.fine("Creating client service user: realm=" + realm + ", username=" + username);++ User serviceUser = new User()+ .setServiceAccount(true)+ .setEnabled(true)+ .setUsername(username);++ serviceUser = identityProvider.createUpdateUser(realm, serviceUser, null);++ if (provisioningConfig.getUserRoles() != null && provisioningConfig.getUserRoles().length > 0) {+ LOG.finer("Setting user roles: realm=" + realm + ", username=" + username + ", roles=" + Arrays.toString(provisioningConfig.getUserRoles()));+ identityProvider.updateUserRoles(+ realm,+ serviceUser.getId(),+ username,+ Arrays.stream(provisioningConfig.getUserRoles()).map(ClientRole::getValue).toArray(String[]::new)+ );+ } else {+ LOG.finer("No user roles defined: realm=" + realm + ", username=" + username);+ }++ if (provisioningConfig.isRestrictedUser()) {+ LOG.finer("User will be made restricted: realm=" + realm + ", username=" + username);+ identityProvider.updateUserRoles(realm, serviceUser.getId(), null, RESTRICTED_USER_REALM_ROLE);+ }++ return serviceUser;+ }++ protected Asset<?> createClientAsset(String realm, String assetId, String uniqueId, User serviceUser, ProvisioningConfig<?> provisioningConfig) throws RuntimeException {+ LOG.fine("Creating client asset: realm=" + realm + ", username=" + serviceUser.getUsername());++ if (TextUtil.isNullOrEmpty(provisioningConfig.getAssetTemplate())) {+ return null;+ }++ // Replace any placeholders in the template+ String assetTemplate = provisioningConfig.getAssetTemplate();+ assetTemplate = assetTemplate.replaceAll(UNIQUE_ID_PLACEHOLDER, uniqueId);++ // Try and parse provisioning config asset template+ Asset<?> asset = ValueUtil.parse(assetTemplate, Asset.class).orElseThrow(() ->+ new RuntimeException("Failed to de-serialise asset template into an asset instance: template=" + provisioningConfig.getAssetTemplate())+ );++ // Set ID and realm+ asset.setId(assetId);+ asset.setRealm(realm);++ assetStorageService.merge(asset);++ if (provisioningConfig.isRestrictedUser()) {+ assetStorageService.storeUserAsset(new UserAsset(realm, serviceUser.getId(), assetId));+ }+ return asset;}}diff --git a/manager/src/main/resources/META-INF/services/org.openremote.model.ContainerService b/manager/src/main/resources/META-INF/services/org.openremote.model.ContainerServiceindex a4e799ed9..60e458962 100644--- a/manager/src/main/resources/META-INF/services/org.openremote.model.ContainerService+++ b/manager/src/main/resources/META-INF/services/org.openremote.model.ContainerService@@ -26,3 +26,4 @@ org.openremote.manager.gateway.GatewayClientServiceorg.openremote.manager.mqtt.MqttBrokerServiceorg.openremote.manager.asset.AssetModelServiceorg.openremote.manager.energy.EnergyOptimisationService+org.openremote.manager.provisioning.ProvisioningServicediff --git a/model/src/main/java/org/openremote/model/provisioning/ErrorResponseMessage.java b/model/src/main/java/org/openremote/model/provisioning/ErrorResponseMessage.javanew file mode 100644index 000000000..6ec289772--- /dev/null+++ b/model/src/main/java/org/openremote/model/provisioning/ErrorResponseMessage.java@@ -0,0 +1,45 @@+/*+ * Copyright 2021, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.provisioning;++public class ErrorResponseMessage extends ProvisioningMessage {++ public enum Error {+ MESSAGE_INVALID,+ CERTIFICATE_INVALID,+ UNAUTHORIZED,+ FORBIDDEN,+ UNIQUE_ID_MISMATCH,+ CONFIG_DISABLED,+ USER_DISABLED,+ SERVER_ERROR,+ ASSET_ERROR+ }++ protected Error error;++ public ErrorResponseMessage(Error error) {+ this.error = error;+ }++ public Error getError() {+ return error;+ }+}diff --git a/model/src/main/java/org/openremote/model/provisioning/ProvisioningConfig.java b/model/src/main/java/org/openremote/model/provisioning/ProvisioningConfig.javanew file mode 100644index 000000000..8b9a8e0f9--- /dev/null+++ b/model/src/main/java/org/openremote/model/provisioning/ProvisioningConfig.java@@ -0,0 +1,200 @@+/*+ * Copyright 2021, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.provisioning;++import com.fasterxml.jackson.annotation.JsonSubTypes;+import com.fasterxml.jackson.annotation.JsonTypeInfo;+import com.vladmihalcea.hibernate.type.array.EnumArrayType;+import org.hibernate.annotations.Parameter;+import org.hibernate.annotations.Type;+import org.hibernate.annotations.TypeDef;+import org.hibernate.annotations.TypeDefs;+import org.openremote.model.security.ClientRole;++import javax.persistence.*;+import javax.validation.constraints.Min;+import javax.validation.constraints.NotNull;+import java.util.Arrays;+import java.util.Date;++import static javax.persistence.DiscriminatorType.STRING;+import static org.openremote.model.Constants.*;++@TypeDefs({+ @TypeDef(+ typeClass = EnumArrayType.class,+ defaultForType = ClientRole[].class,+ parameters = {+ @Parameter(+ name = EnumArrayType.SQL_ARRAY_TYPE,+ value = "client_role"+ )+ }+ )+})+@Table(name = "provisioning_config")+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)+@DiscriminatorColumn(name = "TYPE", discriminatorType = STRING)+@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type", visible = true)+@JsonSubTypes(+ @JsonSubTypes.Type(name = "x509", value = X509ProvisioningConfig.class)+)+public abstract class ProvisioningConfig<T> {++ @Id+ @Column(name = "ID")+ @Min(1)+ @GeneratedValue(generator = PERSISTENCE_SEQUENCE_ID_GENERATOR)+ protected Long id;++ @Temporal(TemporalType.TIMESTAMP)+ @Column(name = "CREATED_ON", updatable = false, nullable = false, columnDefinition= "TIMESTAMP WITH TIME ZONE")+ @org.hibernate.annotations.CreationTimestamp+ protected Date createdOn = new Date();++ @Temporal(TemporalType.TIMESTAMP)+ @Column(name = "LAST_MODIFIED", nullable = false, columnDefinition= "TIMESTAMP WITH TIME ZONE")+ protected Date lastModified;++ @NotNull+ @Column(name = "NAME", nullable = false, columnDefinition = "text")+ protected String name;++ @Column(name = "TYPE", columnDefinition = "text")+ protected String type;++ @Column(name = "REALM", columnDefinition = "text")+ protected String realm;++ @Column(name = "ASSET_TEMPLATE", columnDefinition = "text")+ protected String assetTemplate;++ @Column(name = "RESTRICTED_USER", nullable = false)+ protected boolean restrictedUser;++ @Column(name = "ROLES", columnDefinition = "client_role[]")+ protected ClientRole[] userRoles;++ @Column(name = "DISABLED", nullable = false)+ protected boolean disabled;++ /**+ * JSON serialisable data for a specific implementation+ */+ @Column(name = "DATA", columnDefinition = "jsonb")+ @org.hibernate.annotations.Type(type = PERSISTENCE_JSON_VALUE_TYPE)+ protected T data;++ public Long getId() {+ return id;+ }++ public Date getCreatedOn() {+ return createdOn;+ }++ public Date getLastModified() {+ return lastModified;+ }++ public String getName() {+ return name;+ }++ public ProvisioningConfig<T> setName(String name) {+ this.name = name;+ return this;+ }++ public String getType() {+ return type;+ }++ public String getAssetTemplate() {+ return assetTemplate;+ }++ public ProvisioningConfig<T> setAssetTemplate(String assetTemplate) {+ this.assetTemplate = assetTemplate;+ return this;+ }++ public boolean isRestrictedUser() {+ return restrictedUser;+ }++ public ProvisioningConfig<T> setRestrictedUser(boolean restrictedUser) {+ this.restrictedUser = restrictedUser;+ return this;+ }++ public ClientRole[] getUserRoles() {+ return userRoles;+ }++ public ProvisioningConfig<T> setUserRoles(ClientRole[] userRoles) {+ this.userRoles = userRoles;+ return this;+ }++ public boolean isDisabled() {+ return disabled;+ }++ public ProvisioningConfig<T> setDisabled(boolean disabled) {+ this.disabled = disabled;+ return this;+ }++ public T getData() {+ return data;+ }++ public ProvisioningConfig<T> setData(T data) {+ this.data = data;+ return this;+ }++ public String getRealm() {+ return realm;+ }++ public ProvisioningConfig<T> setRealm(String realm) {+ this.realm = realm;+ return this;+ }++ @Override+ public String toString() {+ return getClass().getSimpleName() + "{" ++ "id=" + id ++ ", createdOn=" + createdOn ++ ", lastModified=" + lastModified ++ ", name='" + name + '\'' ++ ", type='" + type + '\'' ++ ", realm='" + realm + '\'' ++ ", assetTemplate='" + assetTemplate + '\'' ++ ", restrictedUser=" + restrictedUser ++ ", userRoles=" + Arrays.toString(userRoles) ++ ", disabled=" + disabled ++ ", data=" + data ++ '}';+ }+}diff --git a/model/src/main/java/org/openremote/model/provisioning/ProvisioningMessage.java b/model/src/main/java/org/openremote/model/provisioning/ProvisioningMessage.javanew file mode 100644index 000000000..c1d4b1c10--- /dev/null+++ b/model/src/main/java/org/openremote/model/provisioning/ProvisioningMessage.java@@ -0,0 +1,32 @@+/*+ * Copyright 2021, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.provisioning;++import com.fasterxml.jackson.annotation.JsonSubTypes;+import com.fasterxml.jackson.annotation.JsonTypeInfo;++@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")+@JsonSubTypes({+ @JsonSubTypes.Type(name = "error", value = ErrorResponseMessage.class),+ @JsonSubTypes.Type(name = "success", value = SuccessResponseMessage.class),+ @JsonSubTypes.Type(name = "x509", value = X509ProvisioningMessage.class)+})+public abstract class ProvisioningMessage {+}diff --git a/model/src/main/java/org/openremote/model/provisioning/ProvisioningResource.java b/model/src/main/java/org/openremote/model/provisioning/ProvisioningResource.javanew file mode 100644index 000000000..315c97a92--- /dev/null+++ b/model/src/main/java/org/openremote/model/provisioning/ProvisioningResource.java@@ -0,0 +1,55 @@+/*+ * Copyright 2021, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.provisioning;++import org.openremote.model.Constants;+import org.openremote.model.http.RequestParams;++import javax.annotation.security.RolesAllowed;+import javax.validation.Valid;+import javax.ws.rs.*;++import static javax.ws.rs.core.MediaType.APPLICATION_JSON;++public interface ProvisioningResource {++ @GET+ @Produces(APPLICATION_JSON)+ @RolesAllowed({Constants.REALM_ADMIN_ROLE})+ ProvisioningConfig<?> getProvisioningConfigs();++ @POST+ @Consumes(APPLICATION_JSON)+ @Produces(APPLICATION_JSON)+ @RolesAllowed({Constants.REALM_ADMIN_ROLE})+ long createProvisioningConfig(ProvisioningConfig<?> provisioningConfig);++ @PUT+ @Path("{id}")+ @Consumes(APPLICATION_JSON)+ @RolesAllowed({Constants.REALM_ADMIN_ROLE})+ void updateProvisioningConfig(@BeanParam RequestParams requestParams, @PathParam("id") Long id, @Valid ProvisioningConfig<?> provisioningConfig);++ @DELETE+ @Path("{id}")+ @Produces(APPLICATION_JSON)+ @RolesAllowed({Constants.REALM_ADMIN_ROLE})+ void deleteProvisioningConfig(@BeanParam RequestParams requestParams, @PathParam("id") Long id);+}diff --git a/model/src/main/java/org/openremote/model/provisioning/ProvisioningUtil.java b/model/src/main/java/org/openremote/model/provisioning/ProvisioningUtil.javanew file mode 100644index 000000000..58eee4bd4--- /dev/null+++ b/model/src/main/java/org/openremote/model/provisioning/ProvisioningUtil.java@@ -0,0 +1,73 @@+/*+ * Copyright 2021, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.provisioning;++import javax.naming.InvalidNameException;+import javax.naming.ldap.LdapName;+import javax.naming.ldap.Rdn;+import javax.security.auth.x500.X500Principal;+import java.io.ByteArrayInputStream;+import java.io.IOException;+import java.io.InputStream;+import java.nio.charset.StandardCharsets;+import java.security.cert.CertificateException;+import java.security.cert.CertificateFactory;+import java.security.cert.X509Certificate;+import java.util.logging.Level;+import java.util.logging.Logger;++public class ProvisioningUtil {++ protected static final Logger LOG = Logger.getLogger(ProvisioningUtil.class.getName());+ protected static CertificateFactory certificateFactory;++ static {+ try {+ certificateFactory = CertificateFactory.getInstance("X.509");+ } catch (CertificateException e) {+ LOG.log(Level.SEVERE, "Failed to create X.509 certificate factory", e);+ }+ }++ protected ProvisioningUtil() {+ }++ public static X509Certificate getX509Certificate(String pem) throws CertificateException {+ X509Certificate certificate = null;++ try (InputStream stream = new ByteArrayInputStream(pem.getBytes(StandardCharsets.UTF_8))) {+ certificate = (X509Certificate) certificateFactory.generateCertificate(stream);+ } catch (IOException ignored) {+ }++ return certificate;+ }++ public static String getSubjectCN(X500Principal principal) {+ // Use LDAP RFC 2253 which is same spec as X500 principal to get CN+ try {+ LdapName ldapName = new LdapName(principal.getName());+ return ldapName.getRdns().stream().filter(rdn -> "CN".equals(rdn.getType())).map(rdn -> rdn.getValue().toString()).findFirst().orElse(null);+ } catch (InvalidNameException e) {+ LOG.log(Level.WARNING, "Failed to extract subject CN from X500 principal", e);+ return null;+ }+ }+}diff --git a/model/src/main/java/org/openremote/model/provisioning/SuccessResponseMessage.java b/model/src/main/java/org/openremote/model/provisioning/SuccessResponseMessage.javanew file mode 100644index 000000000..d6bd45e10--- /dev/null+++ b/model/src/main/java/org/openremote/model/provisioning/SuccessResponseMessage.java@@ -0,0 +1,41 @@+/*+ * Copyright 2021, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.provisioning;++import org.openremote.model.asset.Asset;++public class SuccessResponseMessage extends ProvisioningMessage {++ protected String realm;+ protected Asset<?> asset;++ public SuccessResponseMessage(String realm, Asset<?> asset) {+ this.realm = realm;+ this.asset = asset;+ }++ public String getRealm() {+ return realm;+ }++ public Asset<?> getAsset() {+ return asset;+ }+}diff --git a/model/src/main/java/org/openremote/model/provisioning/X509ProvisioningConfig.java b/model/src/main/java/org/openremote/model/provisioning/X509ProvisioningConfig.javanew file mode 100644index 000000000..a1197010d--- /dev/null+++ b/model/src/main/java/org/openremote/model/provisioning/X509ProvisioningConfig.java@@ -0,0 +1,57 @@+/*+ * Copyright 2021, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.provisioning;++import org.openremote.model.util.TextUtil;++import javax.persistence.DiscriminatorValue;+import javax.persistence.Entity;+import javax.persistence.Transient;+import java.security.cert.CertificateException;+import java.security.cert.X509Certificate;++@Entity+@DiscriminatorValue("x509")+public class X509ProvisioningConfig extends ProvisioningConfig<X509ProvisioningData> {++ @Transient+ protected X509Certificate certificate;++ @Transient boolean valid = true;++ public synchronized X509Certificate getCertificate() throws IllegalStateException, CertificateException {+ if (!valid) {+ return null;+ }+ if (data == null || TextUtil.isNullOrEmpty(data.getCACertPEM())) {+ valid = false;+ throw new IllegalStateException("CA cert PEM must be defined");+ }+ if (certificate == null) {+ try {+ certificate = ProvisioningUtil.getX509Certificate(data.getCACertPEM());+ } catch (CertificateException e) {+ valid = false;+ throw(e);+ }+ }+ return certificate;+ }+}diff --git a/model/src/main/java/org/openremote/model/provisioning/X509ProvisioningData.java b/model/src/main/java/org/openremote/model/provisioning/X509ProvisioningData.javanew file mode 100644index 000000000..d0734086c--- /dev/null+++ b/model/src/main/java/org/openremote/model/provisioning/X509ProvisioningData.java@@ -0,0 +1,63 @@+/*+ * Copyright 2021, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.provisioning;++public class X509ProvisioningData {++ protected String CACertPEM;+ protected boolean ignoreExpiryDate;+ protected String overrideUniqueIdAttribute;++ public String getCACertPEM() {+ return CACertPEM;+ }++ public X509ProvisioningData setCACertPEM(String CACertPEM) {+ this.CACertPEM = CACertPEM;+ return this;+ }++ public boolean isIgnoreExpiryDate() {+ return ignoreExpiryDate;+ }++ public X509ProvisioningData setIgnoreExpiryDate(boolean ignoreExpiryDate) {+ this.ignoreExpiryDate = ignoreExpiryDate;+ return this;+ }++ public String getOverrideUniqueIdAttribute() {+ return overrideUniqueIdAttribute;+ }++ public X509ProvisioningData setOverrideUniqueIdAttribute(String overrideUniqueIdAttribute) {+ this.overrideUniqueIdAttribute = overrideUniqueIdAttribute;+ return this;+ }++ @Override+ public String toString() {+ return getClass().getSimpleName() +"{" ++ "CACertPEM='" + CACertPEM + '\'' ++ ", ignoreExpiryDate=" + ignoreExpiryDate ++ ", overrideUniqueIdAttribute='" + overrideUniqueIdAttribute + '\'' ++ '}';+ }+}diff --git a/model/src/main/java/org/openremote/model/provisioning/X509ProvisioningMessage.java b/model/src/main/java/org/openremote/model/provisioning/X509ProvisioningMessage.javanew file mode 100644index 000000000..07f587739--- /dev/null+++ b/model/src/main/java/org/openremote/model/provisioning/X509ProvisioningMessage.java@@ -0,0 +1,32 @@+/*+ * Copyright 2021, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.model.provisioning;++public class X509ProvisioningMessage extends ProvisioningMessage {+ protected String cert;++ public X509ProvisioningMessage(String cert) {+ this.cert = cert;+ }++ public String getCert() {+ return cert;+ }+}diff --git a/test/src/main/resources/org/openremote/test/provisioning/ca.key b/test/src/main/resources/org/openremote/test/provisioning/ca.keynew file mode 100644index 000000000..f72dc6e88--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/ca.key@@ -0,0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SA PRIVATE KEY-----diff --git a/test/src/main/resources/org/openremote/test/provisioning/ca_expired.pem b/test/src/main/resources/org/openremote/test/provisioning/ca_expired.pemnew file mode 100644index 000000000..39ed5d9c4--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/ca_expired.pem@@ -0,0 +1,34 @@+-----BEGIN CERTIFICATE-----+MIIF+zCCA+OgAwIBAgIUWv+fEoBokZnefmaUFtHgiRPNggcwDQYJKoZIhvcNAQEL+BQAwgYwxCzAJBgNVBAYTAk5MMRYwFAYDVQQIDA1Ob3J0aCBCcmFiYW50MRIwEAYD+VQQHDAlFaW5kaG92ZW4xEzARBgNVBAoMCk9wZW5SZW1vdGUxFjAUBgNVBAMMDW9w+ZW5yZW1vdGUuaW8xJDAiBgkqhkiG9w0BCQEWFXN1cHBvcnRAb3BlbnJlbW90ZS5p+bzAeFw0yMTEwMjYxMTExMjZaFw0yMTEwMjcxMTExMjZaMIGMMQswCQYDVQQGEwJO+TDEWMBQGA1UECAwNTm9ydGggQnJhYmFudDESMBAGA1UEBwwJRWluZGhvdmVuMRMw+EQYDVQQKDApPcGVuUmVtb3RlMRYwFAYDVQQDDA1vcGVucmVtb3RlLmlvMSQwIgYJ+KoZIhvcNAQkBFhVzdXBwb3J0QG9wZW5yZW1vdGUuaW8wggIiMA0GCSqGSIb3DQEB+AQUAA4ICDwAwggIKAoICAQC2Dc+WVjKRbvtitZDXqd+CnodnJZJwO0Zt1pHu6R6E+6Y3Xahzb0ElY0jgewmQNROfmvDu5lOpL5xN8Hnf4fgzt3EFooW2E8PZTa/ftjC0v+Po58vpQ3rlzjF8XG96IOAp/PJnz4oXbFJJiP4ux5N6Eo6J8iz8nDFvzN3dUui+mJ+IK3ZAN42zLWkfXqXAr/4NT/VgSsxdOaiLNZVRMxlzshdiptqzwHVHFIxaZQWxA8l+IM2wGLHVE89DwrwBYtcvNv8a3lnmUPDpVtU56jDkdHpVQ3/3fAJ/mty1f7kmgYoZ+nUuMr8XKmTRlPkoWwT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bqq73X8MErjOIW+vOh+J+r4rVLaRXDUQCrN5ZfsFSlUwyIqUU9jHD7iR7LqlzsfGrQQtzJUQyq/xOZD+WNhRZit7N+BX+zQSXWTtAxIS7rKznEEFP7aEwZ0beTxmroHAANDMhM8P5v9UJL8=+-----END CERTIFICATE-----diff --git a/test/src/main/resources/org/openremote/test/provisioning/ca_expired.srl b/test/src/main/resources/org/openremote/test/provisioning/ca_expired.srlnew file mode 100644index 000000000..4600f55e3--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/ca_expired.srl@@ -0,0 +1 @@+723C5C7D28D67D5C4288FB0CDAD9069628284Cdiff --git a/test/src/main/resources/org/openremote/test/provisioning/ca_long.pem b/test/src/main/resources/org/openremote/test/provisioning/ca_long.pemnew file mode 100644index 000000000..b98be40e6--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/ca_long.pem@@ -0,0 +1,35 @@+-----BEGIN CERTIFICATE-----+MIIF/TCCA+WgAwIBAgIUZ/o8/s1N8dM2kn3jqrzMfoF+/SMwDQYJKoZIhvcNAQEL+BQAwgYwxCzAJBgNVBAYTAk5MMRYwFAYDVQQIDA1Ob3J0aCBCcmFiYW50MRIwEAYD+VQQHDAlFaW5kaG92ZW4xEzARBgNVBAoMCk9wZW5SZW1vdGUxFjAUBgNVBAMMDW9w+ZW5yZW1vdGUuaW8xJDAiBgkqhkiG9w0BCQEWFXN1cHBvcnRAb3BlbnJlbW90ZS5p+bzAgFw0yMTEwMjgxMTA5MjJaGA8yMDcxMDIwODExMDkyMlowgYwxCzAJBgNVBAYT+Ak5MMRYwFAYDVQQIDA1Ob3J0aCBCcmFiYW50MRIwEAYDVQQHDAlFaW5kaG92ZW4x+EzARBgNVBAoMCk9wZW5SZW1vdGUxFjAUBgNVBAMMDW9wZW5yZW1vdGUuaW8xJDAi+BgkqhkiG9w0BCQEWFXN1cHBvcnRAb3BlbnJlbW90ZS5pbzCCAiIwDQYJKoZIhvcN+AQEBBQADggIPADCCAgoCggIB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2Eay7OZhY8qnH5rvkiUjG+SgkSmxyN3F+EZQj00G15yVmFpJ1bhLT4s9a33gqcMUon0eHVlGpLcF/0vxVvZ5zr+UUPb1MKUhxSqpFC7h+2odlDwtfepCCTAvpnqiI794ewvkblcafJ5lbypNUjTSXBA++Fi1BcJteEBCVGOOLs34bquAtNdPEmc37wZA+5QNdz9WnYLCgvnrPh8VEXTdqqqb+Mf4/Rr0GbUOmRZXk0LordT3IwOq67c2HrbTFD5H6SGgEiyslzGeDjZyMWJ6uy+ae+MydnFVor6diyzew3MwhCZJKxMu/UJYaECuUtazLWhQi3q0YbQlYMcIGHfp7jDpXa+1ibFAeRSri7PXTVqMNuJ1dftG7s08V55N1AB/3w9f8kkOOO2jZpwRauhIUJA++Xh+Iq6M+PLEvBky6g/v6zOf7/68LtseuaSmMw7GxRVXX2BcrEjSLVz24INa24ZxM87P+qQ==+-----END CERTIFICATE-----diff --git a/test/src/main/resources/org/openremote/test/provisioning/ca_long.srl b/test/src/main/resources/org/openremote/test/provisioning/ca_long.srlnew file mode 100644index 000000000..9ee3b8d38--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/ca_long.srl@@ -0,0 +1 @@+01483583083A22CE208EB8006FAB309EBF102ACBdiff --git a/test/src/main/resources/org/openremote/test/provisioning/device1.csr b/test/src/main/resources/org/openremote/test/provisioning/device1.csrnew file mode 100644index 000000000..a0875b01a--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/device1.csr@@ -0,0 +1,27 @@+-----BEGIN CERTIFICATE REQUEST-----+MIIEpTCCAo0CAQAwYDELMAkGA1UEBhMCTkwxFjAUBgNVBAgMDU5vcnRoIEJyYWJh+bnQxEjAQBgNVBAcMCUVpbmRob3ZlbjETMBEGA1UECgwKT3BlblJlbW90ZTEQMA4G+A1UEAwwHZGV2aWNlMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALiI+eN0lxA8+RGoWEFCOgqfNrtxOqb2KSp/yTFSRKyZSAW5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/63QSrl4EOrve1Ue+mGRJZG7GV76/sbzqeuzFBgcRAjexwd+q+XpccTrJN7jRXAMgw/h4eoVLeYh9GPtt7E0rR5j5A0knM0dz/ks3jykdUTVbH+x0Y+BoRjs1WHnCIDrx4z65EGzvBzwp1cQUa+8f+/dR91rp2nkqF53cihXUMAuYGedFAY+djip+XGyumkLChq7A43oNKKPH5WBQ0lHTGyZrmVNDh/ujQbZ83d4q9mXyEQfcfj6+s25qV3xBOf72KUjBD4s1oFexZKWSCntDfxsifKpwhh41L0WloliCEhM=+-----END CERTIFICATE REQUEST-----diff --git a/test/src/main/resources/org/openremote/test/provisioning/device1.key b/test/src/main/resources/org/openremote/test/provisioning/device1.keynew file mode 100644index 000000000..8fd725757--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/device1.key@@ -0,0 +1,51 @@+-----BEGIN RSA PRIVATE KEY-----+MIIJJwIBAAKCAgEAuIh43SXEDz5EahYQUI6Cp82u3E6pvYpKn/JMVJErJlIBbk1i+ZnW2zBYeu0yj8GR7mr11BgxhrjL69y6rZn1aHuB1WLSR0dFOVah970RTYkVunMIO+YOUi5+t935WR4gaohHCa6ZpU0W27HIpSEFjNzEhqGiN1H4Fdq+6tBw4xUCj6T343+rngCDCLLHKA57HQF+vimtceY8OpmE7FOviAOwqQGaMcEvzxj2WdwEXQv0Y+Tn3GY+a4yqJZP/nXaNepYSey6Nk63CH3NDxFIj/Y1c+iTJZ3LzEm3W9VKY31nCJ3auPk8s+obXSTsWwXy7lFKWygXPqjCw4o3vhF5ir5EGD1PvQZSOUm342vcQKeP464ZeGtr7X+qb6xsIgpzocbk4Itl4YvINGjuVIFWJRfdLMSwCzCIUJ1JCiR8ZgHyZxKFk8a38x2+cEE6nbTrSnb3kwyRmkZXd3+i5+Y8MynGQ/l7eHlNGUKlX2u9OWD8KiijiSqKeSfn+quf5CX0TEgvieVbP3O88kEW9b6QAmEsdJiLig6mfQcvu3SGMbhycu0VM+rNfo6lF+xFgbV5XrHf3hj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cusCN7PUBqSgoSiVUunwA1cjoc9pBvwVVQtCzu8CPL/BvnP/CfQbpmhgn5qQ+4UoXV2laLw1pdC9iDl/CXw5IEngbm58CggEAdMXVF96NBnelYlJj24g0PteNLLJO+bVtnR3q9bQH6MdB3AogV37UlQnvzIhjcucvMAf89v0OHO7RdlxaDoMKy0Y7DFXg9+i/4WJ5ALKW2gHQnn3cm6UF5y5IAU7H+Qt+Xi2h5PD5t46UkvFUj4VfVZscnTXZT4+hi31Eo0bJyfPBTNoXfsg6wlYRuajepCDokbQ9pw4Vzibch5DZQjBKoXbmVjlSrBh+1WeyT1G0urnSdhuPGaBVc6y7b+MBxzZDmSaurhsehCZpH4W/vSpRN6DZil3pi0Wz+J8X+OH9oo6IntQkw5CezQ/7A81osAwRvUE5yD/8fsxXGzOOyhhHso3Zn1A==+-----END RSA PRIVATE KEY-----diff --git a/test/src/main/resources/org/openremote/test/provisioning/device1.pem b/test/src/main/resources/org/openremote/test/provisioning/device1.pemnew file mode 100644index 000000000..7cd2b5dbd--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/device1.pem@@ -0,0 +1,32 @@+-----BEGIN CERTIFICATE-----+MIIFdjCCA14CFAFINYMIOiLOII64AG+rMJ6/ECrKMA0GCSqGSIb3DQEBCwUAMIGM+MQswCQYDVQQGEwJOTDEWMBQGA1UECAwNTm9ydGggQnJhYmFudDESMBAGA1UEBwwJ+RWluZGhvdmVuMRMwEQYDVQQKDApPcGVuUmVtb3RlMRYwFAYDVQQDDA1vcGVucmVt+b3RlLmlvMSQwIgYJKoZIhvcNAQkBFhVzdXBwb3J0QG9wZW5yZW1vdGUuaW8wIBcN+MjExMDI2MTExODUzWhgPMjA3MTAyMDYxMTE4NTNaMGAxCzAJBgNVBAYTAk5MMRYw+FAYDVQQIDA1Ob3J0aCBCcmFiYW50MRIwEAYDVQQHDAlFaW5kaG92ZW4xEzARBgNV+BAoMCk9wZW5SZW1vdGUxEDAOBgNVBAMMB2RldmljZTEwggIiMA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41c+KQwrYGn7WsbDOoYhkkSPw70FVVdJyWj9e5o1OwKT+K6Ydy+cqxm6XAtu7+I5aUe7h8LIv2k/6VttMppWRfp2wG7jfTR/mtglj6cpUjUdNY1/i2IrevRKqbouPk+OmTjUGFjwsZTGE26BLbmTLlHuF9Rikh+HHxhyMXgk5x6zU0PlcqCU4tXNcnFuLaE+hWTLqlfMbO5QBa17MxXJp5qws5YLUOWhwrscXfMM6eG/zb6lqFK8BT0rmwonoAtM+fUUCRkPgP8jqeriU3p76TUc6cjiSsPBQxQz3ll819AecgjJiIOUY2Ipniim4Ives+tQDykWW8j4Ts7h/IRaFFZHEHnlDiWb1hUmueYfmxIgSY5trJBef1JDMKtiuZRwhJ+X6Wrw69JQtkUNQ==+-----END CERTIFICATE-----diff --git a/test/src/main/resources/org/openremote/test/provisioning/device2.csr b/test/src/main/resources/org/openremote/test/provisioning/device2.csrnew file mode 100644index 000000000..d8a072069--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/device2.csr@@ -0,0 +1,17 @@+-----BEGIN CERTIFICATE REQUEST-----+MIICpTCCAY0CAQAwYDELMAkGA1UEBhMCTkwxFjAUBgNVBAgMDU5vcnRoIEJyYWJh+bnQxEjAQBgNVBAcMCUVpbmRob3ZlbjETMBEGA1UECgwKT3BlblJlbW90ZTEQMA4G+A1UEAwwHZGV2aWNlMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOSQ+wdJH19AgihxlXU13XzhOIk21kFi1lGSSr/j1BvIzNzh0ofawAgwcAnp/RQs377vx+0xPc8H25i5lNd3U0vsLarfsZH+q83icpszYlC8QuiM8KQYTFP5uaaLHI6oZRxytO+pHG7jHOmI1GaPEpO/xTqG4uf299IMXBZsyCKpJAtuRDAEsXQUga1x5GRSB08exeF+w9220LLbtRJpH/7Nuqs0a9s99kFgVooCnHCSfZ+5zQCr938vRgcitmdq9wKjsy/K+yyVQE3l7GSvruqSRiqVu2NFQxPN9kmKx8c8PZa4hjNQEB1r742G4IZzO/frhqpL9+DQXbFgmLoXX9ij8HIucCAwEAAaAAMA0GCSqGSIb3DQEBCwUAA4IBAQCqKu3l2dGj+pZWJLNyKsnqFKBy7hzOgmZFyN7SOmuXuNuIvVPEB1nEc66Wv/Qu87Abe1hTEvVPy+X9jhoUJ24ejv7UnAEj3PZky8Zq9LOwpKC5GKInHXoIYKrPmxnlIValwb/USUpYlR+WjuJHbrFbwQDT7L8rWs1v4fRC5YK7Pt3z0Xs/lMCtHzKJytQmKt84ArXDuZ3p4Q0+COhyyYwKieZijlRjP6TkRy9obO2cl4mi6KsIVbaKsL3vsQanGRoaR2m/PSqGvpiN+ljl7X0B2BbUEG4Q4S4cl5H/P+CBxq0PuuehYBD9GTHKkataUkasXacl2NE+kUaas+CL2U8FG0qt+m+-----END CERTIFICATE REQUEST-----diff --git a/test/src/main/resources/org/openremote/test/provisioning/device2.key b/test/src/main/resources/org/openremote/test/provisioning/device2.keynew file mode 100644index 000000000..aac26b4d7--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/device2.key@@ -0,0 +1,27 @@+-----BEGIN RSA PRIVATE KEY-----+MIIEpAIBAAKCAQEA5JDB0kfX0CCKHGVdTXdfOE4iTbWQWLWUZJKv+PUG8jM3OHSh+9rACDBwCen9FCzfvu/HTE9zwfbmLmU13dTS+wtqt+xkf6rzeJymzNiULxC6IzwpB+hMU/m5poscjqhlHHK06kcbuMc6YjUZo8Sk7/FOobi5/b30gxcFmzIIqkkC25EMAS+xdBSBrXHkZFIHTx7F4XD3bbQstu1Emkf/s26qzRr2z32QWBWigKccJJ9n7nNAKv3+fy9GByK2Z2r3AqOzL8rLJVATeXsZK+u6pJGKpW7Y0VDE832SYrHxzw9lriGM1AQH+WvvjYbghnM79+uGqkv0NBdsWCYuhdf2KPwci5wIDAQABAoIBAQCps7zktwjKc853+hN9AjBf7wy9/CQaShscV4T+clbjBjTs7xIUYltf+S7GfZ+1IhhCON99jiRBaGLBI+c5b1Q+M644h3vdDPxckf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eRusr9Fdvh2I+T1zg4IwY2PdqEEdRuJGUglXSH8whNzLM1QB7Xu3Ar7y5ArpKzy7UXA==+-----END RSA PRIVATE KEY-----diff --git a/test/src/main/resources/org/openremote/test/provisioning/device2_expired.pem b/test/src/main/resources/org/openremote/test/provisioning/device2_expired.pemnew file mode 100644index 000000000..162e359b8--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/device2_expired.pem@@ -0,0 +1,26 @@+-----BEGIN CERTIFICATE-----+MIIEdDCCAlwCFAFINYMIOiLOII64AG+rMJ6/ECrLMA0GCSqGSIb3DQEBCwUAMIGM+MQswCQYDVQQGEwJOTDEWMBQGA1UECAwNTm9ydGggQnJhYmFudDESMBAGA1UEBwwJ+RWluZGhvdmVuMRMwEQYDVQQKDApPcGVuUmVtb3RlMRYwFAYDVQQDDA1vcGVucmVt+b3RlLmlvMSQwIgYJKoZIhvcNAQkBFhVzdXBwb3J0QG9wZW5yZW1vdGUuaW8wHhcN+MjExMDI2MTExOTMxWhcNMjExMDI3MTExOTMxWjBgMQswCQYDVQQGEwJOTDEWMBQG+A1UECAwNTm9ydGggQnJhYmFudDESMBAGA1UEBwwJRWluZGhvdmVuMRMwEQYDVQQK+DApPcGVuUmVtb3RlMRAwDgYDVQQDDAdkZXZpY2UyMIIBIjANBgkqhkiG9w0BAQEF+AAOCAQ8AMIIBCgKCAQEA5JDB0kfX0CCKHGVdTXdfOE4iTbWQWLWUZJKv+PUG8jM3+OHSh9rACDBwCen9FCzfvu/HTE9zwfbmLmU13dTS+wtqt+xkf6rzeJymzNiULxC6I+zwpBhMU/m5poscjqhlHHK06kcbuMc6YjUZo8Sk7/FOobi5/b30gxcFmzIIqkkC25+EMASxdBSBrXHkZFIHTx7F4XD3bbQstu1Emkf/s26qzRr2z32QWBWigKccJJ9n7nN+AKv3fy9GByK2Z2r3AqOzL8rLJVATeXsZK+u6pJGKpW7Y0VDE832SYrHxzw9lriGM+1AQHWvvjYbghnM79+uGqkv0NBdsWCYuhdf2KPwci5wIDAQABMA0GCSqGSIb3DQEB+CwUAA4ICAQAB4NP1sy5pkLjf9bkSPWSPGknhtqlm8q5sXMv9fe4bAVXeuezPvB4v+z9dX4rR24BnbxasnN7e9teztTV+z4lmCBwwzCdy4zoyjaluyXuB+FOhkLVUdaHjP+JHBls72lxjbJy2PwQGaZDhBOjuv/nNlSQSNM4MB6ANvQVfnRwGYYxpdpGTJ7ymz9+bav52tJpnHGzLQJ9gaMz+otyzdP+jU/AUCsYbpAaAd9mv7+/ncfTfvWwm5AedHBv+B6w1oYGdKVajX+MBgkysjau5m9pu7b+BcxJUzzehYKqYUcDxlpRKT0NUlzvwSsQ0++KpqzVarxqTI8fUWbP/O4OZHZwUYJm4kF4NoRweppmqS6GbISJ46ZVYOuF0YWVYR+wP9PjENOWUgEdCgySvh3l/VprL6xjnktu7/VH9Yg/ap5OoKhbDgA0CN1N2qgZ7e5+zugN7CWnJsO7DH3Y3qhhIFajtfxYH4Rs7LQImZHckLFPGcofGcUyHXBLmBaGI1ym+k4dC5i8rt7CIWKGg0v/NWwINYWLrnF2cOTiOXhkr45qCvYMb2yJkq3KUE7CSnO9x+cQBDmmA7y8C6LpVbdEVXFdXwsFU0KHDgu2TQMPgrJsPyp87HerrGPPkzI4C42+6U+Gw5/qVA4dXTOPfRcqNzrlBxGLMCWH2F38lP3gwQmdxaNLP6i98TdZQ==+-----END CERTIFICATE-----diff --git a/test/src/main/resources/org/openremote/test/provisioning/device3.csr b/test/src/main/resources/org/openremote/test/provisioning/device3.csrnew file mode 100644index 000000000..e1179e71f--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/device3.csr@@ -0,0 +1,17 @@+-----BEGIN CERTIFICATE REQUEST-----+MIICpTCCAY0CAQAwYDELMAkGA1UEBhMCTkwxFjAUBgNVBAgMDU5vcnRoIEJyYWJh+bnQxEjAQBgNVBAcMCUVpbmRob3ZlbjETMBEGA1UECgwKT3BlblJlbW90ZTEQMA4G+A1UEAwwHZGV2aWNlMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOSQ+wdJH19AgihxlXU13XzhOIk21kFi1lGSSr/j1BvIzNzh0ofawAgwcAnp/RQs377vx+0xPc8H25i5lNd3U0vsLarfsZH+q83icpszYlC8QuiM8KQYTFP5uaaLHI6oZRxytO+pHG7jHOmI1GaPEpO/xTqG4uf299IMXBZsyCKpJAtuRDAEsXQUga1x5GRSB08exeF+w9220LLbtRJpH/7Nuqs0a9s99kFgVooCnHCSfZ+5zQCr938vRgcitmdq9wKjsy/K+yyVQE3l7GSvruqSRiqVu2NFQxPN9kmKx8c8PZa4hjNQEB1r742G4IZzO/frhqpL9+DQXbFgmLoXX9ij8HIucCAwEAAaAAMA0GCSqGSIb3DQEBCwUAA4IBAQBv1JssGKji+D1/Q8OXi8bDA9B3TSn8byQFE3u4+/tmNsM892xH26FZY/fPfZSDQH2jH/pYIwQLx+v0AHy1Ipenf4SBUE01GCNUwZFUI4FDW18+N8kYQujLru/uOd+fRk9Yevl9YeJ1D/+o3v+n5dUSLhOJrOzLN6jeTij7Oo7WZ8LE8xdlHGcK49FEzmjqRLiEhh0Gbofmsjq+UpQaeSXtUXD76wUM2ie7dfaVr1gn85x/k3q9u/BSDGrNeEvQkmBNvsiz0qQAt2t4++2fberkEwvNhUfCUBtwD2l/31L+6zwFzkK3pOmxmYZXsc2eeFzYIc8yMNDWW8jhB+lHJ7sapBd29p+-----END CERTIFICATE REQUEST-----diff --git a/test/src/main/resources/org/openremote/test/provisioning/device3.key b/test/src/main/resources/org/openremote/test/provisioning/device3.keynew file mode 100644index 000000000..5e635b07e--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/device3.key@@ -0,0 +1,27 @@+-----BEGIN RSA PRIVATE KEY-----+MIIEpAIBAAKCAQEA+JugmjTLx5g+qAzEuBEBGb9WQvToCP4bL4WUQEkn+s/Z02Hr+jwYktbRFmWFv0D01y4dlAUpuNDECfVjcWkJnON43ejHH9Tkyw2klAtfbBFypJuLV+S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TXWF+28AhITLKFwcGgLoZNRPWk4ECgYAGg+VhgrOhGD/FTfV7eXOGESvxAjc56rUsJYPm+AQfvgJP9U+srAdu3byzNhi0785vIPjm0+3KIIQSbXO37l4RuexIm+IF4Xa4ogmXd+G84hYMsvebblhGDz1TTtHQCRR/hl/aZ4VnjAirEXX7U7cufTKrG/DF9EfQH706NL+WaTW8QKBgQCaHASUJWaSyT6MIK+y66jIic+19d6FDtWr+Xjepwrb5LsoaM3/dYl8+UPna50ojQa5MoUEhIGTNM38+RA/aOEz5GY1aU+QJIas9QOqNgTYwwAxtZOPbQtVo+bnvo+Afa0vLYRdY9gyX0RAiCpFEnpeygKfprxH2+SskInbNBQFV5VA==+-----END RSA PRIVATE KEY-----diff --git a/test/src/main/resources/org/openremote/test/provisioning/device3_caexpired.pem b/test/src/main/resources/org/openremote/test/provisioning/device3_caexpired.pemnew file mode 100644index 000000000..8b55f12a2--- /dev/null+++ b/test/src/main/resources/org/openremote/test/provisioning/device3_caexpired.pem@@ -0,0 +1,26 @@+-----BEGIN CERTIFICATE-----+MIIEdTCCAl0CE3I8XH0o1n1cQoj7DNrZBpYoKEwwDQYJKoZIhvcNAQELBQAwgYwx+CzAJBgNVBAYTAk5MMRYwFAYDVQQIDA1Ob3J0aCBCcmFiYW50MRIwEAYDVQQHDAlF+aW5kaG92ZW4xEzARBgNVBAoMCk9wZW5SZW1vdGUxFjAUBgNVBAMMDW9wZW5yZW1v+dGUuaW8xJDAiBgkqhkiG9w0BCQEWFXN1cHBvcnRAb3BlbnJlbW90ZS5pbzAgFw0y+MTEwMjYxMTIwNTRaGA8yMDcxMDIwNjExMjA1NFowYDELMAkGA1UEBhMCTkwxFjAU+BgNVBAgMDU5vcnRoIEJyYWJhbnQxEjAQBgNVBAcMCUVpbmRob3ZlbjETMBEGA1UE+CgwKT3BlblJlbW90ZTEQMA4GA1UEAwwHZGV2aWNlMzCCASIwDQYJKoZIhvcNAQEB+BQADggEPADCCAQoCggEBAOSQwdJH19Agihxl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groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovy b/test/src/test/groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovyindex 35b1950ec..738d357ac 100644--- a/test/src/test/groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovy+++ b/test/src/test/groovy/org/openremote/test/provisioning/UserAndAssetProvisioningTest.groovy@@ -23,41 +23,57 @@ import io.moquette.BrokerConstantsimport org.junit.Ignoreimport org.openremote.agent.protocol.mqtt.MQTTAgentimport org.openremote.agent.protocol.mqtt.MQTTAgentLink+import org.openremote.agent.protocol.mqtt.MQTTMessageimport org.openremote.agent.protocol.mqtt.MQTTProtocol+import org.openremote.agent.protocol.mqtt.MQTT_IOClientimport org.openremote.agent.protocol.simulator.SimulatorProtocolimport org.openremote.container.util.UniqueIdentifierGeneratorimport org.openremote.manager.agent.AgentServiceimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageServiceimport org.openremote.manager.event.ClientEventService+import org.openremote.manager.mqtt.MqttBrokerService+import org.openremote.manager.provisioning.ProvisioningService+import org.openremote.manager.provisioning.UserAssetProvisioningMQTTHandlerimport org.openremote.manager.setup.SetupServiceimport org.openremote.model.Constantsimport org.openremote.model.asset.agent.Agentimport org.openremote.model.asset.agent.ConnectionStatusimport org.openremote.model.asset.agent.Protocolimport org.openremote.model.asset.impl.ThingAsset+import org.openremote.model.asset.impl.WeatherAssetimport org.openremote.model.attribute.Attributeimport org.openremote.model.attribute.AttributeEventimport org.openremote.model.attribute.MetaItemimport org.openremote.model.auth.UsernamePassword+import org.openremote.model.provisioning.ErrorResponseMessage+import org.openremote.model.provisioning.ProvisioningMessage+import org.openremote.model.provisioning.SuccessResponseMessage+import org.openremote.model.provisioning.X509ProvisioningConfig+import org.openremote.model.provisioning.X509ProvisioningData+import org.openremote.model.provisioning.X509ProvisioningMessage+import org.openremote.model.util.ValueUtilimport org.openremote.test.ManagerContainerTraitimport org.openremote.test.setup.KeycloakTestSetupimport org.openremote.test.setup.ManagerTestSetupimport spock.lang.Specificationimport spock.util.concurrent.PollingConditions+import java.util.function.Consumer+import static org.openremote.container.util.MapAccess.getIntegerimport static org.openremote.container.util.MapAccess.getStringimport static org.openremote.manager.mqtt.MqttBrokerService.MQTT_SERVER_LISTEN_HOSTimport static org.openremote.manager.mqtt.MqttBrokerService.MQTT_SERVER_LISTEN_PORTimport static org.openremote.model.value.MetaItemType.AGENT_LINKimport static org.openremote.model.value.ValueType.NUMBER+import static org.openremote.manager.provisioning.UserAssetProvisioningMQTTHandler.*@Ignoreclass UserAndAssetProvisioningTest extends Specification implements ManagerContainerTrait {@SuppressWarnings("GroovyAccessibility")- def "Check websocket client protocol and linked attribute deployment"() {+ def "Check user and asset provisioning functionality"() {given: "expected conditions"def conditions = new PollingConditions(timeout: 10, delay: 0.2)@@ -65,80 +81,76 @@ class UserAndAssetProvisioningTest extends Specification implements ManagerContaand: "the container starts"def container = startContainer(defaultConfig(), defaultServices())def assetStorageService = container.getService(AssetStorageService.class)+ def provisioningService = container.getService(ProvisioningService.class)+ def mqttBrokerService = container.getService(MqttBrokerService.class)def assetProcessingService = container.getService(AssetProcessingService.class)- def agentService = container.getService(AgentService.class)def managerTestSetup = container.getService(SetupService.class).getTaskOfType(ManagerTestSetup.class)def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)- def clientEventService = container.getService(ClientEventService.class)def mqttHost = getString(container.getConfig(), MQTT_SERVER_LISTEN_HOST, BrokerConstants.HOST)def mqttPort = getInteger(container.getConfig(), MQTT_SERVER_LISTEN_PORT, BrokerConstants.PORT)- when: "an MQTT client agent is created to connect to this tests manager"- def clientId = UniqueIdentifierGenerator.generateId()- def agent = new MQTTAgent("Test agent")- .setRealm(Constants.MASTER_REALM)- .setClientId(clientId)- .setHost(mqttHost)- .setPort(mqttPort)- .setUsernamePassword(new UsernamePassword(keycloakTestSetup.tenantBuilding.realm + ":" + KeycloakTestSetup.serviceUserId, KeycloakTestSetup.serviceUserSecret))-- and: "the agent is added to the asset service"- agent = assetStorageService.merge(agent)-- then: "the protocol should authenticate and the agent status should become CONNECTED"+ when: "a provisioning realm config is added to the system"+ // TODO: implement config persistence and resource implementation+// def provisioningConfig = new X509ProvisioningConfig().setData(+// new X509ProvisioningData()+// .setCACertPEM("")+// ).setAssetTemplate(+// ValueUtil.asJSON(+// new WeatherAsset("Weather Asset")+// ).orElse("")+// )++ then: "then the config should be available in the system"conditions.eventually {- agent = assetStorageService.find(agent.id, Agent.class)- assert agent.getAgentStatus().orElse(null) == ConnectionStatus.CONNECTED+ assert provisioningService.getProvisioningConfigs().size() == 1+ assert provisioningService.getProvisioningConfigs().get(0) instanceof X509ProvisioningConfig+ assert ((X509ProvisioningConfig)provisioningService.getProvisioningConfigs().get(0)).getData() != null+ //assert ((X509ProvisioningConfig)provisioningService.getProvisioningConfigs().get(0)).getData().getCACertPEM() == provisioningConfig.getData().getCACertPEM()}- when: "an asset is created with attributes linked to the agent"- def asset = new ThingAsset("Test Asset")- .setParent(agent)- .addOrReplaceAttributes(- // write attribute value- new Attribute<>("readWriteTargetTemp", NUMBER)- .addMeta(- new MetaItem<>(AGENT_LINK, new MQTTAgentLink(agent.id)- .setSubscriptionTopic("${keycloakTestSetup.tenantBuilding.realm}/$clientId/attributevalue/${managerTestSetup.apartment1LivingroomId}/targetTemperature")- .setPublishTopic("${keycloakTestSetup.tenantBuilding.realm}/$clientId/attributevalue/${managerTestSetup.apartment1LivingroomId}/targetTemperature")- .setWriteValue("${Protocol.DYNAMIC_VALUE_PLACEHOLDER}")- ))- )-- and: "the asset is merged into the asset service"- asset = assetStorageService.merge(asset)+ when: "a mqtt client connects"+ def device1UniqueId = "Device1SerialNumber"+ def mqttClientId = UniqueIdentifierGenerator.generateId()+ MQTT_IOClient client = new MQTT_IOClient(mqttClientId, mqttHost, mqttPort, false, null, null)+ client.connect()- then: "the linked attributes should be correctly linked"+ then: "mqtt connection should exist"conditions.eventually {- assert !(agentService.getProtocolInstance(agent.id) as MQTTProtocol).protocolMessageConsumers.isEmpty()+ assert client.getConnectionStatus() == ConnectionStatus.CONNECTED+ assert mqttBrokerService.clientIdConnectionMap.get(mqttClientId) != null}- when: "the source attribute are updated"- ((SimulatorProtocol)agentService.getProtocolInstance(managerTestSetup.apartment1ServiceAgentId)).updateSensor(new AttributeEvent(managerTestSetup.apartment1LivingroomId, "targetTemperature", 99d))-- then: "the values should be stored in the database"- conditions.eventually {- def livingRoom = assetStorageService.find(managerTestSetup.apartment1LivingroomId)- assert livingRoom != null- assert livingRoom.getAttribute("targetTemperature", Double.class).flatMap{it.value}.orElse(0d) == 99d+ when: "the client subscribes to the provisioning endpoints"+ List<ProvisioningMessage> device1Responses = []+ Consumer<MQTTMessage<String>> device1MessageConsumer = { MQTTMessage<String> msg ->+ device1Responses.add(ValueUtil.parse(msg.payload, ProvisioningMessage.class).orElse(null))}+ def device1RequestTopic = "$PROVISIONING_TOKEN/$device1UniqueId/$REQUEST_TOKEN".toString()+ def device1ResponseTopic = "$PROVISIONING_TOKEN/$device1UniqueId/$RESPONSE_TOKEN".toString()+ client.addMessageConsumer(device1ResponseTopic, device1MessageConsumer)- then: "the linked attributes should also have the updated values of the subscribed attributes"+ then: "the subscriptions should succeed"conditions.eventually {- asset = assetStorageService.find(asset.getId(), true)- assert asset.getAttribute("readWriteTargetTemp").get().getValue().orElse(null) == 99d+ assert client.topicConsumerMap.get(device1ResponseTopic) != null+ assert client.topicConsumerMap.get(device1ResponseTopic).size() == 1+ assert mqttBrokerService.clientIdConnectionMap.get(mqttClientId) != null}- when: "a linked attribute value is updated"- def attributeEvent = new AttributeEvent(asset.id,- "readWriteTargetTemp",- 19.5)- assetProcessingService.sendAttributeEvent(attributeEvent)+ when: "the client publishes a valid x509 certificate that has been signed by the CA stored in the provisioning config"+ client.sendMessage(+ new MQTTMessage<String>(device1RequestTopic, ValueUtil.asJSON(+ new X509ProvisioningMessage(getClass().getResource("/org/openremote/test/provisioning/device1.pem").text)+ ).orElse(null))+ )- then: "the linked targetTemperature attribute should contain this written value (it should have been written to the target temp attribute and then read back again)"+ then: "the broker should have published to the response topic a success message"conditions.eventually {- asset = assetStorageService.find(asset.getId(), true)- assert asset.getAttribute("readWriteTargetTemp", Double.class).flatMap{it.getValue()}.orElse(null) == 19.5d+ assert device1Responses.size() == 1+ assert device1Responses.get(0) instanceof SuccessResponseMessage+ assert ((SuccessResponseMessage)device1Responses.get(0)).realm == managerTestSetup.realmBuildingTenant+ assert ((SuccessResponseMessage)device1Responses.get(0)).asset != null}++}}