Search in sources :

Example 6 with RsaEncrypter

use of org.opensmartgridplatform.shared.security.RsaEncrypter in project open-smart-grid-platform by OSGP.

the class SecurityConfig method decrypterForSecretManagement.

// RsaEncrypter for decrypting secrets received by Secret Management.
@Bean(name = "decrypterForSecretManagement")
public RsaEncrypter decrypterForSecretManagement() {
    try {
        final File privateKeySecretManagementFile = this.rsaPrivateKeySecretManagement.getFile();
        final RsaEncrypter rsaEncrypter = new RsaEncrypter();
        rsaEncrypter.setPrivateKeyStore(privateKeySecretManagementFile);
        return rsaEncrypter;
    } catch (final IOException e) {
        throw new IllegalStateException("Could not initialize decrypterForSecretManagement", e);
    }
}
Also used : RsaEncrypter(org.opensmartgridplatform.shared.security.RsaEncrypter) IOException(java.io.IOException) File(java.io.File) Bean(org.springframework.context.annotation.Bean)

Example 7 with RsaEncrypter

use of org.opensmartgridplatform.shared.security.RsaEncrypter 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)

Example 8 with RsaEncrypter

use of org.opensmartgridplatform.shared.security.RsaEncrypter in project open-smart-grid-platform by OSGP.

the class SoapClientConfig method decrypterForGxfSmartMetering.

// RsaEncrypter for decrypting secrets from applications received by the DLMS protocol adapter.
@Bean(name = "decrypterForGxfSmartMetering")
public RsaEncrypter decrypterForGxfSmartMetering() {
    try {
        final File privateKeyGxfSmartMeteringFile = this.rsaPrivateKeyGxfSmartMetering.getFile();
        final RsaEncrypter rsaEncrypter = new RsaEncrypter();
        rsaEncrypter.setPrivateKeyStore(privateKeyGxfSmartMeteringFile);
        return rsaEncrypter;
    } catch (final IOException e) {
        throw new IllegalStateException("Could not initialize decrypterForGxfSmartMetering", e);
    }
}
Also used : RsaEncrypter(org.opensmartgridplatform.shared.security.RsaEncrypter) IOException(java.io.IOException) File(java.io.File) TrustManagersFactoryBean(org.springframework.ws.soap.security.support.TrustManagersFactoryBean) KeyStoreFactoryBean(org.springframework.ws.soap.security.support.KeyStoreFactoryBean) KeyManagersFactoryBean(org.springframework.ws.soap.security.support.KeyManagersFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

IOException (java.io.IOException)8 RsaEncrypter (org.opensmartgridplatform.shared.security.RsaEncrypter)8 File (java.io.File)7 Bean (org.springframework.context.annotation.Bean)7 KeyManagersFactoryBean (org.springframework.ws.soap.security.support.KeyManagersFactoryBean)4 KeyStoreFactoryBean (org.springframework.ws.soap.security.support.KeyStoreFactoryBean)4 TrustManagersFactoryBean (org.springframework.ws.soap.security.support.TrustManagersFactoryBean)4 ApplicationDataLookupKey (org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationDataLookupKey)1 ApplicationKeyConfiguration (org.opensmartgridplatform.adapter.ws.domain.entities.ApplicationKeyConfiguration)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1 Resource (org.springframework.core.io.Resource)1