com.microsoft.azure.credentials.AzureTokenCredentials Java Examples

The following examples show how to use com.microsoft.azure.credentials.AzureTokenCredentials. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AzureFileSystemBehaviorITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
private static boolean isHttpsTrafficOnly() throws IOException {
	if (StringUtils.isNullOrWhitespaceOnly(RESOURCE_GROUP) || StringUtils.isNullOrWhitespaceOnly(TOKEN_CREDENTIALS_FILE)) {
		// default to https only, as some fields are missing
		return true;
	}

	Assume.assumeTrue("Azure storage account not configured, skipping test...", !StringUtils.isNullOrWhitespaceOnly(ACCOUNT));

	AzureTokenCredentials credentials = ApplicationTokenCredentials.fromFile(new File(TOKEN_CREDENTIALS_FILE));
	Azure azure =
		StringUtils.isNullOrWhitespaceOnly(SUBSCRIPTION_ID) ?
			Azure.authenticate(credentials).withDefaultSubscription() :
			Azure.authenticate(credentials).withSubscription(SUBSCRIPTION_ID);

	return azure.storageAccounts().getByResourceGroup(RESOURCE_GROUP, ACCOUNT).inner().enableHttpsTrafficOnly();
}
 
Example #2
Source File: Utils.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
/**
 * Try to extract the environment the client is authenticated to based
 * on the information on the rest client.
 * @param restClient the RestClient instance
 * @return the non-null AzureEnvironment
 */
public static AzureEnvironment extractAzureEnvironment(RestClient restClient) {
    AzureEnvironment environment = null;
    if (restClient.credentials() instanceof AzureTokenCredentials) {
        environment = ((AzureTokenCredentials) restClient.credentials()).environment();
    } else {
        String baseUrl = restClient.retrofit().baseUrl().toString();
        for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) {
            if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) {
                environment = env;
                break;
            }
        }
        if (environment == null) {
            throw new IllegalArgumentException("Unknown resource manager endpoint " + baseUrl);
        }
    }
    return environment;
}
 
Example #3
Source File: AzureFileSystemBehaviorITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
private static boolean isHttpsTrafficOnly() throws IOException {
	if (StringUtils.isNullOrWhitespaceOnly(RESOURCE_GROUP) || StringUtils.isNullOrWhitespaceOnly(TOKEN_CREDENTIALS_FILE)) {
		// default to https only, as some fields are missing
		return true;
	}

	Assume.assumeTrue("Azure storage account not configured, skipping test...", !StringUtils.isNullOrWhitespaceOnly(ACCOUNT));

	AzureTokenCredentials credentials = ApplicationTokenCredentials.fromFile(new File(TOKEN_CREDENTIALS_FILE));
	Azure azure =
		StringUtils.isNullOrWhitespaceOnly(SUBSCRIPTION_ID) ?
			Azure.authenticate(credentials).withDefaultSubscription() :
			Azure.authenticate(credentials).withSubscription(SUBSCRIPTION_ID);

	return azure.storageAccounts().getByResourceGroup(RESOURCE_GROUP, ACCOUNT).inner().enableHttpsTrafficOnly();
}
 
