use of com.azure.resourcemanager.resources.fluentcore.policy.AuthenticationPolicy in project azure-maven-plugins by microsoft.
the class AppServiceKuduManager method getClient.
public static AppServiceKuduManager getClient(@Nonnull WebAppBase webAppBase, @Nonnull IAppService appService) {
// com/azure/resourcemanager/appservice/implementation/KuduClient.java
if (webAppBase.defaultHostname() == null) {
throw new AzureToolkitRuntimeException("Cannot initialize kudu client before web app is created");
}
String host = webAppBase.defaultHostname().toLowerCase(Locale.ROOT).replace("http://", "").replace("https://", "");
String[] parts = host.split("\\.", 2);
host = parts[0] + ".scm." + parts[1];
host = "https://" + host;
final List<HttpPipelinePolicy> policies = Utils.getPolicyFromPipeline(webAppBase.manager().httpPipeline(), policy -> !(policy instanceof AuthenticationPolicy || policy instanceof ProviderRegistrationPolicy || policy instanceof AuxiliaryAuthenticationPolicy));
policies.add(new KuduAuthenticationPolicy(webAppBase));
final HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])).httpClient(webAppBase.manager().httpPipeline().getHttpClient()).build();
final KuduService kuduService = RestProxy.create(KuduService.class, httpPipeline, SerializerFactory.createDefaultManagementSerializerAdapter());
return new AppServiceKuduManager(host, kuduService, appService);
}
use of com.azure.resourcemanager.resources.fluentcore.policy.AuthenticationPolicy in project azure-maven-plugins by microsoft.
the class AzureFunctionsResourceManager method getClient.
public static AzureFunctionsResourceManager getClient(@Nonnull WebAppBase functionApp, @Nonnull IFunctionAppBase appService) {
// com/azure/resourcemanager/appservice/implementation/KuduClient.java
if (!(functionApp instanceof FunctionApp || functionApp instanceof FunctionDeploymentSlot)) {
throw new AzureToolkitRuntimeException("Functions resource manager only applies to Azure Functions");
}
final List<HttpPipelinePolicy> policies = Utils.getPolicyFromPipeline(functionApp.manager().httpPipeline(), policy -> !(policy instanceof AuthenticationPolicy || policy instanceof ProviderRegistrationPolicy || policy instanceof AuxiliaryAuthenticationPolicy));
policies.add(new AddHeadersPolicy(new HttpHeaders(Collections.singletonMap("x-functions-key", appService.getMasterKey()))));
final HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])).httpClient(functionApp.manager().httpPipeline().getHttpClient()).build();
final FunctionsService functionsService = RestProxy.create(FunctionsService.class, httpPipeline, SerializerFactory.createDefaultManagementSerializerAdapter());
return new AzureFunctionsResourceManager(functionsService, appService);
}
Aggregations