Compare commits

...

49 Commits

Author SHA1 Message Date
norm-traxler
8a0faff455 Merge pull request #23 from Telecominfraproject/WIFI-4415
[Wifi 4415] remove unnecessary code
2021-09-27 15:24:04 -04:00
Thomas-Leung2021
b7d396c6ce [WIFI-4415] remove unnecessary code 2021-09-27 13:25:06 -04:00
norm-traxler
92b97c832a Merge pull request #22 from Telecominfraproject/WIFI-4415
[WIFI-4415] Add Gateway and backend support to turn LED on/off
2021-09-27 10:56:37 -04:00
Thomas Leung
e8dd8724fb Merged in NETEXP-2959 (pull request #3)
[NETEXP-2959] update LedStatus to pass tests

Approved-by: mike.hansen
2021-09-24 16:53:44 -04:00
norm-traxler
3fb4dd16b8 Merge pull request #21 from Telecominfraproject/WIFI-3471
WIFI-3471 Update SDK master to use image tag 1.3.0-SNAPSHOT
2021-08-17 16:34:20 -04:00
norm-traxler
caa99afda1 Merge pull request #20 from Telecominfraproject/WIFI-3416-Remove-RestOperationsWithMetrics
WIFI-3416  Remove RestOperationsWithMetrics
2021-08-16 16:59:33 -04:00
Akshay Jagadish
e531cb8597 WIFI-3471 Update SDK master to use image tag 1.3.0-SNAPSHOT 2021-08-13 13:02:33 -04:00
Thomas Currie
b38393ec20 remove unused import 2021-08-12 14:12:11 -04:00
Thomas Currie
b14f57887f replace our custom RestTemplate class with the default one from Spring. 2021-08-12 10:27:29 -04:00
norm-traxler
267fb477a3 Merge pull request #19 from Telecominfraproject/WIFI-3224-Remote-client-mediatype
[WIFI-3224] change BaseRemoteClient from json contentType from UTF-8 …
2021-07-23 11:54:14 -04:00
Norm Traxler
04c844c2e2 [WIFI-3224] change BaseRemoteClient from json contentType from UTF-8 to UTF-16 (default) 2021-07-23 11:42:19 -04:00
Mike Hansen
72da490a3b Merge pull request #18 from Telecominfraproject/WIFI-3022
[WIFI-3022] fix for getting 00:00:00:00:00:00 mac address
2021-07-14 14:21:48 -04:00
Thomas-Leung2021
bb9c3ba1eb [WIFI-3022] add null checks convertMacStringToLongValue() 2021-07-14 13:53:49 -04:00
Thomas-Leung2021
7dd594644e [WIFI-3022] fix for getting 00:00:00:00:00:00 mac address 2021-07-13 17:33:46 -04:00
Mike Hansen
4c15a9650b Merge pull request #17 from Telecominfraproject/add-http-client-exception-to-tip-error-handler
add basePackes property back to CommonControllerAdvice. Add HttpClien…
2021-06-15 10:22:20 -04:00
Thomas Currie
5c3bf48780 add basePackes property back to CommonControllerAdvice. Add HttpClientErrorException to ExceptionPropogatingErrorHandler. 2021-06-14 18:16:21 -04:00
Mike Hansen
be09681087 Merge pull request #16 from Telecominfraproject/revert-15-WIFI-2633-Change-scope-of-CommonControllerAdvice
Revert "WIFI-2633  Change scope of CommonControllerAdvice"
2021-06-14 17:08:32 -04:00
Mike Hansen
a7076e523b Revert "WIFI-2633 Change scope of CommonControllerAdvice" 2021-06-14 17:04:37 -04:00
norm-traxler
6232b8db7b Merge pull request #15 from Telecominfraproject/WIFI-2633-Change-scope-of-CommonControllerAdvice
WIFI-2633  Change scope of CommonControllerAdvice
2021-06-14 11:06:46 -04:00
Thomas Currie
2bfab69a3a add 'basePackage' attribute to @ControllerAdvice 2021-06-11 09:59:39 -04:00
Mike Hansen
fef03f4bbe AP: ON_CHANNEL survey report sometimes has no information
Signed-off-by: Mike Hansen <mike.hansen@connectus.ai>
2021-06-02 09:07:24 -04:00
norm-traxler
b6a02439b8 Merge pull request #14 from Telecominfraproject/WIFI-2434
WIFI 2434: Update SDK master to use image tag 1.2.0-SNAPSHOT
2021-05-26 21:04:06 -04:00
Akshay Jagadish
789e153519 Update SDK master to use image tag 1.2.0-SNAPSHOT 2021-05-26 18:00:32 -04:00
norm-traxler
c2c67e188c Merge pull request #13 from Telecominfraproject/WIFI-2150-json--parsing-error-message-on-ap-details-save
add null safety check to setAddressAsString in MacAddress.
2021-05-11 10:33:47 -04:00
Thomas Currie
9f5e093ea5 revert to setting address field as null when null is provided to construct / setter. 2021-05-11 09:51:03 -04:00
Thomas Currie
d1bc55745e add assertions to 2 unit tests to appease sonar 2021-05-10 16:13:41 -04:00
Thomas Currie
e185ccaef6 add test coverage MacAddress of old codeand new null check in order to appease sonar 2021-05-10 16:06:08 -04:00
Thomas Currie
92fcaaa0bb Sonar changes based on 'code smell' 2021-05-10 14:40:47 -04:00
Thomas Currie
1bcf2860df add null check to convertMacStringToLongValue to prevent NPE 2021-05-10 14:29:48 -04:00
Thomas Currie
e005180f9f add null safety check to setAddressAsString in MacAdress. 2021-05-10 14:15:35 -04:00
norm-traxler
b1cc93b9df Merge pull request #12 from Telecominfraproject/WIFI-2026
WIFI-2026 Changed pom versions from 0.0.1-SNAPSHOT to 1.1.0-SNAPSHOT
2021-04-16 17:08:38 -04:00
Akshay Jagadish
df157aecfd WIFI-2026 Changed pom versions from 0.0.1-SNAPSHOT to 1.1.0-SNAPSHOT 2021-04-16 15:27:41 -04:00
Kareem Dabbour
143fc61fef WIFI-1718 Updated DecibelUtils (#11)
* WIFI-1718 Updated DecibelUtils

* WIFI-1718 added null check

* WIFI-1718 switched over to iterator rather than making an array copy

* WIFI-1718 division by 0 check

Co-authored-by: Kareem Dabbour <kareemdabbour@Kareems-MacBook-Pro.local>
2021-03-10 11:27:09 -05:00
Dmitry Toptygin
0e496faa5e WIFI-1652 - implement performance counters for ovsdb, cassandra, and kafka 2021-02-23 19:38:41 -05:00
Rahul Sharma
24149ad62e WIFI-1319: Adding sslEnabledProtocol to the SSL-Connector (#8) 2021-02-22 12:14:19 -05:00
Dmitry Toptygin
ce9ae55cd7 WIFI-1624 - in pom.xml files replace ${tip-wlan-cloud.release.version} with 0.0.1-SNAPSHOT to make sure that mvn release:update-versions command works 2021-02-20 10:18:09 -05:00
Dmitry Toptygin
c95521c672 WIFI-1551 - make deserializing mac address as byte array more forgiving - allow it to recover from ' ', '+', '/', '=' characters transparently 2021-02-11 15:52:48 -05:00
Dmitry Toptygin
66bea0dbdf WIFI-1551 - when serializing mac address as byte array we need to use Base64Variants.MODIFIED_FOR_URL class that instead of using plus and slash characters uses hyphen and underscore, respectively 2021-02-11 15:28:08 -05:00
Dmitry Toptygin
baa9453d12 WIFI-1437 - provide a way for 3rd-party developers to register methods to be called before REST controller methods 2021-02-01 18:40:04 -05:00
Dmitry Toptygin
ed6421865d expose ObjectMapper of the BaseJsonModel so that other framework related components get access to a fully configured object mapper that knows about all the subclasses of the BaseJsonModel 2021-01-28 11:34:23 -05:00
Dmitry Toptygin
71cf6b6156 in BaseJsonModel added methods to encode/decode strings in format used to store zipped json in postgresql bytea columns 2021-01-28 10:55:24 -05:00
Dmitry Toptygin
9cf640805d WIFI-1235 - added HasLocationId marker interface 2021-01-08 15:03:10 -05:00
ralphlee3
19e7361e7d WIFI 1251 custom claims processing (#7)
* [WIFI-1251] Adding claimsUrl for custom claims processing, refactoring authority enums

* [WIFI-1251] User to default to CustomerIT authority

* [WIFI-1251] Consolidating all instances of authority to the new class

* [WIFI-1251] Adding authorities in PortalUserRole, fixing environment variables

* [WIFI-1251] Fixing comments on clientId

* [WIFI-1226] callbackUrl removed, updated pom

* [WIFI-1251] Renaming claimsNamespace, removing colon to normalize namespace use

* [WIFI-1251] Defaulting namespace to wlan.telecominfraproject.com
2021-01-06 18:01:37 -05:00
Dmitry Toptygin
e5d2e42751 alow rdbms-related unit tests from different maven modules to be combined to set up composite schemas 2020-12-29 18:48:43 -05:00
Dmitry Toptygin
db60e2f763 added missing clone() methods to RadioBestApSettings, SourceSelectionSteering, and SourceSelectionValue 2020-12-22 13:16:36 -05:00
Dmitry Toptygin
661aecf98d WIFI-1212 allow extension of the portal user roles by the 3rd party vendors 2020-12-17 14:54:54 -05:00
Dmitry Toptygin
269b9f703c added prefix tip.wlan to maxHttpThreads property 2020-12-09 15:51:32 -05:00
Dmitry Toptygin
313092a1d3 HttpClientConfigResolver: allow to override values for maxConnectionsTotal and maxConnectionsPerRoute using environment variables 2020-12-09 15:37:49 -05:00
Mike Hansen
2519f9794b WIFI-1153: Add SAE SecurityType in wlan-cloud-base 2020-12-04 15:14:16 -05:00
68 changed files with 1464 additions and 1193 deletions

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-cassandra-tests</artifactId> <artifactId>base-cassandra-tests</artifactId>
@@ -15,7 +14,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-cassandra</artifactId> <artifactId>base-cassandra</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-cassandra</artifactId> <artifactId>base-cassandra</artifactId>
@@ -14,7 +14,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>cloud-metrics</artifactId> <artifactId>cloud-metrics</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -61,7 +61,9 @@ public class BaseCassandraDataSource {
sessionBuilder.withConfigLoader(DriverConfigLoader.fromClasspath("cassandra-application")); sessionBuilder.withConfigLoader(DriverConfigLoader.fromClasspath("cassandra-application"));
} }
CqlSession session =sessionBuilder.build(); CqlSession session = sessionBuilder.build();
session = new CqlSessionWithMetrics(session);
return session; return session;
} }

View File

@@ -0,0 +1,420 @@
package com.telecominfraproject.wlan.core.server.cassandra;
import java.util.Optional;
import java.util.concurrent.CompletionStage;
import com.datastax.dse.driver.api.core.cql.continuous.ContinuousAsyncResultSet;
import com.datastax.dse.driver.api.core.cql.continuous.ContinuousResultSet;
import com.datastax.dse.driver.api.core.cql.continuous.reactive.ContinuousReactiveResultSet;
import com.datastax.dse.driver.api.core.cql.reactive.ReactiveResultSet;
import com.datastax.dse.driver.api.core.graph.AsyncGraphResultSet;
import com.datastax.dse.driver.api.core.graph.GraphResultSet;
import com.datastax.dse.driver.api.core.graph.GraphStatement;
import com.datastax.dse.driver.api.core.graph.reactive.ReactiveGraphResultSet;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.context.DriverContext;
import com.datastax.oss.driver.api.core.cql.AsyncResultSet;
import com.datastax.oss.driver.api.core.cql.PrepareRequest;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.cql.Statement;
import com.datastax.oss.driver.api.core.metadata.Metadata;
import com.datastax.oss.driver.api.core.metrics.Metrics;
import com.datastax.oss.driver.api.core.session.Request;
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
import com.netflix.servo.DefaultMonitorRegistry;
import com.netflix.servo.monitor.BasicCounter;
import com.netflix.servo.monitor.BasicTimer;
import com.netflix.servo.monitor.Counter;
import com.netflix.servo.monitor.MonitorConfig;
import com.netflix.servo.monitor.Stopwatch;
import com.netflix.servo.monitor.Timer;
import com.netflix.servo.tag.TagList;
import com.telecominfraproject.wlan.cloudmetrics.CloudMetricsTags;
public class CqlSessionWithMetrics implements CqlSession {
private final TagList tags = CloudMetricsTags.commonTags;
final Counter executeCounter = new BasicCounter(MonitorConfig.builder("cassandra-execute").withTags(tags).build());
final Counter executeAsyncCounter = new BasicCounter(MonitorConfig.builder("cassandra-execute-async").withTags(tags).build());
final Counter executeReactiveCounter = new BasicCounter(MonitorConfig.builder("cassandra-execute-reactive").withTags(tags).build());
final Counter executeErrorCounter = new BasicCounter(MonitorConfig.builder("cassandra-execute-errors").withTags(tags).build());
final Counter executeAsyncErrorCounter = new BasicCounter(MonitorConfig.builder("cassandra-execute-async-errors").withTags(tags).build());
final Counter executeReactiveErrorCounter = new BasicCounter(MonitorConfig.builder("cassandra-execute-reactive-errors").withTags(tags).build());
private final Timer executeTimer = new BasicTimer(
MonitorConfig.builder("cassandra-executeTimer").withTags(tags).build());
private final Timer executeAsyncTimer = new BasicTimer(
MonitorConfig.builder("cassandra-executeAsyncTimer").withTags(tags).build());
private final Timer executeReactiveTimer = new BasicTimer(
MonitorConfig.builder("cassandra-executeReactiveTimer").withTags(tags).build());
// dtop: use anonymous constructor to ensure that the following code always
// get executed,
// even when somebody adds another constructor in here
{
DefaultMonitorRegistry.getInstance().register(executeCounter);
DefaultMonitorRegistry.getInstance().register(executeAsyncCounter);
DefaultMonitorRegistry.getInstance().register(executeReactiveCounter);
DefaultMonitorRegistry.getInstance().register(executeErrorCounter);
DefaultMonitorRegistry.getInstance().register(executeAsyncErrorCounter);
DefaultMonitorRegistry.getInstance().register(executeReactiveErrorCounter);
DefaultMonitorRegistry.getInstance().register(executeTimer);
DefaultMonitorRegistry.getInstance().register(executeAsyncTimer);
DefaultMonitorRegistry.getInstance().register(executeReactiveTimer);
}
private final CqlSession delegate;
public CqlSessionWithMetrics(CqlSession delegate) {
this.delegate = delegate;
}
public CompletionStage<AsyncResultSet> executeAsync(Statement<?> statement) {
executeAsyncCounter.increment();
Stopwatch stopwatch = executeAsyncTimer.start();
boolean success = false;
try {
CompletionStage<AsyncResultSet> ret = delegate.executeAsync(statement);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeAsyncErrorCounter.increment();
}
}
}
public ReactiveGraphResultSet executeReactive(GraphStatement<?> statement) {
executeReactiveCounter.increment();
Stopwatch stopwatch = executeReactiveTimer.start();
boolean success = false;
try {
ReactiveGraphResultSet ret = delegate.executeReactive(statement);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeReactiveErrorCounter.increment();
}
}
}
public CompletionStage<Void> closeFuture() {
return delegate.closeFuture();
}
public ResultSet execute(Statement<?> statement) {
executeCounter.increment();
Stopwatch stopwatch = executeTimer.start();
boolean success = false;
try {
ResultSet ret = delegate.execute(statement);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeErrorCounter.increment();
}
}
}
public GraphResultSet execute(GraphStatement<?> graphStatement) {
executeCounter.increment();
Stopwatch stopwatch = executeTimer.start();
boolean success = false;
try {
GraphResultSet ret = delegate.execute(graphStatement);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeErrorCounter.increment();
}
}
}
public boolean isClosed() {
return delegate.isClosed();
}
public ReactiveResultSet executeReactive(String query) {
executeReactiveCounter.increment();
Stopwatch stopwatch = executeReactiveTimer.start();
boolean success = false;
try {
ReactiveResultSet ret = delegate.executeReactive(query);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeReactiveErrorCounter.increment();
}
}
}
public CompletionStage<AsyncResultSet> executeAsync(String query) {
executeAsyncCounter.increment();
Stopwatch stopwatch = executeAsyncTimer.start();
boolean success = false;
try {
CompletionStage<AsyncResultSet> ret = delegate.executeAsync(query);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeAsyncErrorCounter.increment();
}
}
}
public CompletionStage<Void> closeAsync() {
return delegate.closeAsync();
}
public ReactiveResultSet executeReactive(Statement<?> statement) {
executeReactiveCounter.increment();
Stopwatch stopwatch = executeReactiveTimer.start();
boolean success = false;
try {
ReactiveResultSet ret = delegate.executeReactive(statement);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeReactiveErrorCounter.increment();
}
}
}
public CompletionStage<Void> forceCloseAsync() {
return delegate.forceCloseAsync();
}
public CompletionStage<PreparedStatement> prepareAsync(SimpleStatement statement) {
return delegate.prepareAsync(statement);
}
public ContinuousReactiveResultSet executeContinuouslyReactive(String query) {
executeReactiveCounter.increment();
Stopwatch stopwatch = executeReactiveTimer.start();
boolean success = false;
try {
ContinuousReactiveResultSet ret = delegate.executeContinuouslyReactive(query);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeReactiveErrorCounter.increment();
}
}
}
public ResultSet execute(String query) {
executeCounter.increment();
Stopwatch stopwatch = executeTimer.start();
boolean success = false;
try {
ResultSet ret = delegate.execute(query);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeErrorCounter.increment();
}
}
}
public void close() {
delegate.close();
}
public String getName() {
return delegate.getName();
}
public CompletionStage<AsyncGraphResultSet> executeAsync(GraphStatement<?> graphStatement) {
executeAsyncCounter.increment();
Stopwatch stopwatch = executeAsyncTimer.start();
boolean success = false;
try {
CompletionStage<AsyncGraphResultSet> ret = delegate.executeAsync(graphStatement);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeAsyncErrorCounter.increment();
}
}
}
public ContinuousReactiveResultSet executeContinuouslyReactive(Statement<?> statement) {
executeReactiveCounter.increment();
Stopwatch stopwatch = executeReactiveTimer.start();
boolean success = false;
try {
ContinuousReactiveResultSet ret = delegate.executeContinuouslyReactive(statement);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeReactiveErrorCounter.increment();
}
}
}
public CompletionStage<PreparedStatement> prepareAsync(String query) {
return delegate.prepareAsync(query);
}
public PreparedStatement prepare(SimpleStatement statement) {
return delegate.prepare(statement);
}
public Metadata getMetadata() {
return delegate.getMetadata();
}
public ContinuousResultSet executeContinuously(Statement<?> statement) {
executeCounter.increment();
Stopwatch stopwatch = executeTimer.start();
boolean success = false;
try {
ContinuousResultSet ret = delegate.executeContinuously(statement);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeErrorCounter.increment();
}
}
}
public CompletionStage<PreparedStatement> prepareAsync(PrepareRequest request) {
return delegate.prepareAsync(request);
}
public boolean isSchemaMetadataEnabled() {
return delegate.isSchemaMetadataEnabled();
}
public CompletionStage<ContinuousAsyncResultSet> executeContinuouslyAsync(Statement<?> statement) {
executeAsyncCounter.increment();
Stopwatch stopwatch = executeAsyncTimer.start();
boolean success = false;
try {
CompletionStage<ContinuousAsyncResultSet> ret = delegate.executeContinuouslyAsync(statement);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeAsyncErrorCounter.increment();
}
}
}
public CompletionStage<Metadata> setSchemaMetadataEnabled(Boolean newValue) {
return delegate.setSchemaMetadataEnabled(newValue);
}
public CompletionStage<Metadata> refreshSchemaAsync() {
return delegate.refreshSchemaAsync();
}
public Metadata refreshSchema() {
return delegate.refreshSchema();
}
public CompletionStage<Boolean> checkSchemaAgreementAsync() {
return delegate.checkSchemaAgreementAsync();
}
public PreparedStatement prepare(String query) {
return delegate.prepare(query);
}
public boolean checkSchemaAgreement() {
return delegate.checkSchemaAgreement();
}
public DriverContext getContext() {
return delegate.getContext();
}
public Optional<CqlIdentifier> getKeyspace() {
return delegate.getKeyspace();
}
public PreparedStatement prepare(PrepareRequest request) {
return delegate.prepare(request);
}
public Optional<Metrics> getMetrics() {
return delegate.getMetrics();
}
public <RequestT extends Request, ResultT> ResultT execute(RequestT request, GenericType<ResultT> resultType) {
executeCounter.increment();
Stopwatch stopwatch = executeTimer.start();
boolean success = false;
try {
ResultT ret = delegate.execute(request, resultType);
success = true;
return ret;
} finally {
stopwatch.stop();
if(!success) {
executeErrorCounter.increment();
}
}
}
}

