Search in sources :

Example 11 with AzureDockerCertVault

use of com.microsoft.azure.docker.model.AzureDockerCertVault in project azure-tools-for-java by Microsoft.

the class AzureInputDockerLoginCredsDialog method doValidate.

public boolean doValidate() {
    String vmUsername = dockerHostUsernameTextField.getText();
    if (vmUsername == null || vmUsername.isEmpty() || (resetCredentials && !AzureDockerValidationUtils.validateDockerHostUserName(vmUsername))) {
        errDispatcher.addMessage("dockerHostUsernameTextField", AzureDockerValidationUtils.getDockerHostUserNameTip(), null, IMessageProvider.ERROR, dockerHostUsernameTextField);
        setErrorMessage("Invalid user name");
        return false;
    } else {
        errDispatcher.removeMessage("dockerHostUsernameTextField", dockerHostUsernameTextField);
        setErrorMessage(null);
        editableDockerHost.updatedDockerHost.certVault.vmUsername = vmUsername;
    }
    // Password login
    String vmPwd1 = dockerHostFirstPwdField.getText();
    String vmPwd2 = dockerHostSecondPwdField.getText();
    if (((dockerHostKeepSshRadioButton.getSelection() && !editableDockerHost.originalDockerHost.hasSSHLogIn) || (vmPwd1 != null && !vmPwd1.isEmpty()) || (vmPwd2 != null && !vmPwd2.isEmpty())) && (vmPwd1.isEmpty() || vmPwd2.isEmpty() || !vmPwd1.equals(vmPwd2) || (resetCredentials && !AzureDockerValidationUtils.validateDockerHostPassword(vmPwd1)))) {
        errDispatcher.addMessage("dockerHostFirstPwdField", AzureDockerValidationUtils.getDockerHostPasswordTip(), null, IMessageProvider.ERROR, dockerHostFirstPwdField);
        setErrorMessage("Invalid password");
        return false;
    } else {
        errDispatcher.removeMessage("dockerHostFirstPwdField", dockerHostFirstPwdField);
        errDispatcher.removeMessage("dockerHostSecondPwdField", dockerHostSecondPwdField);
        setErrorMessage(null);
        if (vmPwd1 == null || vmPwd1.isEmpty()) {
            editableDockerHost.updatedDockerHost.certVault.vmPwd = null;
            editableDockerHost.updatedDockerHost.hasPwdLogIn = false;
        } else {
            editableDockerHost.updatedDockerHost.certVault.vmPwd = vmPwd1;
            editableDockerHost.updatedDockerHost.hasPwdLogIn = true;
        }
    }
    // SSH key imported from local file directory
    if (dockerHostImportSshRadioButton.getSelection()) {
        String sshPath = dockerHostImportSSHTextField.getText();
        if (sshPath == null || sshPath.isEmpty() || !AzureDockerValidationUtils.validateDockerHostSshDirectory(sshPath)) {
            errDispatcher.addMessage("dockerHostImportSSHTextField", AzureDockerValidationUtils.getDockerHostPasswordTip(), null, IMessageProvider.ERROR, dockerHostImportSSHTextField);
            setErrorMessage("SSH key files not found in the specified directory");
            return false;
        } else {
            try {
                AzureDockerCertVault certVault = AzureDockerCertVaultOps.getSSHKeysFromLocalFile(sshPath);
                AzureDockerCertVaultOps.copyVaultSshKeys(editableDockerHost.updatedDockerHost.certVault, certVault);
                editableDockerHost.updatedDockerHost.hasSSHLogIn = true;
            } catch (Exception e) {
                errDispatcher.addMessage("dockerHostImportSSHTextField", AzureDockerValidationUtils.getDockerHostPasswordTip(), null, IMessageProvider.ERROR, dockerHostImportSSHTextField);
                setErrorMessage("Unexpected error reading SSH key files from specified directory: " + e.getMessage());
                return false;
            }
            errDispatcher.removeMessage("dockerHostImportSSHTextField", dockerHostImportSSHTextField);
            setErrorMessage(null);
        }
    } else {
        errDispatcher.removeMessage("dockerHostImportSSHTextField", dockerHostImportSSHTextField);
        setErrorMessage(null);
    }
    return true;
}
Also used : AzureDockerCertVault(com.microsoft.azure.docker.model.AzureDockerCertVault)

