use of com.microsoft.azure.hdinsight.spark.common.SparkBatchSubmission in project azure-tools-for-java by Microsoft.
the class JobUtils method authenticate.
public static AbstractMap.SimpleImmutableEntry<Integer, List<Header>> authenticate(IClusterDetail clusterDetail) throws HDIException, IOException {
final SparkBatchSubmission submission = SparkBatchSubmission.getInstance();
final String livyUrl = clusterDetail instanceof LivyCluster ? ((LivyCluster) clusterDetail).getLivyBatchUrl() : null;
if (livyUrl == null) {
throw new IOException("Can't get livy connection Url");
}
if (!StringUtils.isEmpty(clusterDetail.getHttpUserName()) && !StringUtils.isEmpty(clusterDetail.getHttpPassword())) {
submission.setUsernamePasswordCredential(clusterDetail.getHttpUserName(), clusterDetail.getHttpPassword());
}
final com.microsoft.azure.hdinsight.sdk.common.HttpResponse response = clusterDetail instanceof MfaEspCluster ? submission.negotiateAuthMethodWithResp(livyUrl) : submission.getHttpResponseViaHead(livyUrl);
final int statusCode = response.getCode();
if (statusCode >= 200 && statusCode <= 302) {
return new AbstractMap.SimpleImmutableEntry<>(statusCode, response.getHeaders());
}
throw new AuthenticationException(response.getContent(), statusCode);
}
Aggregations