Example #4
Source File: AzureClientCredentials.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private AzureTokenCredentials getAzureCredentials() {
    String tenantId = credentialView.getTenantId();
    String clientId = credentialView.getAccessKey();
    String secretKey = credentialView.getSecretKey();
    String subscriptionId = credentialView.getSubscriptionId();
    AzureEnvironment azureEnvironment = AzureEnvironment.AZURE;
    ApplicationTokenCredentials applicationTokenCredentials = new ApplicationTokenCredentials(clientId, tenantId, secretKey, azureEnvironment);
    Optional<Boolean> codeGrantFlow = Optional.ofNullable(credentialView.codeGrantFlow());

    AzureTokenCredentials result = applicationTokenCredentials;
    if (codeGrantFlow.orElse(Boolean.FALSE)) {
        String refreshToken = credentialView.getRefreshToken();
        if (StringUtils.isNotEmpty(refreshToken)) {
            LOGGER.info("Creating Azure credentials for a new delegated token with refresh token, credential: {}", credentialView.getName());
            String resource = azureEnvironment.managementEndpoint();
            CBRefreshTokenClient refreshTokenClient = cbRefreshTokenClientProvider.getCBRefreshTokenClient(azureEnvironment.activeDirectoryEndpoint());
            AuthenticationResult authenticationResult = refreshTokenClient.refreshToken(tenantId, clientId, secretKey, resource, refreshToken, false);

            if (authenticationResult == null) {
                String msg = String.format("New token couldn't be obtain with refresh token for credential: %s", credentialView.getName());
                LOGGER.warn(msg);
                throw new CloudConnectorException(msg);
            }

            Map<String, AuthenticationResult> tokens = Map.of(resource, authenticationResult);
            result = new CbDelegatedTokenCredentials(applicationTokenCredentials, resource, tokens, secretKey, authenticationContextProvider,
                    cbRefreshTokenClientProvider);
        } else {
            LOGGER.info("Creating Azure credentials for a new delegated token with authorization code, credential: {}", credentialView.getName());
            String appReplyUrl = credentialView.getAppReplyUrl();
            String authorizationCode = credentialView.getAuthorizationCode();
            result = new CbDelegatedTokenCredentials(applicationTokenCredentials, appReplyUrl, authorizationCode, secretKey, authenticationContextProvider,
                    cbRefreshTokenClientProvider);
        }
    } else {
        LOGGER.info("Creating Azure credentials with application token credentials, credential: {}", credentialView.getName());
    }
    return result.withDefaultSubscriptionId(subscriptionId);
}
 
Example #5
Source File: AuthorizationManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
* Creates an instance of AuthorizationManager that exposes Authorization resource management API entry points.
*
* @param credentials the credentials to use
* @param subscriptionId the subscription UUID
* @return the AuthorizationManager
*/
public static AuthorizationManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new AuthorizationManager(new RestClient.Builder()
        .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
        .withCredentials(credentials)
        .withSerializerAdapter(new AzureJacksonAdapter())
        .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
        .withInterceptor(new ProviderRegistrationInterceptor(credentials))
        .build(), subscriptionId);
}
 
Example #6
Source File: AppServiceManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of StorageManager that exposes storage resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription UUID
 * @return the StorageManager
 */
public static AppServiceManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new AppServiceManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), credentials.domain(), subscriptionId);
}
 
Example #7
Source File: ContainerRegistryManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of ContainerRegistryManager that exposes Registry resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription
 * @return the ContainerRegistryManager
 */
public static ContainerRegistryManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new ContainerRegistryManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), subscriptionId);
}
 
Example #8
Source File: AzureConfigurableImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public T withAuxiliaryCredentials(AzureTokenCredentials... tokens) {
    if (tokens != null) {
        if (tokens.length > 3) {
            throw new IllegalArgumentException("Only can hold up to three auxiliary tokens.");
        }
        AuxiliaryCredentialsInterceptor interceptor = new AuxiliaryCredentialsInterceptor(tokens);
        this.restClientBuilder = this.restClientBuilder.withInterceptor(interceptor);
    }
    return (T) this;
}
 
Example #9
Source File: AzureConfigurableImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
protected RestClient buildRestClient(AzureTokenCredentials credentials, AzureEnvironment.Endpoint endpoint) {
    RestClient client =  restClientBuilder
            .withBaseUrl(credentials.environment(), endpoint)
            .withCredentials(credentials)
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build();
    if (client.httpClient().proxy() != null) {
        credentials.withProxy(client.httpClient().proxy());
    }
    return client;
}
 
Example #10
Source File: ResourceManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of ResourceManager that exposes resource management API entry points.
 *
 * @param credentials the credentials to use
 * @return the ResourceManager instance
 */
