public IntuneClient()

in src/CsrValidation/java/lib/src/main/java/com/microsoft/intune/scepvalidation/IntuneClient.java [130:202]


    public IntuneClient(Properties configProperties, MSALClientWrapper msalAuthClient, ADALClientWrapper adalAuthClient, HttpClientBuilder httpClientBuilder) throws IllegalArgumentException
    {        
        if(configProperties == null)
        {
            throw new IllegalArgumentException("The argument 'configProperties' is missing"); 
        }
        
        // Read required properties
        String azureAppId = configProperties.getProperty("AAD_APP_ID");
        if(azureAppId == null || azureAppId.isEmpty())
        {
            throw new IllegalArgumentException("The argument 'AAD_APP_ID' is missing");
        }
        
        String azureAppKey = configProperties.getProperty("AAD_APP_KEY");
        if(azureAppKey == null || azureAppKey.isEmpty())
        {
            throw new IllegalArgumentException("The argument 'AAD_APP_KEY' is missing");
        }
        
        this.intuneTenant = configProperties.getProperty("TENANT");
        if(this.intuneTenant == null || this.intuneTenant.isEmpty())
        {
            throw new IllegalArgumentException("The argument 'TENANT' is missing");
        }
        
        // Read optional properties
        this.intuneAppId = configProperties.getProperty("INTUNE_APP_ID", this.intuneAppId);
        this.intuneResourceUrl = configProperties.getProperty("INTUNE_RESOURCE_URL", this.intuneResourceUrl);
        
        this.aadGraphVersion = configProperties.getProperty("GRAPH_API_VERSION", this.aadGraphVersion);
        this.aadGraphResourceUrl = configProperties.getProperty("GRAPH_RESOURCE_URL", this.aadGraphResourceUrl);
        
        this.msGraphVersion = configProperties.getProperty("MS_GRAPH_API_VERSION", this.msGraphVersion);
        this.msGraphResourceUrl = configProperties.getProperty("MS_GRAPH_RESOURCE_URL", this.msGraphResourceUrl);
        
        this.msalAuthClient = msalAuthClient == null ? new MSALClientWrapper(this.intuneTenant, configProperties) : msalAuthClient;
        
        this.aadCredential = new ClientCredential(azureAppId, azureAppKey);
        this.adalAuthClient = adalAuthClient == null ? new ADALClientWrapper(this.intuneTenant, this.aadCredential, configProperties) : adalAuthClient;
        
        this.httpClientBuilder = httpClientBuilder == null ? this.httpClientBuilder : httpClientBuilder;
        
        proxyHost = configProperties.getProperty("PROXY_HOST");
        if(this.proxyHost != null && !this.proxyHost.isEmpty())
        {
            try
            {
                proxyPort = Integer.parseInt(configProperties.getProperty("PROXY_PORT"));
            }
            catch(NumberFormatException e)
            {
                throw new IllegalArgumentException("'PROXY_PORT' is required and must be a value that can be converted to an integer.", e);
            }
            
            if(!(proxyPort >= 0 && proxyPort <= 65535))
            {
                throw new IllegalArgumentException("'PROXY_PORT' must be in the range of available ports 0-65535");
            }
            
            proxyUser = configProperties.getProperty("PROXY_USER");
            if(this.proxyUser != null && !this.proxyUser.isEmpty())
            {
                proxyPass = configProperties.getProperty("PROXY_PASS");
                if(this.proxyPass == null || this.proxyPass.isEmpty())
                {
                    throw new IllegalArgumentException("If the argument 'PROXY_USER' is set then 'PROXY_PASS' must also be set.");
                }
            }
        }
        
        setProxy();
    }