use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SetKeysRequestDto in project open-smart-grid-platform by OSGP.
the class AbstractReplaceKeyCommandExecutor method decryptRsaKeys.
private SetKeysRequestDto decryptRsaKeys(final SetKeysRequestDto setKeysRequestDto) throws FunctionalException {
try {
final byte[] authenticationKey = this.decrypterForGxfSmartMetering.decrypt(setKeysRequestDto.getAuthenticationKey());
final byte[] encryptionKey = this.decrypterForGxfSmartMetering.decrypt(setKeysRequestDto.getEncryptionKey());
return new SetKeysRequestDto(authenticationKey, encryptionKey);
} catch (final EncrypterException e) {
throw new FunctionalException(FunctionalExceptionType.DECRYPTION_EXCEPTION, ComponentType.PROTOCOL_DLMS, e);
}
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SetKeysRequestDto in project open-smart-grid-platform by OSGP.
the class SetKeysRequestMappingTest method testWithNullArrays.
// To test mapping when arrays are null
@Test
public void testWithNullArrays() {
// build test data
final byte[] authenthicationKey = null;
final byte[] encryptionKey = null;
final SetKeysRequestData keySet = new SetKeysRequestData(authenthicationKey, encryptionKey);
// actual mapping
final SetKeysRequestDto keySetDto = this.configurationMapper.map(keySet, SetKeysRequestDto.class);
// check if mapping succeeded
assertThat(keySetDto).isNotNull();
assertThat(keySetDto.getAuthenticationKey()).isNull();
assertThat(keySetDto.getEncryptionKey()).isNull();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SetKeysRequestDto in project open-smart-grid-platform by OSGP.
the class SetKeysRequestMappingTest method testWithArrays.
// To test mapping when arrays hold a value
@Test
public void testWithArrays() {
// build test data
final byte[] authenthicationKey = { 1 };
final byte[] encryptionKey = { 1 };
final SetKeysRequestData keySet = new SetKeysRequestData(authenthicationKey, encryptionKey);
// actual mapping
final SetKeysRequestDto keySetDto = this.configurationMapper.map(keySet, SetKeysRequestDto.class);
// check if mapping succeeded
assertThat(keySetDto).isNotNull();
assertThat(keySetDto.getAuthenticationKey()).isNotNull();
assertThat(keySetDto.getEncryptionKey()).isNotNull();
assertThat(keySetDto.getAuthenticationKey().length).isEqualTo(keySet.getAuthenticationKey().length);
assertThat(keySet.getEncryptionKey().length).isEqualTo(keySetDto.getEncryptionKey().length);
assertThat(keySetDto.getAuthenticationKey()[0]).isEqualTo(keySet.getAuthenticationKey()[0]);
assertThat(keySetDto.getEncryptionKey()[0]).isEqualTo(keySet.getEncryptionKey()[0]);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.SetKeysRequestDto in project open-smart-grid-platform by OSGP.
the class ReplaceKeysRequestMessageProcessor method handleMessage.
@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
this.assertRequestObjectType(SetKeysRequestDto.class, requestObject);
final SetKeysRequestDto keySet = (SetKeysRequestDto) requestObject;
this.configurationService.replaceKeys(conn, device, keySet, messageMetadata);
return null;
}
Aggregations