public static ResourceManager.Authenticated authenticate(AzureTokenCredentials credentials) {
    return new AuthenticatedImpl(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build());
}
 
Example #11
Source File: SqlServerManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of SqlServer that exposes Compute resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription
 * @return the SqlServer
 */
public static SqlServerManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new SqlServerManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), credentials.domain(), subscriptionId);
}
 
Example #12
Source File: AzureClientConfiguration.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Bean
public Azure getAzure() {
        Credential credential = azureProperties.getCredential();
        AzureTokenCredentials azureTokenCredentials =
                new ApplicationTokenCredentials(credential.getAppId(), credential.getTenantId(), credential.getAppPassword(), AzureEnvironment.AZURE);
        return Azure
                .configure()
                .withProxyAuthenticator(new JavaNetAuthenticator())
                .withLogLevel(LogLevel.BODY_AND_HEADERS)
                .authenticate(azureTokenCredentials)
                .withSubscription(credential.getSubscriptionId());
}
 
Example #13
Source File: SearchServiceManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of ContainerRegistryManager that exposes Registry resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription
 * @return the SearchServiceManager
 */
public static SearchServiceManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new SearchServiceManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), subscriptionId);
}
 
Example #14
Source File: GraphRbacManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private GraphRbacManager(RestClient restClient, String tenantId) {
    String graphEndpoint = AzureEnvironment.AZURE.graphEndpoint();
    if (restClient.credentials() instanceof AzureTokenCredentials) {
        graphEndpoint = ((AzureTokenCredentials) restClient.credentials()).environment().graphEndpoint();
    }
    this.graphRbacManagementClient = new GraphRbacManagementClientImpl(
            restClient.newBuilder().withBaseUrl(graphEndpoint).build()).withTenantID(tenantId);
    this.authorizationManagementClient = new AuthorizationManagementClientImpl(restClient);
    this.tenantId = tenantId;
}
 
Example #15
Source File: MonitorManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
* Creates an instance of MonitorManager that exposes Monitor API entry points.
*
* @param credentials the credentials to use
* @param subscriptionId the subscription UUID
* @return the MonitorManager
*/
public static MonitorManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new MonitorManager(new RestClient.Builder()
        .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
        .withCredentials(credentials)
        .withSerializerAdapter(new AzureJacksonAdapter())
        .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
        .withInterceptor(new ProviderRegistrationInterceptor(credentials))
        .build(), subscriptionId);
}
 
Example #16
Source File: AzureConfigurableCoreImpl.java    From autorest-clientruntime-for-java with MIT License 5 votes vote down vote up
protected RestClient buildRestClient(AzureTokenCredentials credentials, AzureEnvironment.Endpoint endpoint) {
    RestClient client =  restClientBuilder
            .withBaseUrl(credentials.environment(), endpoint)
            .withCredentials(credentials)
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build();
    if (client.httpClient().proxy() != null) {
        credentials.withProxy(client.httpClient().proxy());
    }
    return client;
}
 
Example #17
Source File: AzureAccount.java    From clouditor with Apache License 2.0 5 votes vote down vote up
public AzureTokenCredentials resolveCredentials() throws IOException {
  if (this.isAutoDiscovered()) {
    return AzureAccount.defaultCredentialProviderChain();
  } else {
    return new ApplicationTokenCredentials(
        clientId, tenantId, clientSecret, AzureEnvironment.AZURE);
  }
}
 
Example #18
Source File: ComputeManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of ComputeManager that exposes Compute resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription
 * @return the ComputeManager
 */
public static ComputeManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new ComputeManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), subscriptionId);
}
 
Example #19
Source File: ComputeManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private ComputeManager(RestClient restClient, String subscriptionId) {
    super(
            restClient,
            subscriptionId,
            new ComputeManagementClientImpl(restClient).withSubscriptionId(subscriptionId));
    storageManager = StorageManager.authenticate(restClient, subscriptionId);
    networkManager = NetworkManager.authenticate(restClient, subscriptionId);
    rbacManager = GraphRbacManager.authenticate(restClient, ((AzureTokenCredentials) (restClient.credentials())).domain());
}
 
