Search in sources :

Example 6 with TypedSecret

use of org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret in project open-smart-grid-platform by OSGP.

the class SecretManagementEndpoint method storeSecrets.

public StoreSecretsResponse storeSecrets(final StoreSecretsRequest request) throws OsgpException {
    final TypedSecrets soapTypedSecrets = request.getTypedSecrets();
    final List<TypedSecret> typedSecretList = this.converter.convertToTypedSecrets(soapTypedSecrets);
    this.secretManagementService.storeSecrets(request.getDeviceId(), typedSecretList);
    return new StoreSecretsResponse();
}
Also used : StoreSecretsResponse(org.opensmartgridplatform.ws.schema.core.secret.management.StoreSecretsResponse) GenerateAndStoreSecretsResponse(org.opensmartgridplatform.ws.schema.core.secret.management.GenerateAndStoreSecretsResponse) TypedSecrets(org.opensmartgridplatform.ws.schema.core.secret.management.TypedSecrets) TypedSecret(org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret)

Example 7 with TypedSecret

use of org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret in project open-smart-grid-platform by OSGP.

the class SecretManagementService method storeSecrets.

public synchronized void storeSecrets(final String deviceIdentification, final List<TypedSecret> typedSecrets) {
    for (final TypedSecret typedSecret : typedSecrets) {
        this.withdrawExistingKeysWithStatusNew(deviceIdentification, typedSecret.getSecretType());
    }
    final List<EncryptedTypedSecret> aesSecrets = typedSecrets.stream().map(ts -> new EncryptedTypedSecret(ts.getSecret(), ts.getSecretType())).map(this::reencryptRsa2Aes).collect(toList());
    this.storeAesSecrets(deviceIdentification, aesSecrets);
}
Also used : TypedSecret(org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret)

Example 8 with TypedSecret

use of org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret in project open-smart-grid-platform by OSGP.

the class SecretManagementEndpoint method generateAndStoreSecrets.

public GenerateAndStoreSecretsResponse generateAndStoreSecrets(final GenerateAndStoreSecretsRequest request) throws OsgpException {
    final GenerateAndStoreSecretsResponse response = new GenerateAndStoreSecretsResponse();
    final SecretTypes soapSecretTypes = request.getSecretTypes();
    final List<SecretType> secretTypeList = this.converter.convertToSecretTypes(soapSecretTypes);
    final List<TypedSecret> typedSecretList = this.secretManagementService.generateAndStoreSecrets(request.getDeviceId(), secretTypeList);
    response.setTypedSecrets(this.converter.convertToSoapTypedSecrets(typedSecretList));
    return response;
}
Also used : GenerateAndStoreSecretsResponse(org.opensmartgridplatform.ws.schema.core.secret.management.GenerateAndStoreSecretsResponse) SecretType(org.opensmartgridplatform.secretmanagement.application.domain.SecretType) SecretTypes(org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes) TypedSecret(org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret)

Example 9 with TypedSecret

use of org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret in project open-smart-grid-platform by OSGP.

the class SecretManagementEndpoint method getNewSecrets.

public GetNewSecretsResponse getNewSecrets(final GetNewSecretsRequest request) throws OsgpException {
    final GetNewSecretsResponse response = new GetNewSecretsResponse();
    final SecretTypes soapSecretTypes = request.getSecretTypes();
    final List<SecretType> secretTypeList = this.converter.convertToSecretTypes(soapSecretTypes);
    final List<TypedSecret> typedSecrets = this.secretManagementService.retrieveNewSecrets(request.getDeviceId(), secretTypeList);
    final TypedSecrets soapTypedSecrets = this.converter.convertToSoapTypedSecrets(typedSecrets);
    response.setTypedSecrets(soapTypedSecrets);
    return response;
}
Also used : GetNewSecretsResponse(org.opensmartgridplatform.ws.schema.core.secret.management.GetNewSecretsResponse) SecretType(org.opensmartgridplatform.secretmanagement.application.domain.SecretType) SecretTypes(org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes) TypedSecrets(org.opensmartgridplatform.ws.schema.core.secret.management.TypedSecrets) TypedSecret(org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret)

Example 10 with TypedSecret

use of org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret in project open-smart-grid-platform by OSGP.

the class SecretManagementEndpoint method getSecrets.

public GetSecretsResponse getSecrets(final GetSecretsRequest request) throws OsgpException {
    final GetSecretsResponse response = new GetSecretsResponse();
    final SecretTypes soapSecretTypes = request.getSecretTypes();
    final List<SecretType> secretTypeList = this.converter.convertToSecretTypes(soapSecretTypes);
    final List<TypedSecret> typedSecrets = this.secretManagementService.retrieveSecrets(request.getDeviceId(), secretTypeList);
    final TypedSecrets soapTypedSecrets = this.converter.convertToSoapTypedSecrets(typedSecrets);
    response.setTypedSecrets(soapTypedSecrets);
    return response;
}
Also used : GetSecretsResponse(org.opensmartgridplatform.ws.schema.core.secret.management.GetSecretsResponse) SecretType(org.opensmartgridplatform.secretmanagement.application.domain.SecretType) SecretTypes(org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes) TypedSecrets(org.opensmartgridplatform.ws.schema.core.secret.management.TypedSecrets) TypedSecret(org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret)

Aggregations

TypedSecret (org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret)15 Test (org.junit.jupiter.api.Test)8 DbEncryptionKeyReference (org.opensmartgridplatform.secretmanagement.application.domain.DbEncryptionKeyReference)7 DbEncryptedSecret (org.opensmartgridplatform.secretmanagement.application.domain.DbEncryptedSecret)4 SecretType (org.opensmartgridplatform.secretmanagement.application.domain.SecretType)4 TypedSecrets (org.opensmartgridplatform.ws.schema.core.secret.management.TypedSecrets)4 List (java.util.List)3 EncryptedSecret (org.opensmartgridplatform.shared.security.EncryptedSecret)3 SecretTypes (org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes)3 Date (java.util.Date)2 GenerateAndStoreSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.GenerateAndStoreSecretsResponse)2 NoSuchElementException (java.util.NoSuchElementException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 EncrypterException (org.opensmartgridplatform.shared.exceptionhandling.EncrypterException)1 GetNewSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.GetNewSecretsResponse)1 GetSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.GetSecretsResponse)1 StoreSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.StoreSecretsResponse)1