use of org.opensmartgridplatform.oslp.OslpEnvelope in project open-smart-grid-platform by OSGP.
the class CommonStopDeviceTestRequestMessageProcessor method processSignedOslpEnvelope.
@Override
public void processSignedOslpEnvelope(final String deviceIdentification, final SignedOslpEnvelopeDto signedOslpEnvelopeDto) {
final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = signedOslpEnvelopeDto.getUnsignedOslpEnvelopeDto();
final OslpEnvelope oslpEnvelope = signedOslpEnvelopeDto.getOslpEnvelope();
final String correlationUid = unsignedOslpEnvelopeDto.getCorrelationUid();
final String organisationIdentification = unsignedOslpEnvelopeDto.getOrganisationIdentification();
final String domain = unsignedOslpEnvelopeDto.getDomain();
final String domainVersion = unsignedOslpEnvelopeDto.getDomainVersion();
final String messageType = unsignedOslpEnvelopeDto.getMessageType();
final int messagePriority = unsignedOslpEnvelopeDto.getMessagePriority();
final String ipAddress = unsignedOslpEnvelopeDto.getIpAddress();
final int retryCount = unsignedOslpEnvelopeDto.getRetryCount();
final boolean isScheduled = unsignedOslpEnvelopeDto.isScheduled();
final DeviceResponseHandler deviceResponseHandler = new DeviceResponseHandler() {
@Override
public void handleResponse(final DeviceResponse deviceResponse) {
CommonStopDeviceTestRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, CommonStopDeviceTestRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
}
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
CommonStopDeviceTestRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, messagePriority);
try {
this.deviceService.doStopSelfTest(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, messagePriority, retryCount);
}
}
use of org.opensmartgridplatform.oslp.OslpEnvelope in project open-smart-grid-platform by OSGP.
the class OslpDeviceSteps method theDeviceSendsAConfirmRegisterDeviceRequestToThePlatform.
@Given("^the device sends a confirm register device request to the platform over \"([^\"]*)\"$")
public void theDeviceSendsAConfirmRegisterDeviceRequestToThePlatform(final String protocol, final Map<String, String> settings) throws DeviceSimulatorException {
try {
final String deviceIdentification = getString(settings, PlatformPubliclightingKeys.KEY_DEVICE_IDENTIFICATION, PlatformPubliclightingDefaults.DEFAULT_DEVICE_IDENTIFICATION);
final String deviceUid = getString(settings, PlatformPubliclightingKeys.KEY_DEVICE_UID, PlatformPubliclightingDefaults.DEVICE_UID);
final OslpDevice oslpDevice = this.oslpDeviceRepository.findByDeviceIdentification(deviceIdentification);
final int randomDevice = oslpDevice.getRandomDevice();
final int randomPlatform = oslpDevice.getRandomPlatform();
final Oslp.ConfirmRegisterDeviceRequest confirmRegisterDeviceRequest = Oslp.ConfirmRegisterDeviceRequest.newBuilder().setRandomDevice(randomDevice).setRandomPlatform(randomPlatform).build();
final Message message = Message.newBuilder().setConfirmRegisterDeviceRequest(confirmRegisterDeviceRequest).build();
this.oslpMockServer.incrementSequenceNumber(this.getDeviceUid(settings));
final OslpEnvelope request = this.createEnvelopeBuilder(deviceUid, this.oslpMockServer.getSequenceNumber(this.getDeviceUid(settings))).withPayloadMessage(message).build();
this.send(request, settings);
} catch (final IOException | IllegalArgumentException e) {
ScenarioContext.current().put("Error", e);
}
}
use of org.opensmartgridplatform.oslp.OslpEnvelope in project open-smart-grid-platform by OSGP.
the class MockOslpServer method sendRequest.
public Message sendRequest(final String deviceUid, final Message message) throws DeviceSimulatorException, IOException, ParseException {
final OslpEnvelope envelope = new OslpEnvelope();
envelope.setPayloadMessage(message);
return this.channelHandler.handleRequest(envelope, this.getSequenceNumber(deviceUid));
}
use of org.opensmartgridplatform.oslp.OslpEnvelope in project open-smart-grid-platform by OSGP.
the class OslpSigningService method handleSignedOslpRequest.
private void handleSignedOslpRequest(final SignedOslpEnvelopeDto signedOslpEnvelopeDto, final String deviceIdentification) {
final OslpEnvelope oslpEnvelope = signedOslpEnvelopeDto.getOslpEnvelope();
final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = signedOslpEnvelopeDto.getUnsignedOslpEnvelopeDto();
// Handle OSLP request message.
LOGGER.debug(LINES);
LOGGER.info("oslpEnvelope.size: {} for message type: {}", oslpEnvelope.getSize(), unsignedOslpEnvelopeDto.getMessageType());
LOGGER.debug(LINES);
LOGGER.debug("unsignedOslpEnvelopeDto.getCorrelationUid() : {}", unsignedOslpEnvelopeDto.getCorrelationUid());
LOGGER.debug("unsignedOslpEnvelopeDto.getDeviceId() : {}", unsignedOslpEnvelopeDto.getDeviceId());
LOGGER.debug("unsignedOslpEnvelopeDto.getDomain() : {}", unsignedOslpEnvelopeDto.getDomain());
LOGGER.debug("unsignedOslpEnvelopeDto.getDomainVersion() : {}", unsignedOslpEnvelopeDto.getDomainVersion());
LOGGER.debug("unsignedOslpEnvelopeDto.getIpAddress() : {}", unsignedOslpEnvelopeDto.getIpAddress());
LOGGER.debug("unsignedOslpEnvelopeDto.getMessageType() : {}", unsignedOslpEnvelopeDto.getMessageType());
LOGGER.debug("unsignedOslpEnvelopeDto.getMessagePriority() : {}", unsignedOslpEnvelopeDto.getMessagePriority());
LOGGER.debug("unsignedOslpEnvelopeDto.getOrganisationIdentification() : {}", unsignedOslpEnvelopeDto.getOrganisationIdentification());
LOGGER.debug("unsignedOslpEnvelopeDto.getPayloadMessage() : {}", unsignedOslpEnvelopeDto.getPayloadMessage().toString());
LOGGER.debug("unsignedOslpEnvelopeDto.getRetryCount() : {}", unsignedOslpEnvelopeDto.getRetryCount());
LOGGER.debug("unsignedOslpEnvelopeDto.getSequenceNumber() : {}", unsignedOslpEnvelopeDto.getSequenceNumber());
LOGGER.debug("unsignedOslpEnvelopeDto.isScheduled() : {}", unsignedOslpEnvelopeDto.isScheduled());
LOGGER.debug(LINES);
final MessageType messageType = MessageType.valueOf(unsignedOslpEnvelopeDto.getMessageType());
// Handle message for message type.
final OslpEnvelopeProcessor messageProcessor = this.deviceRequestMessageProcessorMap.getOslpEnvelopeProcessor(messageType);
if (messageProcessor == null) {
LOGGER.error("No message processor for messageType: {}", unsignedOslpEnvelopeDto.getMessageType());
return;
}
messageProcessor.processSignedOslpEnvelope(deviceIdentification, signedOslpEnvelopeDto);
}
use of org.opensmartgridplatform.oslp.OslpEnvelope in project open-smart-grid-platform by OSGP.
the class OslpSigningService method handleSignedOslpResponse.
private void handleSignedOslpResponse(final SignedOslpEnvelopeDto signedOslpEnvelopeDto) {
final OslpEnvelope oslpEnvelope = signedOslpEnvelopeDto.getOslpEnvelope();
final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = signedOslpEnvelopeDto.getUnsignedOslpEnvelopeDto();
// Handle OSLP response message.
LOGGER.debug(LINES);
LOGGER.info("oslpEnvelope.size: {} for message type: {}", oslpEnvelope.getSize(), unsignedOslpEnvelopeDto.getMessageType());
LOGGER.debug(LINES);
LOGGER.debug("unsignedOslpEnvelopeDto.getCorrelationUid() : {}", unsignedOslpEnvelopeDto.getCorrelationUid());
LOGGER.debug("unsignedOslpEnvelopeDto.getDeviceId() : {}", unsignedOslpEnvelopeDto.getDeviceId());
LOGGER.debug("unsignedOslpEnvelopeDto.getSequenceNumber() : {}", unsignedOslpEnvelopeDto.getSequenceNumber());
LOGGER.debug("unsignedOslpEnvelopeDto.getPayloadMessage() : {}", unsignedOslpEnvelopeDto.getPayloadMessage().toString());
// Send the signed OSLP envelope to the channel handler server.
this.oslpChannelHandlerServer.processSignedOslpEnvelope(signedOslpEnvelopeDto);
}
Aggregations