View File

@@ -1,11 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-client</artifactId> <artifactId>base-client</artifactId>
@@ -16,25 +14,25 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId> <artifactId>base-models</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-container</artifactId> <artifactId>base-container</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-exceptions</artifactId> <artifactId>base-exceptions</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>cloud-metrics</artifactId> <artifactId>cloud-metrics</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -1,7 +1,5 @@
package com.telecominfraproject.wlan.core.client; package com.telecominfraproject.wlan.core.client;
import java.nio.charset.StandardCharsets;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
@@ -22,20 +20,15 @@ public abstract class BaseRemoteClient {
protected HttpHeaders headers = new HttpHeaders(); protected HttpHeaders headers = new HttpHeaders();
{ {
headers.setContentType(new MediaType("application", "json", StandardCharsets.UTF_8)); // Note: APPLICATION_JSON_UTF8 is deprecated
headers.setContentType(MediaType.APPLICATION_JSON);
//Accept-Encoding: gzip,deflate //Accept-Encoding: gzip,deflate
headers.set("Accept-Encoding", "gzip,deflate"); headers.set("Accept-Encoding", "gzip,deflate");
} }
@Autowired @Autowired
private void setRestTemplate(RestOperations restTemplate) { private void setRestTemplate(RestOperations restTemplate) {
//build user-friendly metrics Id - remove $$EnhancedByCGlib... at the end of the class name this.restTemplate = restTemplate;
String metricsId = this.getClass().getSimpleName();
int idx = metricsId.indexOf('$');
if(idx>0){
metricsId = metricsId.substring(0, idx);
}
this.restTemplate = new RestOperationsWithMetrics(restTemplate, metricsId);
} }
protected String getBaseUrlFromEnvironment(String urlPropName, String defaultUrlPropName) { protected String getBaseUrlFromEnvironment(String urlPropName, String defaultUrlPropName) {

View File

@@ -8,6 +8,7 @@ import org.springframework.core.task.TaskRejectedException;
import org.springframework.http.client.ClientHttpResponse; import org.springframework.http.client.ClientHttpResponse;
import org.springframework.security.access.AccessDeniedException; import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.client.DefaultResponseErrorHandler; import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.HttpServerErrorException; import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.ResponseErrorHandler; import org.springframework.web.client.ResponseErrorHandler;
@@ -38,7 +39,7 @@ public class ExceptionPropagatingErrorHandler extends DefaultResponseErrorHandle
public void handleError(ClientHttpResponse response) throws IOException { public void handleError(ClientHttpResponse response) throws IOException {
try { try {
super.handleError(response); super.handleError(response);
} catch (HttpServerErrorException e) { } catch (HttpServerErrorException | HttpClientErrorException e) {
// look in the response object, and if it contains any of the // look in the response object, and if it contains any of the
// exceptions we recognize - throw that exception instead of the // exceptions we recognize - throw that exception instead of the
// HttpServerErrorException // HttpServerErrorException

View File

@@ -50,6 +50,22 @@ public class HttpClientConfigResolver {
ret = HttpClientConfig.fromString(StreamUtils.copyToString((InputStream) configContent, StandardCharsets.UTF_8), ret = HttpClientConfig.fromString(StreamUtils.copyToString((InputStream) configContent, StandardCharsets.UTF_8),
HttpClientConfig.class); HttpClientConfig.class);
} }
if(environment!=null){
//override values for maxConnectionsTotal and maxConnectionsPerRoute using environment variables, if provided
if(environment.getProperty("tip.wlan.httpClientConfig.maxConnectionsTotal") != null) {
int maxConnectionsTotal = Integer.parseInt(environment.getProperty("tip.wlan.httpClientConfig.maxConnectionsTotal"));
ret.setMaxConnectionsTotal(maxConnectionsTotal);
LOG.info("Overriding http client configuration maxConnectionsTotal {}", maxConnectionsTotal);
}
if(environment.getProperty("tip.wlan.httpClientConfig.maxConnectionsPerRoute") != null) {
int maxConnectionsPerRoute = Integer.parseInt(environment.getProperty("tip.wlan.httpClientConfig.maxConnectionsPerRoute"));
ret.setMaxConnectionsPerRoute(maxConnectionsPerRoute);
LOG.info("Overriding http client configuration maxConnectionsPerRoute {}", maxConnectionsPerRoute);
}
}
LOG.info("Got http client configuration from {}", configLocation); LOG.info("Got http client configuration from {}", configLocation);
return ret; return ret;
} catch (Exception e) { } catch (Exception e) {

View File

@@ -1,842 +0,0 @@
package com.telecominfraproject.wlan.core.client;
import java.net.URI;
import java.util.Map;
import java.util.Set;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RequestCallback;
import org.springframework.web.client.ResponseExtractor;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestOperations;
import com.netflix.servo.DefaultMonitorRegistry;
import com.netflix.servo.monitor.BasicCounter;
import com.netflix.servo.monitor.BasicTimer;
import com.netflix.servo.monitor.Counter;
import com.netflix.servo.monitor.MonitorConfig;
import com.netflix.servo.monitor.Stopwatch;
import com.netflix.servo.monitor.Timer;
import com.netflix.servo.tag.TagList;
import com.telecominfraproject.wlan.cloudmetrics.CloudMetricsTags;
public class RestOperationsWithMetrics implements RestOperations{
final RestOperations delegate;
private final TagList tags = CloudMetricsTags.commonTags;
private final Counter getsExecuted;
private final Counter postsExecuted;
private final Counter putsExecuted;
private final Counter deletesExecuted;
private final Counter exchangesExecuted;
private final Counter headsExecuted;
private final Counter optionsExecuted;
private final Counter execsExecuted;
private final Counter patchesExecuted;
private final Counter getsErrors;
private final Counter postsErrors;
private final Counter putsErrors;
private final Counter deletesErrors;
private final Counter exchangesErrors;
private final Counter headsErrors;
private final Counter optionsErrors;
private final Counter execsErrors;
private final Counter patchesErrors;
private final Timer getsTimer;
private final Timer postsTimer;
private final Timer putsTimer;
private final Timer deletesTimer;
private final Timer exchangesTimer;
private final Timer headsTimer;
private final Timer optionsTimer;
private final Timer execsTimer;
private final Timer patchesTimer;
public RestOperationsWithMetrics(RestOperations delegate, String metricsId){
this.delegate = delegate;
//Monitors.registerObject("RestTemplate-"+metricsId, this);
getsExecuted = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-getsExecuted").withTags(tags).build());
postsExecuted = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-postsExecuted").withTags(tags).build());
putsExecuted = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-putsExecuted").withTags(tags).build());
deletesExecuted = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-deletesExecuted").withTags(tags).build());
exchangesExecuted = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-exchangesExecuted").withTags(tags).build());
headsExecuted = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-headsExecuted").withTags(tags).build());
optionsExecuted = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-optionsExecuted").withTags(tags).build());
execsExecuted = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-execsExecuted").withTags(tags).build());
patchesExecuted = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-patchesExecuted").withTags(tags).build());
getsErrors = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-getsErrors").withTags(tags).build());
postsErrors = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-postsErrors").withTags(tags).build());
putsErrors = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-putsErrors").withTags(tags).build());
deletesErrors = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-deletesErrors").withTags(tags).build());
exchangesErrors = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-exchangesErrors").withTags(tags).build());
headsErrors = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-headsErrors").withTags(tags).build());
optionsErrors = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-optionsErrors").withTags(tags).build());
execsErrors = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-execsErrors").withTags(tags).build());
patchesErrors = new BasicCounter(MonitorConfig.builder("RestTemplate-"+metricsId+"-patchesErrors").withTags(tags).build());
getsTimer = new BasicTimer(MonitorConfig.builder("RestTemplate-"+metricsId+"-getsTimer").withTags(tags).build());
postsTimer = new BasicTimer(MonitorConfig.builder("RestTemplate-"+metricsId+"-postsTimer").withTags(tags).build());
putsTimer = new BasicTimer(MonitorConfig.builder("RestTemplate-"+metricsId+"-putsTimer").withTags(tags).build());
deletesTimer = new BasicTimer(MonitorConfig.builder("RestTemplate-"+metricsId+"-deletesTimer").withTags(tags).build());
exchangesTimer = new BasicTimer(MonitorConfig.builder("RestTemplate-"+metricsId+"-exchangesTimer").withTags(tags).build());
headsTimer = new BasicTimer(MonitorConfig.builder("RestTemplate-"+metricsId+"-headsTimer").withTags(tags).build());
optionsTimer = new BasicTimer(MonitorConfig.builder("RestTemplate-"+metricsId+"-optionsTimer").withTags(tags).build());
execsTimer = new BasicTimer(MonitorConfig.builder("RestTemplate-"+metricsId+"-execsTimer").withTags(tags).build());
patchesTimer = new BasicTimer(MonitorConfig.builder("RestTemplate-"+metricsId+"-patchesTimer").withTags(tags).build());
DefaultMonitorRegistry.getInstance().register(getsExecuted);
DefaultMonitorRegistry.getInstance().register(postsExecuted);
DefaultMonitorRegistry.getInstance().register(putsExecuted);
DefaultMonitorRegistry.getInstance().register(deletesExecuted);
DefaultMonitorRegistry.getInstance().register(exchangesExecuted);
DefaultMonitorRegistry.getInstance().register(headsExecuted);
DefaultMonitorRegistry.getInstance().register(optionsExecuted);
DefaultMonitorRegistry.getInstance().register(execsExecuted);
DefaultMonitorRegistry.getInstance().register(getsErrors);
DefaultMonitorRegistry.getInstance().register(postsErrors);
DefaultMonitorRegistry.getInstance().register(putsErrors);
DefaultMonitorRegistry.getInstance().register(deletesErrors);
DefaultMonitorRegistry.getInstance().register(exchangesErrors);
DefaultMonitorRegistry.getInstance().register(headsErrors);
DefaultMonitorRegistry.getInstance().register(optionsErrors);
DefaultMonitorRegistry.getInstance().register(execsErrors);
DefaultMonitorRegistry.getInstance().register(getsTimer);
DefaultMonitorRegistry.getInstance().register(postsTimer);
DefaultMonitorRegistry.getInstance().register(putsTimer);
DefaultMonitorRegistry.getInstance().register(deletesTimer);
DefaultMonitorRegistry.getInstance().register(exchangesTimer);
DefaultMonitorRegistry.getInstance().register(headsTimer);
DefaultMonitorRegistry.getInstance().register(optionsTimer);
DefaultMonitorRegistry.getInstance().register(execsTimer);
}
public <T> T getForObject(String url, Class<T> responseType, Object... uriVariables) throws RestClientException {
getsExecuted.increment();
Stopwatch s = getsTimer.start();
boolean success = false;
try{
T ret = delegate.getForObject(url, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
getsErrors.increment();
}
}
}
public <T> T getForObject(String url, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException {
getsExecuted.increment();
Stopwatch s = getsTimer.start();
boolean success = false;
try{
T ret = delegate.getForObject(url, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
getsErrors.increment();
}
}
}
public <T> T getForObject(URI url, Class<T> responseType) throws RestClientException {
getsExecuted.increment();
Stopwatch s = getsTimer.start();
boolean success = false;
try{
T ret = delegate.getForObject(url, responseType);
success = true;
return ret;
}finally{
s.stop();
if(!success){
getsErrors.increment();
}
}
}
public <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Object... uriVariables)
throws RestClientException {
getsExecuted.increment();
Stopwatch s = getsTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.getForEntity(url, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
getsErrors.increment();
}
}
}
public <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException {
getsExecuted.increment();
Stopwatch s = getsTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.getForEntity(url, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
getsErrors.increment();
}
}
}
public <T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws RestClientException {
getsExecuted.increment();
Stopwatch s = getsTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.getForEntity(url, responseType);
success = true;
return ret;
}finally{
s.stop();
if(!success){
getsErrors.increment();
}
}
}
public HttpHeaders headForHeaders(String url, Object... uriVariables) throws RestClientException {
headsExecuted.increment();
Stopwatch s = headsTimer.start();
boolean success = false;
try{
HttpHeaders ret = delegate.headForHeaders(url, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
headsErrors.increment();
}
}
}
public HttpHeaders headForHeaders(String url, Map<String, ?> uriVariables) throws RestClientException {
headsExecuted.increment();
Stopwatch s = headsTimer.start();
boolean success = false;
try{
HttpHeaders ret = delegate.headForHeaders(url, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
headsErrors.increment();
}
}
}
public HttpHeaders headForHeaders(URI url) throws RestClientException {
headsExecuted.increment();
Stopwatch s = headsTimer.start();
boolean success = false;
try{
HttpHeaders ret = delegate.headForHeaders(url);
success = true;
return ret;
}finally{
s.stop();
if(!success){
headsErrors.increment();
}
}
}
public URI postForLocation(String url, Object request, Object... uriVariables) throws RestClientException {
postsExecuted.increment();
Stopwatch s = postsTimer.start();
boolean success = false;
try{
URI ret = delegate.postForLocation(url, request, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
postsErrors.increment();
}
}
}
public URI postForLocation(String url, Object request, Map<String, ?> uriVariables) throws RestClientException {
postsExecuted.increment();
Stopwatch s = postsTimer.start();
boolean success = false;
try{
URI ret = delegate.postForLocation(url, request, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
postsErrors.increment();
}
}
}
public URI postForLocation(URI url, Object request) throws RestClientException {
postsExecuted.increment();
Stopwatch s = postsTimer.start();
boolean success = false;
try{
URI ret = delegate.postForLocation(url, request);
success = true;
return ret;
}finally{
s.stop();
if(!success){
postsErrors.increment();
}
}
}
public <T> T postForObject(String url, Object request, Class<T> responseType, Object... uriVariables)
throws RestClientException {
postsExecuted.increment();
Stopwatch s = postsTimer.start();
boolean success = false;
try{
T ret = delegate.postForObject(url, request, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
postsErrors.increment();
}
}
}
public <T> T postForObject(String url, Object request, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException {
postsExecuted.increment();
Stopwatch s = postsTimer.start();
boolean success = false;
try{
T ret = delegate.postForObject(url, request, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
postsErrors.increment();
}
}
}
public <T> T postForObject(URI url, Object request, Class<T> responseType) throws RestClientException {
postsExecuted.increment();
Stopwatch s = postsTimer.start();
boolean success = false;
try{
T ret = delegate.postForObject(url, request, responseType);
success = true;
return ret;
}finally{
s.stop();
if(!success){
postsErrors.increment();
}
}
}
public <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> responseType,
Object... uriVariables) throws RestClientException {
postsExecuted.increment();
Stopwatch s = postsTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.postForEntity(url, request, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
postsErrors.increment();
}
}
}
public <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> responseType,
Map<String, ?> uriVariables) throws RestClientException {
postsExecuted.increment();
Stopwatch s = postsTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.postForEntity(url, request, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
postsErrors.increment();
}
}
}
public <T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> responseType)
throws RestClientException {
postsExecuted.increment();
Stopwatch s = postsTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.postForEntity(url, request, responseType);
success = true;
return ret;
}finally{
s.stop();
if(!success){
postsErrors.increment();
}
}
}
public void put(String url, Object request, Object... uriVariables) throws RestClientException {
putsExecuted.increment();
Stopwatch s = putsTimer.start();
boolean success = false;
try{
delegate.put(url, request, uriVariables);
success = true;
}finally{
s.stop();
if(!success){
putsErrors.increment();
}
}
}
public void put(String url, Object request, Map<String, ?> uriVariables) throws RestClientException {
putsExecuted.increment();
Stopwatch s = putsTimer.start();
boolean success = false;
try{
delegate.put(url, request, uriVariables);
success = true;
}finally{
s.stop();
if(!success){
putsErrors.increment();
}
}
}
public void put(URI url, Object request) throws RestClientException {
putsExecuted.increment();
Stopwatch s = putsTimer.start();
boolean success = false;
try{
delegate.put(url, request);
success = true;
}finally{
s.stop();
if(!success){
putsErrors.increment();
}
}
}
public void delete(String url, Object... uriVariables) throws RestClientException {
deletesExecuted.increment();
Stopwatch s = deletesTimer.start();
boolean success = false;
try{
delegate.delete(url, uriVariables);
success = true;
}finally{
s.stop();
if(!success){
deletesErrors.increment();
}
}
}
public void delete(String url, Map<String, ?> uriVariables) throws RestClientException {
deletesExecuted.increment();
Stopwatch s = deletesTimer.start();
boolean success = false;
try{
delegate.delete(url, uriVariables);
success = true;
}finally{
s.stop();
if(!success){
deletesErrors.increment();
}
}
}
public void delete(URI url) throws RestClientException {
deletesExecuted.increment();
Stopwatch s = deletesTimer.start();
boolean success = false;
try{
delegate.delete(url);
success = true;
}finally{
s.stop();
if(!success){
deletesErrors.increment();
}
}
}
public Set<HttpMethod> optionsForAllow(String url, Object... uriVariables) throws RestClientException {
optionsExecuted.increment();
Stopwatch s = optionsTimer.start();
boolean success = false;
try{
Set<HttpMethod> ret = delegate.optionsForAllow(url, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
optionsErrors.increment();
}
}
}
public Set<HttpMethod> optionsForAllow(String url, Map<String, ?> uriVariables) throws RestClientException {
optionsExecuted.increment();
Stopwatch s = optionsTimer.start();
boolean success = false;
try{
Set<HttpMethod> ret = delegate.optionsForAllow(url, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
optionsErrors.increment();
}
}
}
public Set<HttpMethod> optionsForAllow(URI url) throws RestClientException {
optionsExecuted.increment();
Stopwatch s = optionsTimer.start();
boolean success = false;
try{
Set<HttpMethod> ret = delegate.optionsForAllow(url);
success = true;
return ret;
}finally{
s.stop();
if(!success){
optionsErrors.increment();
}
}
}
public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
Class<T> responseType, Object... uriVariables) throws RestClientException {
exchangesExecuted.increment();
Stopwatch s = exchangesTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.exchange(url, method, requestEntity, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
exchangesErrors.increment();
}
}
}
public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
exchangesExecuted.increment();
Stopwatch s = exchangesTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.exchange(url, method, requestEntity, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
exchangesErrors.increment();
}
}
}
public <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity,
Class<T> responseType) throws RestClientException {
exchangesExecuted.increment();
Stopwatch s = exchangesTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.exchange(url, method, requestEntity, responseType);
success = true;
return ret;
}finally{
s.stop();
if(!success){
exchangesErrors.increment();
}
}
}
public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException {
exchangesExecuted.increment();
Stopwatch s = exchangesTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.exchange(url, method, requestEntity, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
exchangesErrors.increment();
}
}
}
public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
exchangesExecuted.increment();
Stopwatch s = exchangesTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.exchange(url, method, requestEntity, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
exchangesErrors.increment();
}
}
}
public <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType) throws RestClientException {
exchangesExecuted.increment();
Stopwatch s = exchangesTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.exchange(url, method, requestEntity, responseType);
success = true;
return ret;
}finally{
s.stop();
if(!success){
exchangesErrors.increment();
}
}
}
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Class<T> responseType)
throws RestClientException {
exchangesExecuted.increment();
Stopwatch s = exchangesTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.exchange(requestEntity, responseType);
success = true;
return ret;
}finally{
s.stop();
if(!success){
exchangesErrors.increment();
}
}
}
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, ParameterizedTypeReference<T> responseType)
throws RestClientException {
exchangesExecuted.increment();
Stopwatch s = exchangesTimer.start();
boolean success = false;
try{
ResponseEntity<T> ret = delegate.exchange(requestEntity, responseType);
success = true;
return ret;
}finally{
s.stop();
if(!success){
exchangesErrors.increment();
}
}
}
public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor, Object... uriVariables) throws RestClientException {
execsExecuted.increment();
Stopwatch s = execsTimer.start();
boolean success = false;
try{
T ret = delegate.execute(url, method, requestCallback, responseExtractor, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
execsErrors.increment();
}
}
}
public <T> T execute(String url, HttpMethod method, RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor, Map<String, ?> uriVariables) throws RestClientException {
execsExecuted.increment();
Stopwatch s = execsTimer.start();
boolean success = false;
try{
T ret = delegate.execute(url, method, requestCallback, responseExtractor, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
execsErrors.increment();
}
}
}
public <T> T execute(URI url, HttpMethod method, RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor) throws RestClientException {
execsExecuted.increment();
Stopwatch s = execsTimer.start();
boolean success = false;
try{
T ret = delegate.execute(url, method, requestCallback, responseExtractor);
success = true;
return ret;
}finally{
s.stop();
if(!success){
execsErrors.increment();
}
}
}
@Override
public <T> T patchForObject(String url, Object request, Class<T> responseType, Object... uriVariables)
throws RestClientException {
patchesExecuted.increment();
Stopwatch s = patchesTimer.start();
boolean success = false;
try{
T ret = delegate.patchForObject(url, request, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
patchesErrors.increment();
}
}
}
@Override
public <T> T patchForObject(String url, Object request, Class<T> responseType, Map<String, ?> uriVariables)
throws RestClientException {
patchesExecuted.increment();
Stopwatch s = patchesTimer.start();
boolean success = false;
try{
T ret = delegate.patchForObject(url, request, responseType, uriVariables);
success = true;
return ret;
}finally{
s.stop();
if(!success){
patchesErrors.increment();
}
}
}
@Override
public <T> T patchForObject(URI url, Object request, Class<T> responseType) throws RestClientException {
patchesExecuted.increment();
Stopwatch s = patchesTimer.start();
boolean success = false;
try{
T ret = delegate.patchForObject(url, request, responseType);
success = true;
return ret;
}finally{
s.stop();
if(!success){
patchesErrors.increment();
}
}
}
}

