Class AzureAuthHelperLegacy


  • public class AzureAuthHelperLegacy
    extends Object
    Helper class to authenticate with Azure
    • Constructor Detail

      • AzureAuthHelperLegacy

        public AzureAuthHelperLegacy​(AuthConfiguration config)
        Constructor
        Parameters:
        config -
    • Method Detail

      • getAzureClient

        public com.microsoft.azure.management.Azure getAzureClient()
      • getLogLevel

        protected com.microsoft.rest.LogLevel getLogLevel()
      • azureConfigure

        protected com.microsoft.azure.management.Azure.Configurable azureConfigure()
      • getAzureEnvironment

        protected com.microsoft.azure.AzureEnvironment getAzureEnvironment​(String environment)
      • getAuthObj

        protected com.microsoft.azure.management.Azure.Authenticated getAuthObj()
      • getAuthObjFromServerId

        protected com.microsoft.azure.management.Azure.Authenticated getAuthObjFromServerId​(org.apache.maven.settings.Settings settings,
                                                                                            String serverId)
        Get Authenticated object by referencing server definition in Maven settings.xml
        Parameters:
        settings - Settings object
        serverId - Server Id to search in settings.xml
        Returns:
        Authenticated object if configurations are correct; otherwise return null.
      • getAuthObjFromFile

        protected com.microsoft.azure.management.Azure.Authenticated getAuthObjFromFile​(File authFile)
        Get Authenticated object using file.
        Parameters:
        authFile - Authentication file object.
        Returns:
        Authenticated object of file is valid; otherwise return null.
      • getAuthObjFromAzureCli

        protected com.microsoft.azure.management.Azure.Authenticated getAuthObjFromAzureCli()
        Get Authenticated object using authentication file from Azure CLI 2.0 Note: The integrated Azure CLI in Azure Cloud Shell does not have the accessToken.json, so we need to use MSI to authenticate in the Cloud Shell.
        Returns:
        Authenticated object if Azure CLI 2.0 is logged in correctly; otherwise return null.
      • getCredentialFromAzureCliWithServicePrincipal

        protected com.microsoft.azure.credentials.ApplicationTokenCredentials getCredentialFromAzureCliWithServicePrincipal()
                                                                                                                     throws IOException
        Get Authenticated object from token file of Azure CLI 2.0 logged with Service Principal Note: This is a workaround for issue https://github.com/microsoft/azure-maven-plugins/issues/125
        Returns:
        Authenticated object if Azure CLI 2.0 is logged with Service Principal.
        Throws:
        IOException
      • getAppTokenCredentialsFromServer

        protected com.microsoft.azure.credentials.ApplicationTokenCredentials getAppTokenCredentialsFromServer​(org.apache.maven.settings.Server server)
        Get ApplicationTokenCredentials from server definition in Maven settings.xml
        Parameters:
        server - Server object from settings.xml
        Returns:
        ApplicationTokenCredentials object if configuration is correct; otherwise return null.
      • isInCloudShell

        public static boolean isInCloudShell()
      • getDefaultSubscriptionObject

        private static com.google.gson.JsonObject getDefaultSubscriptionObject()
                                                                        throws IOException
        Throws:
        IOException
      • getAzureCliTokenList

        private static com.google.gson.JsonArray getAzureCliTokenList()
                                                               throws IOException
        Throws:
        IOException
      • getServer

        private static org.apache.maven.settings.Server getServer​(org.apache.maven.settings.Settings settings,
                                                                  String serverId)
        Get server credential from Maven settings by server Id.
        Parameters:
        settings - Maven settings object.
        serverId - Server Id.
        Returns:
        Server object if it exists in settings. Otherwise return null.
      • assureServerExist

        private static void assureServerExist​(org.apache.maven.settings.Server server,
                                              String serverId)
                                       throws com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
        Assure the server with specified id does exist in settings.xml. It could be the server used for azure authentication. Or, the server used for docker hub authentication of runtime configuration.
        Parameters:
        server -
        serverId -
        Throws:
        com.microsoft.azure.toolkit.lib.common.exception.AzureExecutionException
      • getValueFromServerConfiguration

        private static String getValueFromServerConfiguration​(org.apache.maven.settings.Server server,
                                                              String key)
        Get string value from server configuration section in settings.xml.
        Parameters:
        server - Server object.
        key - Key string.
        Returns:
        String value if key exists; otherwise, return null.