Commit b89b9c96 authored by Aliaksei Darafeyeu's avatar Aliaksei Darafeyeu
Browse files

move os-core-common to latest version

parent b714d954
......@@ -23,6 +23,7 @@ The following software have components provided under the terms of this license:
- Apache Commons Logging (from http://commons.apache.org/proper/commons-logging/)
- Apache HttpAsyncClient (from http://hc.apache.org/httpcomponents-asyncclient)
- Apache HttpClient (from http://hc.apache.org/httpcomponents-client)
- Apache HttpClient Cache (from http://hc.apache.org/httpcomponents-client)
- Apache HttpCore (from http://hc.apache.org/httpcomponents-core-ga)
- Apache HttpCore NIO (from http://hc.apache.org/httpcomponents-core-ga)
- Apache Log4j API (from )
......
......@@ -32,6 +32,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springfox-version>2.7.0</springfox-version>
<osdu.oscorecommon.version>0.3.23</osdu.oscorecommon.version>
</properties>
<licenses>
......@@ -54,7 +55,7 @@
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>0.3.12</version>
<version>${osdu.oscorecommon.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
......
......@@ -30,8 +30,7 @@
<version>1.0.0-SNAPSHOT</version>
<properties>
<osdu.register-core.version>1.0.0</osdu.register-core.version>
<osdu.corelibazure.version>0.0.50</osdu.corelibazure.version>
<osdu.oscorecommon.version>0.3.16</osdu.oscorecommon.version>
<osdu.corelibazure.version>0.0.51</osdu.corelibazure.version>
<azure.version>1.21.0</azure.version>
<azure-security-keyvault-keys.version>4.1.4</azure-security-keyvault-keys.version>
<azure-mgmt-eventgrid.version>1.0.0-beta-3</azure-mgmt-eventgrid.version>
......
package org.opengroup.osdu.register.subscriber.model;
import lombok.Data;
@Data
public class ChallengeResponse {
private String responseHash = "";
}
\ No newline at end of file
......@@ -16,15 +16,20 @@
package org.opengroup.osdu.register.subscriber.services;
import com.google.common.hash.Hashing;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Map;
import java.util.UUID;
import org.opengroup.osdu.core.common.cryptographic.ISignatureService;
import org.opengroup.osdu.core.common.http.HttpRequest;
import org.opengroup.osdu.core.common.http.HttpResponse;
import org.opengroup.osdu.core.common.http.IHttpClient;
import org.opengroup.osdu.core.common.http.json.HttpResponseBodyMapper;
import org.opengroup.osdu.core.common.http.json.HttpResponseBodyParsingException;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.register.subscriber.model.ChallengeResponse;
import org.opengroup.osdu.register.subscriber.model.GsaSecret;
import org.opengroup.osdu.register.subscriber.model.HmacSecret;
import org.opengroup.osdu.register.subscriber.model.Secret;
......@@ -35,10 +40,9 @@ import org.opengroup.osdu.register.utils.IGoogleServiceAccount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Map;
import java.util.UUID;
import com.google.common.hash.Hashing;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
@Service
public class ChallengeResponseCheck {
......@@ -55,6 +59,8 @@ public class ChallengeResponseCheck {
private AppServiceConfig serviceConfig;
@Autowired
private IHttpClient httpClient;
@Autowired
private HttpResponseBodyMapper responseBodyMapper;
private final static int timeOutMillis = 3000;
......@@ -144,17 +150,14 @@ public class ChallengeResponseCheck {
return Base64.getEncoder().encodeToString(hash.getBytes());
}
private String getChallengeResponseHash(HttpResponse response) {
private String getChallengeResponseHash(HttpResponse response) throws HttpResponseBodyParsingException {
log.info("Challenge info: " + response.toString());
if (!response.isSuccessCode()) {
return "";
}
ChallengeResponse body = response.parseBody(ChallengeResponse.class);
return body.responseHash;
ChallengeResponse body = responseBodyMapper.parseBody(response, ChallengeResponse.class);
return body.getResponseHash();
}
class ChallengeResponse {
public String responseHash = "";
}
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package org.opengroup.osdu.register.utils;
import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig;
import org.opengroup.osdu.core.common.entitlements.EntitlementsFactory;
import org.opengroup.osdu.core.common.entitlements.IEntitlementsFactory;
import org.opengroup.osdu.core.common.http.json.HttpResponseBodyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.stereotype.Component;
......@@ -12,6 +13,8 @@ public class EntitlementsClientFactory extends AbstractFactoryBean<IEntitlements
@Autowired
private AppServiceConfig serviceConfig;
@Autowired
private HttpResponseBodyMapper responseBodyMapper;
@Override
protected IEntitlementsFactory createInstance() {
......@@ -19,7 +22,7 @@ public class EntitlementsClientFactory extends AbstractFactoryBean<IEntitlements
return new EntitlementsFactory(EntitlementsAPIConfig
.builder()
.rootUrl(this.serviceConfig.getEntitlementsApi())
.build());
.build(), responseBodyMapper);
}
@Override
......
......@@ -22,12 +22,14 @@ import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.opengroup.osdu.core.common.http.json.HttpResponseBodyMapper;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.http.HttpResponse;
import org.opengroup.osdu.core.common.http.IHttpClient;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.cryptographic.ISignatureService;
import org.opengroup.osdu.register.subscriber.model.ChallengeResponse;
import org.opengroup.osdu.register.subscriber.model.HmacSecret;
import org.opengroup.osdu.register.subscriber.model.Subscription;
import org.opengroup.osdu.register.utils.AppServiceConfig;
......@@ -58,6 +60,9 @@ public class ChallengeResponseCheckTest {
@Mock
private AppServiceConfig serviceConfig;
@Mock
private HttpResponseBodyMapper responseBodyMapper;
@InjectMocks
private ChallengeResponseCheckSut sut;
......@@ -135,6 +140,9 @@ public class ChallengeResponseCheckTest {
secret.setValue("secret");
s.setSecret(secret);
s.setPushEndpoint("https://");
ChallengeResponse challengeResponse = new ChallengeResponse();
challengeResponse.setResponseHash("YmVlNmIyMGRkMzU1YzcxOTUwMTFjODU3OWZkMjU4ZWIzZDVkNjAzMGYyMjNjYWNkMzI2NWQxNWZjYjQ1MjU5Zg==");
when(responseBodyMapper.parseBody(r, ChallengeResponse.class)).thenReturn(challengeResponse);
boolean result = sut.runCreate(s);
assertTrue(result);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment