Search in sources :

Example 1 with AzureAuthenticationMode

use of tech.pegasys.web3signer.signing.config.AzureAuthenticationMode in project web3signer by ConsenSys.

the class AzureSecretSigningMetadataDeserializer method deserialize.

@Override
public AzureSecretSigningMetadata deserialize(final JsonParser parser, final DeserializationContext ctxt) throws IOException {
    KeyType keyType = null;
    String clientId = null;
    String clientSecret = null;
    String tenantId = null;
    String vaultName = null;
    String secretName = null;
    AzureAuthenticationMode authenticationMode = null;
    final JsonNode node = parser.getCodec().readTree(parser);
    if (node.get(KEY_TYPE) != null) {
        try {
            keyType = KeyType.valueOf(node.get(KEY_TYPE).asText());
        } catch (final IllegalArgumentException e) {
            throw new JsonMappingException(parser, "Error converting " + KEY_TYPE + ": " + e.getMessage());
        }
    }
    if (node.get(AUTH_MODE) != null) {
        try {
            authenticationMode = AzureAuthenticationMode.valueOf(node.get(AUTH_MODE).asText());
        } catch (final IllegalArgumentException e) {
            throw new JsonMappingException(parser, "Error converting " + AUTH_MODE + ": " + e.getMessage());
        }
    }
    if (node.get(VAULT_NAME) != null) {
        vaultName = node.get(VAULT_NAME).asText();
    }
    if (node.get(SECRET_NAME) != null) {
        secretName = node.get(SECRET_NAME).asText();
    }
    if (node.get(CLIENT_ID) != null) {
        clientId = node.get(CLIENT_ID).asText();
    }
    if (node.get(TENANT_ID) != null) {
        tenantId = node.get(TENANT_ID).asText();
    }
    if (node.get(CLIENT_SECRET) != null) {
        clientSecret = node.get(CLIENT_SECRET).asText();
    }
    final AzureSecretSigningMetadata azureSecretSigningMetadata = new AzureSecretSigningMetadata(clientId, clientSecret, tenantId, vaultName, secretName, authenticationMode, keyType);
    validate(parser, azureSecretSigningMetadata);
    return azureSecretSigningMetadata;
}
Also used : KeyType(tech.pegasys.web3signer.signing.KeyType) AzureAuthenticationMode(tech.pegasys.web3signer.signing.config.AzureAuthenticationMode) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 KeyType (tech.pegasys.web3signer.signing.KeyType)1 AzureAuthenticationMode (tech.pegasys.web3signer.signing.config.AzureAuthenticationMode)1