Example #20
Source File: Azure.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Authenticate to Azure using an Azure credentials object.
 *
 * @param credentials the credentials object
 * @return the authenticated Azure client
 */
public static Authenticated authenticate(AzureTokenCredentials credentials) {
    return new AuthenticatedImpl(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), credentials.domain());
}
 
Example #21
Source File: Azure.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public Authenticated authenticate(AzureTokenCredentials credentials) {
    if (credentials.defaultSubscriptionId() != null) {
        return Azure.authenticate(buildRestClient(credentials), credentials.domain(), credentials.defaultSubscriptionId());
    } else {
        return Azure.authenticate(buildRestClient(credentials), credentials.domain());
    }
}
 
Example #22
Source File: RedisManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of RedisManager that exposes Redis resource management API entry points.
 *
 * @param credentials    the credentials to use
 * @param subscriptionId the subscription UUID
 * @return the RedisManager
 */
public static RedisManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new RedisManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), subscriptionId);
}
 
Example #23
Source File: ContainerServiceManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of ContainerServiceManager that exposes Azure Container Service resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription
 * @return the ContainerServiceManager
 */
public static ContainerServiceManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new ContainerServiceManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), subscriptionId);
}
 
Example #24
Source File: NetworkManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of NetworkManager that exposes network resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription UUID
 * @return the NetworkManager
 */
public static NetworkManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new NetworkManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), subscriptionId);
}
 
Example #25
Source File: CdnManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of CDN Manager that exposes CDN manager management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription UUID
 * @return the CDN Manager
 */
public static CdnManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new CdnManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), subscriptionId);
}
 
Example #26
Source File: DnsZoneManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of DnsZoneManager that exposes DNS zone management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription UUID
 * @return the DnsZoneManager
 */
public static DnsZoneManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new DnsZoneManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), subscriptionId);
}
 
Example #27
Source File: ServiceBusManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of ServiceBusManager that exposes servicebus management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription UUID
 * @return the ServiceBusManager
 */
public static ServiceBusManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new ServiceBusManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), subscriptionId);
}
 
Example #28
Source File: CosmosDBManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of ComputeManager that exposes Compute resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription
 * @return the ComputeManager
 */
public static CosmosDBManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new CosmosDBManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), subscriptionId);
}
 
Example #29
Source File: BatchAIManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
* Creates an instance of BatchAIManager that exposes BatchAI resource management API entry points.
*
* @param credentials the credentials to use
* @param subscriptionId the subscription UUID
* @return the BatchAIManager
*/
public static BatchAIManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new BatchAIManager(new RestClient.Builder()
        .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
        .withCredentials(credentials)
        .withSerializerAdapter(new AzureJacksonAdapter())
        .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
        .withInterceptor(new ProviderRegistrationInterceptor(credentials))
        .build(), subscriptionId);
}
 
Example #30
Source File: GraphRbacManager.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
/**
 * Creates an instance of GraphRbacManager that exposes Graph RBAC management API entry points.
 *
 * @param credentials the credentials to use
 * @return the GraphRbacManager instance
 */
public static GraphRbacManager authenticate(AzureTokenCredentials credentials) {
    return new GraphRbacManager(new RestClient.Builder()
            .withBaseUrl(credentials.environment().graphEndpoint())
            .withInterceptor(new RequestIdHeaderInterceptor())
            .withCredentials(credentials)
            .withSerializerAdapter(new AzureJacksonAdapter())
            .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
            .withInterceptor(new ProviderRegistrationInterceptor(credentials))
            .withInterceptor(new ResourceManagerThrottlingInterceptor())
            .build(), credentials.domain());
}