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
Moved WebTargetBuilder into container module and KeycloakIdentityProvider now uses this for improved performance
Rich Turnera05e4cf78f79
diff --git a/agent/src/main/java/org/openremote/agent/protocol/Protocol.java b/agent/src/main/java/org/openremote/agent/protocol/Protocol.javaindex 8d320dce8..94087198c 100644--- a/agent/src/main/java/org/openremote/agent/protocol/Protocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/Protocol.java@@ -21,7 +21,7 @@ package org.openremote.agent.protocol;import org.apache.commons.codec.binary.BinaryCodec;import org.apache.commons.codec.binary.Hex;-import org.openremote.agent.protocol.http.OAuthGrant;+import org.openremote.container.web.OAuthGrant;import org.openremote.container.Container;import org.openremote.container.ContainerService;import org.openremote.model.AbstractValueHolder;diff --git a/agent/src/main/java/org/openremote/agent/protocol/controller/ControllerProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/controller/ControllerProtocol.javaindex e000d3603..85aa23629 100644--- a/agent/src/main/java/org/openremote/agent/protocol/controller/ControllerProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/controller/ControllerProtocol.java@@ -27,7 +27,7 @@ import org.openremote.agent.protocol.AbstractProtocol;import org.openremote.agent.protocol.controller.command.ControllerCommandBasic;import org.openremote.agent.protocol.controller.command.ControllerCommandMapped;import org.openremote.agent.protocol.http.HttpClientProtocol;-import org.openremote.agent.protocol.http.WebTargetBuilder;+import org.openremote.container.web.WebTargetBuilder;import org.openremote.container.Container;import org.openremote.model.AbstractValueHolder;import org.openremote.model.asset.AssetAttribute;@@ -50,8 +50,8 @@ import java.util.function.Consumer;import java.util.logging.Level;import java.util.logging.Logger;-import static org.openremote.agent.protocol.http.WebTargetBuilder.CONNECTION_POOL_SIZE;-import static org.openremote.agent.protocol.http.WebTargetBuilder.createClient;+import static org.openremote.container.web.WebTargetBuilder.CONNECTION_POOL_SIZE;+import static org.openremote.container.web.WebTargetBuilder.createClient;import static org.openremote.container.concurrent.GlobalLock.withLock;import static org.openremote.container.concurrent.GlobalLock.withLockReturning;import static org.openremote.model.Constants.PROTOCOL_NAMESPACE;diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.javaindex 5aa842e25..d7afe199a 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/http/HttpClientProtocol.java@@ -28,6 +28,10 @@ import org.jboss.resteasy.specimpl.ResponseBuilderImpl;import org.openremote.agent.protocol.AbstractProtocol;import org.openremote.agent.protocol.Protocol;import org.openremote.container.Container;+import org.openremote.container.web.HeaderInjectorFilter;+import org.openremote.container.web.OAuthGrant;+import org.openremote.container.web.QueryParameterInjectorFilter;+import org.openremote.container.web.WebTargetBuilder;import org.openremote.model.AbstractValueHolder;import org.openremote.model.ValidationFailure;import org.openremote.model.ValueHolder;diff --git a/agent/src/main/java/org/openremote/agent/protocol/websocket/AbstractWebsocketClientProtocol.java b/agent/src/main/java/org/openremote/agent/protocol/websocket/AbstractWebsocketClientProtocol.javaindex 00063c99c..cadad71b9 100644--- a/agent/src/main/java/org/openremote/agent/protocol/websocket/AbstractWebsocketClientProtocol.java+++ b/agent/src/main/java/org/openremote/agent/protocol/websocket/AbstractWebsocketClientProtocol.java@@ -26,8 +26,8 @@ import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;import org.jboss.resteasy.util.BasicAuthHelper;import org.openremote.agent.protocol.Protocol;import org.openremote.agent.protocol.http.HttpClientProtocol;-import org.openremote.agent.protocol.http.OAuthGrant;-import org.openremote.agent.protocol.http.WebTargetBuilder;+import org.openremote.container.web.OAuthGrant;+import org.openremote.container.web.WebTargetBuilder;import org.openremote.agent.protocol.io.AbstractIoClientProtocol;import org.openremote.container.Container;import org.openremote.model.AbstractValueHolder;@@ -54,7 +54,7 @@ import java.util.logging.Level;import java.util.logging.Logger;import static org.openremote.agent.protocol.http.HttpClientProtocol.*;-import static org.openremote.agent.protocol.http.WebTargetBuilder.createClient;+import static org.openremote.container.web.WebTargetBuilder.createClient;import static org.openremote.model.Constants.PROTOCOL_NAMESPACE;import static org.openremote.model.attribute.MetaItemDescriptor.Access.ACCESS_PRIVATE;import static org.openremote.model.attribute.MetaItemDescriptorImpl.*;diff --git a/agent/src/main/java/org/openremote/agent/protocol/websocket/WebsocketIoClient.java b/agent/src/main/java/org/openremote/agent/protocol/websocket/WebsocketIoClient.javaindex f46f2a668..d47437b7b 100644--- a/agent/src/main/java/org/openremote/agent/protocol/websocket/WebsocketIoClient.java+++ b/agent/src/main/java/org/openremote/agent/protocol/websocket/WebsocketIoClient.java@@ -33,8 +33,8 @@ import io.netty.handler.ssl.util.InsecureTrustManagerFactory;import io.netty.util.CharsetUtil;import org.jboss.resteasy.client.jaxrs.ResteasyClient;import org.openremote.agent.protocol.ProtocolExecutorService;-import org.openremote.agent.protocol.http.OAuthFilter;-import org.openremote.agent.protocol.http.OAuthGrant;+import org.openremote.container.web.OAuthFilter;+import org.openremote.container.web.OAuthGrant;import org.openremote.agent.protocol.io.AbstractNettyIoClient;import org.openremote.model.asset.agent.ConnectionStatus;import org.openremote.model.syslog.SyslogCategory;@@ -52,8 +52,8 @@ import java.util.concurrent.Future;import java.util.logging.Level;import java.util.logging.Logger;-import static org.openremote.agent.protocol.http.WebTargetBuilder.CONNECTION_TIMEOUT_MILLISECONDS;-import static org.openremote.agent.protocol.http.WebTargetBuilder.createClient;+import static org.openremote.container.web.WebTargetBuilder.CONNECTION_TIMEOUT_MILLISECONDS;+import static org.openremote.container.web.WebTargetBuilder.createClient;import static org.openremote.model.syslog.SyslogCategory.PROTOCOL;/**diff --git a/container/src/main/java/org/openremote/container/security/IdentityProvider.java b/container/src/main/java/org/openremote/container/security/IdentityProvider.javaindex 8c1f20d23..198b86309 100644--- a/container/src/main/java/org/openremote/container/security/IdentityProvider.java+++ b/container/src/main/java/org/openremote/container/security/IdentityProvider.java@@ -26,6 +26,9 @@ import io.undertow.servlet.api.DeploymentInfo;*/public interface IdentityProvider {+ String SETUP_ADMIN_PASSWORD = "SETUP_ADMIN_PASSWORD";+ String SETUP_ADMIN_PASSWORD_DEFAULT = "secret";+void init();void start();diff --git a/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java b/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.javaindex e399c69e1..1d902dda6 100644--- a/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java+++ b/container/src/main/java/org/openremote/container/security/keycloak/KeycloakIdentityProvider.java@@ -28,7 +28,9 @@ import io.undertow.server.handlers.proxy.ProxyHandler;import io.undertow.servlet.api.DeploymentInfo;import io.undertow.servlet.api.LoginConfig;import io.undertow.util.HttpString;+import org.jboss.resteasy.client.jaxrs.ResteasyClient;import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;+import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;import org.keycloak.adapters.KeycloakConfigResolver;import org.keycloak.adapters.KeycloakDeployment;import org.keycloak.adapters.KeycloakDeploymentBuilder;@@ -37,18 +39,15 @@ import org.keycloak.representations.adapters.config.AdapterConfig;import org.keycloak.representations.idm.PublishedRealmRepresentation;import org.openremote.container.Container;import org.openremote.container.security.IdentityProvider;-import org.openremote.container.web.ClientRequestInfo;-import org.openremote.container.web.ProxyWebClientBuilder;-import org.openremote.container.web.WebClient;-import org.openremote.container.web.WebService;+import org.openremote.container.web.*;import javax.ws.rs.HttpMethod;import javax.ws.rs.NotFoundException;-import javax.ws.rs.client.Client;import javax.ws.rs.core.Response;import javax.ws.rs.core.UriBuilder;import java.util.Arrays;import java.util.List;+import java.util.concurrent.ExecutorService;import java.util.concurrent.TimeUnit;import java.util.logging.Level;import java.util.logging.Logger;@@ -60,6 +59,7 @@ import static org.openremote.container.util.MapAccess.getInteger;import static org.openremote.container.util.MapAccess.getString;import static org.openremote.container.web.WebClient.getTarget;import static org.openremote.container.web.WebService.pathStartsWithHandler;+import static org.openremote.model.Constants.MASTER_REALM_ADMIN_USER;import static org.openremote.model.Constants.REQUEST_HEADER_REALM;public abstract class KeycloakIdentityProvider implements IdentityProvider {@@ -159,7 +159,8 @@ public abstract class KeycloakIdentityProvider implements IdentityProvider {// This will pass authentication ("NOT ATTEMPTED" state), but later fail any role authorizationfinal protected KeycloakDeployment notAuthenticatedKeycloakDeployment = new KeycloakDeployment();// The client we use to access Keycloak- protected Client httpClient;+ protected ResteasyClient httpClient;+ protected ResteasyWebTarget keycloakTarget;// Cache Keycloak deployment per realm/client so we don't have to access Keycloak for every token validationprotected LoadingCache<KeycloakRealmClient, KeycloakDeployment> keycloakDeploymentCache;// The configuration for the Keycloak servlet extension, looks up the client application per realm@@ -168,7 +169,7 @@ public abstract class KeycloakIdentityProvider implements IdentityProvider {protected HttpHandler authProxyHandler;@SuppressWarnings("deprecation")- public KeycloakIdentityProvider(String clientId, UriBuilder externalServerUri, Container container) {+ protected KeycloakIdentityProvider(String clientId, UriBuilder externalServerUri, ExecutorService executorService, Container container) {this.clientId = clientId;this.externalServerUri = externalServerUri;@@ -210,31 +211,19 @@ public abstract class KeycloakIdentityProvider implements IdentityProvider {.connectionPoolSize(getInteger(container.getConfig(), KEYCLOAK_CLIENT_POOL_SIZE, KEYCLOAK_CLIENT_POOL_SIZE_DEFAULT));-// ResteasyClientBuilder clientBuilder = (ResteasyClientBuilder) ResteasyClientBuilder.newBuilder();-// clientBuilder.httpEngine(-// new EngineBuilder(httpClientBuilder ->-// httpClientBuilder.addInterceptorLast((HttpRequestInterceptor) (request, context) ->-// request.setHeader(HTTP.TARGET_HOST, new HttpHost(externalServerUri.build().getHost(), externalServerUri.build().getPort()).toHostString())-// )-// ).build()-// );-//-// clientBuilder-// .connectionCheckoutTimeout(-// getInteger(container.getConfig(), KEYCLOAK_CONNECT_TIMEOUT, KEYCLOAK_CONNECT_TIMEOUT_DEFAULT),-// TimeUnit.MILLISECONDS-// )-// .readTimeout(-// getInteger(container.getConfig(), KEYCLOAK_REQUEST_TIMEOUT, KEYCLOAK_REQUEST_TIMEOUT_DEFAULT),-// TimeUnit.MILLISECONDS-// )-// .connectionPoolSize(-// getInteger(container.getConfig(), KEYCLOAK_CLIENT_POOL_SIZE, KEYCLOAK_CLIENT_POOL_SIZE_DEFAULT)-// );--httpClient = WebClient.registerDefaults(clientBuilder).build();+ WebTargetBuilder targetBuilder = new WebTargetBuilder(httpClient, keycloakServiceUri.build());+ targetBuilder.setOAuthAuthentication(new OAuthPasswordGrant(+ keycloakServiceUri.clone().path("/realms/master/protocol/openid-connect/token").build().toString(),+ ADMIN_CLI_CLIENT_ID,+ null,+ "openid",+ MASTER_REALM_ADMIN_USER,+ container.getConfig().getOrDefault(SETUP_ADMIN_PASSWORD, SETUP_ADMIN_PASSWORD_DEFAULT)+ ));+ keycloakTarget = targetBuilder.build();+keycloakDeploymentCache = createKeycloakDeploymentCache();keycloakConfigResolver = request -> {@@ -292,8 +281,7 @@ public abstract class KeycloakIdentityProvider implements IdentityProvider {}public KeycloakResource getKeycloak() {- return getTarget(httpClient, keycloakServiceUri.build(), null, null, null)- .proxy(KeycloakResource.class);+ return keycloakTarget.proxy(KeycloakResource.class);}public KeycloakResource getExternalKeycloak() {@@ -326,9 +314,8 @@ public abstract class KeycloakIdentityProvider implements IdentityProvider {* directly). This should not be overloaded because we want to know who is calling this method with "null", as this* can lead to subtle runtime problems.*/- final protected RealmsResource getRealms(ClientRequestInfo clientRequestInfo) {- return getTarget(httpClient, keycloakServiceUri.build(), clientRequestInfo.getAccessToken(), clientRequestInfo.getRemoteAddress(), clientRequestInfo.getRemoteAddress() != null ? externalServerUri.build() : null)- .proxy(RealmsResource.class);+ final protected RealmsResource getRealms() {+ return keycloakTarget.proxy(RealmsResource.class);}protected void waitForKeycloak() {diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/FollowRedirectFilter.java b/container/src/main/java/org/openremote/container/web/FollowRedirectFilter.javasimilarity index 97%rename from agent/src/main/java/org/openremote/agent/protocol/http/FollowRedirectFilter.javarename to container/src/main/java/org/openremote/container/web/FollowRedirectFilter.javaindex 4dc9abf2d..6ac0d8c08 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/FollowRedirectFilter.java+++ b/container/src/main/java/org/openremote/container/web/FollowRedirectFilter.java@@ -17,7 +17,7 @@* 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.agent.protocol.http;+package org.openremote.container.web;import javax.ws.rs.client.ClientRequestContext;import javax.ws.rs.client.ClientResponseContext;diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/HeaderInjectorFilter.java b/container/src/main/java/org/openremote/container/web/HeaderInjectorFilter.javasimilarity index 97%rename from agent/src/main/java/org/openremote/agent/protocol/http/HeaderInjectorFilter.javarename to container/src/main/java/org/openremote/container/web/HeaderInjectorFilter.javaindex 035c71500..6cf740079 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/HeaderInjectorFilter.java+++ b/container/src/main/java/org/openremote/container/web/HeaderInjectorFilter.java@@ -17,7 +17,7 @@* 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.agent.protocol.http;+package org.openremote.container.web;import javax.ws.rs.client.ClientRequestContext;import javax.ws.rs.client.ClientRequestFilter;diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthClientCredentialsGrant.java b/container/src/main/java/org/openremote/container/web/OAuthClientCredentialsGrant.javasimilarity index 98%rename from agent/src/main/java/org/openremote/agent/protocol/http/OAuthClientCredentialsGrant.javarename to container/src/main/java/org/openremote/container/web/OAuthClientCredentialsGrant.javaindex f44dbb506..03a132bda 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthClientCredentialsGrant.java+++ b/container/src/main/java/org/openremote/container/web/OAuthClientCredentialsGrant.java@@ -17,7 +17,7 @@* 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.agent.protocol.http;+package org.openremote.container.web;import com.fasterxml.jackson.annotation.JsonCreator;import com.fasterxml.jackson.annotation.JsonProperty;diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthFilter.java b/container/src/main/java/org/openremote/container/web/OAuthFilter.javasimilarity index 99%rename from agent/src/main/java/org/openremote/agent/protocol/http/OAuthFilter.javarename to container/src/main/java/org/openremote/container/web/OAuthFilter.javaindex 2dac87444..f70323654 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthFilter.java+++ b/container/src/main/java/org/openremote/container/web/OAuthFilter.java@@ -17,7 +17,7 @@* 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.agent.protocol.http;+package org.openremote.container.web;import org.jboss.resteasy.util.BasicAuthHelper;import org.openremote.model.syslog.SyslogCategory;diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthGrant.java b/container/src/main/java/org/openremote/container/web/OAuthGrant.javasimilarity index 98%rename from agent/src/main/java/org/openremote/agent/protocol/http/OAuthGrant.javarename to container/src/main/java/org/openremote/container/web/OAuthGrant.javaindex c9eca0764..428d43131 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthGrant.java+++ b/container/src/main/java/org/openremote/container/web/OAuthGrant.java@@ -17,7 +17,7 @@* 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.agent.protocol.http;+package org.openremote.container.web;import com.fasterxml.jackson.annotation.JsonIgnore;import com.fasterxml.jackson.annotation.JsonProperty;diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthPasswordGrant.java b/container/src/main/java/org/openremote/container/web/OAuthPasswordGrant.javasimilarity index 98%rename from agent/src/main/java/org/openremote/agent/protocol/http/OAuthPasswordGrant.javarename to container/src/main/java/org/openremote/container/web/OAuthPasswordGrant.javaindex f0c9a3752..9a12b8292 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthPasswordGrant.java+++ b/container/src/main/java/org/openremote/container/web/OAuthPasswordGrant.java@@ -17,7 +17,7 @@* 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.agent.protocol.http;+package org.openremote.container.web;import com.fasterxml.jackson.annotation.JsonCreator;import com.fasterxml.jackson.annotation.JsonProperty;diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthRefreshTokenGrant.java b/container/src/main/java/org/openremote/container/web/OAuthRefreshTokenGrant.javasimilarity index 98%rename from agent/src/main/java/org/openremote/agent/protocol/http/OAuthRefreshTokenGrant.javarename to container/src/main/java/org/openremote/container/web/OAuthRefreshTokenGrant.javaindex 4f13425b7..b09f5e133 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthRefreshTokenGrant.java+++ b/container/src/main/java/org/openremote/container/web/OAuthRefreshTokenGrant.java@@ -17,7 +17,7 @@* 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.agent.protocol.http;+package org.openremote.container.web;import com.fasterxml.jackson.annotation.JsonCreator;import com.fasterxml.jackson.annotation.JsonProperty;diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthServerResponse.java b/container/src/main/java/org/openremote/container/web/OAuthServerResponse.javasimilarity index 97%rename from agent/src/main/java/org/openremote/agent/protocol/http/OAuthServerResponse.javarename to container/src/main/java/org/openremote/container/web/OAuthServerResponse.javaindex ea1d53513..392b30273 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/OAuthServerResponse.java+++ b/container/src/main/java/org/openremote/container/web/OAuthServerResponse.java@@ -17,7 +17,7 @@* 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.agent.protocol.http;+package org.openremote.container.web;import com.fasterxml.jackson.annotation.JsonIgnore;import com.fasterxml.jackson.annotation.JsonProperty;diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/PermanentFailureFilter.java b/container/src/main/java/org/openremote/container/web/PermanentFailureFilter.javasimilarity index 98%rename from agent/src/main/java/org/openremote/agent/protocol/http/PermanentFailureFilter.javarename to container/src/main/java/org/openremote/container/web/PermanentFailureFilter.javaindex 7c2a5f4d9..ba59991b7 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/PermanentFailureFilter.java+++ b/container/src/main/java/org/openremote/container/web/PermanentFailureFilter.java@@ -17,7 +17,7 @@* 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.agent.protocol.http;+package org.openremote.container.web;import org.openremote.model.syslog.SyslogCategory;diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/QueryParameterInjectorFilter.java b/container/src/main/java/org/openremote/container/web/QueryParameterInjectorFilter.javasimilarity index 99%rename from agent/src/main/java/org/openremote/agent/protocol/http/QueryParameterInjectorFilter.javarename to container/src/main/java/org/openremote/container/web/QueryParameterInjectorFilter.javaindex f3d4be864..30f92312e 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/QueryParameterInjectorFilter.java+++ b/container/src/main/java/org/openremote/container/web/QueryParameterInjectorFilter.java@@ -17,7 +17,7 @@* 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.agent.protocol.http;+package org.openremote.container.web;import javax.ws.rs.client.ClientRequestContext;import javax.ws.rs.client.ClientRequestFilter;diff --git a/agent/src/main/java/org/openremote/agent/protocol/http/WebTargetBuilder.java b/container/src/main/java/org/openremote/container/web/WebTargetBuilder.javasimilarity index 99%rename from agent/src/main/java/org/openremote/agent/protocol/http/WebTargetBuilder.javarename to container/src/main/java/org/openremote/container/web/WebTargetBuilder.javaindex 39a2db75d..32a715ed0 100644--- a/agent/src/main/java/org/openremote/agent/protocol/http/WebTargetBuilder.java+++ b/container/src/main/java/org/openremote/container/web/WebTargetBuilder.java@@ -17,7 +17,7 @@* 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.agent.protocol.http;+package org.openremote.container.web;import org.apache.http.client.HttpClient;import org.apache.http.client.config.CookieSpecs;diff --git a/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.java b/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.javaindex e566ed01a..c673ec4ec 100644--- a/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.java+++ b/manager/src/main/java/org/openremote/manager/gateway/GatewayClientService.java@@ -22,7 +22,7 @@ package org.openremote.manager.gateway;import io.netty.channel.ChannelHandler;import org.apache.camel.builder.RouteBuilder;import org.apache.http.client.utils.URIBuilder;-import org.openremote.agent.protocol.http.OAuthClientCredentialsGrant;+import org.openremote.container.web.OAuthClientCredentialsGrant;import org.openremote.agent.protocol.io.AbstractNettyIoClient;import org.openremote.agent.protocol.websocket.WebsocketIoClient;import org.openremote.container.Container;diff --git a/manager/src/main/java/org/openremote/manager/security/ManagerIdentityProvider.java b/manager/src/main/java/org/openremote/manager/security/ManagerIdentityProvider.javaindex 88c8fb448..c9b779ff1 100644--- a/manager/src/main/java/org/openremote/manager/security/ManagerIdentityProvider.java+++ b/manager/src/main/java/org/openremote/manager/security/ManagerIdentityProvider.java@@ -41,9 +41,6 @@ import static org.openremote.model.Constants.MASTER_REALM;*/public interface ManagerIdentityProvider extends IdentityProvider {- String SETUP_ADMIN_PASSWORD = "SETUP_ADMIN_PASSWORD";- String SETUP_ADMIN_PASSWORD_DEFAULT = "secret";-User[] getUsers(String realm);User[] getUsers(List<String> userIds);diff --git a/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java b/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.javaindex 5d47e29ad..e052d1378 100644--- a/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java+++ b/manager/src/main/java/org/openremote/manager/security/ManagerKeycloakIdentityProvider.java@@ -35,6 +35,7 @@ import org.openremote.container.timer.TimerService;import org.openremote.container.web.ClientRequestInfo;import org.openremote.container.web.WebService;import org.openremote.manager.apps.ConsoleAppService;+import org.openremote.manager.concurrent.ManagerExecutorService;import org.openremote.manager.event.ClientEventService;import org.openremote.model.Constants;import org.openremote.model.asset.AssetTreeModifiedEvent;@@ -84,7 +85,7 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imfinal protected Container container;public ManagerKeycloakIdentityProvider(UriBuilder externalServerUri, Container container) {- super(KEYCLOAK_CLIENT_ID, externalServerUri, container);+ super(KEYCLOAK_CLIENT_ID, externalServerUri, container.getService(ManagerExecutorService.class), container);this.container = container;this.keycloakAdminPassword = container.getConfig().getOrDefault(SETUP_ADMIN_PASSWORD, SETUP_ADMIN_PASSWORD_DEFAULT);@@ -402,11 +403,6 @@ public class ManagerKeycloakIdentityProvider extends KeycloakIdentityProvider imgetRealms().realm(realm).clients().get(client.getId()).remove();}- // TODO: This shouldn't really be exposed as identity provider shouldn't leak implementation- public RealmsResource getRealms() {- return super.getRealms(new ClientRequestInfo(null, getAdminAccessToken()));- }-public User getClientServiceUser(String realm, String clientId) {ClientRepresentation client = getClient(realm, clientId);if (client == null) {diff --git a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovyindex 896536554..1ff4ef46c 100644--- a/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy+++ b/test/src/test/groovy/org/openremote/test/gateway/GatewayTest.groovy@@ -4,13 +4,12 @@ import com.google.common.collect.Listsimport io.netty.channel.ChannelHandlerimport org.apache.http.client.utils.URIBuilderimport org.openremote.agent.protocol.http.HttpClientProtocol-import org.openremote.agent.protocol.http.OAuthClientCredentialsGrant+import org.openremote.container.web.OAuthClientCredentialsGrantimport org.openremote.agent.protocol.io.AbstractNettyIoClientimport org.openremote.agent.protocol.simulator.SimulatorProtocolimport org.openremote.agent.protocol.websocket.WebsocketIoClientimport org.openremote.container.Containerimport org.openremote.container.util.UniqueIdentifierGenerator-import org.openremote.container.web.ClientRequestInfoimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageServiceimport org.openremote.manager.concurrent.ManagerExecutorServicediff --git a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovyindex 33263abfe..ae2c0cac3 100644--- a/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/http/HttpClientProtocolTest.groovy@@ -24,6 +24,10 @@ import org.jboss.resteasy.util.BasicAuthHelperimport org.openremote.agent.protocol.Protocolimport org.openremote.container.util.Utilimport org.openremote.agent.protocol.http.*+import org.openremote.container.web.OAuthGrant+import org.openremote.container.web.OAuthPasswordGrant+import org.openremote.container.web.OAuthRefreshTokenGrant+import org.openremote.container.web.OAuthServerResponseimport org.openremote.manager.agent.AgentServiceimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService@@ -808,4 +812,4 @@ class HttpClientProtocolTest extends Specification implements ManagerContainerTrcleanup: "the server should be stopped"stopContainer(container)}-}\ No newline at end of file+}diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovyindex a97e39d0e..73929a7b6 100644--- a/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/http/HttpServerProtocolTest.groovy@@ -21,8 +21,11 @@ package org.openremote.test.protocol.httpimport org.jboss.resteasy.spi.ResteasyUriInfoimport org.jboss.resteasy.util.BasicAuthHelper-import org.openremote.agent.protocol.controller.PollingKeyimport org.openremote.agent.protocol.http.*+import org.openremote.container.web.OAuthGrant+import org.openremote.container.web.OAuthPasswordGrant+import org.openremote.container.web.OAuthRefreshTokenGrant+import org.openremote.container.web.OAuthServerResponseimport org.openremote.manager.agent.AgentServiceimport org.openremote.manager.asset.AssetProcessingServiceimport org.openremote.manager.asset.AssetStorageService@@ -434,4 +437,4 @@ class HttpServerProtocolTest extends Specification implements ManagerContainerTrcleanup: "the server should be stopped"stopContainer(container)}-}\ No newline at end of file+}diff --git a/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovyindex 167dd99d4..175adde5a 100644--- a/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/http/WebTargetTest.groovy@@ -23,8 +23,15 @@ import org.apache.http.client.utils.URIBuilderimport org.jboss.resteasy.client.jaxrs.ResteasyClientimport org.jboss.resteasy.spi.ResteasyUriInfoimport org.jboss.resteasy.util.BasicAuthHelper-import org.openremote.agent.protocol.http.*import org.openremote.container.Container+import org.openremote.container.web.HeaderInjectorFilter+import org.openremote.container.web.OAuthClientCredentialsGrant+import org.openremote.container.web.OAuthGrant+import org.openremote.container.web.OAuthPasswordGrant+import org.openremote.container.web.OAuthRefreshTokenGrant+import org.openremote.container.web.OAuthServerResponse+import org.openremote.container.web.QueryParameterInjectorFilter+import org.openremote.container.web.WebTargetBuilderimport spock.lang.Sharedimport spock.lang.Specificationdiff --git a/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovyindex 75f9e5abb..a96274b8e 100644--- a/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/udp/UdpClientProtocolTest.groovy@@ -258,12 +258,11 @@ class UdpClientProtocolTest extends Specification implements ManagerContainerTrathen: "the protocol should be relinked"conditions.eventually {assert udpClientProtocol.protocolIoClientMap.size() == 1- assert udpClientProtocol.protocolIoClientMap.get(new AttributeRef(agent.id, "protocolConfig")) != client+ assert !udpClientProtocol.protocolIoClientMap.get(new AttributeRef(agent.id, "protocolConfig")).is(client)assert udpClientProtocol.protocolMessageConsumers.size() == 1}when: "the linked attributes are also updated to work with hex server"- def consumer = udpClientProtocol.protocolMessageConsumers.get(new AttributeRef(agent.id, "protocolConfig")).stream().filter({it.key.equals(new AttributeRef(asset.id, "echoHello"))})asset.getAttribute("echoHello").ifPresent({it.meta.replaceAll{it.name.get() == UdpClientProtocol.META_ATTRIBUTE_WRITE_VALUE.urn ? new MetaItem(UdpClientProtocol.META_ATTRIBUTE_WRITE_VALUE, Values.create('"abcdef"')) : it}})asset.getAttribute("echoWorld").ifPresent({it.meta.replaceAll{it.name.get() == UdpClientProtocol.META_ATTRIBUTE_WRITE_VALUE.urn ? new MetaItem(UdpClientProtocol.META_ATTRIBUTE_WRITE_VALUE, Values.create('"123456"')) : it}})asset = assetStorageService.merge(asset)@@ -272,7 +271,7 @@ class UdpClientProtocolTest extends Specification implements ManagerContainerTraconditions.eventually {assert udpClientProtocol.protocolMessageConsumers.size() == 1assert udpClientProtocol.protocolMessageConsumers.get(new AttributeRef(agent.id, "protocolConfig")).size() == 2- assert udpClientProtocol.protocolMessageConsumers.get(new AttributeRef(agent.id, "protocolConfig")).stream().filter({it.key.equals(new AttributeRef(asset.id, "echoHello"))}) != consumer+ assert udpClientProtocol.linkedAttributes.get(new AttributeRef(asset.getId(), "echoHello")).getMetaItem(UdpClientProtocol.META_ATTRIBUTE_WRITE_VALUE).flatMap{it.getValueAsString()}.orElse(null) == '"abcdef"'}when: "the hello linked attribute is executed"@@ -296,4 +295,4 @@ class UdpClientProtocolTest extends Specification implements ManagerContainerTra}stopContainer(container)}-}\ No newline at end of file+}diff --git a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovyindex 83a9bbeb3..1b0e6a57d 100644--- a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientProtocolTest.groovy@@ -20,7 +20,7 @@package org.openremote.test.protocol.websocketimport org.openremote.agent.protocol.Protocol-import org.openremote.agent.protocol.http.OAuthPasswordGrant+import org.openremote.container.web.OAuthPasswordGrantimport org.openremote.agent.protocol.simulator.SimulatorProtocolimport org.openremote.agent.protocol.websocket.WebsocketClientProtocolimport org.openremote.agent.protocol.websocket.WebsocketHttpSubscriptiondiff --git a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovyindex 4b82c13e9..8d146c674 100644--- a/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovy+++ b/test/src/test/groovy/org/openremote/test/protocol/websocket/WebsocketClientTest.groovy@@ -21,7 +21,7 @@ package org.openremote.test.protocol.websocketimport io.netty.channel.ChannelHandlerimport org.apache.http.client.utils.URIBuilder-import org.openremote.agent.protocol.http.OAuthPasswordGrant+import org.openremote.container.web.OAuthPasswordGrantimport org.openremote.agent.protocol.io.AbstractNettyIoClientimport org.openremote.agent.protocol.websocket.WebsocketIoClientimport org.openremote.container.Container@@ -34,7 +34,6 @@ import org.openremote.model.asset.agent.ConnectionStatusimport org.openremote.model.attribute.AttributeEventimport org.openremote.model.event.TriggeredEventSubscriptionimport org.openremote.model.event.shared.EventSubscription-import org.openremote.model.event.shared.SharedEventimport org.openremote.model.value.Valuesimport org.openremote.test.ManagerContainerTraitimport spock.lang.Specification