All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.security.keyvault.keys.implementation.KeyVaultKeyHelper Maven / Gradle / Ivy

There is a newer version: 4.9.0
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.security.keyvault.keys.implementation;

import com.azure.security.keyvault.keys.models.JsonWebKey;
import com.azure.security.keyvault.keys.models.KeyVaultKey;

public final class KeyVaultKeyHelper {
    private static KeyVaultKeyAccessor accessor;

    public interface KeyVaultKeyAccessor {
        KeyVaultKey createKeyVaultKey(JsonWebKey jsonWebKey);
    }

    public static KeyVaultKey createKeyVaultKey(JsonWebKey jsonWebKey) {
        // If the class hasn't been loaded yet the accessor won't be set. Attempt to load the class before using the
        // accessor.
        if (accessor == null) {
            try {
                Class.forName(KeyVaultKey.class.getName(), true, KeyVaultKeyHelper.class.getClassLoader());
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        return accessor.createKeyVaultKey(jsonWebKey);
    }

    public static void setAccessor(KeyVaultKeyAccessor accessor) {
        KeyVaultKeyHelper.accessor = accessor;
    }

    private KeyVaultKeyHelper() {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy