Search in sources :

Example 1 with INotification

use of com.microsoft.azuretools.authmanage.interact.INotification in project azure-tools-for-java by Microsoft.

the class AuthMethodManager method getAzureManager.

private AzureManager getAzureManager(AuthMethod authMethod) throws IOException {
    if (azureManager != null)
        return azureManager;
    switch(authMethod) {
        case AD:
            if (StringUtils.isNullOrEmpty(authMethodDetails.getAccountEmail())) {
                return null;
            }
            azureManager = new AccessTokenAzureManager();
            break;
        case SP:
            String credFilePath = authMethodDetails.getCredFilePath();
            if (StringUtils.isNullOrEmpty(credFilePath)) {
                return null;
            }
            Path filePath = Paths.get(credFilePath);
            if (!Files.exists(filePath)) {
                cleanAll();
                INotification nw = CommonSettings.getUiFactory().getNotificationWindow();
                nw.deliver("Credential File Error", "File doesn't exist: " + filePath.toString());
                return null;
            }
            azureManager = new ServicePrincipalAzureManager(new File(credFilePath));
    }
    return azureManager;
}
Also used : Path(java.nio.file.Path) INotification(com.microsoft.azuretools.authmanage.interact.INotification) AccessTokenAzureManager(com.microsoft.azuretools.sdkmanage.AccessTokenAzureManager) ServicePrincipalAzureManager(com.microsoft.azuretools.sdkmanage.ServicePrincipalAzureManager) File(java.io.File)

Aggregations

INotification (com.microsoft.azuretools.authmanage.interact.INotification)1 AccessTokenAzureManager (com.microsoft.azuretools.sdkmanage.AccessTokenAzureManager)1 ServicePrincipalAzureManager (com.microsoft.azuretools.sdkmanage.ServicePrincipalAzureManager)1 File (java.io.File)1 Path (java.nio.file.Path)1