Search in sources :

Example 16 with OslpDevice

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);
}
Also used : OslpLogItemRequestMessage(org.opensmartgridplatform.adapter.protocol.oslp.elster.infra.messaging.OslpLogItemRequestMessage) OslpDevice(org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.OslpDevice)

Example 17 with OslpDevice

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);
}
Also used : PublicKey(java.security.PublicKey) OslpDevice(org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.OslpDevice)

Example 18 with OslpDevice

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);
}
Also used : OslpDevice(org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.OslpDevice)

Aggregations

OslpDevice (org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.OslpDevice)18 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.oslp.elster.exceptions.ProtocolAdapterException)3 ByteString (com.google.protobuf.ByteString)2 Given (io.cucumber.java.en.Given)2 OslpLogItemRequestMessage (org.opensmartgridplatform.adapter.protocol.oslp.elster.infra.messaging.OslpLogItemRequestMessage)2 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)2 Oslp (org.opensmartgridplatform.oslp.Oslp)2 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)2 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)2 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)2 Then (io.cucumber.java.en.Then)1 IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 PublicKey (java.security.PublicKey)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1 PendingSetScheduleRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.PendingSetScheduleRequest)1 EventNotificationDto (org.opensmartgridplatform.dto.valueobjects.EventNotificationDto)1 GpsCoordinatesDto (org.opensmartgridplatform.dto.valueobjects.GpsCoordinatesDto)1