Search in sources :

Example 1 with OslpDevice

use of com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice in project Protocol-Adapter-OSLP 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(com.alliander.osgp.adapter.protocol.oslp.elster.infra.messaging.OslpLogItemRequestMessage) OslpDevice(com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice)

Example 2 with OslpDevice

use of com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice in project Protocol-Adapter-OSLP by OSGP.

the class OslpDeviceService method buildAndSignEnvelope.

private void buildAndSignEnvelope(final DeviceRequest deviceRequest, final Oslp.Message payloadMessage, final Serializable extraData) {
    final String deviceIdentification = deviceRequest.getDeviceIdentification();
    final String organisationIdentification = deviceRequest.getOrganisationIdentification();
    final String correlationUid = deviceRequest.getCorrelationUid();
    final String ipAddress = deviceRequest.getIpAddress();
    final String domain = deviceRequest.getDomain();
    final String domainVersion = deviceRequest.getDomainVersion();
    final String messageType = deviceRequest.getMessageType();
    final int retryCount = deviceRequest.getRetryCount();
    final boolean isScheduled = deviceRequest.isScheduled();
    // Get some values from the database.
    final OslpDevice oslpDevice = this.oslpDeviceSettingsService.getDeviceByDeviceIdentification(deviceIdentification);
    final byte[] deviceId = Base64.decodeBase64(oslpDevice.getDeviceUid());
    final byte[] sequenceNumber = SequenceNumberUtils.convertIntegerToByteArray(oslpDevice.getSequenceNumber());
    this.oslpSigningService.buildAndSignEnvelope(organisationIdentification, deviceIdentification, correlationUid, deviceId, sequenceNumber, ipAddress, domain, domainVersion, messageType, retryCount, isScheduled, payloadMessage, extraData);
}
Also used : ByteString(com.google.protobuf.ByteString) OslpDevice(com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice)

Example 3 with OslpDevice

use of com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice in project Protocol-Adapter-OSLP by OSGP.

the class OslpDeviceService method saveOslpResponseLogEntry.

private void saveOslpResponseLogEntry(final DeviceRequest deviceRequest, final OslpEnvelope oslpResponse) {
    final OslpDevice oslpDevice = this.oslpDeviceSettingsService.getDeviceByDeviceIdentification(deviceRequest.getDeviceIdentification());
    final OslpLogItemRequestMessage oslpLogItemRequestMessage = new OslpLogItemRequestMessage(deviceRequest.getOrganisationIdentification(), oslpDevice.getDeviceUid(), deviceRequest.getDeviceIdentification(), true, oslpResponse.isValid(), oslpResponse.getPayloadMessage(), oslpResponse.getSize());
    this.oslpLogItemRequestMessageSender.send(oslpLogItemRequestMessage);
}
Also used : OslpLogItemRequestMessage(com.alliander.osgp.adapter.protocol.oslp.elster.infra.messaging.OslpLogItemRequestMessage) OslpDevice(com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice)

Example 4 with OslpDevice

use of com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice in project Protocol-Adapter-OSLP by OSGP.

the class OslpDeviceService method updateSequenceNumber.

private void updateSequenceNumber(final String deviceIdentification, final OslpEnvelope oslpResponse) {
    final Integer sequenceNumber = SequenceNumberUtils.convertByteArrayToInteger(oslpResponse.getSequenceNumber());
    final OslpDevice oslpDevice = this.oslpDeviceSettingsService.getDeviceByDeviceIdentification(deviceIdentification);
    oslpDevice.setSequenceNumber(sequenceNumber);
    this.oslpDeviceSettingsService.updateDeviceAndForceSave(oslpDevice);
}
Also used : OslpDevice(com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice)

Example 5 with OslpDevice

use of com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice in project Protocol-Adapter-OSLP by OSGP.

the class DeviceManagementService method revokeKey.

// === REVOKE KEY ===
public void revokeKey(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final DeviceResponseMessageSender responseMessageSender, final String domain, final String domainVersion, final String messageType) {
    LOGGER.info("revokeKey called for device: {} for organisation: {}", deviceIdentification, organisationIdentification);
    try {
        final OslpDevice oslpDevice = this.oslpDeviceSettingsService.getDeviceByDeviceIdentification(deviceIdentification);
        if (oslpDevice == null) {
            throw new ProtocolAdapterException(String.format("Device not found: %s", deviceIdentification));
        }
        oslpDevice.revokePublicKey();
        this.oslpDeviceSettingsService.updateDevice(oslpDevice);
        this.sendResponseMessage(domain, domainVersion, messageType, correlationUid, organisationIdentification, deviceIdentification, ResponseMessageResultType.OK, null, responseMessageSender);
    } catch (final Exception e) {
        LOGGER.error("Unexpected exception during revokeKey", e);
        final TechnicalException ex = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while revoking key", e);
        this.sendResponseMessage(domain, domainVersion, messageType, correlationUid, organisationIdentification, deviceIdentification, ResponseMessageResultType.NOT_OK, ex, responseMessageSender);
    }
}
Also used : TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.oslp.elster.exceptions.ProtocolAdapterException) OslpDevice(com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice) OsgpException(com.alliander.osgp.shared.exceptionhandling.OsgpException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.oslp.elster.exceptions.ProtocolAdapterException) TechnicalException(com.alliander.osgp.shared.exceptionhandling.TechnicalException)

Aggregations

OslpDevice (com.alliander.osgp.adapter.protocol.oslp.elster.domain.entities.OslpDevice)13 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.oslp.elster.exceptions.ProtocolAdapterException)3 OslpLogItemRequestMessage (com.alliander.osgp.adapter.protocol.oslp.elster.infra.messaging.OslpLogItemRequestMessage)3 OsgpException (com.alliander.osgp.shared.exceptionhandling.OsgpException)2 TechnicalException (com.alliander.osgp.shared.exceptionhandling.TechnicalException)2 EventNotificationDto (com.alliander.osgp.dto.valueobjects.EventNotificationDto)1 GpsCoordinatesDto (com.alliander.osgp.dto.valueobjects.GpsCoordinatesDto)1 Oslp (com.alliander.osgp.oslp.Oslp)1 LocationInfo (com.alliander.osgp.oslp.Oslp.LocationInfo)1 OslpEnvelope (com.alliander.osgp.oslp.OslpEnvelope)1 RequestMessage (com.alliander.osgp.shared.infra.jms.RequestMessage)1 ByteString (com.google.protobuf.ByteString)1 InetAddress (java.net.InetAddress)1 PublicKey (java.security.PublicKey)1 ArrayList (java.util.ArrayList)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1