use of org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.OslpDevice in project open-smart-grid-platform by OSGP.
the class OslpDeviceService method saveOslpRequestLogEntry.
private void saveOslpRequestLogEntry(final DeviceRequest deviceRequest, final OslpEnvelope oslpRequest) {
final OslpDevice oslpDevice = this.oslpDeviceSettingsService.getDeviceByDeviceIdentification(deviceRequest.getDeviceIdentification());
final OslpLogItemRequestMessage oslpLogItemRequestMessage = new OslpLogItemRequestMessage(deviceRequest.getOrganisationIdentification(), oslpDevice.getDeviceUid(), deviceRequest.getDeviceIdentification(), false, true, oslpRequest.getPayloadMessage(), oslpRequest.getSize());
this.oslpLogItemRequestMessageSender.send(oslpLogItemRequestMessage);
}
use of org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.OslpDevice in project open-smart-grid-platform by OSGP.
the class OslpSecurityHandler method channelRead0.
@Override
public void channelRead0(final ChannelHandlerContext ctx, final OslpEnvelope message) throws Exception {
LOGGER.info("Entering method: channelRead0 for channel {}", ctx.channel().id().asLongText());
// Upon first registration, a deviceUid is unknown within the platform.
// Search based on deviceIdentification in this case.
OslpDevice oslpDevice;
if (message.getPayloadMessage().hasRegisterDeviceRequest()) {
final String deviceIdentification = message.getPayloadMessage().getRegisterDeviceRequest().getDeviceIdentification();
oslpDevice = this.oslpDeviceSettingsService.getDeviceByDeviceIdentification(deviceIdentification);
} else {
oslpDevice = this.oslpDeviceSettingsService.getDeviceByUid(Base64.encodeBase64String(message.getDeviceId()));
}
if (oslpDevice == null) {
LOGGER.warn("Received message from unknown device.");
} else if (oslpDevice.getPublicKey() == null) {
LOGGER.warn("Received message from device without public key: {}", oslpDevice.getDeviceIdentification());
}
// not valid.
if (oslpDevice != null && oslpDevice.getPublicKey() != null) {
final PublicKey publicKey = CertificateHelper.createPublicKeyFromBase64(oslpDevice.getPublicKey(), this.oslpKeyType, this.oslpSignatureProvider);
message.validate(publicKey);
}
ctx.fireChannelRead(message);
}
use of org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.OslpDevice in project open-smart-grid-platform by OSGP.
the class DeviceRegistrationService method checkSequenceNumber.
public void checkSequenceNumber(final byte[] deviceId, final Integer newSequenceNumber) throws ProtocolAdapterException {
// Lookup device.
final OslpDevice oslpDevice = this.findDevice(deviceId);
this.checkSequenceNumber(oslpDevice.getSequenceNumber(), newSequenceNumber);
}
Aggregations