Search in sources :

Example 1 with GetKeysResponseData

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData in project open-smart-grid-platform by OSGP.

the class GetKeys method theGetKeysResponseIsReturned.

@Then("^the get keys response should return the requested keys$")
public void theGetKeysResponseIsReturned(final Map<String, String> expectedValues) throws Throwable {
    final GetKeysAsyncRequest asyncRequest = GetKeysRequestFactory.fromScenarioContext();
    final GetKeysResponse response = this.smartMeteringConfigurationClient.retrieveGetKeysResponse(asyncRequest);
    assertThat(response).isNotNull();
    assertThat(response.getResult()).as(OPERATION + ", Checking result:").isEqualTo(OsgpResultType.OK);
    final List<GetKeysResponseData> responseDataList = response.getGetKeysResponseData();
    assertThat(responseDataList).noneMatch(getKeysResponseData -> ArrayUtils.isEmpty(getKeysResponseData.getSecretValue()));
    final List<SecretType> secretTypesInResponse = responseDataList.stream().map(GetKeysResponseData::getSecretType).collect(Collectors.toList());
    final List<SecretType> expectedSecretTypes = getSecretTypesFromParameterMap(expectedValues);
    assertThat(secretTypesInResponse).containsExactlyInAnyOrderElementsOf(expectedSecretTypes);
}
Also used : GetKeysResponseData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData) SecretType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SecretType) GetKeysAsyncRequest(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysAsyncRequest) GetKeysResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponse) Then(io.cucumber.java.en.Then)

Example 2 with GetKeysResponseData

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData in project open-smart-grid-platform by OSGP.

the class SmartMeteringConfigurationEndpoint method getGetKeysResponse.

@PayloadRoot(localPart = "GetKeysAsyncRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public GetKeysResponse getGetKeysResponse(@RequestPayload final GetKeysAsyncRequest request) throws OsgpException {
    GetKeysResponse response = null;
    try {
        response = new GetKeysResponse();
        final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
        this.throwExceptionIfResultNotOk(responseData, "getting keys");
        response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
        if (responseData.getMessageData() != null) {
            final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetKeysResponse getKeysResponse = (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetKeysResponse) responseData.getMessageData();
            final List<GetKeysResponseData> keysEncryptedWithGxfKey = this.configurationMapper.mapAsList(getKeysResponse.getKeys(), GetKeysResponseData.class);
            final List<GetKeysResponseData> keysEncryptedForApplication = this.reencryptKeysInGetKeysResponse(keysEncryptedWithGxfKey, responseData.getOrganisationIdentification());
            response.getGetKeysResponseData().addAll(keysEncryptedForApplication);
        } else {
            log.info("Get keys response is null");
        }
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : GetKeysResponseData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData) GetKeysResponseData(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData) ResponseData(org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData) GetKeysResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponse) IOException(java.io.IOException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

GetKeysResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponse)2 GetKeysResponseData (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysResponseData)2 Then (io.cucumber.java.en.Then)1 IOException (java.io.IOException)1 ResponseData (org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData)1 GetKeysAsyncRequest (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.GetKeysAsyncRequest)1 SecretType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.SecretType)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1