Search in sources :

Example 1 with ApplicationDataLookupKey

use of org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey in project open-smart-grid-platform by OSGP.

the class NotificationWebServiceConfigurationBuilder method build.

public NotificationWebServiceConfiguration build() {
    final NotificationWebServiceConfiguration config = new NotificationWebServiceConfiguration(new ApplicationDataLookupKey(this.organisationIdentification, this.applicationName), this.marshallerContextPath, this.targetUri);
    config.useKeyStore(this.keyStoreType, this.keyStoreLocation, this.keyStorePassword);
    config.useTrustStore(this.trustStoreType, this.trustStoreLocation, this.trustStorePassword);
    config.setMaxConnectionsPerRoute(this.maxConnectionsPerRoute);
    config.setMaxConnectionsTotal(this.maxConnectionsTotal);
    config.setConnectionTimeout(this.connectionTimeout);
    config.useCircuitBreaker(this.circuitBreakerThreshold, this.circuitBreakerDurationInitial, this.circuitBreakerDurationMaximum, this.circuitBreakerDurationMultiplier);
    return config;
}
Also used : ApplicationDataLookupKey(org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey) NotificationWebServiceConfiguration(org.opensmartgridplatform.adapter.ws.domain.entities.NotificationWebServiceConfiguration)

Example 2 with ApplicationDataLookupKey

use of org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey in project open-smart-grid-platform by OSGP.

the class DomainResponseMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) {
    log.debug("Processing response message");
    String correlationUid = null;
    String actualMessageType = null;
    String organisationIdentification = null;
    String deviceIdentification = null;
    final String notificationMessage;
    final NotificationType notificationType;
    final ResponseMessageResultType resultType;
    final String resultDescription;
    final Serializable dataObject;
    try {
        correlationUid = message.getJMSCorrelationID();
        actualMessageType = message.getJMSType();
        organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
        deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
        resultType = ResponseMessageResultType.valueOf(message.getStringProperty(Constants.RESULT));
        resultDescription = message.getStringProperty(Constants.DESCRIPTION);
        notificationMessage = message.getStringProperty(Constants.DESCRIPTION);
        notificationType = NotificationType.valueOf(actualMessageType);
        dataObject = message.getObject();
    } catch (final JMSException e) {
        log.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        log.debug("correlationUid: {}", correlationUid);
        log.debug("messageType: {}", actualMessageType);
        log.debug("organisationIdentification: {}", organisationIdentification);
        log.debug("deviceIdentification: {}", deviceIdentification);
        return;
    }
    log.info("Calling application service function to handle response: {} with correlationUid: {}", actualMessageType, correlationUid);
    final CorrelationIds ids = new CorrelationIds(organisationIdentification, deviceIdentification, correlationUid);
    this.handleMessage(ids, actualMessageType, resultType, resultDescription, dataObject);
    try {
        log.info("Send notification for correlationUid: {}", correlationUid);
        // Send notification indicating data is available.
        this.notificationService.sendNotification(new ApplicationDataLookupKey(organisationIdentification, this.webserviceNotificationApplicationName), new GenericNotification(notificationMessage, resultType.name(), deviceIdentification, correlationUid, String.valueOf(notificationType)));
        log.info("Notification sent for correlationUid: {}", correlationUid);
    } catch (final Exception e) {
        // Logging is enough, sending the notification will be done
        // automatically by the resend notification job
        log.warn("Delivering notification with correlationUid: {} and notification type: {} did not complete successfully.", correlationUid, notificationType, e);
    }
}
Also used : Serializable(java.io.Serializable) GenericNotification(org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification) ApplicationDataLookupKey(org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey) NotificationType(org.opensmartgridplatform.adapter.ws.schema.smartmetering.notification.NotificationType) JMSException(javax.jms.JMSException) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds) JMSException(javax.jms.JMSException)

Example 3 with ApplicationDataLookupKey

use of org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey in project open-smart-grid-platform by OSGP.

the class AbstractResendNotificationService method resendNotification.

public void resendNotification(final ResponseData responseData) {
    if (!EnumUtils.isValidEnum(this.notificationClass, responseData.getMessageType())) {
        this.logUnknownNotificationTypeError(responseData.getCorrelationUid(), responseData.getMessageType(), this.notificationServiceReference.getClass().getName());
        return;
    }
    final ApplicationDataLookupKey notificationWebServiceLookupKey = new ApplicationDataLookupKey(responseData.getOrganisationIdentification(), this.applicationName);
    final String notificationMessage = this.getNotificationMessage(responseData.getMessageType());
    final GenericNotification genericNotification = new GenericNotification(notificationMessage, responseData.getResultType().name(), responseData.getDeviceIdentification(), responseData.getCorrelationUid(), responseData.getMessageType());
    this.notificationServiceReference.sendNotification(notificationWebServiceLookupKey, genericNotification);
}
Also used : GenericNotification(org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification) ApplicationDataLookupKey(org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey)

Example 4 with ApplicationDataLookupKey

use of org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey in project open-smart-grid-platform by OSGP.

the class GetKeys method anApplicationKeyIsConfigured.

@Given("^an application key is configured$")
public void anApplicationKeyIsConfigured(final Map<String, String> settings) throws Throwable {
    final ApplicationDataLookupKey applicationDataLookupKey = new ApplicationDataLookupKey(settings.get(PlatformKeys.KEY_ORGANIZATION_IDENTIFICATION), this.applicationName);
    final ApplicationKeyConfiguration applicationKeyConfiguration = new ApplicationKeyConfiguration(applicationDataLookupKey, "/etc/osp/smartmetering/keys/application/smartmetering-rsa-public.key");
    this.applicationKeyConfigurationRepository.save(applicationKeyConfiguration);
}
Also used : ApplicationDataLookupKey(org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey) ApplicationKeyConfiguration(org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationKeyConfiguration) Given(io.cucumber.java.en.Given)

Example 5 with ApplicationDataLookupKey

use of org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey in project open-smart-grid-platform by OSGP.

the class SmartMeteringConfigurationEndpoint method getRsaEncrypterForApplication.

private RsaEncrypter getRsaEncrypterForApplication(final String organisationIdentification) throws OsgpException {
    final ApplicationKeyConfiguration applicationKeyConfiguration = this.applicationKeyConfigurationRepository.findById(new ApplicationDataLookupKey(organisationIdentification, this.webserviceNotificationApplicationName)).orElseThrow(() -> new OsgpException(ComponentType.WS_SMART_METERING, "No public key found for application " + this.webserviceNotificationApplicationName + " and organisation " + organisationIdentification));
    final String publicKeyLocation = applicationKeyConfiguration.getPublicKeyLocation();
    try {
        final Resource keyResource = new FileSystemResource(publicKeyLocation);
        final RsaEncrypter applicationRsaEncrypter = new RsaEncrypter();
        applicationRsaEncrypter.setPublicKeyStore(keyResource.getFile());
        return applicationRsaEncrypter;
    } catch (final IOException e) {
        throw new OsgpException(ComponentType.WS_SMART_METERING, "Could not get public key file for application " + this.webserviceNotificationApplicationName + " and organisation " + organisationIdentification);
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ApplicationKeyConfiguration(org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationKeyConfiguration) ApplicationDataLookupKey(org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey) Resource(org.springframework.core.io.Resource) FileSystemResource(org.springframework.core.io.FileSystemResource) FileSystemResource(org.springframework.core.io.FileSystemResource) RsaEncrypter(org.opensmartgridplatform.shared.security.RsaEncrypter) IOException(java.io.IOException)

Aggregations

ApplicationDataLookupKey (org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey)6 GenericNotification (org.opensmartgridplatform.adapter.ws.schema.shared.notification.GenericNotification)3 Serializable (java.io.Serializable)2 JMSException (javax.jms.JMSException)2 ApplicationKeyConfiguration (org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationKeyConfiguration)2 CorrelationIds (org.opensmartgridplatform.shared.infra.jms.CorrelationIds)2 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)2 Given (io.cucumber.java.en.Given)1 IOException (java.io.IOException)1 NotificationWebServiceConfiguration (org.opensmartgridplatform.adapter.ws.domain.entities.NotificationWebServiceConfiguration)1 NotificationType (org.opensmartgridplatform.adapter.ws.schema.core.notification.NotificationType)1 NotificationType (org.opensmartgridplatform.adapter.ws.schema.smartmetering.notification.NotificationType)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 RsaEncrypter (org.opensmartgridplatform.shared.security.RsaEncrypter)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1 Resource (org.springframework.core.io.Resource)1