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;
}
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);
}
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;
}
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());
}
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;
}
Aggregations