Search in sources :

Example 1 with AuthMethodDetails

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();
}
Also used : AuthMethodDetails(com.microsoft.azuretools.authmanage.models.AuthMethodDetails) SignInWindow(com.microsoft.azuretools.ijidea.ui.SignInWindow)

Example 2 with AuthMethodDetails

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();
}
Also used : AuthMethodDetails(com.microsoft.azuretools.authmanage.models.AuthMethodDetails)

Example 3 with AuthMethodDetails

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;
}
Also used : AuthMethodDetails(com.microsoft.azuretools.authmanage.models.AuthMethodDetails)

Example 4 with 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;
    });
}
Also used : AuthMethodDetails(com.microsoft.azuretools.authmanage.models.AuthMethodDetails) AzureAccount(com.microsoft.azure.toolkit.lib.auth.AzureAccount)

Example 5 with 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;
}
Also used : AuthMethodDetails(com.microsoft.azuretools.authmanage.models.AuthMethodDetails)

Aggregations

AuthMethodDetails (com.microsoft.azuretools.authmanage.models.AuthMethodDetails)20 AuthType (com.microsoft.azure.toolkit.lib.auth.model.AuthType)6 AzureAccount (com.microsoft.azure.toolkit.lib.auth.AzureAccount)5 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)5 AuthConfiguration (com.microsoft.azure.toolkit.lib.auth.model.AuthConfiguration)4 AzureToolkitRuntimeException (com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException)4 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)4 AuthMethodManager (com.microsoft.azuretools.authmanage.AuthMethodManager)4 AzureCloud (com.microsoft.azure.toolkit.lib.auth.AzureCloud)3 AccountEntity (com.microsoft.azure.toolkit.lib.auth.model.AccountEntity)3 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 MsalClientException (com.microsoft.aad.msal4j.MsalClientException)2 Azure (com.microsoft.azure.toolkit.lib.Azure)2 DeviceCodeAccount (com.microsoft.azure.toolkit.lib.auth.core.devicecode.DeviceCodeAccount)2 AzureEnvironmentUtils (com.microsoft.azure.toolkit.lib.auth.util.AzureEnvironmentUtils)2 AzureMessager (com.microsoft.azure.toolkit.lib.common.messager.AzureMessager)2 AzureOperationBundle (com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle)2 AzureTaskManager (com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager)2 IDeviceLoginUI (com.microsoft.azuretools.adauth.IDeviceLoginUI)2