Search in sources :

Example 1 with SecretTypes

use of org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes in project open-smart-grid-platform by OSGP.

the class SecretManagementService method createGetSecretsRequest.

private GetSecretsRequest createGetSecretsRequest(final String deviceIdentification, final List<SecurityKeyType> keyTypes) {
    final GetSecretsRequest request = new GetSecretsRequest();
    request.setDeviceId(deviceIdentification);
    request.setSecretTypes(new SecretTypes());
    final List<SecretType> secretTypeList = request.getSecretTypes().getSecretType();
    keyTypes.stream().forEach(kt -> secretTypeList.add(kt.toSecretType()));
    return request;
}
Also used : SecretType(org.opensmartgridplatform.ws.schema.core.secret.management.SecretType) SecretTypes(org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes) GetSecretsRequest(org.opensmartgridplatform.ws.schema.core.secret.management.GetSecretsRequest)

Example 2 with SecretTypes

use of org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes in project open-smart-grid-platform by OSGP.

the class SecretManagementService method activateNewKeys.

public void activateNewKeys(final MessageMetadata messageMetadata, final String deviceIdentification, final List<SecurityKeyType> keyTypes) {
    final ActivateSecretsRequest request = new ActivateSecretsRequest();
    request.setDeviceId(deviceIdentification);
    request.setSecretTypes(new SecretTypes());
    final List<SecretType> secretTypeList = request.getSecretTypes().getSecretType();
    keyTypes.forEach(kt -> secretTypeList.add(kt.toSecretType()));
    this.secretManagementClient.activateSecretsRequest(messageMetadata, request);
}
Also used : SecretType(org.opensmartgridplatform.ws.schema.core.secret.management.SecretType) SecretTypes(org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes) ActivateSecretsRequest(org.opensmartgridplatform.ws.schema.core.secret.management.ActivateSecretsRequest)

Example 3 with SecretTypes

use of org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes in project open-smart-grid-platform by OSGP.

the class SecretManagementService method createGetNewSecretsRequest.

private GetNewSecretsRequest createGetNewSecretsRequest(final String deviceIdentification, final List<SecurityKeyType> keyTypes) {
    final GetNewSecretsRequest request = new GetNewSecretsRequest();
    request.setDeviceId(deviceIdentification);
    request.setSecretTypes(new SecretTypes());
    final List<SecretType> secretTypeList = request.getSecretTypes().getSecretType();
    keyTypes.stream().forEach(kt -> secretTypeList.add(kt.toSecretType()));
    return request;
}
Also used : SecretType(org.opensmartgridplatform.ws.schema.core.secret.management.SecretType) SecretTypes(org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes) GetNewSecretsRequest(org.opensmartgridplatform.ws.schema.core.secret.management.GetNewSecretsRequest)

Example 4 with SecretTypes

use of org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes in project open-smart-grid-platform by OSGP.

the class SecretManagementService method generate128BitsKeysAndStoreAsNewKeys.

/**
 * Generates a new key that can be used as DLMS master key, authentication key, global unicast
 * encryption key, M-Bus Default key or M-Bus User key.
 *
 * <p>The master keys (DLMS master or M-Bus Default) cannot be changed on a device, but can be
 * generated for use in tests or with simulated devices.
 *
 * @param messageMetadata the metadata of the request message
 * @param deviceIdentification the device identification for which to generate the keys
 * @param keyTypes the requested key types
 * @return a new 128bits key, unencrypted.
 */
public Map<SecurityKeyType, byte[]> generate128BitsKeysAndStoreAsNewKeys(final MessageMetadata messageMetadata, final String deviceIdentification, final List<SecurityKeyType> keyTypes) {
    final SecretTypes secretTypes = new SecretTypes();
    final GenerateAndStoreSecretsRequest request = this.createGenerateAndStoreSecretsRequest(deviceIdentification, secretTypes);
    secretTypes.getSecretType().addAll(keyTypes.stream().map(SecurityKeyType::toSecretType).collect(toList()));
    final GenerateAndStoreSecretsResponse response = this.secretManagementClient.generateAndStoreSecrets(messageMetadata, request);
    final TypedSecrets typedSecrets = response.getTypedSecrets();
    final List<TypedSecret> typedSecretList = typedSecrets.getTypedSecret();
    this.validateGenerateAndStoreResponse(keyTypes, response, typedSecretList);
    return this.convertSoapSecretsToSecretMapByType(typedSecrets.getTypedSecret());
}
Also used : GenerateAndStoreSecretsRequest(org.opensmartgridplatform.ws.schema.core.secret.management.GenerateAndStoreSecretsRequest) GenerateAndStoreSecretsResponse(org.opensmartgridplatform.ws.schema.core.secret.management.GenerateAndStoreSecretsResponse) SecretTypes(org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes) TypedSecrets(org.opensmartgridplatform.ws.schema.core.secret.management.TypedSecrets) SecurityKeyType(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.SecurityKeyType) TypedSecret(org.opensmartgridplatform.ws.schema.core.secret.management.TypedSecret)

Example 5 with SecretTypes

use of org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes 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)

Aggregations

SecretTypes (org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes)8 SecretType (org.opensmartgridplatform.secretmanagement.application.domain.SecretType)3 TypedSecret (org.opensmartgridplatform.secretmanagement.application.domain.TypedSecret)3 SecretType (org.opensmartgridplatform.ws.schema.core.secret.management.SecretType)3 TypedSecrets (org.opensmartgridplatform.ws.schema.core.secret.management.TypedSecrets)3 GenerateAndStoreSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.GenerateAndStoreSecretsResponse)2 SecurityKeyType (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.SecurityKeyType)1 ActivateSecretsRequest (org.opensmartgridplatform.ws.schema.core.secret.management.ActivateSecretsRequest)1 ActivateSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.ActivateSecretsResponse)1 GenerateAndStoreSecretsRequest (org.opensmartgridplatform.ws.schema.core.secret.management.GenerateAndStoreSecretsRequest)1 GetNewSecretsRequest (org.opensmartgridplatform.ws.schema.core.secret.management.GetNewSecretsRequest)1 GetNewSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.GetNewSecretsResponse)1 GetSecretsRequest (org.opensmartgridplatform.ws.schema.core.secret.management.GetSecretsRequest)1 GetSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.GetSecretsResponse)1 TypedSecret (org.opensmartgridplatform.ws.schema.core.secret.management.TypedSecret)1