use of org.opensmartgridplatform.ws.schema.core.secret.management.HasNewSecretResponse in project open-smart-grid-platform by OSGP.
the class SecretManagementServiceTest method testHasNewSecretAuthenticationKey.
@Test
public void testHasNewSecretAuthenticationKey() {
final HasNewSecretResponse responseTrue = new HasNewSecretResponse();
responseTrue.setHasNewSecret(true);
final HasNewSecretResponse responseFalse = new HasNewSecretResponse();
responseFalse.setHasNewSecret(false);
when(this.secretManagementClient.hasNewSecretRequest(same(messageMetadata), any())).thenAnswer(invocationOnMock -> {
if (((HasNewSecretRequest) invocationOnMock.getArgument(1)).getSecretType().equals(SecretType.E_METER_AUTHENTICATION_KEY)) {
return responseTrue;
} else {
return responseFalse;
}
});
// EXECUTE
final boolean result = this.secretManagementTestService.hasNewSecret(messageMetadata, DEVICE_IDENTIFICATION);
// ASSERT
assertThat(result).isTrue();
}
use of org.opensmartgridplatform.ws.schema.core.secret.management.HasNewSecretResponse in project open-smart-grid-platform by OSGP.
the class SecretManagementEndpoint method hasNewSecret.
public HasNewSecretResponse hasNewSecret(final HasNewSecretRequest request) {
final SecretType type = this.converter.convertToSecretType(request.getSecretType());
final boolean result = this.secretManagementService.hasNewSecret(request.getDeviceId(), type);
final HasNewSecretResponse response = new HasNewSecretResponse();
response.setHasNewSecret(result);
return response;
}
use of org.opensmartgridplatform.ws.schema.core.secret.management.HasNewSecretResponse in project open-smart-grid-platform by OSGP.
the class SecretManagementService method hasNewSecret.
public boolean hasNewSecret(final MessageMetadata messageMetadata, final String deviceIdentification) {
final HasNewSecretRequest requestAKey = new HasNewSecretRequest();
final HasNewSecretRequest requestEKey = new HasNewSecretRequest();
requestAKey.setDeviceId(deviceIdentification);
requestAKey.setSecretType(SecretType.E_METER_AUTHENTICATION_KEY);
final HasNewSecretResponse responseAKey = this.secretManagementClient.hasNewSecretRequest(messageMetadata, requestAKey);
requestEKey.setDeviceId(deviceIdentification);
requestEKey.setSecretType(SecretType.E_METER_ENCRYPTION_KEY_UNICAST);
final HasNewSecretResponse responseEKey = this.secretManagementClient.hasNewSecretRequest(messageMetadata, requestEKey);
return responseAKey.isHasNewSecret() || responseEKey.isHasNewSecret();
}
use of org.opensmartgridplatform.ws.schema.core.secret.management.HasNewSecretResponse in project open-smart-grid-platform by OSGP.
the class SecretManagementServiceTest method testHasNewSecretEncryptionKey.
@Test
public void testHasNewSecretEncryptionKey() {
final HasNewSecretResponse responseTrue = new HasNewSecretResponse();
responseTrue.setHasNewSecret(true);
final HasNewSecretResponse responseFalse = new HasNewSecretResponse();
responseFalse.setHasNewSecret(false);
when(this.secretManagementClient.hasNewSecretRequest(same(messageMetadata), any())).thenAnswer(invocationOnMock -> {
if (((HasNewSecretRequest) invocationOnMock.getArgument(1)).getSecretType().equals(SecretType.E_METER_ENCRYPTION_KEY_UNICAST)) {
return responseTrue;
} else {
return responseFalse;
}
});
// EXECUTE
final boolean result = this.secretManagementTestService.hasNewSecret(messageMetadata, DEVICE_IDENTIFICATION);
// ASSERT
assertThat(result).isTrue();
}
Aggregations