Example 12 with AzureDockerCertVault

use of com.microsoft.azure.docker.model.AzureDockerCertVault in project azure-tools-for-java by Microsoft.

the class AzureInputDockerLoginCredsDialog method initUIComponents.

private void initUIComponents(Composite mainContainer) {
    setTitle("Docker Host Log In Credentials");
    if (resetCredentials) {
        setMessage(String.format("Update %s with new log in credentials", editableDockerHost.originalDockerHost.name), IMessageProvider.INFORMATION);
    } else {
        setMessage(String.format("Docker host %s log in credentials not found; enter your log in credentials", editableDockerHost.originalDockerHost.name), IMessageProvider.INFORMATION);
    }
    copyFromAzureKeyButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            AzureSelectKeyVault azureSelectKeyVaultDialog = new AzureSelectKeyVault(mainContainer.getShell(), dockerManager);
            if (azureSelectKeyVaultDialog.open() == Window.OK && azureSelectKeyVaultDialog.getSelectedKeyvault() != null) {
                updateUIWithKeyvault(azureSelectKeyVaultDialog.getSelectedKeyvault());
            }
            okButton.setEnabled(doValidate());
        }
    });
    dockerHostUsernameTextField.setText((editableDockerHost.originalDockerHost.certVault != null && editableDockerHost.originalDockerHost.certVault.vmUsername != null) ? editableDockerHost.originalDockerHost.certVault.vmUsername : "");
    dockerHostUsernameTextField.setToolTipText(AzureDockerValidationUtils.getDockerHostUserNameTip());
    dockerHostUsernameTextField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent event) {
            if (!resetCredentials || AzureDockerValidationUtils.validateDockerHostUserName(((Text) event.getSource()).getText())) {
                errDispatcher.removeMessage("dockerHostUsernameTextField", dockerHostUsernameTextField);
                setErrorMessage(null);
                okButton.setEnabled(doValidate());
            } else {
                errDispatcher.addMessage("dockerHostUsernameTextField", AzureDockerValidationUtils.getDockerHostUserNameTip(), null, IMessageProvider.ERROR, dockerHostUsernameTextField);
                setErrorMessage("Invalid user name");
                okButton.setEnabled(false);
            }
        }
    });
    dockerHostFirstPwdField.setToolTipText(AzureDockerValidationUtils.getDockerHostPasswordTip());
    dockerHostFirstPwdField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent event) {
            String text = ((Text) event.getSource()).getText();
            if (text == null || text.isEmpty() || (!resetCredentials || AzureDockerValidationUtils.validateDockerHostPassword(text))) {
                errDispatcher.removeMessage("dockerHostFirstPwdField", dockerHostFirstPwdField);
                setErrorMessage(null);
                if (!resetCredentials) {
                    dockerHostSecondPwdField.setText(text);
                }
                okButton.setEnabled(doValidate());
            } else {
                errDispatcher.addMessage("dockerHostFirstPwdField", AzureDockerValidationUtils.getDockerHostPasswordTip(), null, IMessageProvider.ERROR, dockerHostFirstPwdField);
                setErrorMessage("Invalid password");
                okButton.setEnabled(false);
            }
        }
    });
    dockerHostSecondPwdField.setVisible(resetCredentials);
    dockerHostSecondPwdField.setToolTipText(AzureDockerValidationUtils.getDockerHostPasswordTip());
    dockerHostSecondPwdField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent event) {
            String pwd1 = dockerHostFirstPwdField.getText();
            String pwd2 = ((Text) event.getSource()).getText();
            if ((pwd1 == null && pwd2 == null) || pwd2.equals(pwd1)) {
                errDispatcher.removeMessage("dockerHostSecondPwdField", dockerHostSecondPwdField);
                setErrorMessage(null);
                okButton.setEnabled(doValidate());
            } else {
                errDispatcher.addMessage("dockerHostSecondPwdField", AzureDockerValidationUtils.getDockerHostPasswordTip(), null, IMessageProvider.ERROR, dockerHostSecondPwdField);
                setErrorMessage("Invalid confirmation password");
                okButton.setEnabled(false);
            }
        }
    });
    dockerHostKeepSshRadioButton.setSelection(true);
    dockerHostKeepSshRadioButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            dockerHostImportSSHTextField.setEnabled(false);
            dockerHostImportSSHBrowseButton.setEnabled(false);
            errDispatcher.removeMessage("dockerHostImportSSHTextField", dockerHostImportSSHTextField);
            setErrorMessage(null);
            if (editableDockerHost.originalDockerHost.hasSSHLogIn) {
                AzureDockerCertVaultOps.copyVaultSshKeys(editableDockerHost.updatedDockerHost.certVault, editableDockerHost.originalDockerHost.certVault);
            }
            editableDockerHost.updatedDockerHost.hasSSHLogIn = editableDockerHost.originalDockerHost.hasSSHLogIn;
            okButton.setEnabled(doValidate());
        }
    });
    dockerHostImportSshRadioButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            dockerHostImportSSHTextField.setEnabled(true);
            dockerHostImportSSHBrowseButton.setEnabled(true);
            okButton.setEnabled(doValidate());
        }
    });
    dockerHostImportSSHTextField.setEnabled(false);
    dockerHostImportSSHTextField.setToolTipText(AzureDockerValidationUtils.getDockerHostSshDirectoryTip());
    dockerHostImportSSHTextField.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent event) {
            if (AzureDockerValidationUtils.validateDockerHostSshDirectory(((Text) event.getSource()).getText())) {
                errDispatcher.removeMessage("dockerHostImportSSHTextField", dockerHostImportSSHTextField);
                setErrorMessage(null);
                okButton.setEnabled(doValidate());
            } else {
                errDispatcher.addMessage("dockerHostImportSSHTextField", AzureDockerValidationUtils.getDockerHostSshDirectoryTip(), null, IMessageProvider.ERROR, dockerHostImportSSHTextField);
                setErrorMessage("SSH key files not found in the specified directory");
                okButton.setEnabled(false);
            }
        }
    });
    dockerHostImportSSHBrowseButton.setEnabled(false);
    dockerHostImportSSHBrowseButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog directoryDialog = new DirectoryDialog(dockerHostImportSSHBrowseButton.getShell());
            directoryDialog.setText("Select SSH Keys Directory");
            directoryDialog.setFilterPath(System.getProperty("user.home"));
            String path = directoryDialog.open();
            if (path == null) {
                return;
            }
            dockerHostImportSSHTextField.setText(path);
            okButton.setEnabled(doValidate());
        }
    });
    dockerHostAutoSshRadioButton.setVisible(resetCredentials);
    dockerHostAutoSshRadioButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            dockerHostImportSSHTextField.setEnabled(false);
            dockerHostImportSSHBrowseButton.setEnabled(false);
            errDispatcher.removeMessage("dockerHostImportSSHTextField", dockerHostImportSSHTextField);
            setErrorMessage(null);
            AzureDockerCertVault certVault = AzureDockerCertVaultOps.generateSSHKeys(null, "SSH keys for " + editableDockerHost.updatedDockerHost.name);
            AzureDockerCertVaultOps.copyVaultSshKeys(editableDockerHost.updatedDockerHost.certVault, certVault);
            editableDockerHost.updatedDockerHost.hasSSHLogIn = true;
            okButton.setEnabled(doValidate());
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AzureDockerCertVault(com.microsoft.azure.docker.model.AzureDockerCertVault) Text(org.eclipse.swt.widgets.Text) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 13 with AzureDockerCertVault

