diff --git a/devicehive-auth/pom.xml b/devicehive-auth/pom.xml index b54d4ad59..3f5fc79b2 100644 --- a/devicehive-auth/pom.xml +++ b/devicehive-auth/pom.xml @@ -5,7 +5,7 @@ devicehive-server com.devicehive - 3.4.4 + 3.4.5 4.0.0 jar diff --git a/devicehive-auth/src/main/java/com/devicehive/application/security/WebSecurityConfig.java b/devicehive-auth/src/main/java/com/devicehive/application/security/WebSecurityConfig.java index cd180f749..77973b84c 100644 --- a/devicehive-auth/src/main/java/com/devicehive/application/security/WebSecurityConfig.java +++ b/devicehive-auth/src/main/java/com/devicehive/application/security/WebSecurityConfig.java @@ -65,8 +65,8 @@ protected void configure(HttpSecurity http) throws Exception { .authenticationEntryPoint(unauthorizedEntryPoint()); http - .addFilterBefore(new HttpAuthenticationFilter(authenticationManager()), BasicAuthenticationFilter.class) - .addFilterAfter(new SimpleCORSFilter(), HttpAuthenticationFilter.class); + .addFilterBefore(new SimpleCORSFilter(), BasicAuthenticationFilter.class) + .addFilterAfter(new HttpAuthenticationFilter(authenticationManager()), SimpleCORSFilter.class); } @Override diff --git a/devicehive-backend/pom.xml b/devicehive-backend/pom.xml index b583fd2a1..3829d8ba7 100644 --- a/devicehive-backend/pom.xml +++ b/devicehive-backend/pom.xml @@ -5,7 +5,7 @@ devicehive-server com.devicehive - 3.4.4 + 3.4.5 4.0.0 diff --git a/devicehive-common-dao/pom.xml b/devicehive-common-dao/pom.xml index 24f9e4ae9..140dcb27b 100644 --- a/devicehive-common-dao/pom.xml +++ b/devicehive-common-dao/pom.xml @@ -7,7 +7,7 @@ com.devicehive devicehive-server - 3.4.4 + 3.4.5 devicehive-common-dao jar diff --git a/devicehive-common-service/pom.xml b/devicehive-common-service/pom.xml index 5b81198f3..0a8151ec6 100644 --- a/devicehive-common-service/pom.xml +++ b/devicehive-common-service/pom.xml @@ -5,7 +5,7 @@ devicehive-server com.devicehive - 3.4.4 + 3.4.5 4.0.0 jar diff --git a/devicehive-common/pom.xml b/devicehive-common/pom.xml index 4b984a5a4..4f402a22c 100644 --- a/devicehive-common/pom.xml +++ b/devicehive-common/pom.xml @@ -7,7 +7,7 @@ com.devicehive devicehive-server - 3.4.4 + 3.4.5 devicehive-common jar diff --git a/devicehive-common/src/main/java/com/devicehive/auth/HiveAction.java b/devicehive-common/src/main/java/com/devicehive/auth/HiveAction.java index ba1aa0fa0..1093db1f5 100644 --- a/devicehive-common/src/main/java/com/devicehive/auth/HiveAction.java +++ b/devicehive-common/src/main/java/com/devicehive/auth/HiveAction.java @@ -89,6 +89,17 @@ public static HiveAction fromString(String text) { return null; } + public static HiveAction fromId(Integer id) { + if (id != null) { + for (HiveAction b : HiveAction.values()) { + if (id.equals(b.id)) { + return b; + } + } + } + return null; + } + public static Set getAllHiveActions() { return KNOWN_ACTIONS; } diff --git a/devicehive-common/src/main/java/com/devicehive/model/DevicePortableFactory.java b/devicehive-common/src/main/java/com/devicehive/model/DevicePortableFactory.java index cc8ab668f..190506ccc 100644 --- a/devicehive-common/src/main/java/com/devicehive/model/DevicePortableFactory.java +++ b/devicehive-common/src/main/java/com/devicehive/model/DevicePortableFactory.java @@ -40,6 +40,8 @@ public Portable create(int classId) { return new Filter(); } else if (Subscriber.CLASS_ID == classId) { return new Subscriber(); + } else if (HazelcastEntityComparator.CLASS_ID == classId) { + return new HazelcastEntityComparator(); } return null; diff --git a/devicehive-common/src/main/java/com/devicehive/model/HazelcastEntityComparator.java b/devicehive-common/src/main/java/com/devicehive/model/HazelcastEntityComparator.java index e22b35748..7b611c155 100644 --- a/devicehive-common/src/main/java/com/devicehive/model/HazelcastEntityComparator.java +++ b/devicehive-common/src/main/java/com/devicehive/model/HazelcastEntityComparator.java @@ -20,13 +20,36 @@ * #L% */ +import com.hazelcast.nio.serialization.Portable; +import com.hazelcast.nio.serialization.PortableReader; +import com.hazelcast.nio.serialization.PortableWriter; + import java.io.Serializable; import java.util.Comparator; import java.util.Date; import java.util.Map; -public class HazelcastEntityComparator implements Comparator>, Serializable { + +public class HazelcastEntityComparator implements Comparator>, Serializable, Portable { private static final long serialVersionUID = 5413354955792888308L; + public static final int FACTORY_ID = 1; + public static final int CLASS_ID = 7; + + @Override + public int getFactoryId() { + return FACTORY_ID; + } + + @Override + public int getClassId() { + return CLASS_ID; + } + + @Override + public void writePortable(PortableWriter out) {} + + @Override + public void readPortable(PortableReader in) {} @Override public int compare(Map.Entry o1, Map.Entry o2) { diff --git a/devicehive-common/src/main/java/com/devicehive/security/jwt/JwtUserPayloadView.java b/devicehive-common/src/main/java/com/devicehive/security/jwt/JwtUserPayloadView.java index e5b773f3e..4449aede5 100644 --- a/devicehive-common/src/main/java/com/devicehive/security/jwt/JwtUserPayloadView.java +++ b/devicehive-common/src/main/java/com/devicehive/security/jwt/JwtUserPayloadView.java @@ -28,6 +28,7 @@ import io.swagger.annotations.ApiModelProperty; import javax.validation.constraints.NotNull; +import javax.ws.rs.BadRequestException; import java.util.Date; import java.util.Objects; import java.util.Optional; @@ -36,7 +37,7 @@ import static com.devicehive.auth.HiveAction.NONE; -public class JwtUserPayloadView implements HiveEntity { +public class JwtUserPayloadView implements HiveEntity { private static final long serialVersionUID = 9015868660504625526L; @@ -54,7 +55,7 @@ public class JwtUserPayloadView implements HiveEntity { @JsonProperty(ACTIONS) @SerializedName(ACTIONS) - private Set actions; + private Set actions; @JsonProperty(NETWORK_IDS) @SerializedName(NETWORK_IDS) @@ -72,7 +73,7 @@ public class JwtUserPayloadView implements HiveEntity { @SerializedName(TOKEN_TYPE) private TokenType tokenType; - public JwtUserPayloadView(Long userId, Set actions, Set networkIds, + public JwtUserPayloadView(Long userId, Set actions, Set networkIds, Set deviceTypeIds, Date expiration, TokenType tokenType) { this.userId = userId; this.actions = actions; @@ -90,11 +91,11 @@ public void setUserId(Long userId) { this.userId = userId; } - public Set getActions() { + public Set getActions() { return actions; } - public void setActions(Set actions) { + public void setActions(Set actions) { this.actions = actions; } @@ -134,7 +135,13 @@ public JwtUserPayload convertTo() { Set actionIds = Optional.ofNullable(actions) .map(value -> value.stream() //Here the compatibility with old behavior is provided to ignore not valid actions - .map(action -> HiveAction.fromString(action)) + .map(action -> { + if (action instanceof String) { + return HiveAction.fromString((String) action); + } else if (action instanceof Number && ((Double) action - ((Double) action).intValue() == 0)) { + return HiveAction.fromId(((Double) action).intValue()); + } else throw new BadRequestException("Actions list should contain only Strings or Integers"); + }) .filter(Objects::nonNull) .mapToInt(HiveAction::getId) .boxed() @@ -148,15 +155,15 @@ public static Builder newBuilder() { return new Builder(); } - public static class Builder { + public static class Builder { private Long userId; - private Set actions; + private Set actions; private Set networkIds; private Set deviceTypeIds; private Date expiration; private TokenType tokenType; - public Builder withPublicClaims(Long userId, Set actions, + public Builder withPublicClaims(Long userId, Set actions, Set networkIds, Set deviceTypeIds) { this.userId = userId; this.actions = actions; @@ -165,7 +172,7 @@ public Builder withPublicClaims(Long userId, Set actions, return this; } - public Builder withPayload(JwtUserPayloadView payload) { + public Builder withPayload(JwtUserPayloadView payload) { this.userId = payload.getUserId(); this.actions = payload.getActions(); this.networkIds = payload.getNetworkIds(); @@ -179,7 +186,7 @@ public Builder withUserId(Long userId) { return this; } - public Builder withActions(Set actions) { + public Builder withActions(Set actions) { this.actions = actions; return this; } @@ -204,8 +211,8 @@ public Builder withExpirationDate(Date expiration) { return this; } - public JwtUserPayloadView buildPayload() { - return new JwtUserPayloadView(userId, actions, networkIds, deviceTypeIds, expiration, tokenType); + public JwtUserPayloadView buildPayload() { + return new JwtUserPayloadView(userId, actions, networkIds, deviceTypeIds, expiration, tokenType); } } } diff --git a/devicehive-frontend/pom.xml b/devicehive-frontend/pom.xml index a46299cf4..f6853b8b8 100644 --- a/devicehive-frontend/pom.xml +++ b/devicehive-frontend/pom.xml @@ -5,7 +5,7 @@ devicehive-server com.devicehive - 3.4.4 + 3.4.5 4.0.0 jar diff --git a/devicehive-frontend/src/main/java/com/devicehive/application/security/WebSecurityConfig.java b/devicehive-frontend/src/main/java/com/devicehive/application/security/WebSecurityConfig.java index cd180f749..77973b84c 100644 --- a/devicehive-frontend/src/main/java/com/devicehive/application/security/WebSecurityConfig.java +++ b/devicehive-frontend/src/main/java/com/devicehive/application/security/WebSecurityConfig.java @@ -65,8 +65,8 @@ protected void configure(HttpSecurity http) throws Exception { .authenticationEntryPoint(unauthorizedEntryPoint()); http - .addFilterBefore(new HttpAuthenticationFilter(authenticationManager()), BasicAuthenticationFilter.class) - .addFilterAfter(new SimpleCORSFilter(), HttpAuthenticationFilter.class); + .addFilterBefore(new SimpleCORSFilter(), BasicAuthenticationFilter.class) + .addFilterAfter(new HttpAuthenticationFilter(authenticationManager()), SimpleCORSFilter.class); } @Override diff --git a/devicehive-plugin/pom.xml b/devicehive-plugin/pom.xml index c6510316d..c76f1f0ae 100644 --- a/devicehive-plugin/pom.xml +++ b/devicehive-plugin/pom.xml @@ -5,7 +5,7 @@ devicehive-server com.devicehive - 3.4.4 + 3.4.5 4.0.0 jar diff --git a/devicehive-plugin/src/main/java/com/devicehive/application/security/WebSecurityConfig.java b/devicehive-plugin/src/main/java/com/devicehive/application/security/WebSecurityConfig.java index cd180f749..77973b84c 100644 --- a/devicehive-plugin/src/main/java/com/devicehive/application/security/WebSecurityConfig.java +++ b/devicehive-plugin/src/main/java/com/devicehive/application/security/WebSecurityConfig.java @@ -65,8 +65,8 @@ protected void configure(HttpSecurity http) throws Exception { .authenticationEntryPoint(unauthorizedEntryPoint()); http - .addFilterBefore(new HttpAuthenticationFilter(authenticationManager()), BasicAuthenticationFilter.class) - .addFilterAfter(new SimpleCORSFilter(), HttpAuthenticationFilter.class); + .addFilterBefore(new SimpleCORSFilter(), BasicAuthenticationFilter.class) + .addFilterAfter(new HttpAuthenticationFilter(authenticationManager()), SimpleCORSFilter.class); } @Override diff --git a/devicehive-plugin/src/main/java/com/devicehive/service/PluginRegisterService.java b/devicehive-plugin/src/main/java/com/devicehive/service/PluginRegisterService.java index 010f8a602..d878e6c81 100644 --- a/devicehive-plugin/src/main/java/com/devicehive/service/PluginRegisterService.java +++ b/devicehive-plugin/src/main/java/com/devicehive/service/PluginRegisterService.java @@ -109,11 +109,6 @@ public PluginRegisterService( public CompletableFuture register(Long userId, PluginReqisterQuery pluginReqisterQuery, PluginUpdate pluginUpdate, String authorization) { validateSubscription(pluginReqisterQuery); - PluginVO existingPlugin = pluginService.findByName(pluginUpdate.getName()); - if (existingPlugin != null) { - logger.error("Plugin with name {} already exists", pluginUpdate.getName()); - throw new HiveException(String.format(Messages.PLUGIN_ALREADY_EXISTS, pluginUpdate.getName()), BAD_REQUEST.getStatusCode()); - } checkAuthServiceAvailable(); diff --git a/devicehive-plugin/src/main/resources/application.properties b/devicehive-plugin/src/main/resources/application.properties index da15f6d24..ce919fa2c 100644 --- a/devicehive-plugin/src/main/resources/application.properties +++ b/devicehive-plugin/src/main/resources/application.properties @@ -66,4 +66,4 @@ auth.base.url=http://localhost:8090/dh/rest #proxy link proxy.connect=localhost:3000 -proxy.plugin.connect=localhost:3001 \ No newline at end of file +proxy.plugin.connect=ws://localhost:3001 \ No newline at end of file diff --git a/devicehive-proxy-api/pom.xml b/devicehive-proxy-api/pom.xml index ee271c3c4..611ecead5 100644 --- a/devicehive-proxy-api/pom.xml +++ b/devicehive-proxy-api/pom.xml @@ -7,7 +7,7 @@ com.devicehive devicehive-server - 3.4.4 + 3.4.5 devicehive-proxy-api jar diff --git a/devicehive-proxy-ws-kafka-impl/pom.xml b/devicehive-proxy-ws-kafka-impl/pom.xml index a32d9f204..228f4ac2e 100644 --- a/devicehive-proxy-ws-kafka-impl/pom.xml +++ b/devicehive-proxy-ws-kafka-impl/pom.xml @@ -7,7 +7,7 @@ com.devicehive devicehive-server - 3.4.4 + 3.4.5 devicehive-proxy-ws-kafka-impl jar diff --git a/devicehive-rdbms-dao/pom.xml b/devicehive-rdbms-dao/pom.xml index 429ce215a..a332dd886 100644 --- a/devicehive-rdbms-dao/pom.xml +++ b/devicehive-rdbms-dao/pom.xml @@ -7,7 +7,7 @@ com.devicehive devicehive-server - 3.4.4 + 3.4.5 devicehive-rdbms-dao jar diff --git a/devicehive-rdbms-dao/src/main/resources/application-persistence.properties b/devicehive-rdbms-dao/src/main/resources/application-persistence.properties index a283d2bf4..0cd49439f 100644 --- a/devicehive-rdbms-dao/src/main/resources/application-persistence.properties +++ b/devicehive-rdbms-dao/src/main/resources/application-persistence.properties @@ -24,7 +24,8 @@ spring.datasource.username=postgres spring.datasource.password=12345 # JPA spring.jpa.hibernate.ddl-auto=none -spring.jpa.show-sql=false +spring.jpa.show-sql=true +hibernate.show_sq=true spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect spring.jpa.properties.hibernate.format_sql=true spring.data.jpa.repositories.enabled=false diff --git a/devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_11__alter_plugin_table_name_constraint.sql b/devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_11__alter_plugin_table_name_constraint.sql new file mode 100644 index 000000000..1765ea711 --- /dev/null +++ b/devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_11__alter_plugin_table_name_constraint.sql @@ -0,0 +1,21 @@ +--- +-- #%L +-- DeviceHive Dao RDBMS Implementation +-- %% +-- Copyright (C) 2016 DataArt +-- %% +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- #L% +--- + +ALTER TABLE plugin DROP CONSTRAINT plugin_name_unique; \ No newline at end of file diff --git a/devicehive-shim-api/pom.xml b/devicehive-shim-api/pom.xml index 9f2e3438b..0692667ab 100644 --- a/devicehive-shim-api/pom.xml +++ b/devicehive-shim-api/pom.xml @@ -7,7 +7,7 @@ com.devicehive devicehive-server - 3.4.4 + 3.4.5 devicehive-shim-api jar diff --git a/devicehive-shim-kafka-impl/pom.xml b/devicehive-shim-kafka-impl/pom.xml index 256aa1f6f..9b2a1b5c1 100644 --- a/devicehive-shim-kafka-impl/pom.xml +++ b/devicehive-shim-kafka-impl/pom.xml @@ -5,7 +5,7 @@ devicehive-server com.devicehive - 3.4.4 + 3.4.5 4.0.0 diff --git a/devicehive-test-utils/pom.xml b/devicehive-test-utils/pom.xml index 519310b76..81b10f65e 100644 --- a/devicehive-test-utils/pom.xml +++ b/devicehive-test-utils/pom.xml @@ -1 +1 @@ - devicehive-server com.devicehive 3.4.4 4.0.0 devicehive-test-utils DeviceHive Test Utils ${project.parent.basedir} org.hsqldb hsqldb ${hsqldb.version} org.hibernate hibernate-core ${hibernate-version} org.springframework.boot spring-boot-starter-test org.apache.kafka kafka-clients ${kafka.version} test org.apache.kafka kafka_${scala-binaries.version} ${kafka.version} slf4j-log4j12 org.slf4j org.apache.kafka kafka_${scala-binaries.version} ${kafka.version} test slf4j-log4j12 org.slf4j \ No newline at end of file + devicehive-server com.devicehive 3.4.5 4.0.0 devicehive-test-utils DeviceHive Test Utils ${project.parent.basedir} org.hsqldb hsqldb ${hsqldb.version} org.hibernate hibernate-core ${hibernate-version} org.springframework.boot spring-boot-starter-test org.apache.kafka kafka-clients ${kafka.version} test org.apache.kafka kafka_${scala-binaries.version} ${kafka.version} slf4j-log4j12 org.slf4j org.apache.kafka kafka_${scala-binaries.version} ${kafka.version} test slf4j-log4j12 org.slf4j \ No newline at end of file diff --git a/dockerfiles/devicehive-auth.Dockerfile b/dockerfiles/devicehive-auth.Dockerfile index b8bdacff8..adb788c45 100644 --- a/dockerfiles/devicehive-auth.Dockerfile +++ b/dockerfiles/devicehive-auth.Dockerfile @@ -2,7 +2,7 @@ FROM openjdk:8u151-jre-slim MAINTAINER devicehive -ENV DH_VERSION="3.4.4" +ENV DH_VERSION="3.4.5" LABEL org.label-schema.url="https://devicehive.com" \ org.label-schema.vendor="DeviceHive" \ diff --git a/dockerfiles/devicehive-backend.Dockerfile b/dockerfiles/devicehive-backend.Dockerfile index 079357401..5a2ecad1e 100644 --- a/dockerfiles/devicehive-backend.Dockerfile +++ b/dockerfiles/devicehive-backend.Dockerfile @@ -2,7 +2,7 @@ FROM openjdk:8u151-jre-slim MAINTAINER devicehive -ENV DH_VERSION="3.4.4" +ENV DH_VERSION="3.4.5" LABEL org.label-schema.url="https://devicehive.com" \ org.label-schema.vendor="DeviceHive" \ diff --git a/dockerfiles/devicehive-frontend.Dockerfile b/dockerfiles/devicehive-frontend.Dockerfile index 9823c5805..51ae729a2 100644 --- a/dockerfiles/devicehive-frontend.Dockerfile +++ b/dockerfiles/devicehive-frontend.Dockerfile @@ -2,7 +2,7 @@ FROM openjdk:8u151-jre-slim MAINTAINER devicehive -ENV DH_VERSION="3.4.4" +ENV DH_VERSION="3.4.5" LABEL org.label-schema.url="https://devicehive.com" \ org.label-schema.vendor="DeviceHive" \ diff --git a/dockerfiles/devicehive-hazelcast.Dockerfile b/dockerfiles/devicehive-hazelcast.Dockerfile index 75b8d9cd1..44112bed5 100644 --- a/dockerfiles/devicehive-hazelcast.Dockerfile +++ b/dockerfiles/devicehive-hazelcast.Dockerfile @@ -2,7 +2,7 @@ FROM hazelcast/hazelcast:3.8.8 MAINTAINER devicehive -ENV DH_VERSION="3.4.4" +ENV DH_VERSION="3.4.5" LABEL org.label-schema.url="https://devicehive.com" \ org.label-schema.vendor="DeviceHive" \ diff --git a/dockerfiles/devicehive-plugin.Dockerfile b/dockerfiles/devicehive-plugin.Dockerfile index 640d4b9d8..9e0a8511c 100644 --- a/dockerfiles/devicehive-plugin.Dockerfile +++ b/dockerfiles/devicehive-plugin.Dockerfile @@ -2,7 +2,7 @@ FROM openjdk:8u151-jre-slim MAINTAINER devicehive -ENV DH_VERSION="3.4.4" +ENV DH_VERSION="3.4.5" LABEL org.label-schema.url="https://devicehive.com" \ org.label-schema.vendor="DeviceHive" \ diff --git a/pom.xml b/pom.xml index b925b4753..641dad369 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.devicehive devicehive-server pom - 3.4.4 + 3.4.5 DeviceHive Java Server