View File

@@ -8,7 +8,7 @@ import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.client.RestOperations; import org.springframework.web.client.RestTemplate;
import java.net.URI; import java.net.URI;
@@ -18,7 +18,7 @@ public class PingClientTest {
PingClient pingClient = mock(PingClient.class, CALLS_REAL_METHODS); PingClient pingClient = mock(PingClient.class, CALLS_REAL_METHODS);
RestOperations restTemplate = mock(RestOperationsWithMetrics.class); RestTemplate restTemplate = mock(RestTemplate.class);
Environment env = mock(Environment.class); Environment env = mock(Environment.class);

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-container</artifactId> <artifactId>base-container</artifactId>
@@ -18,7 +18,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId> <artifactId>base-models</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
@@ -32,7 +32,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>cloud-metrics</artifactId> <artifactId>cloud-metrics</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- Auth0 dependencies --> <!-- Auth0 dependencies -->

View File

@@ -24,9 +24,15 @@ import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.ListenableFuture;
import com.netflix.servo.DefaultMonitorRegistry;
import com.netflix.servo.annotations.DataSourceType; import com.netflix.servo.annotations.DataSourceType;
import com.netflix.servo.annotations.Monitor; import com.netflix.servo.annotations.Monitor;
import com.netflix.servo.monitor.Monitors; import com.netflix.servo.monitor.BasicCounter;
import com.netflix.servo.monitor.Counter;
import com.netflix.servo.monitor.MonitorConfig;
import com.netflix.servo.monitor.NumberGauge;
import com.netflix.servo.tag.TagList;
import com.telecominfraproject.wlan.cloudmetrics.CloudMetricsTags;
import com.telecominfraproject.wlan.core.server.async.example.AsyncCallerExample; import com.telecominfraproject.wlan.core.server.async.example.AsyncCallerExample;
import com.telecominfraproject.wlan.core.server.async.example.AsyncExample; import com.telecominfraproject.wlan.core.server.async.example.AsyncExample;
@@ -51,18 +57,31 @@ public class AsyncConfiguration implements AsyncConfigurer {
private static final Logger LOG = LoggerFactory.getLogger(AsyncConfiguration.class); private static final Logger LOG = LoggerFactory.getLogger(AsyncConfiguration.class);
@Autowired private Environment environment; @Autowired private Environment environment;
@Monitor(name="TotalAsyncThreads", type=DataSourceType.GAUGE)
private static final AtomicInteger totalAsyncThreads = new AtomicInteger(0);
@Monitor(name="TotalTasksExecuted", type=DataSourceType.COUNTER) private final TagList tags = CloudMetricsTags.commonTags;
private static final AtomicInteger totalTasksExecuted = new AtomicInteger(0);
final Counter totalTasksExecuted = new BasicCounter(MonitorConfig.builder("async-totalTasksExecuted").withTags(tags).build());
@Monitor(name = "TotalTasksRejected", type = DataSourceType.COUNTER) final Counter totalTasksRejected = new BasicCounter(MonitorConfig.builder("async-totalTasksRejected").withTags(tags).build());
private static final AtomicInteger totalTasksRejected = new AtomicInteger(0);
private static final AtomicInteger totalAsyncThreads = new AtomicInteger(0);
private final NumberGauge totalAsyncThreadsGauge = new NumberGauge(
MonitorConfig.builder("async-totalAsyncThreads").withTags(tags).build(), totalAsyncThreads);
@Monitor(name="TasksInTheQueue", type=DataSourceType.GAUGE) @Monitor(name="TasksInTheQueue", type=DataSourceType.GAUGE)
private static final AtomicInteger tasksInTheQueue = new AtomicInteger(0); private static final AtomicInteger tasksInTheQueue = new AtomicInteger(0);
private final NumberGauge tasksInTheQueueGauge = new NumberGauge(
MonitorConfig.builder("async-tasksInTheQueue").withTags(tags).build(), tasksInTheQueue);
// dtop: use anonymous constructor to ensure that the following code always
// get executed,
// even when somebody adds another constructor in here
{
DefaultMonitorRegistry.getInstance().register(totalTasksExecuted);
DefaultMonitorRegistry.getInstance().register(totalTasksRejected);
DefaultMonitorRegistry.getInstance().register(totalAsyncThreadsGauge);
DefaultMonitorRegistry.getInstance().register(tasksInTheQueueGauge);
}
static interface RunnableBlockingQueueInSpringClassloaderInterface extends BlockingQueue<Runnable> { static interface RunnableBlockingQueueInSpringClassloaderInterface extends BlockingQueue<Runnable> {
} }
@@ -266,7 +285,7 @@ public class AsyncConfiguration implements AsyncConfigurer {
} }
@Override @Override
public void execute(Runnable task) { public void execute(Runnable task) {
totalTasksExecuted.incrementAndGet(); totalTasksExecuted.increment();
super.execute(task); super.execute(task);
} }
@@ -274,10 +293,10 @@ public class AsyncConfiguration implements AsyncConfigurer {
public Future<?> submit(Runnable task) { public Future<?> submit(Runnable task) {
try { try {
Future<?> result = super.submit(task); Future<?> result = super.submit(task);
totalTasksExecuted.incrementAndGet(); totalTasksExecuted.increment();
return result; return result;
} catch (TaskRejectedException exp) { } catch (TaskRejectedException exp) {
totalTasksRejected.incrementAndGet(); totalTasksRejected.increment();
throw exp; throw exp;
} }
} }
@@ -286,10 +305,10 @@ public class AsyncConfiguration implements AsyncConfigurer {
public <T> Future<T> submit(Callable<T> task) { public <T> Future<T> submit(Callable<T> task) {
try { try {
Future<T> result = super.submit(task); Future<T> result = super.submit(task);
totalTasksExecuted.incrementAndGet(); totalTasksExecuted.increment();
return result; return result;
} catch (TaskRejectedException exp) { } catch (TaskRejectedException exp) {
totalTasksRejected.incrementAndGet(); totalTasksRejected.increment();
throw exp; throw exp;
} }
} }
@@ -298,10 +317,10 @@ public class AsyncConfiguration implements AsyncConfigurer {
public ListenableFuture<?> submitListenable(Runnable task) { public ListenableFuture<?> submitListenable(Runnable task) {
try { try {
ListenableFuture<?> result = super.submitListenable(task); ListenableFuture<?> result = super.submitListenable(task);
totalTasksExecuted.incrementAndGet(); totalTasksExecuted.increment();
return result; return result;
} catch (TaskRejectedException exp) { } catch (TaskRejectedException exp) {
totalTasksRejected.incrementAndGet(); totalTasksRejected.increment();
throw exp; throw exp;
} }
} }
@@ -310,10 +329,10 @@ public class AsyncConfiguration implements AsyncConfigurer {
public <T> ListenableFuture<T> submitListenable(Callable<T> task) { public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
try { try {
ListenableFuture<T> result = super.submitListenable(task); ListenableFuture<T> result = super.submitListenable(task);
totalTasksExecuted.incrementAndGet(); totalTasksExecuted.increment();
return result; return result;
} catch (TaskRejectedException exp) { } catch (TaskRejectedException exp) {
totalTasksRejected.incrementAndGet(); totalTasksRejected.increment();
throw exp; throw exp;
} }
} }
@@ -346,7 +365,7 @@ public class AsyncConfiguration implements AsyncConfigurer {
RejectedExecutionHandler rejectedExecutionHandler = new RejectedExecutionHandler() { RejectedExecutionHandler rejectedExecutionHandler = new RejectedExecutionHandler() {
@Override @Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) { public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
totalTasksRejected.incrementAndGet(); totalTasksRejected.increment();
defaultRejectionHandler.rejectedExecution(r, executor); defaultRejectionHandler.rejectedExecution(r, executor);
} }
}; };
@@ -356,8 +375,6 @@ public class AsyncConfiguration implements AsyncConfigurer {
LOG.info("Configuring {} with CorePoolSize={} MaxPoolSize={} QueueCapacity={}", LOG.info("Configuring {} with CorePoolSize={} MaxPoolSize={} QueueCapacity={}",
executor.getThreadNamePrefix(), executor.getCorePoolSize(), executor.getMaxPoolSize(), queueCapacity); executor.getThreadNamePrefix(), executor.getCorePoolSize(), executor.getMaxPoolSize(), queueCapacity);
Monitors.registerObject(AsyncConfiguration.class.getSimpleName(), this);
return executor; return executor;
} }

View File

@@ -35,7 +35,7 @@ public class NoSSLContainerCustomizer extends ServletContainerCustomizer {
@Override @Override
public void customize(Connector connector) { public void customize(Connector connector) {
connector.setAttribute(ConnectorType.CONNECTOR_ATTRIBUTE_NAME, ConnectorType.externalConnector); connector.setAttribute(ConnectorType.CONNECTOR_ATTRIBUTE_NAME, ConnectorType.externalConnector);
connector.setAttribute("maxThreads", Integer.parseInt(appContext.getEnvironment().getProperty("maxHttpThreads", "100"))); connector.setAttribute("maxThreads", Integer.parseInt(appContext.getEnvironment().getProperty("tip.wlan.maxHttpThreads", "100")));
enableCompression(connector); enableCompression(connector);

View File

@@ -178,8 +178,14 @@ public abstract class ServletContainerCustomizer implements WebServerFactoryCust
LOG.debug("setting SSL useServerCipherSuitesOrder to {}", bValue); LOG.debug("setting SSL useServerCipherSuitesOrder to {}", bValue);
connector.setAttribute("useServerCipherSuitesOrder", bValue); connector.setAttribute("useServerCipherSuitesOrder", bValue);
} }
connector.setAttribute("maxThreads", Integer.parseInt(appContext.getEnvironment().getProperty("maxHttpThreads", "100"))); strValue = getSslProperty(environment, "sslEnabledProtocols", sslPropPrefix);
if (null != strValue) {
LOG.debug("setting SSL EnabledProtocols to {}", strValue);
connector.setProperty("enabledProtocols", strValue);
}
connector.setAttribute("maxThreads", Integer.parseInt(appContext.getEnvironment().getProperty("tip.wlan.maxHttpThreads", "100")));
LOG.info("Configured https connector for port {} with {} threads", connector.getPort(), connector.getAttribute("maxThreads")); LOG.info("Configured https connector for port {} with {} threads", connector.getPort(), connector.getAttribute("maxThreads"));
} }

View File

@@ -66,6 +66,7 @@ import org.springframework.security.web.header.HeaderWriter;
import org.springframework.security.web.util.matcher.AnyRequestMatcher; import org.springframework.security.web.util.matcher.AnyRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher; import org.springframework.security.web.util.matcher.RequestMatcher;
import com.telecominfraproject.wlan.core.model.role.PortalUserRole;
import com.telecominfraproject.wlan.core.server.container.ConnectorProperties; import com.telecominfraproject.wlan.core.server.container.ConnectorProperties;
import com.telecominfraproject.wlan.core.server.security.auth0.Auth0AuthenticationEntryPoint; import com.telecominfraproject.wlan.core.server.security.auth0.Auth0AuthenticationEntryPoint;
import com.telecominfraproject.wlan.core.server.security.auth0.Auth0AuthenticationFilter; import com.telecominfraproject.wlan.core.server.security.auth0.Auth0AuthenticationFilter;
@@ -87,14 +88,9 @@ public abstract class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private static final Logger LOG = LoggerFactory.getLogger(WebSecurityConfig.class); private static final Logger LOG = LoggerFactory.getLogger(WebSecurityConfig.class);
public static final String AUTH_CACHE_NAME = "auth_details_cache"; public static final String AUTH_CACHE_NAME = "auth_details_cache";
public static final SimpleGrantedAuthority USER_AUTHORITY = new SimpleGrantedAuthority("ROLE_USER");
public static final SimpleGrantedAuthority MSP_AUTHORITY = new SimpleGrantedAuthority("ROLE_MSP");
public static final SimpleGrantedAuthority SERVICE_PROVIDER_AUTHORITY = new SimpleGrantedAuthority("ROLE_SERVICE_PROVIDER");
public static final SimpleGrantedAuthority TECH_SUPPORT_AUTHORITY = new SimpleGrantedAuthority("ROLE_TECH_SUPPORT");
public static final SimpleGrantedAuthority CUSTOMER_EQUIPMENT_AUTHORITY = new SimpleGrantedAuthority("ROLE_CUSTOMER_EQUIPMENT"); public static final SimpleGrantedAuthority CUSTOMER_EQUIPMENT_AUTHORITY = new SimpleGrantedAuthority("ROLE_CUSTOMER_EQUIPMENT");
public static final SimpleGrantedAuthority API_AUTHORITY = new SimpleGrantedAuthority("ROLE_API"); public static final SimpleGrantedAuthority API_AUTHORITY = new SimpleGrantedAuthority("ROLE_API");
/** /**
* Maximum number of auth0 provider * Maximum number of auth0 provider
@@ -109,11 +105,13 @@ public abstract class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Bean @Bean
public UserDetailsService userDetailsService() { public UserDetailsService userDetailsService() {
List<SimpleGrantedAuthority> authorities = PortalUserRole.getAllAuthorities();
authorities.add(CUSTOMER_EQUIPMENT_AUTHORITY);
authorities.add(API_AUTHORITY);
UserDetailsService uds = new InMemoryUserDetailsManager( UserDetailsService uds = new InMemoryUserDetailsManager(
Arrays.asList(new UserDetails[] { new User(environment.getProperty("tip.wlan.serviceUser", "user"), Arrays.asList(new UserDetails[] { new User(environment.getProperty("tip.wlan.serviceUser", "user"),
environment.getProperty("tip.wlan.servicePassword", "password"), true, true, true, true, environment.getProperty("tip.wlan.servicePassword", "password"), true, true, true, true,
Arrays.asList(new SimpleGrantedAuthority[] { USER_AUTHORITY, MSP_AUTHORITY, authorities)}));
SERVICE_PROVIDER_AUTHORITY, TECH_SUPPORT_AUTHORITY, API_AUTHORITY })), }));
return uds; return uds;
} }
@@ -865,41 +863,42 @@ public abstract class WebSecurityConfig extends WebSecurityConfigurerAdapter {
* *
* @param providerIndex * @param providerIndex
* @param defaultProperties * @param defaultProperties
* @return null if clientId is not set. * @return null if clientSecret is not set.
* @throws Exception * @throws Exception
*/ */
protected Auth0AuthenticationProvider createAuth0AuthenticationProvider(int providerIndex) throws Exception { protected Auth0AuthenticationProvider createAuth0AuthenticationProvider(int providerIndex) throws Exception {
String clientId;
String clientSecret; String clientSecret;
String issuer; String issuer;
String accessTypeValue; String accessTypeValue;
String jwksLocation; String jwksLocation;
String claimsNamespace;
if (0 == providerIndex) { if (0 == providerIndex) {
clientId = environment.getProperty("tip.wlan.auth0.clientId", DEFAULT_AUTH0_PROPERTY);
clientSecret = environment.getProperty("tip.wlan.auth0.clientSecret", DEFAULT_AUTH0_PROPERTY); clientSecret = environment.getProperty("tip.wlan.auth0.clientSecret", DEFAULT_AUTH0_PROPERTY);
issuer = environment.getProperty("tip.wlan.auth0.issuerUri", DEFAULT_AUTH0_PROPERTY); issuer = environment.getProperty("tip.wlan.auth0.issuerUri", DEFAULT_AUTH0_PROPERTY);
accessTypeValue = environment.getProperty("tip.wlan.auth0.accessType", accessTypeValue = environment.getProperty("tip.wlan.auth0.accessType",
getDefaultAccessType(providerIndex)); getDefaultAccessType(providerIndex));
jwksLocation = environment.getProperty("tip.wlan.auth0.jwksLocation", DEFAULT_AUTH0_PROPERTY); jwksLocation = environment.getProperty("tip.wlan.auth0.jwksLocation", DEFAULT_AUTH0_PROPERTY);
claimsNamespace = environment.getProperty("tip.wlan.auth0.claimsNamespace", "https://wlan.telecominfraproject.com/"); // See Auth0UserDetails
} else { } else {
clientId = environment.getProperty("tip.wlan.auth0.clientId" + providerIndex);
clientSecret = environment.getProperty("tip.wlan.auth0.clientSecret" + providerIndex); clientSecret = environment.getProperty("tip.wlan.auth0.clientSecret" + providerIndex);
issuer = environment.getProperty("tip.wlan.auth0.issuer" + providerIndex); issuer = environment.getProperty("tip.wlan.auth0.issuerUri" + providerIndex);
accessTypeValue = environment.getProperty("tip.wlan.auth0.accessType" + providerIndex, accessTypeValue = environment.getProperty("tip.wlan.auth0.accessType" + providerIndex,
getDefaultAccessType(providerIndex)); getDefaultAccessType(providerIndex));
jwksLocation = environment.getProperty("tip.wlan.auth0.jwksLocation" + providerIndex); jwksLocation = environment.getProperty("tip.wlan.auth0.jwksLocation" + providerIndex);
claimsNamespace = environment.getProperty("tip.wlan.auth0.claimsNamespace" + providerIndex, "https://wlan.telecominfraproject.com/");
} }
if (null == clientId) { // Be default, use HS256 decoding which requires clientSecret
if (null == clientSecret) {
return null; return null;
} }
try { try {
AccessType accessType = AccessType.valueOf(accessTypeValue); AccessType accessType = AccessType.valueOf(accessTypeValue);
Auth0AuthenticationProvider auth0Provider = new Auth0AuthenticationProvider(accessType); Auth0AuthenticationProvider auth0Provider = new Auth0AuthenticationProvider(accessType);
auth0Provider.setClientId(clientId);
auth0Provider.setClientSecret(clientSecret); auth0Provider.setClientSecret(clientSecret);
auth0Provider.setIssuer(issuer); auth0Provider.setIssuer(issuer);
auth0Provider.setJwksLocation(jwksLocation); auth0Provider.setJwksLocation(jwksLocation);
auth0Provider.setClaimsNamespace(claimsNamespace);
auth0Provider.afterPropertiesSet(); auth0Provider.afterPropertiesSet();
LOG.info("Loaded configuration for auth0 provider {}", providerIndex); LOG.info("Loaded configuration for auth0 provider {}", providerIndex);
return auth0Provider; return auth0Provider;

View File

@@ -34,7 +34,7 @@ import com.telecominfraproject.wlan.core.server.security.AccessType;
import com.telecominfraproject.wlan.server.exceptions.ConfigurationException; import com.telecominfraproject.wlan.server.exceptions.ConfigurationException;
/** /**
* Class that verifies the JWT token and in case of beeing valid, it will set * Class that verifies the JWT token and in case of being valid, it will set
* the userdetails in the authentication object * the userdetails in the authentication object
* *
* @author Daniel Teixeira * @author Daniel Teixeira
@@ -47,9 +47,9 @@ public class Auth0AuthenticationProvider implements AuthenticationProvider, Init
private ObjectMapper mapper = new ObjectMapper(); private ObjectMapper mapper = new ObjectMapper();
private String clientSecret = null; private String clientSecret = null;
private String clientId = null;
private String issuer = null; private String issuer = null;
private String jwksLocation = null; private String jwksLocation = null;
private String claimsNamespace = null;
private final AccessType accessType; private final AccessType accessType;
private static final AuthenticationException AUTH_ERROR = new Auth0TokenException("Authentication error occured"); private static final AuthenticationException AUTH_ERROR = new Auth0TokenException("Authentication error occured");
@@ -90,7 +90,7 @@ public class Auth0AuthenticationProvider implements AuthenticationProvider, Init
jwt = verifier.verify(token); jwt = verifier.verify(token);
LOG.trace("Decoded JWT token {}", jwt); LOG.trace("Decoded JWT token {}", jwt);
tokenAuth.setAuthenticated(true); tokenAuth.setAuthenticated(true);
tokenAuth.setPrincipal(new Auth0UserDetails(jwt, this.accessType)); tokenAuth.setPrincipal(new Auth0UserDetails(jwt, this.accessType, claimsNamespace));
tokenAuth.setDetails(jwt); tokenAuth.setDetails(jwt);
return authentication; return authentication;
@@ -114,8 +114,8 @@ public class Auth0AuthenticationProvider implements AuthenticationProvider, Init
} }
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
if ((clientSecret == null) || (clientId == null) || (issuer == null)) { if ((clientSecret == null) || (issuer == null)) {
throw new ConfigurationException("Client secret, client id, or issuer URI is not set for Auth0AuthenticationProvider"); throw new ConfigurationException("Client secret or issuer URI is not set for Auth0AuthenticationProvider");
} }
} }
@@ -202,14 +202,6 @@ public class Auth0AuthenticationProvider implements AuthenticationProvider, Init
this.clientSecret = clientSecret; this.clientSecret = clientSecret;
} }
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getIssuer() { public String getIssuer() {
return issuer; return issuer;
} }
@@ -226,7 +218,15 @@ public class Auth0AuthenticationProvider implements AuthenticationProvider, Init
this.jwksLocation = jwksLocation; this.jwksLocation = jwksLocation;
} }
/** public String getClaimsNamespace() {
return claimsNamespace;
}
public void setClaimsNamespace(String claimsNamespace) {
this.claimsNamespace = claimsNamespace;
}
/**
* Use to encode raw secret to Base 64 URL safe string * Use to encode raw secret to Base 64 URL safe string
* *
* @param args * @param args

View File

@@ -2,6 +2,7 @@ package com.telecominfraproject.wlan.core.server.security.auth0;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@@ -10,6 +11,7 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import com.auth0.jwt.interfaces.DecodedJWT; import com.auth0.jwt.interfaces.DecodedJWT;
import com.telecominfraproject.wlan.core.model.role.PortalUserRole;
import com.telecominfraproject.wlan.core.server.security.AccessType; import com.telecominfraproject.wlan.core.server.security.AccessType;
import com.telecominfraproject.wlan.core.server.security.AuthProviderInfo; import com.telecominfraproject.wlan.core.server.security.AuthProviderInfo;
@@ -17,6 +19,8 @@ import com.telecominfraproject.wlan.core.server.security.AuthProviderInfo;
* Implementation of UserDetails in compliance with the decoded object returned * Implementation of UserDetails in compliance with the decoded object returned
* by the Auth0 JWT * by the Auth0 JWT
* *
* claimsNamespace is used to allow for OIDC compliance of custom claims in JWT.
*
* @author Daniel Teixeira * @author Daniel Teixeira
* *
*/ */
@@ -35,13 +39,32 @@ public class Auth0UserDetails implements UserDetails, AuthProviderInfo {
private static final String ROLES_CLAIM = "roles"; private static final String ROLES_CLAIM = "roles";
private static final Log LOGGER = LogFactory.getLog(Auth0UserDetails.class); private static final Log LOGGER = LogFactory.getLog(Auth0UserDetails.class);
public Auth0UserDetails(DecodedJWT jwt, AccessType accessType) { public Auth0UserDetails(DecodedJWT jwt, AccessType accessType) {
this(jwt, accessType, null);
}
public Auth0UserDetails(DecodedJWT jwt, AccessType accessType, String claimsNamespace) {
this.accessType = accessType; this.accessType = accessType;
if (!jwt.getClaim(EMAIL_CLAIM).isNull()) { String emailClaim;
this.username = jwt.getClaim(EMAIL_CLAIM).asString(); String emailVerifiedClaim;
} else if (!jwt.getClaim(NICKNAME_CLAIM).isNull()) { String nicknameClaim;
this.username = jwt.getClaim(NICKNAME_CLAIM).asString(); String rolesClaim;
if (claimsNamespace != null) {
emailClaim = claimsNamespace + EMAIL_CLAIM;
emailVerifiedClaim = claimsNamespace + EMAIL_VERIFIED_CLAIM;
nicknameClaim = claimsNamespace + NICKNAME_CLAIM;
rolesClaim = claimsNamespace + ROLES_CLAIM;
} else {
emailClaim = EMAIL_CLAIM;
emailVerifiedClaim = EMAIL_VERIFIED_CLAIM;
nicknameClaim = NICKNAME_CLAIM;
rolesClaim = ROLES_CLAIM;
}
if (!jwt.getClaim(emailClaim).isNull()) {
this.username = jwt.getClaim(emailClaim).asString();
} else if (!jwt.getClaim(nicknameClaim).isNull()) {
this.username = jwt.getClaim(nicknameClaim).asString();
} else if (jwt.getId() != null) { } else if (jwt.getId() != null) {
this.username = jwt.getId(); this.username = jwt.getId();
} else if (jwt.getSubject() != null) { } else if (jwt.getSubject() != null) {
@@ -50,16 +73,16 @@ public class Auth0UserDetails implements UserDetails, AuthProviderInfo {
this.username = "UNKNOWN_USER"; this.username = "UNKNOWN_USER";
} }
if (!jwt.getClaim(EMAIL_CLAIM).isNull()) { if (!jwt.getClaim(emailClaim).isNull()) {
this.emailVerified = Boolean.valueOf(jwt.getClaim(EMAIL_VERIFIED_CLAIM).toString()); this.emailVerified = Boolean.valueOf(jwt.getClaim(emailVerifiedClaim).toString());
} }
// set authorities // set authorities
authorities = new ArrayList<>(); authorities = new ArrayList<>();
if (!jwt.getClaim(ROLES_CLAIM).isNull()) { if (!jwt.getClaim(rolesClaim).isNull()) {
ArrayList<String> roles = null; List<String> roles = null;
try { try {
roles = (ArrayList<String>) jwt.getClaim(ROLES_CLAIM).asList(String.class); roles = jwt.getClaim(rolesClaim).asList(String.class);
for (String role : roles) { for (String role : roles) {
authorities.add(new SimpleGrantedAuthority(role)); authorities.add(new SimpleGrantedAuthority(role));
} }
@@ -68,9 +91,9 @@ public class Auth0UserDetails implements UserDetails, AuthProviderInfo {
} }
} }
// By default if nothing is added // By default, set to CustomerIT authority if nothing is added
if (authorities.isEmpty()) { if (authorities.isEmpty()) {
authorities.add(new SimpleGrantedAuthority("ROLE_USER")); authorities.add(PortalUserRole.CustomerIT.getAuthority());
} }
this.details = jwt; this.details = jwt;

View File

@@ -0,0 +1,33 @@
package com.telecominfraproject.wlan.core.server.webconfig;
import java.util.ArrayList;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
@Configuration
public class ByteArrayHttpMessageConverterConfig {
/**
* Create byte array http message converter
* @return
*/
@Bean
public ByteArrayHttpMessageConverter byteArrayHttpMessageConverter() {
ByteArrayHttpMessageConverter arrayHttpMessageConverter = new ByteArrayHttpMessageConverter();
arrayHttpMessageConverter.setSupportedMediaTypes(getSupportedMediaTypes());
return arrayHttpMessageConverter;
}
private List<MediaType> getSupportedMediaTypes() {
List<MediaType> list = new ArrayList<>();
list.add(MediaType.APPLICATION_OCTET_STREAM);
list.add(MediaType.IMAGE_JPEG);
list.add(MediaType.IMAGE_PNG);
return list;
}
}

View File

@@ -20,7 +20,7 @@ import com.telecominfraproject.wlan.core.model.json.JsonSerializedException;
/** /**
* @author dtoptygin * @author dtoptygin
*/ */
@ControllerAdvice @ControllerAdvice(basePackages = "com.telecominfraproject")
public class CommonControllerAdvice { public class CommonControllerAdvice {
private static final Logger LOG = LoggerFactory.getLogger(CommonControllerAdvice.class); private static final Logger LOG = LoggerFactory.getLogger(CommonControllerAdvice.class);

View File

@@ -0,0 +1,57 @@
package com.telecominfraproject.wlan.core.server.webconfig;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Profile;
import org.springframework.core.MethodParameter;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
/**
* This is an example of ServletPreInvocableHandler.
* To enable it - activate spring profile "useExampleServletPreInvocableHandler".
*
* @author dtop
*
*/
@Component
@Profile("useExampleServletPreInvocableHandler")
public class ExampleServletPreInvocableHandler implements ServletPreInvocableHandler {
final static Logger LOG = LoggerFactory.getLogger(ExampleServletPreInvocableHandler.class);
@Override
public void preInvoke(HandlerMethod handlerMethod, Object[] args) {
RequestMapping reqMapping = handlerMethod.getMethodAnnotation(RequestMapping.class);
MethodParameter[] methodParamDefs = handlerMethod.getMethodParameters();
Map<String, Object> methodParams = new HashMap<>();
String pName;
for(int i=0; i< args.length; i++) {
if(i< methodParamDefs.length) {
pName = methodParamDefs[i].getParameterName();
if(pName==null) {
pName = "unknown" + i;
}
} else {
pName = "unknown" + i;
}
methodParams.put(pName, args[i]);
}
LOG.info("Calling doInvoke on {}.{} : {} {} with parameters {} ", handlerMethod.getBean().getClass().getName(), handlerMethod.getMethod().getName(),
reqMapping.path(), reqMapping.method(), methodParams);
//TODO: invoke some application logic in here, like fine-grained role-based access control
if(reqMapping.path()[0].equals("/equipment/forCustomerWithFilter")) {
throw new RuntimeException("Cannot do that!");
}
}
}

View File

@@ -0,0 +1,17 @@
package com.telecominfraproject.wlan.core.server.webconfig;
import org.springframework.web.method.HandlerMethod;
/**
* This interface defines a method that is called after all the parameters are deserialized and converted to java objects but before the Controller method gets called.
* Can be used for fine-grained role-based access control.
* Many classes can implement this interface.
* When marked as @Bean, all such classes will be registered and called before every Controller method.
*
* @see ExampleServletPreInvocableHandler
* @author dtop
*
*/
public interface ServletPreInvocableHandler {
void preInvoke(HandlerMethod handlerMethod, Object[] args);
}

View File

@@ -6,18 +6,16 @@ import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.format.FormatterRegistry; import org.springframework.format.FormatterRegistry;
import org.springframework.http.MediaType;
import org.springframework.http.converter.ByteArrayHttpMessageConverter; import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistration; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel; import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
@@ -28,9 +26,14 @@ import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
@Configuration @Configuration
//@EnableWebMvc - DTOP: do not use this, it will break mapping for index.html file //@EnableWebMvc - DTOP: do not use this, it will break mapping for index.html file
// see http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-auto-configuration // see http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-auto-configuration
public class WebConfig extends WebMvcConfigurerAdapter { public class WebConfig implements WebMvcConfigurer {
@Autowired
private Environment environment;
@Autowired
private ByteArrayHttpMessageConverter byteArrayHttpMessageConverter;
@Autowired private Environment environment;
private static final Logger LOG = LoggerFactory.getLogger(WebConfig.class); private static final Logger LOG = LoggerFactory.getLogger(WebConfig.class);
private static final String WEB_RESOURCE_PROP = "tip.wlan.webResources"; private static final String WEB_RESOURCE_PROP = "tip.wlan.webResources";
@@ -54,8 +57,6 @@ public class WebConfig extends WebMvcConfigurerAdapter {
resourceHandlerRegistration.setCachePeriod(Integer.getInteger("tip.wlan.webResources.cachePeriodSec", 0)); resourceHandlerRegistration.setCachePeriod(Integer.getInteger("tip.wlan.webResources.cachePeriodSec", 0));
} }
super.addResourceHandlers(registry);
} }
@Override @Override
@@ -91,26 +92,7 @@ public class WebConfig extends WebMvcConfigurerAdapter {
@Override @Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(byteArrayHttpMessageConverter()); converters.add(byteArrayHttpMessageConverter);
}
/**
* Create byte array http message converter
* @return
*/
@Bean
public ByteArrayHttpMessageConverter byteArrayHttpMessageConverter() {
ByteArrayHttpMessageConverter arrayHttpMessageConverter = new ByteArrayHttpMessageConverter();
arrayHttpMessageConverter.setSupportedMediaTypes(getSupportedMediaTypes());
return arrayHttpMessageConverter;
}
private List<MediaType> getSupportedMediaTypes() {
List<MediaType> list = new ArrayList<>();
list.add(MediaType.APPLICATION_OCTET_STREAM);
list.add(MediaType.IMAGE_JPEG);
list.add(MediaType.IMAGE_PNG);
return list;
} }
} }

View File

@@ -4,9 +4,11 @@
package com.telecominfraproject.wlan.core.server.webconfig; package com.telecominfraproject.wlan.core.server.webconfig;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations; import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@@ -14,19 +16,30 @@ import org.springframework.context.annotation.Profile;
import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles; import org.springframework.core.env.Profiles;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod;
/** /**
* @author yongli * @author yongli
* @author dtop
* *
*/ */
@Configuration @Configuration
public class WebMvcRegistrationsConfiguration { public class WebMvcRegistrationsConfiguration {
final static Logger LOG = LoggerFactory.getLogger(WebMvcRegistrationsConfiguration.class); final static Logger LOG = LoggerFactory.getLogger(WebMvcRegistrationsConfiguration.class);
@Autowired(required = false)
private List<ServletPreInvocableHandler> servletPreInvocableHandlers;
/** /**
* Use adaptor to filter out RequestMapping methods based on condition * Use adaptor to filter out RequestMapping methods based on condition.<br>
* Provide a way to register pre-invoke servlet handlers - to have common logic applied
* after the parameters have been parsed and converted to java objects but before the Controller method itself is called.
* @see ExampleServletPreInvocableHandler
* @see ServletPreInvocableHandler
* *
* @param environment * @param environment
* @return * @return
@@ -34,6 +47,11 @@ public class WebMvcRegistrationsConfiguration {
@Bean @Bean
public WebMvcRegistrations mvcRegistrations(Environment environment) { public WebMvcRegistrations mvcRegistrations(Environment environment) {
LOG.info("Customizing WebMvcRegistrations"); LOG.info("Customizing WebMvcRegistrations");
if(servletPreInvocableHandlers!=null) {
servletPreInvocableHandlers.forEach(h -> LOG.info("registering pre-invoke servlet handler {}", h) );
}
return new WebMvcRegistrations() { return new WebMvcRegistrations() {
@Override @Override
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
@@ -63,6 +81,28 @@ public class WebMvcRegistrationsConfiguration {
} }
}; };
} }
@Override
public RequestMappingHandlerAdapter getRequestMappingHandlerAdapter() {
return new RequestMappingHandlerAdapter() {
@Override
protected ServletInvocableHandlerMethod createInvocableHandlerMethod(HandlerMethod handlerMethod) {
return new ServletInvocableHandlerMethod(handlerMethod) {
@Override
protected Object doInvoke(Object... args) throws Exception {
//apply all registered pre-invoke servlet handlers
if(servletPreInvocableHandlers!=null) {
servletPreInvocableHandlers.forEach(h -> h.preInvoke(handlerMethod, args) );
}
return super.doInvoke(args);
}
};
}
};
}
}; };
} }
} }

View File

@@ -1,11 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-datastore-inmemory</artifactId> <artifactId>base-datastore-inmemory</artifactId>
@@ -15,7 +13,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-exceptions</artifactId> <artifactId>base-exceptions</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-elasticsearch</artifactId> <artifactId>base-elasticsearch</artifactId>
@@ -15,12 +14,12 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-exceptions</artifactId> <artifactId>base-exceptions</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId> <artifactId>base-models</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- ElasticSearch dependencies --> <!-- ElasticSearch dependencies -->
<dependency> <dependency>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-exceptions</artifactId> <artifactId>base-exceptions</artifactId>

View File

@@ -1,11 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-hazelcast-client</artifactId> <artifactId>base-hazelcast-client</artifactId>
@@ -23,12 +21,12 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>common-hazelcast</artifactId> <artifactId>common-hazelcast</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId> <artifactId>base-models</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-hierarchical-datastore</artifactId> <artifactId>base-hierarchical-datastore</artifactId>
@@ -13,17 +13,17 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId> <artifactId>base-models</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-hazelcast-client</artifactId> <artifactId>base-hazelcast-client</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>cloud-metrics</artifactId> <artifactId>cloud-metrics</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-jdbc-tests</artifactId> <artifactId>base-jdbc-tests</artifactId>
@@ -17,7 +16,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-jdbc</artifactId> <artifactId>base-jdbc</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -1,18 +1,11 @@
package com.telecominfraproject.wlan.core.server.jdbc.test; package com.telecominfraproject.wlan.core.server.jdbc.test;
import java.net.URL; import java.io.IOException;
import java.util.ArrayList; import java.lang.reflect.Field;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.reflections.Reflections;
import org.reflections.scanners.ResourcesScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -22,18 +15,19 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Profile;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.test.annotation.Rollback; import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.transaction.AfterTransaction; import org.springframework.test.context.transaction.AfterTransaction;
import org.springframework.test.context.transaction.BeforeTransaction; import org.springframework.test.context.transaction.BeforeTransaction;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
import com.telecominfraproject.wlan.core.server.jdbc.BaseJDbcDataSource; import com.telecominfraproject.wlan.core.server.jdbc.BaseJDbcDataSource;
import com.telecominfraproject.wlan.core.server.jdbc.BaseKeyColumnConverter; import com.telecominfraproject.wlan.core.server.jdbc.BaseKeyColumnConverter;
import com.telecominfraproject.wlan.core.server.jdbc.KeyColumnUpperCaseConverter; import com.telecominfraproject.wlan.core.server.jdbc.KeyColumnUpperCaseConverter;
@@ -100,51 +94,68 @@ public abstract class BaseJdbcTest {
// creates a HSQL in-memory db populated from scripts // creates a HSQL in-memory db populated from scripts
// classpath:schema-hsqldb-test.sql and classpath:test-data.sql // classpath:schema-hsqldb-test.sql and classpath:test-data.sql
// this will auto-wire DataSource object // this will auto-wire DataSource object
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder() EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
.addScript("classpath:schema-hsqldb-test.sql");
// If the EmbeddedDatabaseBuilder class had a following method, we would have used it directly:
// public EmbeddedDatabaseBuilder addScript(Resource scriptResource) {
// this.databasePopulator.addScript(scriptResource);
// return this;
// }
// But it does not have this method, and we will have to use reflection to achieve similar effect.
//
// We need to expose ResourceDatabasePopulator databasePopulator field of the
// EmbeddedDatabaseBuilder to be able to pass to it resources with the same name
// in the classpath, i.e. schema-hsqldb-test.sql files that are defined in
// different modules
ResourceDatabasePopulator dbPopulator;
try {
Field dbPopulatorField = EmbeddedDatabaseBuilder.class.getDeclaredField("databasePopulator");
//the field is private, so we have to use a hammer
dbPopulatorField.setAccessible(true);
dbPopulator = (ResourceDatabasePopulator) dbPopulatorField.get(builder);
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
throw new RuntimeException("Cannot get access to dbPopulator of the EmbeddedDatabaseBuilder : " + e.getMessage(), e);
}
//
// Add the schema-hsqldb-test.sql scripts to the DB builder
//
try {
PathMatchingResourcePatternResolver pRes = new PathMatchingResourcePatternResolver();
Resource[] resources = pRes.getResources("classpath*:schema-hsqldb-test.sql");
if(resources!=null) {
for(Resource r: resources) {
dbPopulator.addScript(r);
LOG.debug("Adding SQL script {} - {}", r.getFilename(), r.getURI());
}
}
} catch (IOException e) {
throw new RuntimeException("Cannot load SQL scripts: " + e.getMessage(), e);
}
builder.generateUniqueName(true); builder.generateUniqueName(true);
// //
// We only want to add the test-data.sql if the file actually // Now add the test-data.sql scripts to the DB builder
// exists.
// //
Set<String> testDataFiles = getReflections().getResources(Pattern.compile("test-data.sql")); try {
PathMatchingResourcePatternResolver pRes = new PathMatchingResourcePatternResolver();
if (!CollectionUtils.isEmpty(testDataFiles)) { Resource[] resources = pRes.getResources("classpath*:test-data.sql");
builder.addScript("classpath:test-data.sql"); if(resources!=null) {
for(Resource r: resources) {
dbPopulator.addScript(r);
LOG.debug("Adding SQL script {} - {}", r.getFilename(), r.getURI());
}
}
} catch (IOException e) {
throw new RuntimeException("Cannot load SQL scripts: ", e);
} }
EmbeddedDatabase db = builder.build(); EmbeddedDatabase db = builder.build();
return new BaseJdbcTestDatabase(db, new KeyColumnUpperCaseConverter());
}
public static Reflections getReflections() {
//scan urls that contain 'com.telecominfraproject.wlan' and vendor-specific top level packages, use the ResourcesScanner
List<URL> urls = new ArrayList<>();
urls.addAll(ClasspathHelper.forPackage("com.telecominfraproject.wlan"));
//add vendor packages return new BaseJdbcTestDatabase(db, new KeyColumnUpperCaseConverter());
String vendorTopLevelPackages = BaseJsonModel.getVendorTopLevelPackages();
if(vendorTopLevelPackages!=null) {
String[] vendorPkgs = vendorTopLevelPackages.split(",");
for(int i=0; i< vendorPkgs.length; i++) {
if(vendorPkgs[i].trim().isEmpty()) {
continue;
}
urls.addAll(ClasspathHelper.forPackage(vendorPkgs[i]));
}
}
Reflections reflections = new Reflections(new ConfigurationBuilder()
.setUrls(urls)
.setScanners(new ResourcesScanner() ));
return reflections;
} }
@Bean @Bean

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-jdbc</artifactId> <artifactId>base-jdbc</artifactId>
@@ -41,7 +41,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>cloud-metrics</artifactId> <artifactId>cloud-metrics</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -8,7 +8,6 @@ import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException; import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;
import javax.sql.DataSource; import javax.sql.DataSource;
@@ -21,11 +20,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import com.netflix.servo.DefaultMonitorRegistry; import com.netflix.servo.DefaultMonitorRegistry;
import com.netflix.servo.annotations.DataSourceType; import com.netflix.servo.monitor.BasicCounter;
import com.netflix.servo.annotations.Monitor;
import com.netflix.servo.monitor.BasicGauge; import com.netflix.servo.monitor.BasicGauge;
import com.netflix.servo.monitor.Counter;
import com.netflix.servo.monitor.MonitorConfig; import com.netflix.servo.monitor.MonitorConfig;
import com.netflix.servo.monitor.Monitors;
import com.netflix.servo.tag.TagList; import com.netflix.servo.tag.TagList;
import com.telecominfraproject.wlan.cloudmetrics.CloudMetricsTags; import com.telecominfraproject.wlan.cloudmetrics.CloudMetricsTags;
import com.telecominfraproject.wlan.server.exceptions.ConfigurationException; import com.telecominfraproject.wlan.server.exceptions.ConfigurationException;
@@ -39,8 +37,14 @@ public abstract class BaseDataSourceConfig {
@Autowired @Autowired
private Environment environment; private Environment environment;
@Monitor(name = "getConnection", type = DataSourceType.COUNTER) final Counter getConnectionExecuted = new BasicCounter(MonitorConfig.builder("jdbc-getConnection").withTags(tags).build());
private final AtomicInteger getConnectionExecuted = new AtomicInteger(0);
// dtop: use anonymous constructor to ensure that the following code always
// get executed,
// even when somebody adds another constructor in here
{
DefaultMonitorRegistry.getInstance().register(getConnectionExecuted);
}
static interface DataSourceInSpringClassloaderInterface extends DataSource { static interface DataSourceInSpringClassloaderInterface extends DataSource {
} }
@@ -71,7 +75,7 @@ public abstract class BaseDataSourceConfig {
} }
public Connection getConnection() throws SQLException { public Connection getConnection() throws SQLException {
getConnectionExecuted.incrementAndGet(); getConnectionExecuted.increment();
return dataSource.getConnection(); return dataSource.getConnection();
} }
@@ -80,7 +84,7 @@ public abstract class BaseDataSourceConfig {
} }
public Connection getConnection(String username, String password) throws SQLException { public Connection getConnection(String username, String password) throws SQLException {
getConnectionExecuted.incrementAndGet(); getConnectionExecuted.increment();
return dataSource.getConnection(username, password); return dataSource.getConnection(username, password);
} }
@@ -139,8 +143,6 @@ public abstract class BaseDataSourceConfig {
String datasourceId = getDataSourceName(); String datasourceId = getDataSourceName();
DataSourceInSpringClassloader wrappedObj = new DataSourceInSpringClassloader(datasourceId, poolDataSource); DataSourceInSpringClassloader wrappedObj = new DataSourceInSpringClassloader(datasourceId, poolDataSource);
Monitors.registerObject(datasourceId, this);
BasicGauge<Integer> numberOfActiveJDBCConnections = new BasicGauge<>( BasicGauge<Integer> numberOfActiveJDBCConnections = new BasicGauge<>(
MonitorConfig.builder(getDataSourceName() + "-numberOfActiveJDBCConnections").withTags(tags).build(), MonitorConfig.builder(getDataSourceName() + "-numberOfActiveJDBCConnections").withTags(tags).build(),
new Callable<Integer>() { new Callable<Integer>() {

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
@@ -16,7 +15,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId> <artifactId>base-models</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -1,11 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-models</artifactId> <artifactId>base-models</artifactId>
@@ -16,20 +14,20 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-exceptions</artifactId> <artifactId>base-exceptions</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>json-patch-tip</artifactId> <artifactId>json-patch-tip</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- this is used to register all subclasses of BaseJsonModel for deserialization --> <!-- this is used to register all subclasses of BaseJsonModel for deserialization -->
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>reflections-tip</artifactId> <artifactId>reflections-tip</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 --> <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-math3 -->
@@ -45,6 +43,11 @@
<artifactId>base62</artifactId> <artifactId>base62</artifactId>
<version>${seruco.base62.version}</version> <version>${seruco.base62.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
</dependencies> </dependencies>

View File

@@ -0,0 +1,9 @@
package com.telecominfraproject.wlan.core.model.equipment;
public enum LedStatus {
led_on,
led_off,
led_blink,
UNKNOWN;
}

View File

@@ -4,9 +4,11 @@ import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel; import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
import com.telecominfraproject.wlan.core.model.serializers.Base64UrlByteArrayDeserializer;
import com.telecominfraproject.wlan.core.model.serializers.Base64UrlByteArraySerializer;
@JsonSerialize() @JsonSerialize()
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
@@ -40,10 +42,12 @@ public class MacAddress extends BaseJsonModel implements Comparable<MacAddress>
(byte) ((valueAsLong >> 8) & 0xff), (byte) (valueAsLong & 0xff) }); (byte) ((valueAsLong >> 8) & 0xff), (byte) (valueAsLong & 0xff) });
} }
@JsonDeserialize(using = Base64UrlByteArrayDeserializer.class)
public void setAddress(byte[] address) { public void setAddress(byte[] address) {
this.address = address; this.address = address;
} }
@JsonSerialize(using = Base64UrlByteArraySerializer.class)
public byte[] getAddress() { public byte[] getAddress() {
return this.address; return this.address;
} }
@@ -54,7 +58,7 @@ public class MacAddress extends BaseJsonModel implements Comparable<MacAddress>
if(address.length >= 6) if(address.length >= 6)
{ {
long mac = 0; long mac = 0;
for (int i = 0; i < 6; i++) { for (var i = 0; i < 6; i++) {
long t = (address[i] & 0xffL) << ((5 - i) * 8); long t = (address[i] & 0xffL) << ((5 - i) * 8);
mac |= t; mac |= t;
} }
@@ -69,7 +73,7 @@ public class MacAddress extends BaseJsonModel implements Comparable<MacAddress>
} }
public String getAddressAsString() { public String getAddressAsString() {
StringBuilder sb = new StringBuilder(124); var sb = new StringBuilder(124);
if(address != null) if(address != null)
{ {
@@ -78,14 +82,15 @@ public class MacAddress extends BaseJsonModel implements Comparable<MacAddress>
} }
sb.setLength(sb.length() - 1); sb.setLength(sb.length() - 1);
return sb.toString();
} }
return sb.toString(); return null;
} }
@JsonIgnore @JsonIgnore
public String getAsLowerCaseString() { public String getAsLowerCaseString() {
StringBuilder sb = new StringBuilder(124); var sb = new StringBuilder(124);
for (byte single : address) { for (byte single : address) {
sb.append(String.format("%02x", single)); sb.append(String.format("%02x", single));
} }
@@ -127,8 +132,8 @@ public class MacAddress extends BaseJsonModel implements Comparable<MacAddress>
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final var prime = 31;
int result = 1; var result = 1;
result = prime * result + Arrays.hashCode(address); result = prime * result + Arrays.hashCode(address);
return result; return result;
} }
@@ -159,12 +164,16 @@ public class MacAddress extends BaseJsonModel implements Comparable<MacAddress>
private static byte[] stringToByteArray(String str) { private static byte[] stringToByteArray(String str) {
byte[] ret = new byte[6]; if (str == null || str.equals(""))
{
return null;
}
var ret = new byte[6];
String octets[] = str.split(":"); String octets[] = str.split(":");
if(octets.length == 1 && octets[0].length() == str.length() && str.length()<=12) { if(octets.length == 1 && octets[0].length() == str.length() && str.length()<=12) {
// hex string without colon // hex string without colon
for(int i = 0; i< str.length(); i+=2) { for(var i = 0; i< str.length(); i+=2) {
Integer hex = Integer.parseInt(str.substring(i, i==str.length()-1?i+1:i+2), 16); Integer hex = Integer.parseInt(str.substring(i, i==str.length()-1?i+1:i+2), 16);
ret[i/2] = hex.byteValue(); ret[i/2] = hex.byteValue();
} }
@@ -174,7 +183,7 @@ public class MacAddress extends BaseJsonModel implements Comparable<MacAddress>
} }
else { else {
try { try {
for (int i = 0; i < octets.length; i++) { for (var i = 0; i < octets.length; i++) {
Integer hex = Integer.parseInt(octets[i], 16); Integer hex = Integer.parseInt(octets[i], 16);
ret[i] = hex.byteValue(); ret[i] = hex.byteValue();
} }
@@ -206,8 +215,8 @@ public class MacAddress extends BaseJsonModel implements Comparable<MacAddress>
else else
{ {
String[] value = lowercaseValue.split(":"); String[] value = lowercaseValue.split(":");
StringBuilder sb = new StringBuilder(6); var sb = new StringBuilder(6);
for(int i=0; i<3; i++) for(var i=0; i<3; i++)
{ {
sb.append(value[i].toLowerCase()); sb.append(value[i].toLowerCase());
} }
@@ -217,11 +226,11 @@ public class MacAddress extends BaseJsonModel implements Comparable<MacAddress>
} }
public String toOuiString() { public String toOuiString() {
if(address == null) { if(address == null || address.length == 0) {
return null; return null;
} }
StringBuilder sb = new StringBuilder(6); var sb = new StringBuilder(6);
for (int i = 0; i< 3; i++) { for (var i = 0; i< 3; i++) {
sb.append(String.format("%02x", address[i])); sb.append(String.format("%02x", address[i]));
} }
return sb.toString(); return sb.toString();
@@ -284,11 +293,17 @@ public class MacAddress extends BaseJsonModel implements Comparable<MacAddress>
* @return * @return
*/ */
public static Long convertMacStringToLongValue(String macStr) { public static Long convertMacStringToLongValue(String macStr) {
if (macStr == null)
{
return null;
}
byte[] bval = stringToByteArray(macStr); byte[] bval = stringToByteArray(macStr);
if (bval.length >= 6) { if (bval != null && bval.length >= 6) {
long mac = 0; long mac = 0;
for (int i = 0; i < 6; i++) { for (var i = 0; i < 6; i++) {
long t = (bval[i] & 0xffL) << ((5 - i) * 8); long t = (bval[i] & 0xffL) << ((5 - i) * 8);
mac |= t; mac |= t;
} }

View File

@@ -104,4 +104,8 @@ public class RadioBestApSettings extends BaseJsonModel
return false; return false;
} }
@Override
public RadioBestApSettings clone() {
return (RadioBestApSettings) super.clone();
}
} }

View File

@@ -9,6 +9,7 @@ public enum SecurityType
OPEN, OPEN,
RADIUS, RADIUS,
PSK, PSK,
SAE,
UNSUPPORTED; UNSUPPORTED;

View File

@@ -38,4 +38,15 @@ public class SourceSelectionSteering extends AbstractSource<RadioBestApSettings>
return false; return false;
} }
@Override
public SourceSelectionSteering clone() {
SourceSelectionSteering ret = (SourceSelectionSteering) super.clone();
if(this.value!=null) {
ret.value = this.value.clone();
}
return ret;
}
} }

View File

@@ -47,4 +47,10 @@ public class SourceSelectionValue extends AbstractSource<Integer>{
return false; return false;
} }
@Override
public SourceSelectionValue clone() {
SourceSelectionValue ret = (SourceSelectionValue) super.clone();
return ret;
}
} }

View File

@@ -89,6 +89,11 @@ public abstract class BaseJsonModel implements Cloneable, Serializable {
PRETTY_WRITTER = MAPPER.writer().withDefaultPrettyPrinter(); PRETTY_WRITTER = MAPPER.writer().withDefaultPrettyPrinter();
} }
public static ObjectMapper getMapper() {
return MAPPER;
}
/** /**
* For NoSQL databases we do not use synthetic keys, but they are still part of the object model. * For NoSQL databases we do not use synthetic keys, but they are still part of the object model.
* This method allows us to calculate a value of synthetic key from two long elements, for example equipmentId and timestamp. * This method allows us to calculate a value of synthetic key from two long elements, for example equipmentId and timestamp.
@@ -404,7 +409,48 @@ public abstract class BaseJsonModel implements Cloneable, Serializable {
return listFromString(jsonPayload, clazz); return listFromString(jsonPayload, clazz);
} }
public static void main(String[] args) { public static void main_1(String[] args) {
String plainStr = "{\"model_type\":\"CustomerDetails\",\"autoProvisioning\":{\"model_type\":\"EquipmentAutoProvisioningSettings\",\"enabled\":true,\"locationId\":8,\"equipmentProfileIdPerModel\":{\"TIP_AP\":5,\"ECW5410\":6,\"ECW5211\":6,\"AP2220\":6,\"EA8300-CA\":5,\"EA8300\":5,\"default\":5}},\"bannedChannels\":[]}";
String encZipStr = "504b03041400080808006b513c5200000000000000000000000001000000615d4f3d0bc23010fd2f375768ab15c9166a870e4240c141445273d5409ad4f62288f4bf9b561d74ba77efde07f784c62934277ab4080c72df936bb05b23496d7a88407a72a27377dd6b67b5bd007bfe5a8a9bd76d8396f89f728b44618c216865655001a3ce6304c69d250551199855b87e1382bbd6064b25b0db8c1d63d9ae14272e80651114f93e5b2431b0e51ba74932612ed234fdd07c358fe359cedf86699ba0c25a7a43010f430495b416557e1d4778931d8ec30b504b0708be151e61b70000000a010000504b010214001400080808006b513c52be151e61b70000000a01000001000000000000000000000000000000000061504b050600000000010001002f000000e60000000000";
decodePostgresGzipBytea(encZipStr);
encodePostgresGzipBytea(plainStr);
}
public static void encodePostgresGzipBytea(String plainStr) {
byte[] bytes = BaseJsonModel.toZippedBytesFromString(plainStr);
StringBuilder encZipStr = new StringBuilder(bytes.length * 2);
String oneByteStr;
int unsignedByte;
for(int i = 0; i<bytes.length; i++) {
unsignedByte = 0x00ff & bytes[i];
oneByteStr = Integer.toHexString(unsignedByte);
if(oneByteStr.length()<2) {
oneByteStr = "0" + oneByteStr;
}
encZipStr.append( oneByteStr );
}
System.out.println(encZipStr.toString());
}
public static void decodePostgresGzipBytea(String encZipStr) {
byte[] bytes = new byte[encZipStr.length()/2];
for(int i = 0; i+2<encZipStr.length(); i+=2) {
bytes[i/2] = (byte) Integer.parseUnsignedInt(encZipStr, i, i+2, 16);
}
System.out.println(BaseJsonModel.fromZippedBytesAsString(bytes));
}
public static void main_syntheticKey(String[] args) {
long one = 1; long one = 1;
long maxEncodable = 0x3FFFFFL; long maxEncodable = 0x3FFFFFL;

View File

@@ -0,0 +1,14 @@
package com.telecominfraproject.wlan.core.model.json.interfaces;
/**
* Marker interface that tells if current object can provide locationId for which it belongs to
* @author dtop
*
*/
public interface HasLocationId {
/**
* @return locationId for which this object belongs to
*/
long getLocationId();
}

View File

@@ -0,0 +1,13 @@
package com.telecominfraproject.wlan.core.model.json.interfaces;
/**
* Marker interface that tells if current object can provide a timestamp from its source data (i.e. timestamp for stats report used to generate a ServiceMetric)
* @author mikehansen1970
*
*/
public interface HasSourceTimestamp {
/**
* @return the timestamp of the source data for this object (i.e. for the stats that were used for a ServiceMetric)
*/
public long getSourceTimestampMs();
}

View File

@@ -3,105 +3,152 @@
*/ */
package com.telecominfraproject.wlan.core.model.role; package com.telecominfraproject.wlan.core.model.role;
import java.util.HashMap; import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.telecominfraproject.wlan.core.model.json.JsonDeserializationUtils; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.telecominfraproject.wlan.core.model.extensibleenum.EnumWithId;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
/** /**
* All available roles for the portal users that can be handled by the CloudSDK.
* <br>This enumeration-like class can be extended by vendors - new elements can be defined by extending this class like so:
* <br>
* <pre>
* public class VendorExtendedPortalUserRole extends PortalUserRole {
*
* public static final PortalUserRole
* VENDOR_USER_ROLE_A = new VendorExtendedPortalUserRole(100, "VENDOR_USER_ROLE_A", 5) ,
* VENDOR_USER_ROLE_B = new VendorExtendedPortalUserRole(101, "VENDOR_USER_ROLE_B", 5)
* ;
*
* private VendorExtendedPortalUserRole(int id, String name, int permissionLevel) {
* super(id, name, permissionLevel);
* }
*
* }
* </pre>
* @see com.telecominfraproject.wlan.core.model.extensibleenum.EnumWithId
* @see com.telecominfraproject.wlan.core.model.role.vendorextensions.VendorExtendedPortalUserRole
* <br>
* @author dtop
* @author ekeddy * @author ekeddy
* *
* Defines the various user roles and permissions. Highest permission * Defines the various user roles and permissions. Highest permission
* level has greatest permission. * level has greatest permission.
*/ */
public enum PortalUserRole { public class PortalUserRole implements EnumWithId {
private static final Logger LOG = LoggerFactory.getLogger(PortalUserRole.class);
private static Object lock = new Object();
private static final Map<Integer, PortalUserRole> ELEMENTS = new ConcurrentHashMap<>();
private static final Map<String, PortalUserRole> ELEMENTS_BY_NAME = new ConcurrentHashMap<>();
public static final PortalUserRole
/** /**
* Public user - Read Only * Public user - Read Only
*/ */
Public(0, 0), Public = new PortalUserRole(0, "Public", 0),
/** /**
* Customer - Read Write * Customer - Read Write
*/ */
CustomerIT(1, 10), CustomerIT = new PortalUserRole(1, "CustomerIT", 10),
/** /**
* MSP - Read Write * MSP - Read Write
*/ */
ManagedServiceProvider(2, 20), ManagedServiceProvider = new PortalUserRole(2, "ManagedServiceProvider", 20),
/** /**
* Service Distributor - Read Write * Service Distributor - Read Write
*/ */
Distributor(3, 30), Distributor = new PortalUserRole(3, "Distributor", 30),
/** /**
* Technical Support - Read Write * Technical Support - Read Write
*/ */
TechSupport(4, 40), TechSupport = new PortalUserRole(4, "TechSupport", 40),
/** /**
* Super User - Read Write * Super User - Read Write
*/ */
SuperUser(Integer.MAX_VALUE, Integer.MAX_VALUE), SuperUser = new PortalUserRole(Integer.MAX_VALUE, "SuperUser", Integer.MAX_VALUE),
/** /**
* Customer - Read Only * Customer - Read Only
*/ */
CustomerIT_RO(5, 5), CustomerIT_RO = new PortalUserRole(5, "CustomerIT_RO", 5),
/** /**
* MSP - Read Only * MSP - Read Only
*/ */
ManagedServiceProvider_RO(6, 15), ManagedServiceProvider_RO = new PortalUserRole(6, "ManagedServiceProvider_RO", 15),
/** /**
* Service Distributor - Read Only * Service Distributor - Read Only
*/ */
Distributor_RO(7, 25), Distributor_RO = new PortalUserRole(7, "Distributor_RO", 25),
/** /**
* Technical Support - Read Only * Technical Support - Read Only
*/ */
TechSupport_RO(8, 35), TechSupport_RO = new PortalUserRole(8, "TechSupport_RO", 35),
/** /**
* Super User - Read Only * Super User - Read Only
*/ */
SuperUser_RO(Integer.MAX_VALUE - 1, Integer.MAX_VALUE - 5), SuperUser_RO = new PortalUserRole(Integer.MAX_VALUE - 1, "SuperUser_RO", Integer.MAX_VALUE - 5),
/** /**
* Unknown * Unknown
*/ */
Unknown(-1, -1); Unknown = new PortalUserRole(-1, "Unknown", -1);
private final static Map<Integer, PortalUserRole> ID_MAP;
static { static {
ID_MAP = new HashMap<>(); //try to load all the subclasses explicitly - to avoid timing issues when items coming from subclasses may be registered some time later, after the parent class is loaded
for (PortalUserRole r : PortalUserRole.values()) { Set<Class<? extends PortalUserRole>> subclasses = BaseJsonModel.getReflections().getSubTypesOf(PortalUserRole.class);
if (PortalUserRole.isUnsupported(r)) { for(Class<?> cls: subclasses) {
continue; try {
Class.forName(cls.getName());
} catch (ClassNotFoundException e) {
LOG.warn("Cannot load class {} : {}", cls.getName(), e);
} }
ID_MAP.put(r.getId(), r);
} }
} }
public static final String SYSTEM_IDENTIFIER = "System"; public static final String SYSTEM_IDENTIFIER = "System";
public static PortalUserRole getById(int id) {
PortalUserRole result = ID_MAP.get(id);
if (result == null) {
return PortalUserRole.Unknown;
}
return result;
}
@JsonCreator
public static PortalUserRole getByName(String value) {
return JsonDeserializationUtils.deserializEnum(value, PortalUserRole.class, Unknown);
}
public static boolean isUnsupported(PortalUserRole userRole) {
return Unknown.equals(userRole);
}
private final int permissionLevel; private final int permissionLevel;
private final SimpleGrantedAuthority authority;
private final int id; private final int id;
private final String name;
private PortalUserRole(int id, int permissionLevel) { protected PortalUserRole(int id, String name, int permissionLevel) {
this.id = id; synchronized(lock) {
this.permissionLevel = permissionLevel;
LOG.debug("Registering PortalUserRole by {} : {}", this.getClass().getSimpleName(), name);
this.id = id;
this.name = name;
this.permissionLevel = permissionLevel;
this.authority = new SimpleGrantedAuthority(name);
ELEMENTS_BY_NAME.values().forEach(s -> {
if(s.getName().equals(name)) {
throw new IllegalStateException("PortalUserRole item for "+ name + " is already defined, cannot have more than one of them");
}
});
if(ELEMENTS.containsKey(id)) {
throw new IllegalStateException("PortalUserRole item "+ name + "("+id+") is already defined, cannot have more than one of them");
}
ELEMENTS.put(id, this);
ELEMENTS_BY_NAME.put(name, this);
}
} }
public int getId() { public int getId() {
@@ -111,4 +158,76 @@ public enum PortalUserRole {
public int getPermissionLevel() { public int getPermissionLevel() {
return this.permissionLevel; return this.permissionLevel;
} }
public String getName() {
return name;
}
public SimpleGrantedAuthority getAuthority() {
return authority;
}
@Override
public int hashCode() {
return id;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof PortalUserRole)) {
return false;
}
PortalUserRole other = (PortalUserRole) obj;
return id == other.id;
}
public String toString() {
return name;
}
@JsonIgnore
public static PortalUserRole[] values() {
return new ArrayList<>(ELEMENTS.values()).toArray(new PortalUserRole[0]);
}
public static PortalUserRole getById(int enumId){
PortalUserRole result = ELEMENTS.get(enumId);
if (result == null) {
return Unknown;
}
return result;
}
@JsonCreator
public static PortalUserRole getByName(String value) {
PortalUserRole ret = ELEMENTS_BY_NAME.get(value);
if (ret == null) {
ret = Unknown;
}
return ret;
}
public static List<PortalUserRole> getValues() {
return new ArrayList<>(ELEMENTS.values());
}
public static List<SimpleGrantedAuthority> getAllAuthorities() {
List<SimpleGrantedAuthority> authorities = new ArrayList<>();
ELEMENTS.values().forEach(y -> authorities.add(y.getAuthority()));
return authorities;
}
public static boolean isUnsupported(PortalUserRole value) {
return (Unknown.equals(value));
}
} }

View File

@@ -0,0 +1,40 @@
package com.telecominfraproject.wlan.core.model.serializers;
import java.io.IOException;
import com.fasterxml.jackson.core.Base64Variants;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
/**
* Characters plus and slash, that would need quoting in URLs, are replaced with hyphen and underscore, respectively.
* @see com.fasterxml.jackson.core.Base64Variants.MODIFIED_FOR_URL
*/
public class Base64UrlByteArrayDeserializer extends JsonDeserializer<byte[]> {
@Override
public byte[] deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonToken token = p.currentToken();
// we only support base64 encoded String
if (token == JsonToken.VALUE_STRING) {
try {
String text = p.getText();
return Base64Variants.MODIFIED_FOR_URL.decode(text.replace(' ', '-').replace('+', '-').replace('/', '_').replace("=", ""));
} catch (JsonParseException e) {
String msg = e.getOriginalMessage();
if (msg.contains("base64")) {
return (byte[]) ctxt.handleWeirdStringValue(byte[].class,
p.getText().replace(' ', '+'), msg);
}
}
}
throw new JsonParseException(p, "Cannot convert to byte[]");
}
}

View File

@@ -0,0 +1,21 @@
package com.telecominfraproject.wlan.core.model.serializers;
import java.io.IOException;
import com.fasterxml.jackson.core.Base64Variants;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
/**
* Characters plus and slash, that would need quoting in URLs, are replaced with hyphen and underscore, respectively.
* @see com.fasterxml.jackson.core.Base64Variants.MODIFIED_FOR_URL
*/
public class Base64UrlByteArraySerializer extends JsonSerializer<byte[]> {
@Override
public void serialize(byte[] value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeString(Base64Variants.MODIFIED_FOR_URL.encode(value));
}
}

View File

@@ -1,5 +1,8 @@
package com.telecominfraproject.wlan.core.model.utils; package com.telecominfraproject.wlan.core.model.utils;
import java.util.Collection;
import java.util.Iterator;
import org.apache.commons.math3.stat.descriptive.rank.Percentile; import org.apache.commons.math3.stat.descriptive.rank.Percentile;
@@ -19,6 +22,30 @@ public class DecibelUtils
return avgDbVal10; return avgDbVal10;
} }
public static double getAverageDecibel(Collection<Integer> decibels)
{
if (decibels == null || decibels.isEmpty()) {
return 0.0;
}
double aggregation = 0;
int count=0;
Iterator<Integer> iter = decibels.iterator();
while(iter.hasNext()) {
Integer value = iter.next();
if(value!=null) {
aggregation += Math.pow(10, value/10.0);
count++;
}
}
if (count == 0) {
return 0.0;
}else {
return 10 * Math.log10(aggregation/count);
}
}
public static double getDecibelStandardDeviation(int[] decibels) public static double getDecibelStandardDeviation(int[] decibels)
{ {

View File

@@ -5,6 +5,8 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assert.assertNotNull;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.HashMap; import java.util.HashMap;
@@ -14,8 +16,6 @@ import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
public class MacAddressTest { public class MacAddressTest {
private static final Logger LOG = LoggerFactory.getLogger(MacAddressTest.class); private static final Logger LOG = LoggerFactory.getLogger(MacAddressTest.class);
@@ -145,5 +145,97 @@ public class MacAddressTest {
assertEquals(first, equalToFirst); assertEquals(first, equalToFirst);
assertNotEquals(first, notEqualToFirst); assertNotEquals(first, notEqualToFirst);
} }
@Test
public void testSetAddress() {
MacAddress nullCheck = new MacAddress();
nullCheck.setAddress(null);
assertNull(nullCheck.getAddress());
MacAddress realValue = new MacAddress();
realValue.setAddress(new byte[] { 1, 2, 3, 4, 5, 6 });
assertNotNull(realValue.getAddress());
}
@Test
public void testGetAddressAsLong()
{
MacAddress macAddress = new MacAddress("00:2a:f7:7a:1e:a0");
assertNotNull(macAddress.getAddressAsLong());
MacAddress otherMacAddress = new MacAddress(new byte[] { 1, 2, 3, 4, 5});
assertNull(otherMacAddress.getAddressAsLong());
}
@Test
public void testGetAddressAsString() {
MacAddress macAddress = new MacAddress("00:2a:f7:7a:1e:a0");
assertNotNull(macAddress.getAddressAsString());
}
@Test
public void testGetAsLowerCaseString() {
MacAddress macAddress = new MacAddress("00:2a:f7:7a:1e:a0");
assertNotNull(macAddress.getAsLowerCaseString().toCharArray());
}
@Test
public void testHashCode()
{
MacAddress macAddress = new MacAddress("00:2a:f7:7a:1e:a0");
assertNotEquals(macAddress.hashCode(), 0);
}
@Test
public void testStringToByteArray()
{
MacAddress macAddress = new MacAddress();
macAddress.setAddressAsString(null);
assertNull(macAddress.getAddress());
macAddress.setAddressAsString("00:2a:f7:7a:1e:a0");
assertNotNull(macAddress.getAddress());
try {
macAddress.setAddressAsString("00:2a:f7:7a:1e:a0:b0:f1");
fail("expected exception.");
} catch (IllegalArgumentException e)
{
//expected it
}
try {
macAddress.setAddressAsString("00:2a:f7:7a:1esdafsat:a0");
fail("expected exception.");
} catch (IllegalArgumentException e)
{
//expected it
}
}
@Test
public void testOuiFromLowerCaseString()
{
assertNotNull(MacAddress.ouiFromLowerCaseString("00:2a:f7:7a:1e:a0", true));
assertNotNull(MacAddress.ouiFromLowerCaseString("00:2a:f7:7a:1e:a0", false));
}
@Test
public void testToOuiString()
{
MacAddress macAddress = new MacAddress("00:2a:f7:7a:1e:a0");
assertNotNull(macAddress.toOuiString());
MacAddress nullCheck = new MacAddress();
nullCheck.setAddressAsString(null);
assertNull(nullCheck.toOuiString());
}
@Test
public void testConvertMacStringToLongValue()
{
assertNotNull(MacAddress.convertMacStringToLongValue("00:2a:f7:7a:1e:a0"));
assertNull(MacAddress.convertMacStringToLongValue(null));
}
} }

View File

@@ -32,24 +32,4 @@ public class VendorExtendedEquipmentTypeModel extends BaseJsonModel{
this.dataType = dataType; this.dataType = dataType;
} }
public static void main(String[] args) {
VendorExtendedEquipmentTypeModel t1 = new VendorExtendedEquipmentTypeModel("t1", EquipmentType.AP);
VendorExtendedEquipmentTypeModel t2 = new VendorExtendedEquipmentTypeModel("t2", VendorExtendedEquipmentType.AP);
VendorExtendedEquipmentTypeModel t3 = new VendorExtendedEquipmentTypeModel("t3", VendorExtendedEquipmentType.VENDOR_EQ_B);
System.out.println("t1 = "+ t1);
System.out.println("t2 = "+ t2);
System.out.println("t3 = "+ t3);
VendorExtendedEquipmentTypeModel t1d = BaseJsonModel.fromString(t1.toString(), VendorExtendedEquipmentTypeModel.class);
VendorExtendedEquipmentTypeModel t2d = BaseJsonModel.fromString(t2.toString(), VendorExtendedEquipmentTypeModel.class);
VendorExtendedEquipmentTypeModel t3d = BaseJsonModel.fromString(t3.toString(), VendorExtendedEquipmentTypeModel.class);
System.out.println("=======================");
System.out.println("t1d = "+ t1d);
System.out.println("t2d = "+ t2d);
System.out.println("t3d = "+ t3d);
}
} }