use of com.microsoft.azure.docker.model.AzureDockerCertVault in project azure-tools-for-java by Microsoft.

the class AzureDockerUIResources method createDockerKeyVault.

public static void createDockerKeyVault(DockerHost dockerHost, AzureDockerHostsManager dockerManager) {
    Job createDockerHostJob = new Job(String.format("Creating Azure Key Vault %s for %s", dockerHost.certVault.name, dockerHost.name)) {

        @Override
        protected IStatus run(IProgressMonitor progressMonitor) {
            progressMonitor.beginTask("start task", 100);
            try {
                progressMonitor.subTask(String.format("Reading subscription details for Docker host %s ...", dockerHost.apiUrl));
                progressMonitor.worked(5);
                Azure azureClient = dockerManager.getSubscriptionsMap().get(dockerHost.sid).azureClient;
                KeyVaultClient keyVaultClient = dockerManager.getSubscriptionsMap().get(dockerHost.sid).keyVaultClient;
                if (progressMonitor.isCanceled()) {
                    progressMonitor.done();
                    return Status.CANCEL_STATUS;
                }
                String retryMsg = "Create";
                int retries = 5;
                AzureDockerCertVault certVault = null;
                do {
                    progressMonitor.subTask(String.format("%s new key vault %s ...", retryMsg, dockerHost.certVault.name));
                    progressMonitor.worked(15 + 15 * retries);
                    if (AzureDockerUtils.DEBUG)
                        System.out.println(retryMsg + " new Docker key vault: " + new Date().toString());
                    AzureDockerCertVaultOps.createOrUpdateVault(azureClient, dockerHost.certVault, keyVaultClient);
                    if (AzureDockerUtils.DEBUG)
                        System.out.println("Done creating new key vault: " + new Date().toString());
                    if (progressMonitor.isCanceled()) {
                        progressMonitor.done();
                        return Status.CANCEL_STATUS;
                    }
                    certVault = AzureDockerCertVaultOps.getVault(azureClient, dockerHost.certVault.name, dockerHost.certVault.resourceGroupName, keyVaultClient);
                    retries++;
                    retryMsg = "Retry creating";
                } while (// Retry couple times
                retries < 5 && (certVault == null || certVault.vmUsername == null));
                progressMonitor.subTask("Updating key vaults ...");
                progressMonitor.worked(95);
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Refreshing key vaults: " + new Date().toString());
                dockerManager.refreshDockerVaults();
                dockerManager.refreshDockerVaultDetails();
                if (AzureDockerUtils.DEBUG)
                    System.out.println("Done refreshing key vaults: " + new Date().toString());
                //					progressMonitor.subTask("");
                //					progressMonitor.worked(1);
                //					if (progressMonitor.isCanceled()) {
                //						if (displayWarningOnCreateKeyVaultCancelAction() == 0) {
                //							progressMonitor.done();
                //							return Status.CANCEL_STATUS;
                //						}
                //					}
                //
                progressMonitor.done();
                return Status.OK_STATUS;
            } catch (Exception e) {
                String msg = "An error occurred while attempting to create a new Azure Key Vault." + "\n" + e.getMessage();
                log.log(Level.SEVERE, "createDockerKeyVault: " + msg, e);
                e.printStackTrace();
                PluginUtil.displayErrorDialog(Display.getDefault().getActiveShell(), "Error Creating Azure Key Vault " + dockerHost.certVault.name, "An error occurred while attempting to create a new Azure Key Vault." + "\n" + e.getMessage());
                return Status.CANCEL_STATUS;
            }
        }
    };
    createDockerHostJob.schedule();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Azure(com.microsoft.azure.management.Azure) KeyVaultClient(com.microsoft.azure.keyvault.KeyVaultClient) AzureDockerCertVault(com.microsoft.azure.docker.model.AzureDockerCertVault) Job(org.eclipse.core.runtime.jobs.Job) Date(java.util.Date)

Example 14 with AzureDockerCertVault

use of com.microsoft.azure.docker.model.AzureDockerCertVault in project azure-tools-for-java by Microsoft.

the class AzureNewDockerLoginStep method doValidate.

private ValidationInfo doValidate(boolean shakeOnError) {
    if (dockerHostImportKeyvaultCredsRadioButton.isSelected()) {
        // read key vault secrets and set the credentials for the new host
        AzureDockerCertVault certVault = (AzureDockerCertVault) dockerHostImportKeyvaultComboBox.getSelectedItem();
        if (certVault == null) {
            ValidationInfo info = AzureDockerUIResources.validateComponent("Missing vault", rootConfigureContainerPanel, dockerHostImportKeyvaultComboBox, dockerHostImportKeyvaultComboLabel);
            setDialogButtonsState(false);
            if (shakeOnError) {
                model.DialogShaker(info);
            }
            return info;
        }
        dockerHostImportKeyvaultComboLabel.setVisible(false);
        newHost.certVault.name = certVault.name;
        newHost.certVault.resourceGroupName = certVault.resourceGroupName;
        newHost.certVault.region = certVault.region;
        newHost.certVault.uri = certVault.uri;
        AzureDockerCertVaultOps.copyVaultLoginCreds(newHost.certVault, certVault);
        AzureDockerCertVaultOps.copyVaultSshKeys(newHost.certVault, certVault);
        AzureDockerCertVaultOps.copyVaultTlsCerts(newHost.certVault, certVault);
        // create a weak link (resource tag) between the virtual machine and the key vault
        //  we will not create/update the key vault unless the user checks the specific option
        newHost.certVault.hostName = null;
        newHost.hasKeyVault = true;
    } else {
        // reset key vault info
        newHost.hasKeyVault = false;
        newHost.certVault.name = null;
        newHost.certVault.uri = null;
        dockerHostImportKeyvaultComboLabel.setVisible(false);
        // User name
        String vmUsername = dockerHostUsernameTextField.getText();
        if (vmUsername == null || vmUsername.isEmpty() || !AzureDockerValidationUtils.validateDockerHostUserName(vmUsername)) {
            ValidationInfo info = AzureDockerUIResources.validateComponent("Missing username", vmCredsPanel, dockerHostUsernameTextField, dockerHostUsernameLabel);
            credsTabbedPane.setSelectedComponent(vmCredsPanel);
            setDialogButtonsState(false);
            if (shakeOnError) {
                model.DialogShaker(info);
            }
            return info;
        }
        newHost.certVault.vmUsername = vmUsername;
        // Password login
        String vmPwd1 = new String(dockerHostFirstPwdField.getPassword());
        String vmPwd2 = new String(dockerHostSecondPwdField.getPassword());
        if ((dockerHostNoSshRadioButton.isSelected() || dockerHostFirstPwdField.getPassword().length > 0 || dockerHostSecondPwdField.getPassword().length > 0) && (vmPwd1.isEmpty() || vmPwd2.isEmpty() || !vmPwd1.equals(vmPwd2) || !AzureDockerValidationUtils.validateDockerHostPassword(vmPwd1))) {
            ValidationInfo info = AzureDockerUIResources.validateComponent("Incorrect password", vmCredsPanel, dockerHostFirstPwdField, dockerHostFirstPwdLabel);
            credsTabbedPane.setSelectedComponent(vmCredsPanel);
            setDialogButtonsState(false);
            if (shakeOnError) {
                model.DialogShaker(info);
            }
            return info;
        }
        dockerHostFirstPwdLabel.setVisible(false);
        if (dockerHostFirstPwdField.getPassword().length > 0) {
            newHost.certVault.vmPwd = new String(dockerHostFirstPwdField.getPassword());
            newHost.hasPwdLogIn = true;
        } else {
            newHost.certVault.vmPwd = null;
            newHost.hasPwdLogIn = false;
        }
        // SSH key auto generated
        if (dockerHostAutoSshRadioButton.isSelected()) {
            AzureDockerCertVault certVault = AzureDockerCertVaultOps.generateSSHKeys(null, "SSH keys for " + newHost.name);
            AzureDockerCertVaultOps.copyVaultSshKeys(newHost.certVault, certVault);
            newHost.hasSSHLogIn = true;
        }
        if (dockerHostNoSshRadioButton.isSelected()) {
            newHost.hasSSHLogIn = false;
            newHost.certVault.sshKey = null;
            newHost.certVault.sshPubKey = null;
        }
        // SSH key imported from local file directory
        if (dockerHostImportSshRadioButton.isSelected()) {
            if (dockerHostImportSSHBrowseTextField.getText() == null || dockerHostImportSSHBrowseTextField.getText().isEmpty() || !AzureDockerValidationUtils.validateDockerHostSshDirectory(dockerHostImportSSHBrowseTextField.getText())) {
                ValidationInfo info = AzureDockerUIResources.validateComponent("SSH key files were not found in the selected directory", vmCredsPanel, dockerHostImportSSHBrowseTextField, dockerHostImportSSHBrowseLabel);
                credsTabbedPane.setSelectedComponent(vmCredsPanel);
                setDialogButtonsState(false);
                if (shakeOnError) {
                    model.DialogShaker(info);
                }
                return info;
            } else {
                AzureDockerCertVault certVault = AzureDockerCertVaultOps.getSSHKeysFromLocalFile(dockerHostImportSSHBrowseTextField.getText());
                AzureDockerCertVaultOps.copyVaultSshKeys(newHost.certVault, certVault);
                newHost.hasSSHLogIn = true;
            }
        }
        // No Docker daemon security
        if (dockerHostNoTlsRadioButton.isSelected()) {
            newHost.isTLSSecured = false;
        }
        // TLS certs auto generated
        if (dockerHostAutoTlsRadioButton.isSelected()) {
            AzureDockerCertVault certVault = AzureDockerCertVaultOps.generateTLSCerts("TLS certs for " + newHost.name);
            AzureDockerCertVaultOps.copyVaultTlsCerts(newHost.certVault, certVault);
            newHost.isTLSSecured = true;
        }
        // TLS certs imported from local file directory
        if (dockerHostImportTlsRadioButton.isSelected()) {
            if (dockerHostImportTLSBrowseTextField.getText() == null || dockerHostImportTLSBrowseTextField.getText().isEmpty() || !AzureDockerValidationUtils.validateDockerHostTlsDirectory(dockerHostImportTLSBrowseTextField.getText())) {
                ValidationInfo info = AzureDockerUIResources.validateComponent("TLS certificates files were not found in the selected directory", vmCredsPanel, dockerHostImportTLSBrowseTextField, dockerHostImportTLSBrowseLabel);
                credsTabbedPane.setSelectedComponent(vmCredsPanel);
                setDialogButtonsState(false);
                if (shakeOnError) {
                    model.DialogShaker(info);
                }
                return info;
            } else {
                AzureDockerCertVault certVault = AzureDockerCertVaultOps.getTLSCertsFromLocalFile(dockerHostImportTLSBrowseTextField.getText());
                AzureDockerCertVaultOps.copyVaultTlsCerts(newHost.certVault, certVault);
                newHost.isTLSSecured = true;
            }
        }
    }
    // Docker daemon port settings
    if (dockerDaemonPortTextField.getText() == null || dockerDaemonPortTextField.getText().isEmpty() || !AzureDockerValidationUtils.validateDockerHostPort(dockerDaemonPortTextField.getText())) {
        ValidationInfo info = AzureDockerUIResources.validateComponent("Invalid Docker daemon port settings", daemonCredsPanel, dockerDaemonPortTextField, dockerDaemonPortLabel);
        credsTabbedPane.setSelectedComponent(daemonCredsPanel);
        setDialogButtonsState(false);
        if (shakeOnError) {
            model.DialogShaker(info);
        }
        return info;
    }
    newHost.port = dockerDaemonPortTextField.getText();
    // create new key vault for storing the credentials
    if (dockerHostSaveCredsCheckBox.isSelected()) {
        if (dockerHostNewKeyvaultTextField.getText() == null || dockerHostNewKeyvaultTextField.getText().isEmpty() || !AzureDockerValidationUtils.validateDockerHostKeyvaultName(dockerHostNewKeyvaultTextField.getText(), dockerManager, true)) {
            ValidationInfo info = AzureDockerUIResources.validateComponent("Incorrect Azure Key Vault", rootConfigureContainerPanel, dockerHostNewKeyvaultTextField, dockerHostNewKeyvaultLabel);
            setDialogButtonsState(false);
            return info;
        } else {
            newHost.hasKeyVault = true;
            newHost.certVault.name = dockerHostNewKeyvaultTextField.getText();
            newHost.certVault.hostName = (newHost.name != null) ? newHost.name : null;
            newHost.certVault.region = (newHost.hostVM.region != null) ? newHost.hostVM.region : null;
            newHost.certVault.resourceGroupName = (newHost.hostVM.resourceGroupName != null) ? newHost.hostVM.resourceGroupName : null;
            newHost.certVault.uri = (newHost.hostVM.region != null && newHost.hostVM.resourceGroupName != null) ? "https://" + newHost.certVault.name + ".vault.azure.net" : null;
        }
    } else {
        newHost.certVault.hostName = null;
    }
    setDialogButtonsState(true);
    return null;
}
Also used : ValidationInfo(com.intellij.openapi.ui.ValidationInfo) AzureDockerCertVault(com.microsoft.azure.docker.model.AzureDockerCertVault)

Example 15 with AzureDockerCertVault

use of com.microsoft.azure.docker.model.AzureDockerCertVault in project azure-tools-for-java by Microsoft.

the class AzureDockerHostUpdateLoginPanel method updateUIWithKeyvault.

private void updateUIWithKeyvault(String keyvault) {
    AzureDockerCertVault certVault = dockerManager.getDockerVault(keyvault);
    if (certVault != null) {
        editableHost.updatedDockerHost.certVault = certVault;
        dockerHostUsernameTextField.setText((certVault.vmUsername != null) ? certVault.vmUsername : "");
        dockerHostFirstPwdField.setText((certVault.vmPwd != null) ? certVault.vmPwd : "");
        dockerHostSecondPwdField.setText((certVault.vmPwd != null) ? certVault.vmPwd : "");
    }
}
Also used : AzureDockerCertVault(com.microsoft.azure.docker.model.AzureDockerCertVault)

Aggregations

AzureDockerCertVault (com.microsoft.azure.docker.model.AzureDockerCertVault)18 AzureDockerException (com.microsoft.azure.docker.model.AzureDockerException)8 CloudException (com.microsoft.azure.CloudException)7 KeyVaultClient (com.microsoft.azure.keyvault.KeyVaultClient)3 Azure (com.microsoft.azure.management.Azure)3 Vault (com.microsoft.azure.management.keyvault.Vault)3 ValidationInfo (com.intellij.openapi.ui.ValidationInfo)2 JSch (com.jcraft.jsch.JSch)2 KeyPair (com.jcraft.jsch.KeyPair)2 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)2 Text (org.eclipse.swt.widgets.Text)2