Class AzureIdentityReactiveService
java.lang.Object
it.pagopa.swclient.mil.azureservices.identity.service.AzureIdentityReactiveService
Reactive service to get an access token for an Azure resource using a cache to reduce the invocations of Microsoft Entra ID.
- Author:
- Antonio Tarricone
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<String, AccessToken> Cache of access tokens.private AzureIdentityClientReactive client to retrieve an access token from Microsoft Entra ID. -
Constructor Summary
ConstructorsConstructorDescriptionAzureIdentityReactiveService(Optional<String> identityClientId, Optional<String> identityEndpoint, Optional<String> identityHeader, Optional<String> authorityHost, Optional<String> tenantId, Optional<String> clientId, Optional<String> federatedTokenFile, jakarta.enterprise.inject.Instance<AzureIdentityClient> anyIdentityClient) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the access tokens cache.io.smallrye.mutiny.Uni<AccessToken> getAccessToken(String scope) Retrieves an access token for an Azure resource looking in the cache for a valid one and, in case of cache-miss, invokes Microsoft Entra ID.Returns identity client in use.io.smallrye.mutiny.Uni<AccessToken> Retrieves an access token from Microsoft Entra ID and stores it in the cache.
-
Field Details
-
identityClient
Reactive client to retrieve an access token from Microsoft Entra ID.
-
cache
Cache of access tokens. The key is the
Scope.
-
-
Constructor Details
-
AzureIdentityReactiveService
@Inject AzureIdentityReactiveService(Optional<String> identityClientId, Optional<String> identityEndpoint, Optional<String> identityHeader, Optional<String> authorityHost, Optional<String> tenantId, Optional<String> clientId, Optional<String> federatedTokenFile, @Any jakarta.enterprise.inject.Instance<AzureIdentityClient> anyIdentityClient) Constructor.
- Parameters:
identityClientId- Client ID to get access token by means of user managed identityidentityEndpoint- Endpoint to get access token by means of system(user managed identityidentityHeader- Value to use to set x-identity-headerauthorityHost- Endpoint to get access token by means of workload identitytenantId- Tenant IDclientId- Client IDfederatedTokenFile- Token file with client assertionanyIdentityClient- Any identity client
-
-
Method Details
-
getNewAccessTokenAndCacheIt
Retrieves an access token from Microsoft Entra ID and stores it in the cache.
- Parameters:
scope-Scope- Returns:
AccessToken
-
getAccessToken
Retrieves an access token for an Azure resource looking in the cache for a valid one and, in case of cache-miss, invokes Microsoft Entra ID.
- Parameters:
scope-Scope- Returns:
AccessToken
-
clearAccessTokenCache
public void clearAccessTokenCache()Clears the access tokens cache.
-
getIdentityClient
Returns identity client in use.
- Returns:
AzureIdentityClient
-