Search in sources :

Example 1 with GenerateAndStoreSecretsRequest

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

the class SecretManagementService method createGenerateAndStoreSecretsRequest.

private GenerateAndStoreSecretsRequest createGenerateAndStoreSecretsRequest(final String deviceIdentification, final SecretTypes secretTypes) {
    final GenerateAndStoreSecretsRequest request = new GenerateAndStoreSecretsRequest();
    request.setDeviceId(deviceIdentification);
    request.setSecretTypes(secretTypes);
    return request;
}
Also used : GenerateAndStoreSecretsRequest(org.opensmartgridplatform.ws.schema.core.secret.management.GenerateAndStoreSecretsRequest)

Example 2 with GenerateAndStoreSecretsRequest

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

Aggregations

GenerateAndStoreSecretsRequest (org.opensmartgridplatform.ws.schema.core.secret.management.GenerateAndStoreSecretsRequest)2 SecurityKeyType (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.SecurityKeyType)1 GenerateAndStoreSecretsResponse (org.opensmartgridplatform.ws.schema.core.secret.management.GenerateAndStoreSecretsResponse)1 SecretTypes (org.opensmartgridplatform.ws.schema.core.secret.management.SecretTypes)1 TypedSecret (org.opensmartgridplatform.ws.schema.core.secret.management.TypedSecret)1 TypedSecrets (org.opensmartgridplatform.ws.schema.core.secret.management.TypedSecrets)1