use of org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException in project open-smart-grid-platform by OSGP.
the class AdminNotificationService method doSendNotification.
private void doSendNotification(final NotificationType notificationType, final String organisationIdentification, final String deviceIdentification, final String correlationUid, final String result, final String message) {
final Notification notification = new Notification();
// Required fields.
notification.setNotificationType(notificationType);
notification.setDeviceIdentification(deviceIdentification);
// Optional fields.
if (StringUtils.hasText(correlationUid)) {
notification.setCorrelationUid(correlationUid);
}
if (StringUtils.hasText(result)) {
notification.setResult(OsgpResultType.valueOf(result));
}
if (StringUtils.hasText(message)) {
notification.setMessage(message);
}
// Try to send notification and catch security exceptions.
try {
this.sendNotificationServiceClient.sendNotification(organisationIdentification, notification);
} catch (final WebServiceSecurityException e) {
LOGGER.error("Unable to send notification", e);
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException in project open-smart-grid-platform by OSGP.
the class CreateDeviceSteps method receivingAnUpdateDeviceRequest.
@When("^receiving an update device request")
public void receivingAnUpdateDeviceRequest(final Map<String, String> settings) {
final UpdateDeviceRequest request = new UpdateDeviceRequest();
String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformCommonDefaults.DEFAULT_DEVICE_IDENTIFICATION);
// DeviceIdentification with only spaces
if (deviceIdentification.matches("(?!\")\\s*(?=\")")) {
deviceIdentification = deviceIdentification.replaceAll("\"", " ");
}
request.setDeviceIdentification(deviceIdentification);
final Device device = this.createDevice(settings);
request.setUpdatedDevice(device);
try {
ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.updateDevice(request));
} catch (final WebServiceSecurityException | SoapFaultClientException ex) {
ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException in project open-smart-grid-platform by OSGP.
the class NotificationWebServiceTemplateFactory method createKeyStore.
private KeyStore createKeyStore(final String type, final String location, final String password) throws WebServiceSecurityException {
final KeyStoreFactoryBean keyStoreFactory = new KeyStoreFactoryBean();
keyStoreFactory.setType(type);
keyStoreFactory.setLocation(new FileSystemResource(location));
keyStoreFactory.setPassword(password);
try {
keyStoreFactory.afterPropertiesSet();
final KeyStore keyStore = keyStoreFactory.getObject();
if ((keyStore == null) || (keyStore.size() == 0)) {
throw new KeyStoreException("Key store is empty");
}
return keyStore;
} catch (final GeneralSecurityException | IOException e) {
LOGGER.error("Exception creating {} key store for file {}", type, location, e);
throw new WebServiceSecurityException("Unable to create KeyStore", e);
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException in project open-smart-grid-platform by OSGP.
the class AbstractNotificationServiceWs method doSendNotification.
protected void doSendNotification(final WebserviceTemplateFactory wsTemplateFactory, final String organisationIdentification, final String userName, final String notificationURL, final Object notification) {
try {
/*
* Get a template for the organisation representing the OSGP
* platform, on behalf of which the notification is sent to the
* organisation identified by the organisationIdentification.
*/
final WebServiceTemplate wsTemplate = wsTemplateFactory.getTemplate(this.notificationOrganisation, userName, notificationURL);
wsTemplate.marshalSendAndReceive(notification);
} catch (WebServiceSecurityException | WebServiceIOException | SoapFaultClientException e) {
final String msg = String.format("error sending notification message org=%s, user=%s, to org=%s, notifyUrl=%s, errmsg=%s", this.notificationOrganisation, userName, organisationIdentification, notificationURL, e.getMessage());
LOGGER.error(msg, e);
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.WebServiceSecurityException in project open-smart-grid-platform by OSGP.
the class UpdateDeviceSettingsSteps method receivingAnUpdateDeviceRequest.
@When("^receiving a device management update device request")
public void receivingAnUpdateDeviceRequest(final Map<String, String> settings) {
final UpdateDeviceRequest request = new UpdateDeviceRequest();
String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformCommonDefaults.DEFAULT_DEVICE_IDENTIFICATION);
// DeviceIdentification with only spaces
if (deviceIdentification.matches("(?!\")\\s*(?=\")")) {
deviceIdentification = deviceIdentification.replaceAll("\"", " ");
}
final UpdatedDevice device = this.createUpdatedDevice(settings);
request.setDeviceIdentification(deviceIdentification);
request.setUpdatedDevice(device);
try {
ScenarioContext.current().put(PlatformKeys.RESPONSE, this.client.updateDevice(request));
} catch (final WebServiceSecurityException | SoapFaultClientException ex) {
ScenarioContext.current().put(PlatformKeys.RESPONSE, ex);
}
}
Aggregations