use of com.microsoft.azuretools.authmanage.models.AuthMethodDetails in project azure-tools-for-java by Microsoft.
the class AzureSignInAction method doSignIn.
public static boolean doSignIn(AuthMethodManager authMethodManager, Project project) throws Exception {
boolean isSignIn = authMethodManager.isSignedIn();
if (isSignIn)
return true;
SignInWindow w = SignInWindow.go(authMethodManager.getAuthMethodDetails(), project);
if (w != null) {
AuthMethodDetails authMethodDetailsUpdated = w.getAuthMethodDetails();
authMethodManager.setAuthMethodDetails(authMethodDetailsUpdated);
SelectSubscriptionsAction.onShowSubscriptions(project);
authMethodManager.notifySignInEventListener();
}
return authMethodManager.isSignedIn();
}
use of com.microsoft.azuretools.authmanage.models.AuthMethodDetails in project azure-tools-for-java by Microsoft.
the class SignInDialog method okPressed.
@Override
public void okPressed() {
// dropCurrentAzureManager();
AuthMethodDetails authMethodDetailsResult = new AuthMethodDetails();
if (rbtnInteractive.getSelection()) {
doSignIn();
if (StringUtils.isNullOrEmpty(accountEmail)) {
System.out.println("Canceled by the user.");
return;
}
authMethodDetailsResult.setAuthMethod(AuthMethod.AD);
authMethodDetailsResult.setAccountEmail(accountEmail);
} else {
// automated
String authPath = textAuthenticationFilePath.getText();
if (StringUtils.isNullOrWhiteSpace(authPath)) {
this.setErrorMessage("Select authentication file");
return;
}
authMethodDetailsResult.setAuthMethod(AuthMethod.SP);
// TODO: check the file is valid
authMethodDetailsResult.setCredFilePath(authPath);
}
this.authMethodDetails = authMethodDetailsResult;
super.okPressed();
}
use of com.microsoft.azuretools.authmanage.models.AuthMethodDetails in project azure-tools-for-java by Microsoft.
the class SignInCommandHandler method fromAccountEntity.
private static AuthMethodDetails fromAccountEntity(AccountEntity entity) {
final AuthMethodDetails authMethodDetails = new AuthMethodDetails();
authMethodDetails.setAuthMethod(AuthMethod.IDENTITY);
authMethodDetails.setAuthType(entity.getType());
authMethodDetails.setClientId(entity.getClientId());
authMethodDetails.setTenantId(CollectionUtils.isEmpty(entity.getTenantIds()) ? "" : entity.getTenantIds().get(0));
authMethodDetails.setAzureEnv(AzureEnvironmentUtils.getCloudNameForAzureCli(entity.getEnvironment()));
authMethodDetails.setAccountEmail(entity.getEmail());
return authMethodDetails;
}
use of com.microsoft.azuretools.authmanage.models.AuthMethodDetails in project azure-tools-for-java by Microsoft.
the class IdentityAzureManager method signInServicePrincipal.
public Mono<AuthMethodDetails> signInServicePrincipal(AuthConfiguration auth) {
return Azure.az(AzureAccount.class).loginAsync(auth, false).flatMap(Account::continueLogin).map(account -> {
if (secureStore != null && StringUtils.isNotBlank(auth.getKey())) {
secureStore.savePassword(SERVICE_PRINCIPAL_STORE_SERVICE, auth.getClient(), null, auth.getKey());
}
AuthMethodDetails authMethodDetails = fromAccountEntity(account.getEntity());
// special handle for SP
authMethodDetails.setCertificate(auth.getCertificate());
return authMethodDetails;
});
}
use of com.microsoft.azuretools.authmanage.models.AuthMethodDetails in project azure-tools-for-java by Microsoft.
the class AzureSignInAction method fromAccountEntity.
private static AuthMethodDetails fromAccountEntity(AccountEntity entity) {
final AuthMethodDetails authMethodDetails = new AuthMethodDetails();
authMethodDetails.setAuthMethod(AuthMethod.IDENTITY);
authMethodDetails.setAuthType(entity.getType());
authMethodDetails.setClientId(entity.getClientId());
authMethodDetails.setTenantId(CollectionUtils.isEmpty(entity.getTenantIds()) ? "" : entity.getTenantIds().get(0));
authMethodDetails.setAzureEnv(AzureEnvironmentUtils.getCloudNameForAzureCli(entity.getEnvironment()));
authMethodDetails.setAccountEmail(entity.getEmail());
return authMethodDetails;
}
Aggregations