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);
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations