use of org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto 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);
}
use of org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto in project open-smart-grid-platform by OSGP.
the class OslpSigningService method buildAndSignEnvelope.
/**
* Build OslpEnvelope for an OSLP request using the arguments supplied and have the envelope
* signed by the signing server.
*/
public void buildAndSignEnvelope(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final byte[] deviceId, final byte[] sequenceNumber, final String ipAddress, final String domain, final String domainVersion, final String messageType, final int messagePriority, final int retryCount, final boolean isScheduled, final Oslp.Message payloadMessage, final Serializable extraData) {
// Create DTO to transfer data using request message.
final UnsignedOslpEnvelopeDto oslpEnvelopeDto = new UnsignedOslpEnvelopeDto(sequenceNumber, deviceId, payloadMessage, ipAddress, domain, domainVersion, messageType, messagePriority, retryCount, isScheduled, organisationIdentification, correlationUid, extraData);
final RequestMessage requestMessage = new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, oslpEnvelopeDto);
// Send request message to signing server.
this.signingServerRequestMessageSender.send(requestMessage, SIGNING_REQUEST_MESSAGE_TYPE, messagePriority);
}
use of org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto in project open-smart-grid-platform by OSGP.
the class CommonSetConfigurationRequestMessageProcessor 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 setConfigurationDeviceResponseHandler = new DeviceResponseHandler() {
@Override
public void handleResponse(final DeviceResponse deviceResponse) {
if (((EmptyDeviceResponse) deviceResponse).getStatus().equals(DeviceMessageStatus.OK)) {
// If the response is OK, just log it. The setReboot()
// function will be called next.
LOGGER.info("setConfiguration() successful for device : {}", deviceResponse.getDeviceIdentification());
} else {
// If the response is not OK, send a response message to the
// responses queue.
CommonSetConfigurationRequestMessageProcessor.this.handleScheduledEmptyDeviceResponse(deviceResponse, CommonSetConfigurationRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, isScheduled, retryCount);
}
}
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
CommonSetConfigurationRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
final DeviceRequest setConfigurationDeviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, messagePriority);
final DeviceResponseHandler setRebootDeviceResponseHandler = this.commonRebootRequestMessageProcessor.createSetRebootDeviceResponseHandler(domain, domainVersion, messageType, retryCount, isScheduled);
final DeviceRequest setRebootDeviceRequest = DeviceRequest.newBuilder().organisationIdentification(organisationIdentification).deviceIdentification(deviceIdentification).correlationUid(correlationUid).messagePriority(messagePriority).messageType(MessageType.SET_REBOOT.name()).domain(domain).domainVersion(domainVersion).ipAddress(ipAddress).isScheduled(isScheduled).retryCount(retryCount).build();
try {
this.deviceService.doSetConfiguration(oslpEnvelope, setConfigurationDeviceRequest, setRebootDeviceRequest, setConfigurationDeviceResponseHandler, setRebootDeviceResponseHandler, ipAddress);
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, messagePriority, retryCount);
}
}
use of org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto in project open-smart-grid-platform by OSGP.
the class CommonSwitchFirmwareRequestMessageProcessor 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) {
CommonSwitchFirmwareRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, CommonSwitchFirmwareRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
}
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
CommonSwitchFirmwareRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, messagePriority);
try {
this.deviceService.doSwitchFirmware(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, messagePriority, retryCount);
}
}
use of org.opensmartgridplatform.oslp.UnsignedOslpEnvelopeDto in project open-smart-grid-platform by OSGP.
the class CommonUpdateFirmwareRequestMessageProcessor 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) {
CommonUpdateFirmwareRequestMessageProcessor.this.handleEmptyDeviceResponse(deviceResponse, CommonUpdateFirmwareRequestMessageProcessor.this.responseMessageSender, domain, domainVersion, messageType, retryCount);
}
@Override
public void handleException(final Throwable t, final DeviceResponse deviceResponse) {
CommonUpdateFirmwareRequestMessageProcessor.this.handleUnableToConnectDeviceResponse(deviceResponse, t, domain, domainVersion, messageType, isScheduled, retryCount);
}
};
final DeviceRequest deviceRequest = new DeviceRequest(organisationIdentification, deviceIdentification, correlationUid, messagePriority);
try {
this.deviceService.doUpdateFirmware(oslpEnvelope, deviceRequest, deviceResponseHandler, ipAddress);
} catch (final IOException e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, domain, domainVersion, messageType, messagePriority, retryCount);
}
}
Aggregations