diff --git a/NOTICE b/NOTICE index 57f4349896d27dd15d77651b7bf11ae44fe20db1..f73c1d74c29f88416022c7422cad7530a32b3a9e 100644 --- a/NOTICE +++ b/NOTICE @@ -2,6 +2,13 @@ Generated by fossa-cli (https://github.com/fossas/fossa-cli). This software includes the following software and licenses: +======================================================================== +Android-Sdk +======================================================================== +The following software have components provided under the terms of this license: + +- Android SDK (from https://www.android.com/) + ======================================================================== Apache-2.0 ======================================================================== @@ -41,7 +48,7 @@ The following software have components provided under the terms of this license: - Adapter: RxJava (from https://repo1.maven.org/maven2/com/squareup/retrofit2/adapter-rxjava) - Apache Commons Codec (from https://commons.apache.org/proper/commons-codec/) - Apache Commons Collections (from https://commons.apache.org/proper/commons-collections/) -- Apache Commons Lang (from http://commons.apache.org/proper/commons-lang/) +- Apache Commons Lang (from https://commons.apache.org/proper/commons-lang/) - Apache Commons Logging (from http://commons.apache.org/proper/commons-logging/) - Apache Commons Logging (from http://commons.apache.org/proper/commons-logging/) - Apache Geronimo JMS Spec 2.0 (from http://geronimo.apache.org/maven/${siteId}/${version}) @@ -54,41 +61,61 @@ The following software have components provided under the terms of this license: - Apache Log4j Core (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core) - Apache Log4j JUL Adapter (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-jul) - Apache Log4j SLF4J Binding (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-slf4j-impl) -- Apache Log4j to SLF4J Adapter (from ) +- Apache Log4j to SLF4J Adapter (from https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-to-slf4j) - AssertJ fluent assertions (from https://repo1.maven.org/maven2/org/assertj/assertj-core) -- Asynchronous Http Client (from ) -- Asynchronous Http Client Netty Utils (from ) +- Asynchronous Http Client (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client) +- Asynchronous Http Client Netty Utils (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client-netty-utils) +- AutoValue Annotations (from https://github.com/google/auto/tree/master/value) - Azure Spring Boot Starter for Azure AD Spring Security Integration (from https://github.com/Azure/azure-sdk-for-java) - Bean Validation API (from http://beanvalidation.org) -- Brave Instrumentation: Http Adapters (from ) +- Bean Validation API (from http://beanvalidation.org) +- Brave (from https://repo1.maven.org/maven2/io/zipkin/brave/brave) +- Brave Instrumentation: Http Adapters (from https://repo1.maven.org/maven2/io/zipkin/brave/brave-instrumentation-http) - Brave instrumentation for Reactor Netty HTTP (from https://github.com/reactor/reactor-netty) - Byte Buddy (without dependencies) (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy) - Byte Buddy Java agent (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy-agent) - ClassMate (from http://github.com/cowtowncoder/java-classmate) +- Cloud Storage JSON API v1-rev20210127-1.32.1 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-storage) - Converter: Jackson (from https://repo1.maven.org/maven2/com/squareup/retrofit2/converter-jackson) - Core functionality for the Reactor Netty library (from https://github.com/reactor/reactor-netty) - Elastic JNA Distribution (from https://github.com/java-native-access/jna) - Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - Expression Language 3.0 (from http://uel.java.net) - FindBugs-jsr305 (from http://findbugs.sourceforge.net/) +- GSON extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-gson) - Google APIs Client Library for Java (from https://repo1.maven.org/maven2/com/google/api-client/google-api-client) +- Google App Engine extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-appengine) +- Google Cloud Common Protos for Java (from https://github.com/googleapis/common-protos-java) - Google Cloud Common Protos for Java (from https://github.com/googleapis/common-protos-java) +- Google Cloud Core (from https://github.com/googleapis/java-core) +- Google Cloud Core HTTP (from https://github.com/googleapis/java-core) +- Google Cloud Core gRPC (from https://github.com/googleapis/java-core) +- Google Cloud Datastore (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-datastore) +- Google Cloud IAM Service Account Credentials (from https://github.com/googleapis/java-iamcredentials) +- Google Cloud Key Management Service (KMS) API v1-rev9-1.22.0 (from https://repo1.maven.org/maven2/com/google/apis/google-api-services-cloudkms) +- Google Cloud Logging (from https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-logging) +- Google Cloud Pub/Sub (from https://github.com/googleapis/java-pubsub) +- Google Cloud Storage (from https://github.com/googleapis/java-storage) +- Google HTTP Client Library for Java (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client) - Google HTTP Client Library for Java (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client) - Google OAuth Client Library for Java (from https://repo1.maven.org/maven2/com/google/oauth-client/google-oauth-client) - Gson (from https://github.com/google/gson) - Gson (from https://github.com/google/gson) - Guava InternalFutureFailureAccess and InternalFutures (from https://repo1.maven.org/maven2/com/google/guava/failureaccess) +- Guava InternalFutureFailureAccess and InternalFutures (from https://repo1.maven.org/maven2/com/google/guava/failureaccess) +- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) - Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) - HPPC Collections (from https://repo1.maven.org/maven2/com/carrotsearch/hppc) - HTTP functionality for the Reactor Netty library (from https://github.com/reactor/reactor-netty) -- Hibernate Validator Engine (from ) -- Hibernate Validator Engine (from ) +- Hibernate Validator Engine (from https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator) +- Hibernate Validator Engine (from https://repo1.maven.org/maven2/org/hibernate/validator/hibernate-validator) - IBM COS Java SDK for Amazon S3 (from https://github.com/ibm/ibm-cos-sdk-java) - IBM COS Java SDK for COS KMS (from https://github.com/ibm/ibm-cos-sdk-java) - IBM COS SDK For Java (from https://github.com/ibm/ibm-cos-sdk-java) - IBM COS SDK for Java - Core (from https://github.com/ibm/ibm-cos-sdk-java) - IO (from http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/) - Identity and Access Management (IAM) API v1-rev247-1.23.0 (from ) +- Identity and Access Management (IAM) API v1-rev247-1.23.0 (from ) - IntelliJ IDEA Annotations (from http://www.jetbrains.org) - J2ObjC Annotations (from https://github.com/google/j2objc/) - JBoss Logging 3 (from http://www.jboss.org) @@ -96,30 +123,31 @@ The following software have components provided under the terms of this license: - JCIP Annotations under Apache License (from http://stephenc.github.com/jcip-annotations) - JMES Path Query library (from https://aws.amazon.com/sdkforjava) - JSON Small and Fast Parser (from https://repo1.maven.org/maven2/net/minidev/json-smart) -- JSON Web Token support for the JVM (from https://github.com/jwtk/jjwt.git) +- JSON Web Token support for the JVM (from https://github.com/jwtk/jjwt) - JSON library from Android SDK (from http://developer.android.com/sdk) - JSONassert (from https://github.com/skyscreamer/JSONassert) +- Jackson (from http://jackson.codehaus.org) - Jackson 2 extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-jackson2) - Jackson dataformat: CBOR (from http://github.com/FasterXML/jackson-dataformats-binary) - Jackson dataformat: Smile (from http://github.com/FasterXML/jackson-dataformats-binary) - Jackson datatype: JSR310 (from https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310) +- Jackson datatype: Joda (from https://github.com/FasterXML/jackson-datatype-joda) - Jackson datatype: jdk8 (from https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8) +- Jackson extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-jackson) - Jackson module: Afterburner (from https://github.com/FasterXML/jackson-modules-base) - Jackson module: JAXB-annotations (from http://github.com/FasterXML/jackson-module-jaxb-annotations) -- Jackson-annotations (from http://wiki.fasterxml.com/JacksonHome) -- Jackson-core (from http://wiki.fasterxml.com/JacksonHome) -- Jackson-core (from http://wiki.fasterxml.com/JacksonHome) +- Jackson-annotations (from http://github.com/FasterXML/jackson) +- Jackson-core (from https://github.com/FasterXML/jackson-core) +- Jackson-core (from https://github.com/FasterXML/jackson-core) - Jackson-dataformat-XML (from http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding) - Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson-dataformats-text) -- Jackson-datatype-Joda (from http://wiki.fasterxml.com/JacksonModuleJoda) - Jackson-module-parameter-names (from https://repo1.maven.org/maven2/com/fasterxml/jackson/module/jackson-module-parameter-names) -- Jakarta Bean Validation API (from https://beanvalidation.org) - Java Native Access (from https://github.com/java-native-access/jna) - Java Native Access Platform (from https://github.com/java-native-access/jna) - Java Servlet 4.0 API (from ) - Java Servlet 4.0 API (from ) -- Java Servlet API (from https://projects.eclipse.org/projects/ee4j.servlet) - Java Servlet API (from http://servlet-spec.java.net) +- Java Servlet API (from https://projects.eclipse.org/projects/ee4j.servlet) - Java UUID Generator (from http://wiki.fasterxml.com/JugHome) - Javassist (from http://www.javassist.org/) - Javassist (from http://www.javassist.org/) @@ -132,13 +160,15 @@ The following software have components provided under the terms of this license: - KeePassJava2 :: KDBX (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-kdbx) - KeePassJava2 :: Simple (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-simple) - Logback Contrib :: JSON :: Classic (from ) +- Logback Contrib :: JSON :: Core (from ) +- Logback Contrib :: Jackson (from ) - Lucene Common Analyzers (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-analyzers-common) - Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) - Lucene Grouping (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-grouping) - Lucene Highlighter (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-highlighter) - Lucene Join (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-join) -- Lucene Memory (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-backward-codecs) - Lucene Memory (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-memory) +- Lucene Memory (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-backward-codecs) - Lucene Miscellaneous (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-misc) - Lucene Queries (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-queries) - Lucene QueryParsers (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-queryparser) @@ -147,7 +177,7 @@ The following software have components provided under the terms of this license: - Lucene Spatial 3D (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-spatial3d) - Lucene Spatial Extras (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-spatial-extras) - Lucene Suggest (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-suggest) -- MapStruct Core (from ) +- MapStruct Core (from https://repo1.maven.org/maven2/org/mapstruct/mapstruct) - Metrics Core (from https://repo1.maven.org/maven2/io/dropwizard/metrics/metrics-core) - Microsoft Application Insights Java SDK Spring Boot starter (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Java SDK Web Module (from https://github.com/Microsoft/ApplicationInsights-Java) @@ -157,7 +187,7 @@ The following software have components provided under the terms of this license: - Microsoft Azure SDK for SQL API of Azure Cosmos DB Service (from https://github.com/Azure/azure-sdk-for-java) - Mockito (from http://www.mockito.org) - Netty Reactive Streams HTTP support (from https://repo1.maven.org/maven2/com/typesafe/netty/netty-reactive-streams-http) -- Netty Reactive Streams Implementation (from ) +- Netty Reactive Streams Implementation (from https://repo1.maven.org/maven2/com/typesafe/netty/netty-reactive-streams) - Netty/Buffer (from https://repo1.maven.org/maven2/io/netty/netty-buffer) - Netty/Buffer (from https://repo1.maven.org/maven2/io/netty/netty-buffer) - Netty/Codec (from https://repo1.maven.org/maven2/io/netty/netty-codec) @@ -181,68 +211,51 @@ The following software have components provided under the terms of this license: - Netty/Transport (from https://repo1.maven.org/maven2/io/netty/netty-transport) - Netty/Transport/Native/Unix/Common (from https://repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common) - Netty/Transport/Native/Unix/Common (from https://repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common) +- Nimbus Content Type (from https://bitbucket.org/connect2id/nimbus-content-type) - Nimbus JOSE+JWT (from https://bitbucket.org/connect2id/nimbus-jose-jwt) - Nimbus JOSE+JWT (from https://bitbucket.org/connect2id/nimbus-jose-jwt) +- Nimbus JOSE+JWT (from https://bitbucket.org/connect2id/nimbus-jose-jwt) +- Nimbus LangTag (from https://bitbucket.org/connect2id/nimbus-language-tags) - Nimbus LangTag (from https://bitbucket.org/connect2id/nimbus-language-tags) - Non-Blocking Reactive Foundation for the JVM (from https://github.com/reactor/reactor-core) - OAuth 2.0 SDK with OpenID Connect extensions (from https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions) +- OAuth 2.0 SDK with OpenID Connect extensions (from https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions) - Objenesis (from http://objenesis.org) -- OkHttp (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp) -- OkHttp (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp) -- OkHttp Logging Interceptor (from https://repo1.maven.org/maven2/com/squareup/okhttp3/logging-interceptor) -- OkHttp URLConnection (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp-urlconnection) -- OkHttp URLConnection (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp-urlconnection) - Okio (from https://github.com/square/okio/) - Okio (from https://github.com/square/okio/) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) +- OpenCensus (from https://github.com/census-instrumentation/opencensus-java) - PWDB :: Database (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/database) - PowerMock (from http://www.powermock.org) +- Protocol Buffer extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-protobuf) +- Proton-J (from https://repo1.maven.org/maven2/org/apache/qpid/proton-j) - QpidJMS Client (from ) - Reactive Streams Netty driver (from https://github.com/reactor/reactor-netty) -- Retrofit (from https://repo1.maven.org/maven2/com/squareup/retrofit2/retrofit) +- Retrofit (from https://github.com/square/retrofit) - SnakeYAML (from http://code.google.com/p/snakeyaml/) -- Spring Boot (from http://projects.spring.io/spring-boot/) -- Spring Boot Actuator (from http://projects.spring.io/spring-boot/) -- Spring Boot Actuator AutoConfigure (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-actuator-autoconfigure) -- Spring Boot Actuator Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot AutoConfigure (from http://projects.spring.io/spring-boot/) -- Spring Boot Dependencies (from http://projects.spring.io/spring-boot/) +- Spring AOP (from https://github.com/spring-projects/spring-framework) +- Spring Beans (from https://github.com/spring-projects/spring-framework) +- Spring Boot Dependencies (from https://projects.spring.io/spring-boot/#) - Spring Boot Json Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-json) -- Spring Boot Log4J2 Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Logging Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Reactor Netty Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-reactor-netty) -- Spring Boot Security Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Test (from http://projects.spring.io/spring-boot/) -- Spring Boot Test Auto-Configure (from http://projects.spring.io/spring-boot/) -- Spring Boot Test Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Tomcat Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Undertow Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Undertow Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Validation Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Validation Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Web Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot Web Starter (from http://projects.spring.io/spring-boot/) -- Spring Boot WebFlux Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-webflux) +- Spring Boot Tomcat Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-tomcat) +- Spring Boot Web Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-web) +- Spring Boot Web Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-web) - Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework) +- Spring Context (from https://github.com/spring-projects/spring-framework) +- Spring Core (from https://github.com/spring-projects/spring-framework) - Spring Data Core (from https://repo1.maven.org/maven2/org/springframework/data/spring-data-commons) - Spring Expression Language (SpEL) (from https://github.com/spring-projects/spring-framework) -- Spring Framework: AOP (from http://www.springframework.org) -- Spring Framework: Context (from http://www.springframework.org) -- Spring Framework: WebMVC (from http://www.springframework.org) - Spring JMS (from https://github.com/spring-projects/spring-framework) - Spring Messaging (from https://github.com/spring-projects/spring-framework) - Spring Plugin - Core (from ) - Spring Plugin - Metadata Extension (from https://repo1.maven.org/maven2/org/springframework/plugin/spring-plugin-metadata) -- Spring Security - Core (from https://repo1.maven.org/maven2/org/springframework/security/spring-security-core) - Spring TestContext Framework (from https://github.com/spring-projects/spring-framework) - Spring Transaction (from https://github.com/spring-projects/spring-framework) +- Spring Web (from https://github.com/spring-projects/spring-framework) +- Spring Web MVC (from https://github.com/spring-projects/spring-framework) - Spring WebFlux (from https://github.com/spring-projects/spring-framework) -- Spring beans (from https://repo1.maven.org/maven2/org/springframework/spring-beans) -- Spring core (from https://repo1.maven.org/maven2/org/springframework/spring-core) -- Spring web (from https://repo1.maven.org/maven2/org/springframework/spring-web) - T-Digest (from https://github.com/tdunning/t-digest) - Undertow Core (from https://repo1.maven.org/maven2/io/undertow/undertow-core) - Undertow Core (from https://repo1.maven.org/maven2/io/undertow/undertow-core) @@ -256,29 +269,42 @@ The following software have components provided under the terms of this license: - XNIO API (from http://www.jboss.org/xnio) - XNIO NIO Implementation (from ) - XNIO NIO Implementation (from ) +- Zipkin Core Library (from https://repo1.maven.org/maven2/io/zipkin/zipkin2/zipkin) - Zipkin Reporter Brave (from https://repo1.maven.org/maven2/io/zipkin/reporter2/zipkin-reporter-brave) -- Zipkin Reporter: Core (from ) -- Zipkin v2 (from ) +- Zipkin Reporter: Core (from https://repo1.maven.org/maven2/io/zipkin/reporter2/zipkin-reporter) - aalto-xml (from ) - aggs-matrix-stats (from https://github.com/elastic/elasticsearch) - aws-ssm-java-caching-client (from https://github.com/awslabs/aws-ssm-java-caching-client) -- brave (from ) +- com.google.api.grpc:grpc-google-cloud-pubsub-v1 (from https://github.com/googleapis/googleapis) +- com.google.api.grpc:proto-google-cloud-logging-v2 (from https://github.com/googleapis/googleapis) - compiler (from http://github.com/spullara/mustache.java) +- datastore-v1-proto-client (from ) - elasticsearch-cli (from https://github.com/elastic/elasticsearch) - elasticsearch-core (from https://github.com/elastic/elasticsearch) - elasticsearch-secure-sm (from https://github.com/elastic/elasticsearch) - elasticsearch-x-content (from https://github.com/elastic/elasticsearch) - error-prone annotations (from https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations) +- error-prone annotations (from https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations) +- io.grpc:grpc-alts (from https://github.com/grpc/grpc-java) +- io.grpc:grpc-api (from https://github.com/grpc/grpc-java) +- io.grpc:grpc-auth (from https://github.com/grpc/grpc-java) +- io.grpc:grpc-context (from https://github.com/grpc/grpc-java) - io.grpc:grpc-context (from https://github.com/grpc/grpc-java) - io.grpc:grpc-core (from https://github.com/grpc/grpc-java) +- io.grpc:grpc-core (from https://github.com/grpc/grpc-java) +- io.grpc:grpc-grpclb (from https://github.com/grpc/grpc-java) - io.grpc:grpc-netty-shaded (from https://github.com/grpc/grpc-java) +- io.grpc:grpc-netty-shaded (from https://github.com/grpc/grpc-java) +- io.grpc:grpc-protobuf (from https://github.com/grpc/grpc-java) - io.grpc:grpc-protobuf (from https://github.com/grpc/grpc-java) - io.grpc:grpc-protobuf-lite (from https://github.com/grpc/grpc-java) +- io.grpc:grpc-protobuf-lite (from https://github.com/grpc/grpc-java) +- io.grpc:grpc-stub (from https://github.com/grpc/grpc-java) - io.grpc:grpc-stub (from https://github.com/grpc/grpc-java) - ion-java (from https://github.com/amznlabs/ion-java/) - ion-java (from https://github.com/amznlabs/ion-java/) -- jackson-databind (from http://wiki.fasterxml.com/JacksonHome) -- jackson-databind (from http://wiki.fasterxml.com/JacksonHome) +- jackson-databind (from http://github.com/FasterXML/jackson) +- jackson-databind (from http://github.com/FasterXML/jackson) - java-cloudant (from https://cloudant.com) - java-cloudant (from https://cloudant.com) - javatuples (from http://www.javatuples.org) @@ -291,23 +317,52 @@ The following software have components provided under the terms of this license: - mockito-core (from https://github.com/mockito/mockito) - nio-multipart-parser (from ) - nio-stream-storage (from https://github.com/synchronoss/nio-stream-storage) +- okhttp (from https://square.github.io/okhttp/) +- okhttp (from https://square.github.io/okhttp/) +- okhttp-logging-interceptor (from https://square.github.io/okhttp/) +- okhttp-urlconnection (from https://github.com/square/okhttp) +- okhttp-urlconnection (from https://github.com/square/okhttp) - org.apiguardian:apiguardian-api (from https://github.com/apiguardian-team/apiguardian) +- org.conscrypt:conscrypt-openjdk-uber (from https://conscrypt.org/) - org.opentest4j:opentest4j (from https://github.com/ota4j-team/opentest4j) - org.xmlunit:xmlunit-core (from http://www.xmlunit.org/) - parent-join (from https://github.com/elastic/elasticsearch) +- perfmark:perfmark-api (from https://github.com/perfmark/perfmark) - powermock-api-support (from ) - powermock-core (from http://www.powermock.org) - powermock-module-junit4 (from http://www.powermock.org) - powermock-module-junit4-common (from ) - powermock-reflect (from ) -- proton-j (from https://repo1.maven.org/maven2/org/apache/qpid/proton-j) +- proto-google-cloud-datastore-v1 (from https://github.com/googleapis/api-client-staging) +- proto-google-cloud-iamcredentials-v1 (from https://repo1.maven.org/maven2/com/google/api/grpc/proto-google-cloud-iamcredentials-v1) +- proto-google-cloud-pubsub-v1 (from https://github.com/googleapis/java-pubsub/proto-google-cloud-pubsub-v1) +- proto-google-iam-v1 (from https://github.com/googleapis/java-iam/proto-google-iam-v1) - rank-eval (from https://github.com/elastic/elasticsearch) - rest (from https://github.com/elastic/elasticsearch) - rest-high-level (from https://github.com/elastic/elasticsearch) - rxjava (from https://github.com/ReactiveX/RxJava) - server (from https://github.com/elastic/elasticsearch) +- spring-boot (from https://spring.io/projects/spring-boot) +- spring-boot-actuator (from https://spring.io/projects/spring-boot) +- spring-boot-actuator-autoconfigure (from https://spring.io/projects/spring-boot) +- spring-boot-autoconfigure (from https://spring.io/projects/spring-boot) +- spring-boot-starter (from https://spring.io/projects/spring-boot) +- spring-boot-starter-actuator (from https://spring.io/projects/spring-boot) +- spring-boot-starter-log4j2 (from https://spring.io/projects/spring-boot) +- spring-boot-starter-logging (from https://spring.io/projects/spring-boot) +- spring-boot-starter-reactor-netty (from https://spring.io/projects/spring-boot) +- spring-boot-starter-security (from https://spring.io/projects/spring-boot) +- spring-boot-starter-test (from https://spring.io/projects/spring-boot) +- spring-boot-starter-undertow (from https://spring.io/projects/spring-boot) +- spring-boot-starter-undertow (from https://spring.io/projects/spring-boot) +- spring-boot-starter-validation (from https://spring.io/projects/spring-boot) +- spring-boot-starter-validation (from https://spring.io/projects/spring-boot) +- spring-boot-starter-webflux (from https://spring.io/projects/spring-boot) +- spring-boot-test (from https://spring.io/projects/spring-boot) +- spring-boot-test-autoconfigure (from https://spring.io/projects/spring-boot) - spring-security-config (from http://spring.io/spring-security) - spring-security-config (from http://spring.io/spring-security) +- spring-security-core (from http://spring.io/spring-security) - spring-security-oauth2-core (from http://spring.io/spring-security) - spring-security-oauth2-jose (from http://spring.io/spring-security) - spring-security-oauth2-resource-server (from http://spring.io/spring-security) @@ -322,8 +377,10 @@ The following software have components provided under the terms of this license: - springfox-swagger2 (from https://github.com/springfox/springfox) - swagger-annotations (from https://repo1.maven.org/maven2/io/swagger/swagger-annotations) - swagger-jaxrs (from ) -- swagger-models (from ) +- swagger-models (from https://repo1.maven.org/maven2/io/swagger/swagger-models) +- tomcat-embed-core (from http://tomcat.apache.org/) - tomcat-embed-el (from https://tomcat.apache.org/) +- tomcat-embed-websocket (from https://tomcat.apache.org/) - wildfly-common (from ) ======================================================================== @@ -331,19 +388,30 @@ BSD-2-Clause ======================================================================== The following software have components provided under the terms of this license: +- API Common (from https://github.com/googleapis/api-common-java) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) - Lucene Common Analyzers (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-analyzers-common) - Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) - Reflections (from http://github.com/ronmamo/reflections) - Stax2 API (from http://github.com/FasterXML/stax2-api) +- ThreeTen backport (from https://www.threeten.org/threetenbp) ======================================================================== BSD-3-Clause ======================================================================== The following software have components provided under the terms of this license: +- API Common (from https://github.com/googleapis/api-common-java) - ASM Core (from ) - Apache Commons Codec (from https://commons.apache.org/proper/commons-codec/) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) +- GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) - Google APIs Client Library for Java (from https://repo1.maven.org/maven2/com/google/api-client/google-api-client) +- Google Auth Library for Java - Credentials (from https://repo1.maven.org/maven2/com/google/auth/google-auth-library-credentials) +- Google Auth Library for Java - OAuth2 HTTP (from https://repo1.maven.org/maven2/com/google/auth/google-auth-library-oauth2-http) - Lucene Common Analyzers (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-analyzers-common) - Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) - Lucene Suggest (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-suggest) @@ -354,9 +422,12 @@ The following software have components provided under the terms of this license: - Netty/Codec/HTTP (from https://repo1.maven.org/maven2/io/netty/netty-codec-http) - Netty/Codec/HTTP (from https://repo1.maven.org/maven2/io/netty/netty-codec-http) - Protocol Buffers [Core] (from https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java) +- Protocol Buffers [Core] (from https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java) +- Protocol Buffers [Util] (from https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java-util) - Reflections (from http://github.com/ronmamo/reflections) - SnakeYAML (from http://code.google.com/p/snakeyaml/) -- Spring core (from https://repo1.maven.org/maven2/org/springframework/spring-core) +- Spring Core (from https://github.com/spring-projects/spring-framework) +- ThreeTen backport (from https://www.threeten.org/threetenbp) ======================================================================== CC-BY-2.5 @@ -389,7 +460,7 @@ The following software have components provided under the terms of this license: - JavaBeans Activation Framework API jar (from ) - Old JAXB Core (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-core) -- jaxb-impl (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl) +- Old JAXB Runtime (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl) ======================================================================== CDDL-1.1 @@ -407,6 +478,7 @@ The following software have components provided under the terms of this license: - JavaBeans(TM) Activation Framework (from http://java.sun.com/javase/technologies/desktop/javabeans/jaf/index.jsp) - JavaMail API (from https://repo1.maven.org/maven2/com/sun/mail/javax.mail) - javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250) +- tomcat-embed-core (from http://tomcat.apache.org/) ======================================================================== CPL-1.0 @@ -431,19 +503,21 @@ The following software have components provided under the terms of this license: - Common Annotations 1.3 API (from ) - Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) +- JUnit Jupiter API (from https://junit.org/junit5/) +- JUnit Jupiter Engine (from https://junit.org/junit5/) +- JUnit Jupiter Params (from https://junit.org/junit5/) - Java Servlet 4.0 API (from ) - Java Servlet API (from https://projects.eclipse.org/projects/ee4j.servlet) - Java(TM) API for WebSocket (from ) -- Logback Classic Module (from http://logback.qos.ch) +- Logback Classic Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-classic) - Logback Contrib :: JSON :: Classic (from ) -- Logback Core Module (from http://logback.qos.ch) +- Logback Contrib :: JSON :: Core (from ) +- Logback Contrib :: Jackson (from ) +- Logback Core Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-core) - Microsoft Application Insights Java SDK Spring Boot starter (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Java SDK Web Module (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Log4j 2 Appender (from https://github.com/Microsoft/ApplicationInsights-Java) - SnakeYAML (from http://code.google.com/p/snakeyaml/) -- org.junit.jupiter:junit-jupiter-api (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-engine (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-params (from http://junit.org/junit5/) - org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) - org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) @@ -455,12 +529,12 @@ The following software have components provided under the terms of this license: - Common Annotations 1.3 API (from ) - Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) - JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) +- JUnit Jupiter API (from https://junit.org/junit5/) +- JUnit Jupiter Engine (from https://junit.org/junit5/) +- JUnit Jupiter Params (from https://junit.org/junit5/) - Java Servlet 4.0 API (from ) - Java Servlet API (from https://projects.eclipse.org/projects/ee4j.servlet) - Java(TM) API for WebSocket (from ) -- org.junit.jupiter:junit-jupiter-api (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-engine (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-params (from http://junit.org/junit5/) - org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) - org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) @@ -478,8 +552,9 @@ The following software have components provided under the terms of this license: - Java(TM) API for WebSocket (from ) - JavaBeans Activation Framework (from ) - Old JAXB Core (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-core) +- Old JAXB Runtime (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl) - javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250) -- jaxb-impl (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl) +- tomcat-embed-core (from http://tomcat.apache.org/) ======================================================================== GPL-2.0-or-later @@ -493,9 +568,10 @@ GPL-2.0-with-classpath-exception ======================================================================== The following software have components provided under the terms of this license: +- Checker Qual (from https://checkerframework.org) - Common Annotations 1.3 API (from ) -- Expression Language 3.0 (from http://uel.java.net) - Expression Language 3.0 (from https://projects.eclipse.org/projects/ee4j.el) +- Expression Language 3.0 (from http://uel.java.net) - Java Architecture for XML Binding (from http://jaxb.java.net/) - Java Architecture for XML Binding (from http://jaxb.java.net/) - Java Servlet 4.0 API (from ) @@ -506,8 +582,9 @@ The following software have components provided under the terms of this license: - Java(TM) API for WebSocket (from ) - JavaBeans Activation Framework (from ) - Old JAXB Core (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-core) +- Old JAXB Runtime (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl) - javax.annotation-api (from http://jcp.org/en/jsr/detail?id=250) -- jaxb-impl (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl) +- tomcat-embed-core (from http://tomcat.apache.org/) ======================================================================== GPL-3.0-only @@ -521,8 +598,8 @@ The following software have components provided under the terms of this license: - Java Servlet API (from https://projects.eclipse.org/projects/ee4j.servlet) - Java(TM) API for WebSocket (from ) - Old JAXB Core (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-core) +- Old JAXB Runtime (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl) - Project Lombok (from https://projectlombok.org) -- jaxb-impl (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl) ======================================================================== ImageMagick @@ -549,9 +626,11 @@ The following software have components provided under the terms of this license: - Java Native Access Platform (from https://github.com/java-native-access/jna) - Javassist (from http://www.javassist.org/) - Javassist (from http://www.javassist.org/) -- Logback Classic Module (from http://logback.qos.ch) +- Logback Classic Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-classic) - Logback Contrib :: JSON :: Classic (from ) -- Logback Core Module (from http://logback.qos.ch) +- Logback Contrib :: JSON :: Core (from ) +- Logback Contrib :: Jackson (from ) +- Logback Core Module (from https://repo1.maven.org/maven2/ch/qos/logback/logback-core) - Microsoft Application Insights Java SDK Spring Boot starter (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Java SDK Web Module (from https://github.com/Microsoft/ApplicationInsights-Java) - Microsoft Application Insights Log4j 2 Appender (from https://github.com/Microsoft/ApplicationInsights-Java) @@ -581,11 +660,14 @@ The following software have components provided under the terms of this license: - AWS Java SDK for AWS Lambda (from https://aws.amazon.com/sdkforjava) - Animal Sniffer Annotations (from https://repo1.maven.org/maven2/org/codehaus/mojo/animal-sniffer-annotations) +- Animal Sniffer Annotations (from https://repo1.maven.org/maven2/org/codehaus/mojo/animal-sniffer-annotations) - Azure Java Client Authentication Library for AutoRest (from https://github.com/Azure/autorest-clientruntime-for-java) - Azure Java Client Runtime for ARM (from https://github.com/Azure/autorest-clientruntime-for-java) - Azure Java Client Runtime for AutoRest (from https://github.com/Azure/autorest-clientruntime-for-java) - Azure Spring Boot AutoConfigure (from https://github.com/Azure/azure-sdk-for-java) - Checker Qual (from https://checkerframework.org) +- Checker Qual (from https://checkerframework.org) +- Checker Qual (from https://checkerframework.org) - Extensions on Apache Proton-J library (from https://github.com/Azure/qpid-proton-j-extensions) - JOpt Simple (from http://pholser.github.io/jopt-simple) - JUL to SLF4J bridge (from http://www.slf4j.org) @@ -617,16 +699,17 @@ The following software have components provided under the terms of this license: - SLF4J API Module (from http://www.slf4j.org) - Spongy Castle (from http://rtyley.github.io/spongycastle/) - Spring Data for Azure Cosmos DB SQL API (from https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/cosmos/azure-spring-data-cosmos) -- Spring Security - Core (from https://repo1.maven.org/maven2/org/springframework/security/spring-security-core) - adal4j (from https://github.com/AzureAD/azure-activedirectory-library-for-java) - azure-documentdb (from https://azure.microsoft.com/en-us/services/cosmos-db/) - documentdb-bulkexecutor (from http://azure.microsoft.com/en-us/services/documentdb/) - java jwt (from http://www.jwt.io) +- java jwt (from http://www.jwt.io) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) - mockito-core (from https://github.com/mockito/mockito) - mockito-junit-jupiter (from https://github.com/mockito/mockito) - msal4j (from https://github.com/AzureAD/microsoft-authentication-library-for-java) - msal4j-persistence-extension (from https://github.com/AzureAD/microsoft-authentication-extensions-for-java) +- spring-security-core (from http://spring.io/spring-security) ======================================================================== MPL-1.1 @@ -643,7 +726,7 @@ The following software have components provided under the terms of this license: - Javassist (from http://www.javassist.org/) - Javassist (from http://www.javassist.org/) -- OkHttp (from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp) +- okhttp (from https://square.github.io/okhttp/) ======================================================================== MS-RL @@ -658,14 +741,15 @@ Public-Domain The following software have components provided under the terms of this license: - Old JAXB Core (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-core) +- Old JAXB Runtime (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl) - Spongy Castle (from http://rtyley.github.io/spongycastle/) -- jaxb-impl (from https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl) ======================================================================== SPL-1.0 ======================================================================== The following software have components provided under the terms of this license: +- Checker Qual (from https://checkerframework.org) - Checker Qual (from https://checkerframework.org) ======================================================================== @@ -695,7 +779,8 @@ public-domain The following software have components provided under the terms of this license: - AWS Java SDK :: SDK Core (from https://aws.amazon.com/sdkforjava) -- Asynchronous Http Client (from ) +- Asynchronous Http Client (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client) +- Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) - Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) - HdrHistogram (from http://hdrhistogram.github.io/HdrHistogram/) - Joda-Time (from https://www.joda.org/joda-time/) @@ -705,7 +790,7 @@ The following software have components provided under the terms of this license: - Microsoft Azure SDK for SQL API of Azure Cosmos DB Service (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure client library for Blob Storage (from https://github.com/Azure/azure-sdk-for-java) - Project Lombok (from https://projectlombok.org) -- Spring web (from https://repo1.maven.org/maven2/org/springframework/spring-web) +- Spring Web (from https://github.com/spring-projects/spring-framework) - azure-documentdb (from https://azure.microsoft.com/en-us/services/cosmos-db/) - msal4j (from https://github.com/AzureAD/microsoft-authentication-library-for-java) - reactive-streams (from http://www.reactive-streams.org/) @@ -716,13 +801,14 @@ unknown The following software have components provided under the terms of this license: - Byte Buddy (without dependencies) (from https://repo1.maven.org/maven2/net/bytebuddy/byte-buddy) +- Checker Qual (from https://checkerframework.org) - JSON in Java (from https://github.com/douglascrockford/JSON-java) - JUnit (from http://junit.org) - JUnit Jupiter (Aggregator) (from https://junit.org/junit5/) +- JUnit Jupiter API (from https://junit.org/junit5/) +- JUnit Jupiter Engine (from https://junit.org/junit5/) +- JUnit Jupiter Params (from https://junit.org/junit5/) - Spongy Castle (from http://rtyley.github.io/spongycastle/) -- org.junit.jupiter:junit-jupiter-api (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-engine (from http://junit.org/junit5/) -- org.junit.jupiter:junit-jupiter-params (from http://junit.org/junit5/) - org.junit.platform:junit-platform-commons (from http://junit.org/junit5/) - org.junit.platform:junit-platform-engine (from http://junit.org/junit5/) diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java b/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java index c571c062b0eb713a9f36f55c9192935c03c368e4..33ea6281af557e5f028bd599e05f83779ccfe805 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java @@ -16,29 +16,13 @@ package org.opengroup.osdu.notification.api; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Strings; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import org.apache.http.HttpStatus; -import org.opengroup.osdu.core.common.cryptographic.ISignatureService; -import org.opengroup.osdu.core.common.http.HttpClient; -import org.opengroup.osdu.core.common.http.HttpRequest; import org.opengroup.osdu.core.common.http.HttpResponse; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; -import org.opengroup.osdu.core.common.model.http.AppException; -import org.opengroup.osdu.core.common.model.http.DpsHeaders; -import org.opengroup.osdu.core.common.model.notification.*; -import org.opengroup.osdu.core.common.notification.ISubscriptionFactory; -import org.opengroup.osdu.core.common.notification.ISubscriptionService; -import org.opengroup.osdu.core.common.notification.SubscriptionException; -import org.opengroup.osdu.notification.di.SubscriptionCacheFactory; -import org.opengroup.osdu.notification.provider.interfaces.IPubsubHandshakeHandler; import org.opengroup.osdu.notification.provider.interfaces.IPubsubRequestBodyExtractor; +import org.opengroup.osdu.notification.service.NotificationHandler; import org.opengroup.osdu.notification.utils.Config; -import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.PostMapping; @@ -46,12 +30,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.context.annotation.RequestScope; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; import java.util.Map; - @RestController @RequestScope @RequestMapping("/push-handlers") @@ -59,29 +39,12 @@ public class PubsubEndpoint { @Autowired private IPubsubRequestBodyExtractor pubsubRequestBodyExtractor; @Autowired - private IPubsubHandshakeHandler pubsubHandshakeHandler; - @Autowired - private ISignatureService signatureService; - @Autowired - private HttpClient httpClient; - @Autowired - private IGoogleServiceAccount gsaTokenProvider; + private NotificationHandler notificationHandler; @Autowired private JaxRsDpsLog log; - @Autowired - private SubscriptionCacheFactory subscriptionCacheFactory; - @Autowired - private ISubscriptionFactory subscriptionFactory; - @Autowired - private DpsHeaders headers; - private static final String HMAC_TYPE = "HMAC"; - private static final String GSA_TYPE = "GSA"; - private final int WAITING_TIME = 30000; private final String ACKNOWLEDGE = "message acknowledged by client"; private final String NOT_ACKNOWLEDGE = "message not acknowledged by client"; - private static final Gson gson = new Gson(); - private ObjectMapper objectMapper; @PostMapping("/records-changed") @PreAuthorize("@authorizationFilter.hasAnyPermission('" + Config.OPS + "', '" + Config.PUBSUB + "')") @@ -89,92 +52,12 @@ public class PubsubEndpoint { String notificationId = this.pubsubRequestBodyExtractor.extractNotificationIdFromRequestBody(); String pubsubMessage = this.pubsubRequestBodyExtractor.extractDataFromRequestBody(); Map<String, String> headerAttributes = this.pubsubRequestBodyExtractor.extractAttributesFromRequestBody(); - - Subscription subscription = getSubscriptionFromCache(notificationId); - Secret secret = subscription.getSecret(); - String endpoint = subscription.getPushEndpoint(); - - String secretType = secret.getSecretType(); - String pushUrl = ""; - Map<String, String> requestHeader = new HashMap<>(); - - if (secretType.equalsIgnoreCase(HMAC_TYPE)) { - this.log.debug("receiving pubsub message, will send out hmac type request, pubsub message: " + pubsubMessage); - HmacSecret hmacSecret = (HmacSecret) secret; - String signedjwt = this.signatureService.getSignedSignature(endpoint, hmacSecret.getValue()); - pushUrl = endpoint + "?hmac=" + signedjwt; - } else if (secretType.equalsIgnoreCase(GSA_TYPE)) { - this.log.debug("receiving pubsub message, will send out gsa type request, pubsub message: " + pubsubMessage); - GsaSecret gsaSecret = (GsaSecret) secret; - GsaSecretValue gsaSecretValue = gsaSecret.getValue(); - - JsonParser jsonParser = new JsonParser(); - JsonElement root = jsonParser.parse(gsaSecretValue.getKey()); - String keyString = root.getAsJsonObject().toString(); - - String idToken = this.gsaTokenProvider.getIdToken(keyString, gsaSecretValue.getAudience()); - pushUrl = endpoint; - requestHeader.put("Authorization", idToken); - } - - this.log.debug("sending out notification to endpoint: " + endpoint); - requestHeader.put(DpsHeaders.CONTENT_TYPE, "application/json"); - requestHeader.put(DpsHeaders.CORRELATION_ID, headerAttributes.get(DpsHeaders.CORRELATION_ID)); - requestHeader.put(DpsHeaders.DATA_PARTITION_ID, headerAttributes.get(DpsHeaders.DATA_PARTITION_ID)); - - HttpRequest request = HttpRequest.post().url(pushUrl).headers(requestHeader).body(pubsubMessage).connectionTimeout(WAITING_TIME).build(); - HttpResponse response = httpClient.send(request); + HttpResponse response = notificationHandler.notifySubscriber(notificationId, pubsubMessage, headerAttributes); if (!response.isSuccessCode()) { - this.log.error(NOT_ACKNOWLEDGE); - return ResponseEntity.badRequest().body(NOT_ACKNOWLEDGE); + this.log.error(NOT_ACKNOWLEDGE + response.getBody()); + return new ResponseEntity<String>(NOT_ACKNOWLEDGE, HttpStatus.valueOf(response.getResponseCode())); } this.log.debug(ACKNOWLEDGE); - return ResponseEntity.ok(ACKNOWLEDGE); - } - - private Subscription getSubscriptionFromCache(String notificationId) throws IOException, SubscriptionException { - String subscriptionString = subscriptionCacheFactory.get(notificationId); - try { - if (Strings.isNullOrEmpty(subscriptionString)) - subscriptionString = querySubscriptionAndUpdateCache(notificationId); - ObjectMapper objectMapper = this.getObjectMapper(); - Subscription subscription = objectMapper.readValue(subscriptionString, Subscription.class); - return subscription; - } catch (IOException e) { - this.log.warning("Error Parsing subscription String to object."); - throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error in getting subscription for notificationId:" + notificationId, "Unexpected error in pushing message", e); - } catch (SubscriptionException se) { - this.log.warning("Error query subscription from registration."); - throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error in getting subscription for notificationId:" + notificationId, "Unexpected error in pushing message", se); - } - } - - private String querySubscriptionAndUpdateCache(String notificationId) throws AppException, SubscriptionException { - ISubscriptionService service = subscriptionFactory.create(headers); - - List<Subscription> subscriptionList = service.query(notificationId); - if (subscriptionList == null || subscriptionList.size() == 0) { - this.log.warning(String.format("Subscription with notification ID %s not found in registration", notificationId)); - throw new AppException(HttpStatus.SC_NOT_FOUND, "Not found subscription for notificationId:" + notificationId, "Subscription not found"); - } - - Subscription subscription = subscriptionList.get(0); - String jsonSubscription = gson.toJson(subscription); - this.subscriptionCacheFactory.put(subscription.getNotificationId(), jsonSubscription); - - return jsonSubscription; - } - - //unit test purpose - protected ObjectMapper getObjectMapper() { - if (this.objectMapper == null) { - this.objectMapper = new ObjectMapper(); - } - return this.objectMapper; - } - - //unit test purpose - void setObjectMapper(ObjectMapper objectMapper) { - this.objectMapper = objectMapper; + return new ResponseEntity<String>(ACKNOWLEDGE, HttpStatus.OK); } } diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/GsaAuth.java b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/GsaAuth.java new file mode 100644 index 0000000000000000000000000000000000000000..565c6635802339ffafe8499da66974e8ad164c0e --- /dev/null +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/GsaAuth.java @@ -0,0 +1,63 @@ +/* + * Copyright 2017-2020, Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.opengroup.osdu.notification.auth; + +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import org.opengroup.osdu.core.common.model.notification.GsaSecret; +import org.opengroup.osdu.core.common.model.notification.GsaSecretValue; +import org.opengroup.osdu.core.common.model.notification.Secret; +import org.opengroup.osdu.notification.auth.interfaces.SecretAuth; +import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + +import java.util.HashMap; +import java.util.Map; + +@Component +public class GsaAuth implements SecretAuth { + @Autowired + private IGoogleServiceAccount gsaTokenProvider; + + private GsaSecret gsaSecret; + + public void setSecret(Secret secret) { + this.gsaSecret = (GsaSecret) secret; + } + + public Secret getSecret() { + return this.gsaSecret; + } + + public String getPushUrl(String endpoint) throws Exception { + return endpoint; + } + + public Map<String, String> getRequestHeaders() { + Map<String, String> requestHeader = new HashMap<>(); + if (gsaSecret != null) { + GsaSecretValue gsaSecretValue = gsaSecret.getValue(); + JsonParser jsonParser = new JsonParser(); + JsonElement root = jsonParser.parse(gsaSecretValue.getKey()); + String keyString = root.getAsJsonObject().toString(); + String idToken = this.gsaTokenProvider.getIdToken(keyString, gsaSecretValue.getAudience()); + requestHeader.put("Authorization", idToken); + } + return requestHeader; + } +} diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/HmacAuth.java b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/HmacAuth.java new file mode 100644 index 0000000000000000000000000000000000000000..0a2885e2d2aeb91b62e65564a0d37a10a282bb73 --- /dev/null +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/HmacAuth.java @@ -0,0 +1,56 @@ +/* + * Copyright 2017-2020, Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.opengroup.osdu.notification.auth; + +import org.opengroup.osdu.core.common.cryptographic.ISignatureService; +import org.opengroup.osdu.core.common.model.notification.HmacSecret; +import org.opengroup.osdu.core.common.model.notification.Secret; +import org.opengroup.osdu.notification.auth.interfaces.SecretAuth; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + +import java.util.HashMap; +import java.util.Map; + +@Component +public class HmacAuth implements SecretAuth { + @Autowired + private ISignatureService signatureService; + + private HmacSecret hmacSecret; + + public void setSecret(Secret secret) { + this.hmacSecret = (HmacSecret) secret; + } + + public Secret getSecret() { + return this.hmacSecret; + } + + public String getPushUrl(String endpoint) throws Exception { + String pushUrl = endpoint; + String signedjwt = this.signatureService.getSignedSignature(endpoint, hmacSecret.getValue()); + pushUrl += "?hmac=" + signedjwt; + return pushUrl; + } + + public Map<String, String> getRequestHeaders() { + Map<String, String> requestHeader = new HashMap<>(); + return requestHeader; + + } +} diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/factory/AuthFactory.java b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/factory/AuthFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..5cedb532daabcf4806eb30dfffbbd97878b38750 --- /dev/null +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/factory/AuthFactory.java @@ -0,0 +1,49 @@ +/* + * Copyright 2017-2020, Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.opengroup.osdu.notification.auth.factory; + +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.notification.auth.GsaAuth; +import org.opengroup.osdu.notification.auth.HmacAuth; +import org.opengroup.osdu.notification.auth.interfaces.SecretAuth; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + +@Component +public class AuthFactory { + private final String HMAC_TYPE = "HMAC"; + private final String GSA_TYPE = "GSA"; + + @Autowired + private HmacAuth hmacAuth; + @Autowired + private GsaAuth gsaAuth; + @Autowired + private JaxRsDpsLog log; + + public SecretAuth getSecretAuth(String secretType) { + switch (secretType.toUpperCase()) { + case HMAC_TYPE: + return hmacAuth; + case GSA_TYPE: + return gsaAuth; + default: + throw new AppException(404, "Secret Type Not Found", "Unrecognised secret type encountered :" + secretType); + } + } +} diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/interfaces/SecretAuth.java b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/interfaces/SecretAuth.java new file mode 100644 index 0000000000000000000000000000000000000000..487a7f0acac68bcf12ddbfe0b05a6df742cb2d51 --- /dev/null +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/interfaces/SecretAuth.java @@ -0,0 +1,30 @@ +/* + * Copyright 2017-2020, Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.opengroup.osdu.notification.auth.interfaces; + +import org.opengroup.osdu.core.common.model.notification.Secret; + +import java.util.Map; + +public interface SecretAuth { + String getPushUrl(String endpoint) throws Exception; + + void setSecret(Secret secret); + + Secret getSecret(); + + Map<String, String> getRequestHeaders(); +} diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionCacheFactory.java b/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionCacheFactory.java index 5879641c8219a4dd4af318e5ce8da70ca3d5b0c5..0291e67f48be2d75a689fce3caa0d010ebd116ed 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionCacheFactory.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionCacheFactory.java @@ -19,7 +19,10 @@ package org.opengroup.osdu.notification.di; import org.opengroup.osdu.core.common.cache.ICache; import org.opengroup.osdu.core.common.cache.MultiTenantCache; import org.opengroup.osdu.core.common.cache.VmCache; +import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.tenant.TenantInfo; +import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -27,7 +30,9 @@ import org.springframework.stereotype.Component; @Component public class SubscriptionCacheFactory implements ICache<String, String> { @Autowired - private TenantInfo tenant; + private DpsHeaders headers; + @Autowired + private ITenantFactory tenantFactory; private MultiTenantCache<String> caches; @@ -56,6 +61,10 @@ public class SubscriptionCacheFactory implements ICache<String, String> { } private ICache<String, String> partitionCache() { - return this.caches.get(String.format("%s:subscription", this.tenant.getDataPartitionId())); + TenantInfo tenantInfo = this.tenantFactory.getTenantInfo(this.headers.getPartitionIdWithFallbackToAccountId()); + if (tenantInfo == null) { + throw AppException.createUnauthorized(String.format("could not retrieve tenant info for data partition id: %s", this.headers.getPartitionIdWithFallbackToAccountId())); + } + return this.caches.get(String.format("%s:subscription", tenantInfo.getDataPartitionId())); } } diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/service/NotificationHandler.java b/notification-core/src/main/java/org/opengroup/osdu/notification/service/NotificationHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..9ba4a823ab5d54fa97e5f79ffa8bc2a926ed09cb --- /dev/null +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/service/NotificationHandler.java @@ -0,0 +1,72 @@ +/* + * Copyright 2017-2020, Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.notification.service; + +import org.opengroup.osdu.core.common.http.HttpClient; +import org.opengroup.osdu.core.common.http.HttpRequest; +import org.opengroup.osdu.core.common.http.HttpResponse; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.core.common.model.notification.*; +import org.opengroup.osdu.notification.auth.factory.AuthFactory; +import org.opengroup.osdu.notification.auth.interfaces.SecretAuth; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + +import java.util.HashMap; +import java.util.Map; + +@Component +public class NotificationHandler { + private final static Logger LOGGER = LoggerFactory.getLogger(NotificationHandler.class); + @Autowired + private HttpClient httpClient; + @Autowired + private SubscriptionHandler subscriptionHandler; + @Autowired + private AuthFactory authFactory; + @Value("${app.waitingTime:30000}") + private int WAITING_TIME; + + public HttpResponse notifySubscriber(String notificationId, String pubsubMessage, Map<String, String> headerAttributes) throws Exception { + Subscription subscription = subscriptionHandler.getSubscriptionFromCache(notificationId); + Secret secret = subscription.getSecret(); + String endpoint = subscription.getPushEndpoint(); + String secretType = secret.getSecretType(); + String pushUrl = ""; + Map<String, String> requestHeader = new HashMap<String, String>(); + + // Authentication Secret + SecretAuth secretAuth = authFactory.getSecretAuth(secretType); + secretAuth.setSecret(secret); + pushUrl = secretAuth.getPushUrl(endpoint); + requestHeader = secretAuth.getRequestHeaders(); + + requestHeader.put(DpsHeaders.CONTENT_TYPE, "application/json"); + requestHeader.put(DpsHeaders.CORRELATION_ID, headerAttributes.get(DpsHeaders.CORRELATION_ID)); + requestHeader.put(DpsHeaders.DATA_PARTITION_ID, headerAttributes.get(DpsHeaders.DATA_PARTITION_ID)); + + HttpRequest request = HttpRequest.post().url(pushUrl).headers(requestHeader).body(pubsubMessage).connectionTimeout(WAITING_TIME).build(); + HttpResponse response = httpClient.send(request); + this.LOGGER.debug("Sending out notification to endpoint: " + endpoint); + return response; + } +} diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/service/SubscriptionHandler.java b/notification-core/src/main/java/org/opengroup/osdu/notification/service/SubscriptionHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..016ca4f49a55e630b95bbdf0c7ace92359c25a02 --- /dev/null +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/service/SubscriptionHandler.java @@ -0,0 +1,93 @@ +/* + * Copyright 2017-2020, Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.notification.service; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Strings; +import com.google.gson.Gson; +import org.apache.http.HttpStatus; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.core.common.model.notification.Subscription; +import org.opengroup.osdu.core.common.notification.ISubscriptionFactory; +import org.opengroup.osdu.core.common.notification.ISubscriptionService; +import org.opengroup.osdu.core.common.notification.SubscriptionException; +import org.opengroup.osdu.notification.di.SubscriptionCacheFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.util.List; + +@Component +public class SubscriptionHandler { + @Autowired + private ISubscriptionFactory subscriptionFactory; + @Autowired + private SubscriptionCacheFactory subscriptionCacheFactory; + @Autowired + private JaxRsDpsLog log; + @Autowired + private DpsHeaders headers; + + private static final Gson gson = new Gson(); + private ObjectMapper objectMapper; + + public Subscription getSubscriptionFromCache(String notificationId) throws IOException, SubscriptionException { + String subscriptionString = subscriptionCacheFactory.get(notificationId); + try { + if (Strings.isNullOrEmpty(subscriptionString)) + subscriptionString = querySubscriptionAndUpdateCache(notificationId); + ObjectMapper objectMapper = this.getObjectMapper(); + Subscription subscription = objectMapper.readValue(subscriptionString, Subscription.class); + return subscription; + } catch (IOException e) { + throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error Parsing subscription String to object", "Unexpected error in pushing message", e); + } catch (SubscriptionException se) { + throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Error query subscription from registration", "Unexpected error in pushing message", se); + } + } + + private String querySubscriptionAndUpdateCache(String notificationId) throws AppException, SubscriptionException { + ISubscriptionService service = subscriptionFactory.create(headers); + + List<Subscription> subscriptionList = service.query(notificationId); + if (subscriptionList == null || subscriptionList.size() == 0) { + throw new AppException(HttpStatus.SC_NOT_FOUND, "Not found subscription for notificationId:" + notificationId, "Subscription not found"); + } + + Subscription subscription = subscriptionList.get(0); + String jsonSubscription = gson.toJson(subscription); + this.subscriptionCacheFactory.put(subscription.getNotificationId(), jsonSubscription); + + return jsonSubscription; + } + + //unit test purpose + protected ObjectMapper getObjectMapper() { + if (this.objectMapper == null) { + this.objectMapper = new ObjectMapper(); + } + return this.objectMapper; + } + + //unit test purpose + void setObjectMapper(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + } +} diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java b/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java index 707a59fc951ab821160f71d35f766bc68ff39eff..ce98167953803ac6b257a31f38e5efb621fe27f0 100644 --- a/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java @@ -16,39 +16,26 @@ package org.opengroup.osdu.notification.api; -import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.opengroup.osdu.core.common.cryptographic.ISignatureService; -import org.opengroup.osdu.core.common.http.HttpClient; import org.opengroup.osdu.core.common.http.HttpResponse; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; -import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.DpsHeaders; -import org.opengroup.osdu.core.common.model.notification.Subscription; -import org.opengroup.osdu.core.common.notification.ISubscriptionService; import org.opengroup.osdu.core.common.notification.SubscriptionException; -import org.opengroup.osdu.core.common.notification.SubscriptionFactory; -import org.opengroup.osdu.core.common.notification.SubscriptionService; -import org.opengroup.osdu.notification.di.CredentialHeadersProvider; -import org.opengroup.osdu.notification.di.SubscriptionCacheFactory; -import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount; import org.opengroup.osdu.notification.provider.interfaces.IPubsubRequestBodyExtractor; +import org.opengroup.osdu.notification.service.NotificationHandler; import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.http.ResponseEntity; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; +import java.util.HashMap; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @RunWith(PowerMockRunner.class) @@ -56,31 +43,14 @@ public class PubsubEndpointTests { @Mock private IPubsubRequestBodyExtractor pubsubRequestBodyExtractor; @Mock - private ISignatureService signatureService; - @Mock - private HttpClient httpClient; - @Mock - private DpsHeaders headers; - @Mock - private SubscriptionCacheFactory subscriptionCacheFactory; - @Mock - private IGoogleServiceAccount googleIdTokenProducer; + private NotificationHandler notificationHandler; @Mock private JaxRsDpsLog log; @InjectMocks private PubsubEndpoint sut; - @Mock - private CredentialHeadersProvider credentialHeadersProvider; - @Mock - private SubscriptionFactory subscriptionFactory; - @Mock - private ObjectMapper objectMapper; - private static final String SIGNED_SIGNATURE = "testEncodedInfo.testSignature"; - private static final String GOOGLE_ID_TOKEN = "testHeader.testPayload.testSignature"; private static final String NOTIFICATION_ID = "test-notification-id"; private static final String PUBSUB_MESSAGE = "test-pubsub-message-data"; - private HttpResponse response = new HttpResponse(); @Before @@ -90,163 +60,28 @@ public class PubsubEndpointTests { } @Test - public void should_return200_whenPubsubMessageValidAndSuccessCodeReturnedFromClient_hmac() throws Exception { - response.setResponseCode(200); - - when(this.signatureService.getSignedSignature(any(), any())).thenReturn(SIGNED_SIGNATURE); - when(this.httpClient.send(any())).thenReturn(response); - when(this.subscriptionCacheFactory.get(any())).thenReturn(getHmacSubscription()); - sut.setObjectMapper(new ObjectMapper()); - ResponseEntity responseEntity = this.sut.recordChanged(); - Assert.assertEquals(200, responseEntity.getStatusCode().value()); - Assert.assertEquals("message acknowledged by client", responseEntity.getBody().toString()); - } - - @Test - public void should_return200_whenPubsubMessageValidAndSuccessCodeReturnedFromClient_gsa() throws Exception { + public void should_return200_whenPubsubMessageValidAndSuccessCodeReturnedFromNotificationHandler() throws Exception { response.setResponseCode(200); - - when(this.googleIdTokenProducer.getIdToken(any(), any())).thenReturn(GOOGLE_ID_TOKEN); - when(this.httpClient.send(any())).thenReturn(response); - when(this.subscriptionCacheFactory.get(any())).thenReturn(getGsaSubscription()); - sut.setObjectMapper(new ObjectMapper()); - + when(this.notificationHandler.notifySubscriber(NOTIFICATION_ID, PUBSUB_MESSAGE, new HashMap<>())).thenReturn(response); ResponseEntity responseEntity = this.sut.recordChanged(); Assert.assertEquals(200, responseEntity.getStatusCode().value()); Assert.assertEquals("message acknowledged by client", responseEntity.getBody().toString()); } @Test - public void should_return400_whenSendOutRequestButNoSuccessCodeReturned_hmac() throws Exception { - response.setResponseCode(500); - - when(this.signatureService.getSignedSignature(any(), any())).thenReturn(SIGNED_SIGNATURE); - when(this.httpClient.send(any())).thenReturn(response); - when(this.subscriptionCacheFactory.get(any())).thenReturn(getHmacSubscription()); - sut.setObjectMapper(new ObjectMapper()); - - ResponseEntity responseEntity = this.sut.recordChanged(); - Assert.assertEquals(400, responseEntity.getStatusCode().value()); - Assert.assertEquals("message not acknowledged by client", responseEntity.getBody().toString()); - } - - @Test - public void should_return400_whenSendOutRequestButNoSuccessCodeReturned_gsa() throws Exception { - response.setResponseCode(500); - - when(this.googleIdTokenProducer.getIdToken(any(), any())).thenReturn(GOOGLE_ID_TOKEN); - when(this.httpClient.send(any())).thenReturn(response); - when(this.subscriptionCacheFactory.get(any())).thenReturn(getGsaSubscription()); - sut.setObjectMapper(new ObjectMapper()); - + public void should_return400_whenPubsubMessageValidAndFailureCodeReturnedFromNotificationHandler() throws Exception { + response.setResponseCode(400); + when(this.notificationHandler.notifySubscriber(NOTIFICATION_ID, PUBSUB_MESSAGE, new HashMap<>())).thenReturn(response); ResponseEntity responseEntity = this.sut.recordChanged(); Assert.assertEquals(400, responseEntity.getStatusCode().value()); Assert.assertEquals("message not acknowledged by client", responseEntity.getBody().toString()); } - @Test(expected = AppException.class) - public void should_throwException_whenSubscriptionNotFound() throws Exception { - when(this.subscriptionCacheFactory.get(any())).thenReturn(null); - when(this.credentialHeadersProvider.getObject()).thenReturn(new DpsHeaders()); - ISubscriptionService subscriptionService = mock(SubscriptionService.class); - when(this.subscriptionFactory.create(any())).thenReturn(subscriptionService); - - HttpResponse response = new HttpResponse(); - when(subscriptionService.query(any())).thenThrow(new SubscriptionException("error", response)); - this.sut.recordChanged(); - fail("should throw AppException"); - } - - @Test(expected = AppException.class) - public void should_throwException_whenSubscriptionParsingErrorOccurs() throws Exception { - - when(this.subscriptionCacheFactory.get(any())).thenReturn(null); - when(this.credentialHeadersProvider.getObject()).thenReturn(new DpsHeaders()); - ISubscriptionService subscriptionService = mock(SubscriptionService.class); - when(this.subscriptionFactory.create(any())).thenReturn(subscriptionService); - - String jsonSubscription = this.getHmacSubscription(); - ObjectMapper objectMapper = new ObjectMapper(); - Subscription subscription = objectMapper.readValue(jsonSubscription, Subscription.class); - List<Subscription> queryResult = new ArrayList<>(); - queryResult.add(subscription); - - when(subscriptionService.query(any())).thenReturn(queryResult); - - sut.setObjectMapper(this.objectMapper); - when(this.objectMapper.readValue(anyString(), any(Class.class))).thenThrow(new IOException()); + @Test(expected = Exception.class) + public void should_return400_whenPubsubMessageValidAndNotificationHandlerThrowsException() throws Exception { + response.setResponseCode(400); + when(this.notificationHandler.notifySubscriber(NOTIFICATION_ID, PUBSUB_MESSAGE, new HashMap<>())).thenThrow(new Exception("error")); this.sut.recordChanged(); - fail("should throw AppException"); - } - - @Test - public void should_return200_whenSubscriptionGotFromRegistration() throws Exception { - response.setResponseCode(200); - - when(this.googleIdTokenProducer.getIdToken(any(), any())).thenReturn(GOOGLE_ID_TOKEN); - when(this.httpClient.send(any())).thenReturn(response); - - when(this.subscriptionCacheFactory.get(any())).thenReturn(null); - when(this.credentialHeadersProvider.getObject()).thenReturn(new DpsHeaders()); - ISubscriptionService subscriptionService = mock(SubscriptionService.class); - when(this.subscriptionFactory.create(any())).thenReturn(subscriptionService); - sut.setObjectMapper(new ObjectMapper()); - - String jsonSubscription = this.getHmacSubscription(); - ObjectMapper objectMapper = new ObjectMapper(); - // unit test purpose, not sure if this is osdu compliant - Subscription subscription = objectMapper.readValue(jsonSubscription, Subscription.class); - List<Subscription> queryResult = new ArrayList<>(); - queryResult.add(subscription); - when(subscriptionService.query(any())).thenReturn(queryResult); - ResponseEntity responseEntity = this.sut.recordChanged(); - Assert.assertEquals(200, responseEntity.getStatusCode().value()); - Assert.assertEquals("message acknowledged by client", responseEntity.getBody().toString()); - } - - @Test(expected = IllegalArgumentException.class) - public void should_throwException_whenErrorGeneratingSignature_hmac() throws Exception { - IllegalArgumentException ex = new IllegalArgumentException("Error generating signed signature"); - - when(this.subscriptionCacheFactory.get(any())).thenReturn(getHmacSubscription()); - when(this.signatureService.getSignedSignature(any(), any())).thenThrow(ex); - sut.setObjectMapper(new ObjectMapper()); - - this.sut.recordChanged(); - } - - private String getHmacSubscription() { - return "{\n" + - "\t\"name\": \"testSubscription\",\n" + - "\t\"description\": \"Description\",\n" + - "\t\"topic\": \"records-changed\",\n" + - "\t\"pushEndpoint\": \"http://challenge\",\n" + - "\t\"notificationId\": \"notificationId\",\n" + - "\t\"id\": \"id_1\",\n" + - "\t\"createdBy\": \"test@test.com\",\n" + - "\t\"secret\": {\n" + - "\t\t\"secretType\": \"HMAC\",\n" + - "\t\t\"value\": \"testsecret\"\n" + - "\t}\n" + - "}"; - } - - private String getGsaSubscription() { - return "{\n" + - "\t\"name\": \"testSubscription\",\n" + - "\t\"description\": \"Description\",\n" + - "\t\"topic\": \"records-changed\",\n" + - "\t\"pushEndpoint\": \"http:///gsa-challenge\",\n" + - "\t\"notificationId\": \"notificationId\",\n" + - "\t\"id\": \"id_1\",\n" + - "\t\"createdBy\": \"test@test.com\",\n" + - "\t\"secret\": {\n" + - "\t\t\"secretType\": \"GSA\",\n" + - "\t\t\"value\": {\n" + - "\t\t\t\"audience\":\"audience\",\n" + - "\t\t\t\"key\":\"keyFile\"\n" + - "\t\t}\n" + - "\t}\n" + - "}"; + fail("should throw Exception"); } } diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/GsaAuthTest.java b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/GsaAuthTest.java new file mode 100644 index 0000000000000000000000000000000000000000..077db3917a777340d9483ac7fe0621ba770a9fed --- /dev/null +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/GsaAuthTest.java @@ -0,0 +1,91 @@ +/* + * Copyright 2017-2020, Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.notification.auth; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.opengroup.osdu.core.common.model.notification.GsaSecret; +import org.opengroup.osdu.core.common.model.notification.GsaSecretValue; +import org.opengroup.osdu.core.common.model.notification.Subscription; +import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.utils.Asserts; + +import java.util.Map; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +@RunWith(PowerMockRunner.class) +public class GsaAuthTest { + @Mock + private IGoogleServiceAccount gsaTokenProvider; + @InjectMocks + private GsaAuth sut; + + private static Subscription gsa_subscription; + private static final String GOOGLE_ID_TOKEN = "testHeader.testPayload.testSignature"; + + @BeforeClass + public static void setup() { + setGsa_subscription(); + } + + @Test + public void should_return_valid_EndpointAndHeaders_gsaClient() throws Exception { + GsaSecret secret = (GsaSecret) gsa_subscription.getSecret(); + when(this.gsaTokenProvider.getIdToken(any(), any())).thenReturn(GOOGLE_ID_TOKEN); + sut.setSecret(gsa_subscription.getSecret()); + Asserts.assertNotNull(sut.getSecret(), "Unable to set Secret"); + Map<String, String> headers = sut.getRequestHeaders(); + Assert.assertEquals(GOOGLE_ID_TOKEN, headers.get("Authorization")); + String pushUrl = sut.getPushUrl(gsa_subscription.getPushEndpoint()); + Assert.assertEquals(pushUrl, gsa_subscription.getPushEndpoint()); + } + + @Test + public void should_return_emptyHeaders_when_secret_is_null() throws Exception { + GsaSecret secret = (GsaSecret) gsa_subscription.getSecret(); + when(this.gsaTokenProvider.getIdToken(any(), any())).thenReturn(GOOGLE_ID_TOKEN); + Map<String, String> headers = sut.getRequestHeaders(); + Assert.assertEquals(0, headers.size()); + String pushUrl = sut.getPushUrl(gsa_subscription.getPushEndpoint()); + Assert.assertEquals(pushUrl, gsa_subscription.getPushEndpoint()); + } + + private static void setGsa_subscription() { + gsa_subscription = new Subscription(); + gsa_subscription.setName("gsa_test_subscription"); + gsa_subscription.setPushEndpoint("http:///gsa-challenge"); + gsa_subscription.setDescription("Description"); + gsa_subscription.setTopic("records-changed"); + gsa_subscription.setNotificationId("test-notification-id"); + gsa_subscription.setId("id_1"); + gsa_subscription.setCreatedBy("test@test.com"); + GsaSecret secret = new GsaSecret(); + GsaSecretValue value = new GsaSecretValue(); + value.setAudience("audience"); + value.setKey("{\"keyFile\":{\"key\":\"gsa\"}}"); + secret.setValue(value); + gsa_subscription.setSecret(secret); + } + +} diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/HmacAuthTest.java b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/HmacAuthTest.java new file mode 100644 index 0000000000000000000000000000000000000000..130beb4d81c0392cb9896527b25bfbc347533709 --- /dev/null +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/HmacAuthTest.java @@ -0,0 +1,84 @@ +/* + * Copyright 2017-2020, Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.notification.auth; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.opengroup.osdu.core.common.cryptographic.ISignatureService; +import org.opengroup.osdu.core.common.model.notification.HmacSecret; +import org.opengroup.osdu.core.common.model.notification.Subscription; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.Map; + +import static org.junit.Assert.fail; +import static org.mockito.Mockito.when; + +@RunWith(PowerMockRunner.class) +public class HmacAuthTest { + @Mock + private ISignatureService signatureService; + @InjectMocks + private HmacAuth sut; + + private static Subscription hmac_subscription; + private static final String SIGNED_SIGNATURE = "testEncodedInfo.testSignature"; + + @BeforeClass + public static void setup() { + setHmac_subscription(); + } + + @Test + public void should_return_valid_EndpointAndHeaders() throws Exception { + HmacSecret secret = (HmacSecret) hmac_subscription.getSecret(); + when(this.signatureService.getSignedSignature(hmac_subscription.getPushEndpoint(), secret.getValue())).thenReturn(SIGNED_SIGNATURE); + sut.setSecret(hmac_subscription.getSecret()); + Assert.assertEquals(secret, sut.getSecret()); + Map<String, String> headers = sut.getRequestHeaders(); + Assert.assertEquals(0, headers.size()); + String pushUrl = sut.getPushUrl(hmac_subscription.getPushEndpoint()); + Assert.assertEquals(hmac_subscription.getPushEndpoint() + "?hmac=" + SIGNED_SIGNATURE, pushUrl); + } + + @Test(expected = Exception.class) + public void should_throwException_whenErrorGeneratingSignature_hmac() throws Exception { + Exception ex = new Exception("Error generating signed signature"); + HmacSecret secret = (HmacSecret) hmac_subscription.getSecret(); + when(this.signatureService.getSignedSignature(hmac_subscription.getPushEndpoint(), secret.getValue())).thenThrow(ex); + sut.getPushUrl(hmac_subscription.getPushEndpoint()); + fail("should throw Exception"); + } + + private static void setHmac_subscription() { + hmac_subscription = new Subscription(); + hmac_subscription.setName("hamc_test_subscription"); + hmac_subscription.setPushEndpoint("http://challenge"); + hmac_subscription.setDescription("Description"); + hmac_subscription.setTopic("records-changed"); + hmac_subscription.setNotificationId("test-notification-id"); + hmac_subscription.setId("id_1"); + hmac_subscription.setCreatedBy("test@test.com"); + HmacSecret secret = new HmacSecret(); + secret.setValue("testsecret"); + hmac_subscription.setSecret(secret); + } +} diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/service/NotificationHandlerTests.java b/notification-core/src/test/java/org/opengroup/osdu/notification/service/NotificationHandlerTests.java new file mode 100644 index 0000000000000000000000000000000000000000..0c5f8636d7e9c9d2d3c4fc8ea652372524361415 --- /dev/null +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/service/NotificationHandlerTests.java @@ -0,0 +1,137 @@ +/* + * Copyright 2017-2020, Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.notification.service; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.opengroup.osdu.core.common.http.HttpClient; +import org.opengroup.osdu.core.common.http.HttpResponse; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.notification.*; +import org.opengroup.osdu.core.common.notification.SubscriptionException; +import org.opengroup.osdu.notification.auth.factory.AuthFactory; +import org.opengroup.osdu.notification.auth.interfaces.SecretAuth; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +@RunWith(PowerMockRunner.class) +public class NotificationHandlerTests { + @Mock + private SubscriptionHandler subscriptionHandler; + @Mock + private AuthFactory authFactory; + @Mock + private SecretAuth secretAuth; + @Mock + private HttpClient httpClient; + @Mock + private JaxRsDpsLog log; + @InjectMocks + private NotificationHandler sut; + + private HttpResponse response = new HttpResponse(); + private static final String NOTIFICATION_ID = "test-notification-id"; + private static final String PUBSUB_MESSAGE = "test-pubsub-message-data"; + private static Subscription gsa_subscription; + private static Subscription hmac_subscription; + + @BeforeClass + public static void setup() { + setHmac_subscription(); + setGsa_subscription(); + } + + @Test + public void should_return200_whenPubsubMessageValidAndSuccessCodeReturnedFromClient_gsa() throws Exception { + response.setResponseCode(200); + Map<String, String> headers = new HashMap<String, String>(); + when(this.subscriptionHandler.getSubscriptionFromCache(this.NOTIFICATION_ID)).thenReturn(gsa_subscription); + when(this.authFactory.getSecretAuth(any())).thenReturn(secretAuth); + when(this.httpClient.send(any())).thenReturn(response); + when(this.secretAuth.getPushUrl(gsa_subscription.getPushEndpoint())).thenReturn(gsa_subscription.getPushEndpoint()); + when(this.secretAuth.getRequestHeaders()).thenReturn(headers); + HttpResponse response = this.sut.notifySubscriber(this.NOTIFICATION_ID, this.PUBSUB_MESSAGE, headers); + Assert.assertEquals(200, response.getResponseCode()); + } + + @Test + public void should_return200_whenPubsubMessageValidAndSuccessCodeReturnedFromClient_hmac() throws Exception { + response.setResponseCode(200); + Map<String, String> headers = new HashMap<String, String>(); + when(this.subscriptionHandler.getSubscriptionFromCache(this.NOTIFICATION_ID)).thenReturn(hmac_subscription); + when(this.authFactory.getSecretAuth(any())).thenReturn(secretAuth); + when(this.httpClient.send(any())).thenReturn(response); + when(this.secretAuth.getPushUrl(hmac_subscription.getPushEndpoint())).thenReturn(hmac_subscription.getPushEndpoint()); + when(this.secretAuth.getRequestHeaders()).thenReturn(headers); + HttpResponse response = this.sut.notifySubscriber(this.NOTIFICATION_ID, this.PUBSUB_MESSAGE, headers); + Assert.assertEquals(200, response.getResponseCode()); + } + + @Test(expected = SubscriptionException.class) + public void should_throwException_whenSubscriptionHandlerThrowsException() throws Exception { + Map<String, String> headers = new HashMap<String, String>(); + when(this.authFactory.getSecretAuth(any())).thenReturn(secretAuth); + when(this.httpClient.send(any())).thenReturn(response); + when(this.secretAuth.getPushUrl(gsa_subscription.getPushEndpoint())).thenReturn(gsa_subscription.getPushEndpoint()); + when(this.secretAuth.getRequestHeaders()).thenReturn(headers); + when(subscriptionHandler.getSubscriptionFromCache(this.NOTIFICATION_ID)).thenThrow(new SubscriptionException("error", response)); + this.sut.notifySubscriber(this.NOTIFICATION_ID, this.PUBSUB_MESSAGE, headers); + fail("should throw SubscriptionException"); + } + + private static void setGsa_subscription() { + gsa_subscription = new Subscription(); + gsa_subscription.setName("gsa_test_subscription"); + gsa_subscription.setPushEndpoint("http:///gsa-challenge"); + gsa_subscription.setDescription("Description"); + gsa_subscription.setTopic("records-changed"); + gsa_subscription.setNotificationId(NOTIFICATION_ID); + gsa_subscription.setId("id_1"); + gsa_subscription.setCreatedBy("test@test.com"); + GsaSecret secret = new GsaSecret(); + GsaSecretValue value = new GsaSecretValue(); + value.setAudience("audience"); + value.setKey("keyFile"); + secret.setValue(value); + gsa_subscription.setSecret(secret); + + } + + private static void setHmac_subscription() { + hmac_subscription = new Subscription(); + hmac_subscription.setName("hamc_test_subscription"); + hmac_subscription.setPushEndpoint("http://challenge"); + hmac_subscription.setDescription("Description"); + hmac_subscription.setTopic("records-changed"); + hmac_subscription.setNotificationId(NOTIFICATION_ID); + hmac_subscription.setId("id_1"); + hmac_subscription.setCreatedBy("test@test.com"); + HmacSecret secret = new HmacSecret(); + secret.setValue("testsecret"); + hmac_subscription.setSecret(secret); + } +} diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/service/SubscriptionHandlerTests.java b/notification-core/src/test/java/org/opengroup/osdu/notification/service/SubscriptionHandlerTests.java new file mode 100644 index 0000000000000000000000000000000000000000..aefb8b62c74d2a68000f07e2b713b085c0ebbc6a --- /dev/null +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/service/SubscriptionHandlerTests.java @@ -0,0 +1,119 @@ +/* + * Copyright 2017-2020, Schlumberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.opengroup.osdu.notification.service; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.opengroup.osdu.core.common.http.HttpResponse; +import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; +import org.opengroup.osdu.core.common.model.notification.Subscription; +import org.opengroup.osdu.core.common.notification.ISubscriptionFactory; +import org.opengroup.osdu.core.common.notification.ISubscriptionService; +import org.opengroup.osdu.core.common.notification.SubscriptionException; +import org.opengroup.osdu.core.common.notification.SubscriptionService; +import org.opengroup.osdu.notification.di.SubscriptionCacheFactory; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@RunWith(PowerMockRunner.class) +public class SubscriptionHandlerTests { + @Mock + private ISubscriptionFactory subscriptionFactory; + @Mock + private SubscriptionCacheFactory subscriptionCacheFactory; + @Mock + private ObjectMapper objectMapper; + @InjectMocks + private SubscriptionHandler sut; + + private static final String NOTIFICATION_ID = "test-notification-id"; + + @Test(expected = AppException.class) + public void should_throwException_whenSubscriptionNotFound() throws Exception { + when(this.subscriptionCacheFactory.get(any())).thenReturn(null); + ISubscriptionService subscriptionService = mock(SubscriptionService.class); + when(this.subscriptionFactory.create(any())).thenReturn(subscriptionService); + HttpResponse response = new HttpResponse(); + when(subscriptionService.query(any())).thenThrow(new SubscriptionException("error", response)); + this.sut.getSubscriptionFromCache(this.NOTIFICATION_ID); + fail("should throw AppException"); + } + + @Test(expected = AppException.class) + public void should_throwException_whenSubscriptionParsingErrorOccurs() throws Exception { + when(this.subscriptionCacheFactory.get(any())).thenReturn(null); + ISubscriptionService subscriptionService = mock(SubscriptionService.class); + when(this.subscriptionFactory.create(any())).thenReturn(subscriptionService); + String jsonSubscription = this.getHmacSubscription(); + ObjectMapper objectMapper = new ObjectMapper(); + Subscription subscription = objectMapper.readValue(jsonSubscription, Subscription.class); + List<Subscription> queryResult = new ArrayList<>(); + queryResult.add(subscription); + when(subscriptionService.query(any())).thenReturn(queryResult); + sut.setObjectMapper(this.objectMapper); + when(this.objectMapper.readValue(anyString(), any(Class.class))).thenThrow(new IOException()); + this.sut.getSubscriptionFromCache(NOTIFICATION_ID); + fail("should throw AppException"); + } + + @Test + public void should_return200_whenSubscriptionGotFromRegistration() throws Exception { + when(this.subscriptionCacheFactory.get(any())).thenReturn(null); + ISubscriptionService subscriptionService = mock(SubscriptionService.class); + when(this.subscriptionFactory.create(any())).thenReturn(subscriptionService); + sut.setObjectMapper(new ObjectMapper()); + String jsonSubscription = this.getHmacSubscription(); + ObjectMapper objectMapper = new ObjectMapper(); + Subscription subscription = objectMapper.readValue(jsonSubscription, Subscription.class); + List<Subscription> queryResult = new ArrayList<>(); + queryResult.add(subscription); + when(subscriptionService.query(any())).thenReturn(queryResult); + Subscription response = this.sut.getSubscriptionFromCache(NOTIFICATION_ID); + Assert.assertEquals("testSubscription", response.getName()); + } + + private String getHmacSubscription() { + return "{\n" + + "\t\"name\": \"testSubscription\",\n" + + "\t\"description\": \"Description\",\n" + + "\t\"topic\": \"records-changed\",\n" + + "\t\"pushEndpoint\": \"http://challenge\",\n" + + "\t\"notificationId\": \"notificationId\",\n" + + "\t\"id\": \"id_1\",\n" + + "\t\"createdBy\": \"test@test.com\",\n" + + "\t\"secret\": {\n" + + "\t\t\"secretType\": \"HMAC\",\n" + + "\t\t\"value\": \"testsecret\"\n" + + "\t}\n" + + "}"; + } +} diff --git a/pom.xml b/pom.xml index e926c0eb615f49d3035dc63664a9c7cd70f2c2e5..af5e0210e18b18ac7b5203eeb355ee7a0b94da53 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ <java.version>8</java.version> <maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.source>${java.version}</maven.compiler.source> - <os-core-common.version>0.9.0</os-core-common.version> + <os-core-common.version>0.10.0</os-core-common.version> </properties> <licenses> diff --git a/provider/notification-aws/pom.xml b/provider/notification-aws/pom.xml index eadd469376f6a0d31f0ba4b4b5c24172482761cd..a586f4aaf721cecd034111c3ebe1541904ebfd26 100644 --- a/provider/notification-aws/pom.xml +++ b/provider/notification-aws/pom.xml @@ -42,7 +42,7 @@ <dependency> <groupId>org.opengroup.osdu.core.aws</groupId> <artifactId>os-core-lib-aws</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.10.0</version> </dependency> <!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-secretsmanager --> diff --git a/provider/notification-azure/pom.xml b/provider/notification-azure/pom.xml index d7fdc248474b6586287104bb17975e039b2bab3b..48d5797b94ab63c53f65ac89186543680fad56d9 100644 --- a/provider/notification-azure/pom.xml +++ b/provider/notification-azure/pom.xml @@ -37,9 +37,9 @@ <jacoco-maven-plugin.version>0.8.2</jacoco-maven-plugin.version> <osdu.notification-core.version>0.10.0-SNAPSHOT</osdu.notification-core.version> <springframework.version>4.3.0.RELEASE</springframework.version> - <reactor.netty.version>0.9.0.RELEASE</reactor.netty.version> + <reactor.netty.version>0.10.0.RELEASE</reactor.netty.version> <reactor.core.version>3.3.0.RELEASE</reactor.core.version> - <osdu.corelibazure.version>0.10.0-rc8</osdu.corelibazure.version> + <osdu.corelibazure.version>0.10.1</osdu.corelibazure.version> <junit.version>5.6.0</junit.version> <jjwt.version>3.8.1</jjwt.version> <mockito.version>2.23.0</mockito.version> diff --git a/provider/notification-gcp/pom.xml b/provider/notification-gcp/pom.xml index 02ef95b6d78987d86c2872679c8584b5867a1feb..2cde8c2adffdd77fdda05e5cf2266bb4953ce095 100644 --- a/provider/notification-gcp/pom.xml +++ b/provider/notification-gcp/pom.xml @@ -40,12 +40,12 @@ <dependency> <groupId>org.opengroup.osdu</groupId> <artifactId>os-core-common</artifactId> - <version>0.9.0-rc17</version> + <version>0.10.0</version> </dependency> <dependency> <groupId>org.opengroup.osdu</groupId> <artifactId>core-lib-gcp</artifactId> - <version>0.9.0-SNAPSHOT</version> + <version>0.10.0</version> </dependency> <dependency> diff --git a/provider/notification-ibm/pom.xml b/provider/notification-ibm/pom.xml index 5d97c46433036bc6ca84f168b4834b4dfdcb826b..062ba56e9e5e38e018cd4a31287eb28ba5cc7107 100644 --- a/provider/notification-ibm/pom.xml +++ b/provider/notification-ibm/pom.xml @@ -44,7 +44,7 @@ <dependency> <groupId>org.opengroup.osdu</groupId> <artifactId>os-core-lib-ibm</artifactId> - <version>0.7.0</version> + <version>0.9.0</version> </dependency> <dependency> diff --git a/testing/notification-test-core/pom.xml b/testing/notification-test-core/pom.xml index 1b91dd43d8fdc609888a96beadc249f41f050163..12664d65658a985ad4fa143dde2e681516572d7e 100644 --- a/testing/notification-test-core/pom.xml +++ b/testing/notification-test-core/pom.xml @@ -113,7 +113,7 @@ <dependency> <groupId>com.google.auth</groupId> <artifactId>google-auth-library-oauth2-http</artifactId> - <version>0.9.0</version> + <version>0.10.0</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> diff --git a/testing/notification-test-ibm/src/test/java/org/opengroup/osdu/notification/api/TestPubsubEndpointHMAC.java b/testing/notification-test-ibm/src/test/java/org/opengroup/osdu/notification/api/TestPubsubEndpointHMAC.java index 9a1f59c5a4d8f9d51cfb3175be4ddbc103554d5b..e01b1c888f7f1f79f9707246c3ebb3ed26d56380 100644 --- a/testing/notification-test-ibm/src/test/java/org/opengroup/osdu/notification/api/TestPubsubEndpointHMAC.java +++ b/testing/notification-test-ibm/src/test/java/org/opengroup/osdu/notification/api/TestPubsubEndpointHMAC.java @@ -56,6 +56,14 @@ public class TestPubsubEndpointHMAC extends PubsubEndpointHMACTests { // TODO getting SubscriptionException only on ci-cd env super.should_return20XResponseCode_when_makingValidHttpsRequest(); } + + //running against tenant - 'nonexistenttenant' and entitlement throws 403 for invalid teanant + @Override + @Test + public void should_return401_when_noAccessOnCustomerTenant() throws Exception { + ClientResponse response = descriptor.runOnCustomerTenant(getArg(), getOsduTenantAdminCredentials()); + assertEquals(error( response.getEntity(String.class)),403, response.getStatus()); + } } \ No newline at end of file