View File

@@ -0,0 +1,28 @@
package com.telecominfraproject.wlan.core.model.role.vendorextensions;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
import com.telecominfraproject.wlan.core.model.role.PortalUserRole;
public class TestVendorExtentions {
@Test
public void testExtendedEnum() {
VendorExtendedPortalUserRoleModel t1 = new VendorExtendedPortalUserRoleModel("t1", PortalUserRole.CustomerIT);
VendorExtendedPortalUserRoleModel t2 = new VendorExtendedPortalUserRoleModel("t2", VendorExtendedPortalUserRole.CustomerIT);
VendorExtendedPortalUserRoleModel t3 = new VendorExtendedPortalUserRoleModel("t3", VendorExtendedPortalUserRole.VENDOR_USER_ROLE_B);
VendorExtendedPortalUserRoleModel t1d = BaseJsonModel.fromString(t1.toString(), VendorExtendedPortalUserRoleModel.class);
VendorExtendedPortalUserRoleModel t2d = BaseJsonModel.fromString(t2.toString(), VendorExtendedPortalUserRoleModel.class);
VendorExtendedPortalUserRoleModel t3d = BaseJsonModel.fromString(t3.toString(), VendorExtendedPortalUserRoleModel.class);
assertEquals(t1.toString(), t1d.toString());
assertEquals(t2.toString(), t2d.toString());
assertEquals(t3.toString(), t3d.toString());
}
}

