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

com.azure.identity.VirtualMachineMsiCredential Maven / Gradle / Ivy

The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.identity;

import com.azure.core.credential.AccessToken;
import com.azure.core.annotation.Immutable;
import com.azure.core.credential.TokenRequestContext;
import com.azure.identity.implementation.IdentityClient;
import reactor.core.publisher.Mono;

/**
 * The Managed Service Identity credential for Virtual Machines.
 */
@Immutable
class VirtualMachineMsiCredential extends ManagedIdentityServiceCredential {

    /**
     * Creates an instance of VirtualMachineMSICredential.
     * @param clientId the client id of user assigned or system assigned identity
     * @param identityClient the identity client to acquire a token with.
     */
    VirtualMachineMsiCredential(String clientId, IdentityClient identityClient) {
        super(clientId, identityClient, "AZURE VM IMDS ENDPOINT");
    }

    /**
     * Gets an access token for the token request.
     *
     * @param request The details of the token request.
     * @return A publisher that emits an {@link AccessToken}.
     */
    public Mono authenticate(TokenRequestContext request) {
        return identityClient.authenticateWithManagedIdentityMsalClient(request);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy