use of org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationKeyConfiguration 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);
}
use of org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationKeyConfiguration 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);
}
}
Aggregations