View File

@@ -0,0 +1,16 @@
package com.telecominfraproject.wlan.core.model.role.vendorextensions;
import com.telecominfraproject.wlan.core.model.role.PortalUserRole;
public class VendorExtendedPortalUserRole extends PortalUserRole {
public static final PortalUserRole
VENDOR_USER_ROLE_A = new VendorExtendedPortalUserRole(100, "VENDOR_USER_ROLE_A", 5) ,
VENDOR_USER_ROLE_B = new VendorExtendedPortalUserRole(101, "VENDOR_USER_ROLE_B", 5)
;
private VendorExtendedPortalUserRole(int id, String name, int permissionLevel) {
super(id, name, permissionLevel);
}
}

View File

@@ -0,0 +1,36 @@
package com.telecominfraproject.wlan.core.model.role.vendorextensions;
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
import com.telecominfraproject.wlan.core.model.role.PortalUserRole;
public class VendorExtendedPortalUserRoleModel extends BaseJsonModel{
private static final long serialVersionUID = -7571240065645860754L;
private String name;
private PortalUserRole role;
protected VendorExtendedPortalUserRoleModel() {
//for deserializer
}
public VendorExtendedPortalUserRoleModel(String name, PortalUserRole role) {
this.name = name;
this.role = role;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public PortalUserRole getRole() {
return role;
}
public void setRole(PortalUserRole role) {
this.role = role;
}
}

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-partitioner</artifactId> <artifactId>base-partitioner</artifactId>
@@ -13,7 +13,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-hazelcast-client</artifactId> <artifactId>base-hazelcast-client</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-remote-tests</artifactId> <artifactId>base-remote-tests</artifactId>
@@ -15,7 +14,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-tx-tests</artifactId> <artifactId>base-tx-tests</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-scheduler</artifactId> <artifactId>base-scheduler</artifactId>
@@ -15,7 +14,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId> <artifactId>base-models</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-stream-consumer</artifactId> <artifactId>base-stream-consumer</artifactId>
@@ -14,8 +14,15 @@
<dependency> <dependency>
<artifactId>base-models</artifactId> <artifactId>base-models</artifactId>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>com.telecominfraproject.wlan</groupId>
<artifactId>cloud-metrics</artifactId>
<version>1.3.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -9,6 +9,12 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.netflix.servo.DefaultMonitorRegistry;
import com.netflix.servo.monitor.BasicCounter;
import com.netflix.servo.monitor.Counter;
import com.netflix.servo.monitor.MonitorConfig;
import com.netflix.servo.tag.TagList;
import com.telecominfraproject.wlan.cloudmetrics.CloudMetricsTags;
import com.telecominfraproject.wlan.core.model.streams.QueuedStreamMessage; import com.telecominfraproject.wlan.core.model.streams.QueuedStreamMessage;
/** /**
@@ -21,10 +27,21 @@ public class StreamMessageDispatcher {
private static final Logger LOG = LoggerFactory.getLogger(StreamMessageDispatcher.class); private static final Logger LOG = LoggerFactory.getLogger(StreamMessageDispatcher.class);
private final TagList tags = CloudMetricsTags.commonTags;
final Counter messagesProcessed = new BasicCounter(MonitorConfig.builder("stream-processors-messagesProcessed").withTags(tags).build());
//autowire all available stream processors //autowire all available stream processors
@Autowired(required = false) @Autowired(required = false)
List<StreamProcessor> streamProcessors; List<StreamProcessor> streamProcessors;
// dtop: use anonymous constructor to ensure that the following code always
// get executed,
// even when somebody adds another constructor in here
{
DefaultMonitorRegistry.getInstance().register(messagesProcessed);
}
@PostConstruct @PostConstruct
private void postConstruct() { private void postConstruct() {
if(streamProcessors!=null && !streamProcessors.isEmpty()) { if(streamProcessors!=null && !streamProcessors.isEmpty()) {
@@ -46,7 +63,7 @@ public class StreamMessageDispatcher {
} }
LOG.trace("Pushing message to stream processors {}", message); LOG.trace("Pushing message to stream processors {}", message);
messagesProcessed.increment();
streamProcessors.forEach(sp -> sp.push(message)); streamProcessors.forEach(sp -> sp.push(message));
} }
} }

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-stream-interface</artifactId> <artifactId>base-stream-interface</artifactId>

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>base-tx-tests</artifactId> <artifactId>base-tx-tests</artifactId>

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>cloud-metrics</artifactId> <artifactId>cloud-metrics</artifactId>
@@ -14,18 +13,18 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-exceptions</artifactId> <artifactId>base-exceptions</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId> <artifactId>base-models</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-elasticsearch</artifactId> <artifactId>base-elasticsearch</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -26,11 +26,19 @@ public class CloudMetricsTags {
public static final String localIpV4 = getPropertyAsString("container.localipv4", UNDEFINED_STR); public static final String localIpV4 = getPropertyAsString("container.localipv4", UNDEFINED_STR);
public static final TagList commonTags = new BasicTagList(Arrays.asList( public static final TagList commonTags;
new BasicTag("InstanceId", instanceId),
new BasicTag("local-ipv4", localIpV4), static {
new BasicTag("cloudTag", buildCloudTag()) if(Boolean.parseBoolean(getPropertyAsString("tip.wlan.cloudMetricTags.enabled", "false"))) {
)); commonTags = new BasicTagList(Arrays.asList(
new BasicTag("InstanceId", instanceId),
new BasicTag("local-ipv4", localIpV4),
new BasicTag("cloudTag", buildCloudTag())
));
} else {
commonTags = BasicTagList.EMPTY;
}
}
private static String buildCloudTag(){ private static String buildCloudTag(){
return role + "-" + stack + "-" + deployment; return role + "-" + stack + "-" + deployment;

View File

@@ -242,11 +242,12 @@ public class StartServoMetricsCollector implements CommandLineRunner {
MetricObserver transformElasticSearch = new CounterToRateMetricTransform( MetricObserver transformElasticSearch = new CounterToRateMetricTransform(
elasticSearchObserver, aggregationHeartbeatMultiplier * samplingIntervalMs, TimeUnit.MILLISECONDS); elasticSearchObserver, aggregationHeartbeatMultiplier * samplingIntervalMs, TimeUnit.MILLISECONDS);
observers.add(transformElasticSearch); observers.add(transformElasticSearch);
LOG.info("ElasticSearch metrics collection is ON");
}catch(UnknownHostException e){ }catch(UnknownHostException e){
LOG.error("Cannot initialize ElasticSearch client", e); LOG.error("Cannot initialize ElasticSearch client", e);
} }
} else { } else {
LOG.info("ElasticSearch metrics collection is OFF"); LOG.debug("ElasticSearch metrics collection is OFF");
} }
} }
} }

View File

@@ -1,10 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>common-hazelcast</artifactId> <artifactId>common-hazelcast</artifactId>
@@ -20,7 +19,7 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-models</artifactId> <artifactId>base-models</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -1,13 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>

View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>reflections-tip</artifactId> <artifactId>reflections-tip</artifactId>

View File

@@ -1,11 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>tip-wlan-cloud-root-pom</artifactId> <artifactId>tip-wlan-cloud-root-pom</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<relativePath>../../wlan-cloud-root</relativePath> <relativePath>../../wlan-cloud-root</relativePath>
</parent> </parent>
<artifactId>webtoken-auth-service</artifactId> <artifactId>webtoken-auth-service</artifactId>
@@ -16,13 +14,13 @@
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-container</artifactId> <artifactId>base-container</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.telecominfraproject.wlan</groupId> <groupId>com.telecominfraproject.wlan</groupId>
<artifactId>base-client</artifactId> <artifactId>base-client</artifactId>
<version>${tip-wlan-cloud.release.version}</version> <version>1.3.0-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -8,10 +8,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import com.telecominfraproject.wlan.core.model.role.PortalUserRole;
import com.telecominfraproject.wlan.core.model.webtoken.IntrospectWebTokenResult; import com.telecominfraproject.wlan.core.model.webtoken.IntrospectWebTokenResult;
import com.telecominfraproject.wlan.core.server.security.AccessType; import com.telecominfraproject.wlan.core.server.security.AccessType;
import com.telecominfraproject.wlan.core.server.security.AuthProviderInfo; import com.telecominfraproject.wlan.core.server.security.AuthProviderInfo;
import com.telecominfraproject.wlan.core.server.security.WebSecurityConfig;
/** /**
* Implementation of UserDetails in compliance with the decoded object returned * Implementation of UserDetails in compliance with the decoded object returned
@@ -42,7 +42,7 @@ public class WebtokenUserDetails implements UserDetails, AuthProviderInfo {
// set authorities // set authorities
authorities = new ArrayList<>(); authorities = new ArrayList<>();
authorities.add(WebSecurityConfig.TECH_SUPPORT_AUTHORITY); authorities.add(PortalUserRole.TechSupport.getAuthority());
} }