Search in sources :

Example 1 with ServiceProviderConflictException

use of com.aws.greengrass.security.exceptions.ServiceProviderConflictException in project aws-greengrass-nucleus by aws-greengrass.

the class SecurityService method registerCryptoKeyProvider.

/**
 * Register crypto key provider for the key type.
 *
 * @param keyProvider Crypto key provider
 * @throws ServiceProviderConflictException if key type is already registered
 */
public void registerCryptoKeyProvider(CryptoKeySpi keyProvider) throws ServiceProviderConflictException {
    CaseInsensitiveString keyType = new CaseInsensitiveString(keyProvider.supportedKeyType());
    logger.atInfo().kv(KEY_TYPE, keyType).log("Register crypto key service provider");
    CryptoKeySpi provider = cryptoKeyProviderMap.computeIfAbsent(keyType, k -> keyProvider);
    if (!provider.equals(keyProvider)) {
        throw new ServiceProviderConflictException(String.format("Key type %s crypto key provider is registered", keyType));
    }
}
Also used : ServiceProviderConflictException(com.aws.greengrass.security.exceptions.ServiceProviderConflictException) CaseInsensitiveString(com.aws.greengrass.config.CaseInsensitiveString)

Example 2 with ServiceProviderConflictException

use of com.aws.greengrass.security.exceptions.ServiceProviderConflictException in project aws-greengrass-nucleus by aws-greengrass.

the class SecurityService method registerMqttConnectionProvider.

/**
 * Register mqtt connection provider for the key type.
 *
 * @param mqttProvider Mqtt connection provider
 * @throws ServiceProviderConflictException if key type is already registered
 */
public void registerMqttConnectionProvider(MqttConnectionSpi mqttProvider) throws ServiceProviderConflictException {
    CaseInsensitiveString keyType = new CaseInsensitiveString(mqttProvider.supportedKeyType());
    logger.atInfo().kv(KEY_TYPE, keyType).log("Register crypto key service provider");
    MqttConnectionSpi provider = mqttConnectionProviderMap.computeIfAbsent(keyType, k -> mqttProvider);
    if (!provider.equals(mqttProvider)) {
        throw new ServiceProviderConflictException(String.format("Key type %s mqtt connection provider is " + "registered", keyType));
    }
}
Also used : ServiceProviderConflictException(com.aws.greengrass.security.exceptions.ServiceProviderConflictException) CaseInsensitiveString(com.aws.greengrass.config.CaseInsensitiveString)

Aggregations

CaseInsensitiveString (com.aws.greengrass.config.CaseInsensitiveString)2 ServiceProviderConflictException (com.aws.greengrass.security.exceptions.ServiceProviderConflictException)2