com.microsoft.windowsazure.Configuration Java Examples
The following examples show how to use
com.microsoft.windowsazure.Configuration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AzureComputeServiceImpl.java From crate with Apache License 2.0 | 6 votes |
private Configuration createConfiguration() { Configuration conf = null; try { AuthenticationResult authRes = AuthHelper.getAccessTokenFromServicePrincipalCredentials( Azure.ENDPOINT, Azure.AUTH_ENDPOINT, tenantId, appId, appSecret ); DefaultBuilder registry = DefaultBuilder.create(); AzureConfiguration.registerServices(registry); conf = ManagementConfiguration.configure(null, new Configuration(registry), URI.create(Azure.ENDPOINT), subscriptionId, authRes.getAccessToken()); } catch (Exception e) { LOGGER.error("Could not create configuration for Azure clients", e); } return conf; }
Example #2
Source File: AzureComputeServiceImpl.java From crate with Apache License 2.0 | 5 votes |
@Override public Configuration configuration() { if (configuration == null) { LOGGER.trace("Creating new Azure configuration for [{}], [{}]", subscriptionId, resourceGroupName); configuration = createConfiguration(); } return configuration; }
Example #3
Source File: AzureComputeServiceImpl.java From crate with Apache License 2.0 | 5 votes |
@Nullable @Override public NetworkResourceProviderClient networkResourceClient() { if (networkResourceClient == null) { Configuration conf = configuration(); if (conf == null) { return null; } networkResourceClient = NetworkResourceProviderService.create(conf); } return networkResourceClient; }
Example #4
Source File: AzureComputeServiceImpl.java From crate with Apache License 2.0 | 5 votes |
@Nullable @Override public ComputeManagementClient computeManagementClient() { if (computeManagementClient == null) { Configuration conf = configuration(); if (conf == null) { return null; } computeManagementClient = ComputeManagementService.create(conf); } return computeManagementClient; }
Example #5
Source File: AzureConnector.java From cloudml with GNU Lesser General Public License v3.0 | 5 votes |
private Configuration createConfiguration(String endpoint, String provider,String login,String secretKey) throws Exception { return ManagementConfiguration.configure( new URI("https://management.core.windows.net"), endpoint, login, secretKey, KeyStoreType.pkcs12 ); }
Example #6
Source File: AzureConnector.java From cloudml with GNU Lesser General Public License v3.0 | 5 votes |
public AzureConnector(String endpoint, String provider,String login,String secretKey){ journal.log(Level.INFO, ">> Connecting to "+provider+" ..."); Configuration config = null; try { config = createConfiguration(endpoint,provider,login,secretKey); } catch (Exception e) { e.printStackTrace(); } journal.log(Level.INFO, ">> Authenticating ..."); computeManagementClient = ComputeManagementService.create(config); hostedServicesOperations = computeManagementClient.getHostedServicesOperations(); }
Example #7
Source File: ServicePrincipalWithClientCertificate.java From azure-sdk-for-media-services-java-samples with Apache License 2.0 | 4 votes |
public static void main(String[] args) { ExecutorService executorService = Executors.newFixedThreadPool(1); try { String tenant = "tenant.domain.com"; String clientId = "%client_id%"; String restApiEndpoint = "https://account.restv2.region.media.azure.net/api/"; String pfxFilename = "%path_to_keystore.pfx%"; String pfxPassword = "%keystore_password%"; InputStream pfx = new FileInputStream(pfxFilename); // Connect to Media Services API with service principal and client certificate AzureAdTokenCredentials credentials = new AzureAdTokenCredentials( tenant, AsymmetricKeyCredential.create(clientId, pfx, pfxPassword), AzureEnvironments.AZURE_CLOUD_ENVIRONMENT); TokenProvider provider = new AzureAdTokenProvider(credentials, executorService); // create a new configuration with the new credentials Configuration configuration = MediaConfiguration.configureWithAzureAdTokenProvider( new URI(restApiEndpoint), provider); // create the media service with the new configuration MediaContract mediaService = MediaService.create(configuration); System.out.println("Listing assets"); ListResult<AssetInfo> assets = mediaService.list(Asset.list()); for (AssetInfo asset : assets) { System.out.println(asset.getId()); } } catch (ServiceException se) { System.out.println("ServiceException encountered."); System.out.println(se.toString()); } catch (Throwable e) { System.out.println("Exception encountered."); e.printStackTrace(); System.out.println(e.toString()); } finally { executorService.shutdown(); } }
Example #8
Source File: Program.java From azure-sdk-for-media-services-java-samples with Apache License 2.0 | 4 votes |
public static void main(String[] args) { ExecutorService executorService = Executors.newFixedThreadPool(1); try { // Connect to Media Services API with service principal and client symmetric key AzureAdTokenCredentials credentials = new AzureAdTokenCredentials( tenant, new AzureAdClientSymmetricKey(clientId, clientKey), AzureEnvironments.AZURE_CLOUD_ENVIRONMENT); TokenProvider provider = new AzureAdTokenProvider(credentials, executorService); // create a new configuration with the new credentials Configuration configuration = MediaConfiguration.configureWithAzureAdTokenProvider( new URI(restApiEndpoint), provider); // create the media service provisioned with the new configuration mediaService = MediaService.create(configuration); System.out.println("Azure SDK for Java - AES Dynamic Encryption Sample"); // Upload a local file to an Asset AssetInfo uploadAsset = uploadFileAndCreateAsset("Azure-Video.wmv"); System.out.println("Uploaded Asset Id: " + uploadAsset.getId()); // Transform the Asset AssetInfo encodedAsset = encode(uploadAsset); System.out.println("Encoded Asset Id: " + encodedAsset.getId()); // Create the ContentKey ContentKeyInfo contentKeyInfo = createEnvelopeTypeContentKey(encodedAsset); System.out.println("Envelope Encryption Content Key: " + contentKeyInfo.getId()); // Create the ContentKeyAuthorizationPolicy String tokenTemplateString = null; if (tokenRestriction) { tokenTemplateString = addTokenRestrictedAuthorizationPolicy(contentKeyInfo, tokenType); } else { addOpenAuthorizationPolicy(contentKeyInfo); } // Create the AssetDeliveryPolicy createAssetDeliveryPolicy(encodedAsset, contentKeyInfo); if (tokenTemplateString != null) { // Deserializes a string containing the XML representation of the TokenRestrictionTemplate TokenRestrictionTemplate tokenTemplate = TokenRestrictionTemplateSerializer .deserialize(tokenTemplateString); // Generate a test token based on the the data in the given // TokenRestrictionTemplate. // Note: You need to pass the ContentKey Id because we specified // TokenClaim.ContentKeyIdentifierClaim in during the creation // of TokenRestrictionTemplate. UUID rawKey = UUID.fromString(contentKeyInfo.getId().substring("nb:kid:UUID:".length())); // Token expiration: 1-year Calendar date = Calendar.getInstance(); date.setTime(new Date()); date.add(Calendar.YEAR, 1); // Generate token String testToken = TokenRestrictionTemplateSerializer.generateTestToken(tokenTemplate, null, rawKey, date.getTime(), null); System.out.println(tokenTemplate.getTokenType().toString() + " Test Token: Bearer " + testToken); } // Create the Streaming Origin Locator String url = getStreamingOriginLocator(encodedAsset); System.out.println("Origin Locator URL: " + url); System.out.println("Sample completed!"); } catch (ServiceException se) { System.out.println("ServiceException encountered."); System.out.println(se.toString()); } catch (Exception e) { System.out.println("Exception encountered."); System.out.println(e.toString()); } finally { executorService.shutdown(); } }
Example #9
Source File: AzureKms.java From sfs with Apache License 2.0 | 4 votes |
public Configuration createConfiguration(VertxContext<Server> vertxContext) throws Exception { return configure(null, createCredentials(vertxContext)); }
Example #10
Source File: UserPassAuth.java From azure-sdk-for-media-services-java-samples with Apache License 2.0 | 4 votes |
public static void main(String[] args) { ExecutorService executorService = Executors.newFixedThreadPool(1); try { String tenant = "tenant.domain.com"; String username = "[email protected]"; String password = "thePass"; String restApiEndpoint = "https://account.restv2.region.media.azure.net/api/"; // Connect to Media Services API with user/password authentication AzureAdTokenCredentials credentials = new AzureAdTokenCredentials( tenant, new AzureAdClientUsernamePassword(username, password), AzureEnvironments.AZURE_CLOUD_ENVIRONMENT); TokenProvider provider = new AzureAdTokenProvider(credentials, executorService); // create a new configuration with the new credentials Configuration configuration = MediaConfiguration.configureWithAzureAdTokenProvider( new URI(restApiEndpoint), provider); // create the media service provisioned with the new configuration MediaContract mediaService = MediaService.create(configuration); System.out.println("Listing assets"); ListResult<AssetInfo> assets = mediaService.list(Asset.list()); for (AssetInfo asset : assets) { System.out.println(asset.getId()); } } catch (ServiceException se) { System.out.println("ServiceException encountered."); System.out.println(se.toString()); } catch (Throwable e) { System.out.println("Exception encountered."); e.printStackTrace(); System.out.println(e.toString()); } finally { executorService.shutdown(); } }
Example #11
Source File: ServicePrincipalWithSymmetricKey.java From azure-sdk-for-media-services-java-samples with Apache License 2.0 | 4 votes |
public static void main(String[] args) { ExecutorService executorService = Executors.newFixedThreadPool(1); try { String tenant = "tenant.domain.com"; String clientId = "%client_id%"; String clientKey = "%client_key%"; String restApiEndpoint = "https://account.restv2.region.media.azure.net/api/"; // Connect to Media Services API with service principal and client symmetric key AzureAdTokenCredentials credentials = new AzureAdTokenCredentials( tenant, new AzureAdClientSymmetricKey(clientId, clientKey), AzureEnvironments.AZURE_CLOUD_ENVIRONMENT); TokenProvider provider = new AzureAdTokenProvider(credentials, executorService); // create a new configuration with the new credentials Configuration configuration = MediaConfiguration.configureWithAzureAdTokenProvider( new URI(restApiEndpoint), provider); // create the media service provisioned with the new configuration MediaContract mediaService = MediaService.create(configuration); System.out.println("Listing assets"); ListResult<AssetInfo> assets = mediaService.list(Asset.list()); for (AssetInfo asset : assets) { System.out.println(asset.getId()); } } catch (ServiceException se) { System.out.println("ServiceException encountered."); System.out.println(se.toString()); } catch (Throwable e) { System.out.println("Exception encountered."); e.printStackTrace(); System.out.println(e.toString()); } finally { executorService.shutdown(); } }
Example #12
Source File: Program.java From azure-sdk-for-media-services-java-samples with Apache License 2.0 | 4 votes |
public static void main(String[] args) { ExecutorService executorService = Executors.newFixedThreadPool(1); try { // Setup Azure AD Service Principal Symmetric Key Credentials AzureAdTokenCredentials credentials = new AzureAdTokenCredentials( tenant, new AzureAdClientSymmetricKey(clientId, clientKey), AzureEnvironments.AZURE_CLOUD_ENVIRONMENT); TokenProvider provider = new AzureAdTokenProvider(credentials, executorService); // create a new configuration with the new credentials Configuration configuration = MediaConfiguration.configureWithAzureAdTokenProvider( new URI(restApiEndpoint), provider); // create the media service provisioned with the new configuration mediaService = MediaService.create(configuration); System.out.println("Azure SDK for Java - PlayReady & Widevine Dynamic Encryption Sample"); // Upload a local file to a media asset. AssetInfo uploadAsset = uploadFileAndCreateAsset("Azure-Video.wmv"); System.out.println("Uploaded Asset Id: " + uploadAsset.getId()); // Transform the asset. AssetInfo encodedAsset = encode(uploadAsset); System.out.println("Encoded Asset Id: " + encodedAsset.getId()); // Create the ContentKey ContentKeyInfo contentKeyInfo = createCommonTypeContentKey(encodedAsset); System.out.println("Common Encryption Content Key: " + contentKeyInfo.getId()); // Create the ContentKeyAuthorizationPolicy String tokenTemplateString = null; if (tokenRestriction) { tokenTemplateString = addTokenRestrictedAuthorizationPolicy(contentKeyInfo, tokenType); } else { addOpenAuthorizationPolicy(contentKeyInfo); } // Create the AssetDeliveryPolicy createAssetDeliveryPolicy(encodedAsset, contentKeyInfo); if (tokenTemplateString != null) { // Deserializes a string containing the XML representation of the TokenRestrictionTemplate TokenRestrictionTemplate tokenTemplate = TokenRestrictionTemplateSerializer .deserialize(tokenTemplateString); // Generate a test token based on the the data in the given // TokenRestrictionTemplate. // Note: You need to pass the key id Guid because we specified // TokenClaim.ContentKeyIdentifierClaim in during the creation // of TokenRestrictionTemplate. UUID rawKey = UUID.fromString(contentKeyInfo.getId().substring("nb:kid:UUID:".length())); // Token expiration: 1-year Calendar date = Calendar.getInstance(); date.setTime(new Date()); date.add(Calendar.YEAR, 1); // Generate token String testToken = TokenRestrictionTemplateSerializer.generateTestToken(tokenTemplate, null, rawKey, date.getTime(), null); System.out.println(tokenTemplate.getTokenType().toString() + " Test Token: Bearer " + testToken); } // Create the Streaming Origin Locator String url = getStreamingOriginLocator(encodedAsset); System.out.println("Origin Locator Url: " + url); System.out.println("Sample completed!"); } catch (ServiceException se) { System.out.println("ServiceException encountered."); System.out.println(se.toString()); } catch (Exception e) { System.out.println("Exception encountered."); System.out.println(e.toString()); } finally { executorService.shutdown(); } }
Example #13
Source File: Program.java From azure-sdk-for-media-services-java-samples with Apache License 2.0 | 4 votes |
public static void main(String[] args) { ExecutorService executorService = Executors.newFixedThreadPool(1); try { // Connect to Media Services API with service principal and client symmetric key AzureAdTokenCredentials credentials = new AzureAdTokenCredentials( tenant, new AzureAdClientSymmetricKey(clientId, clientKey), AzureEnvironments.AZURE_CLOUD_ENVIRONMENT); TokenProvider provider = new AzureAdTokenProvider(credentials, executorService); // create a new configuration with the new credentials Configuration configuration = MediaConfiguration.configureWithAzureAdTokenProvider( new URI(restApiEndpoint), provider); // create the media service provisioned with the new configuration mediaService = MediaService.create(configuration); System.out.println("Azure SDK for Java - FairPlay Dynamic Encryption Sample"); // Upload a local file to a media asset. AssetInfo uploadAsset = uploadFileAndCreateAsset("Azure-Video.wmv"); System.out.println("Uploaded Asset Id: " + uploadAsset.getId()); // Transform the asset. AssetInfo encodedAsset = encode(uploadAsset); System.out.println("Encoded Asset Id: " + encodedAsset.getId()); // Create the ContentKey ContentKeyInfo contentKeyInfo = createCommonCBCTypeContentKey(encodedAsset); System.out.println("Common Encryption Content Key: " + contentKeyInfo.getId()); // Create the ContentKeyAuthorizationPolicy String tokenTemplateString = null; if (tokenRestriction) { tokenTemplateString = addTokenRestrictedAuthorizationPolicy(contentKeyInfo, tokenType); } else { addOpenAuthorizationPolicy(contentKeyInfo); } // Create the AssetDeliveryPolicy createAssetDeliveryPolicy(encodedAsset, contentKeyInfo); if (tokenTemplateString != null) { // Deserializes a string containing the XML representation of the TokenRestrictionTemplate TokenRestrictionTemplate tokenTemplate = TokenRestrictionTemplateSerializer .deserialize(tokenTemplateString); // Generate a test token based on the the data in the given // TokenRestrictionTemplate. // Note: You need to pass the key id Guid because we specified // TokenClaim.ContentKeyIdentifierClaim in during the creation // of TokenRestrictionTemplate. UUID rawKey = UUID.fromString(contentKeyInfo.getId().substring("nb:kid:UUID:".length())); // Token expiration: 1-year Calendar date = Calendar.getInstance(); date.setTime(new Date()); date.add(Calendar.YEAR, 1); // Generate token String testToken = TokenRestrictionTemplateSerializer.generateTestToken(tokenTemplate, null, rawKey, date.getTime(), null); System.out.println(tokenTemplate.getTokenType().toString() + " Test Token: Bearer " + testToken); } // Create the Streaming Origin Locator String url = getStreamingOriginLocator(encodedAsset); System.out.println("Origin Locator Url: " + url); System.out.println("Sample completed!"); } catch (ServiceException se) { System.out.println("ServiceException encountered."); System.out.println(se.toString()); } catch (Exception e) { System.out.println("Exception encountered."); System.out.println(e.toString()); } finally { executorService.shutdown(); } }
Example #14
Source File: Program.java From azure-sdk-for-media-services-java-samples with Apache License 2.0 | 4 votes |
public static void main(String[] args) { ExecutorService executorService = Executors.newFixedThreadPool(1); try { // Connect to Media Services API with service principal and client symmetric key AzureAdTokenCredentials credentials = new AzureAdTokenCredentials( tenant, new AzureAdClientSymmetricKey(clientId, clientKey), AzureEnvironments.AZURE_CLOUD_ENVIRONMENT); TokenProvider provider = new AzureAdTokenProvider(credentials, executorService); // create a new configuration with the new credentials Configuration configuration = MediaConfiguration.configureWithAzureAdTokenProvider( new URI(restApiEndpoint), provider); // create the media service provisioned with the new configuration mediaService = MediaService.create(configuration); System.out.println("Azure SDK for Java - Media Analytics Sample (Indexer)"); // Upload a local file to an Asset AssetInfo sourceAsset = uploadFileAndCreateAsset(mediaFileName); System.out.println("Uploaded Asset Id: " + sourceAsset.getId()); // Create indexing task configuration based on parameters String indexerTaskPresetTemplate = new String(Files.readAllBytes( Paths.get(new URL(Program.class.getClassLoader().getResource(""), indexerTaskPresetTemplateFileName).toURI()))); String taskConfiguration = String.format(indexerTaskPresetTemplate, title, description, language, captionFormats, generateAIB, generateKeywords); // Run indexing job to generate output asset AssetInfo outputAsset = runIndexingJob(sourceAsset, taskConfiguration); System.out.println("Output Asset Id: " + outputAsset.getId()); // Download output asset files downloadAssetFiles(outputAsset, destinationPath); // Done System.out.println("Sample completed!"); } catch (ServiceException se) { System.out.println("ServiceException encountered."); System.out.println(se.toString()); } catch (Exception e) { System.out.println("Exception encountered."); System.out.println(e.toString()); } finally { executorService.shutdown(); } }
Example #15
Source File: Program.java From azure-sdk-for-media-services-java-samples with Apache License 2.0 | 4 votes |
public static void main(String[] args) { ExecutorService executorService = Executors.newFixedThreadPool(1); try { // Connect to Media Services API with service principal and client symmetric key AzureAdTokenCredentials credentials = new AzureAdTokenCredentials( tenant, new AzureAdClientSymmetricKey(clientId, clientKey), AzureEnvironments.AZURE_CLOUD_ENVIRONMENT); TokenProvider provider = new AzureAdTokenProvider(credentials, executorService); // create a new configuration with the new credentials Configuration configuration = MediaConfiguration.configureWithAzureAdTokenProvider( new URI(restApiEndpoint), provider); // create the media service provisioned with the new configuration mediaService = MediaService.create(configuration); System.out.println("Azure SDK for Java - PlayReady Dynamic Encryption Sample"); // Upload a local file to a media asset. AssetInfo uploadAsset = uploadFileAndCreateAsset("Azure-Video.wmv"); System.out.println("Uploaded Asset Id: " + uploadAsset.getId()); // Transform the asset. AssetInfo encodedAsset = encode(uploadAsset); System.out.println("Encoded Asset Id: " + encodedAsset.getId()); // Create the ContentKey ContentKeyInfo contentKeyInfo = createCommonTypeContentKey(encodedAsset); System.out.println("Common Encryption Content Key: " + contentKeyInfo.getId()); // Create the ContentKeyAuthorizationPolicy String tokenTemplateString = null; if (tokenRestriction) { tokenTemplateString = addTokenRestrictedAuthorizationPolicy(contentKeyInfo, tokenType); } else { addOpenAuthorizationPolicy(contentKeyInfo); } // Create the AssetDeliveryPolicy createAssetDeliveryPolicy(encodedAsset, contentKeyInfo); if (tokenTemplateString != null) { // Deserializes a string containing the XML representation of the TokenRestrictionTemplate TokenRestrictionTemplate tokenTemplate = TokenRestrictionTemplateSerializer .deserialize(tokenTemplateString); // Generate a test token based on the the data in the given // TokenRestrictionTemplate. // Note: You need to pass the key id Guid because we specified // TokenClaim.ContentKeyIdentifierClaim in during the creation // of TokenRestrictionTemplate. UUID rawKey = UUID.fromString(contentKeyInfo.getId().substring("nb:kid:UUID:".length())); // Token expiration: 1-year Calendar date = Calendar.getInstance(); date.setTime(new Date()); date.add(Calendar.YEAR, 1); // Generate token String testToken = TokenRestrictionTemplateSerializer.generateTestToken(tokenTemplate, null, rawKey, date.getTime(), null); System.out.println(tokenTemplate.getTokenType().toString() + " Test Token: Bearer " + testToken); } // Create the Streaming Origin Locator String url = getStreamingOriginLocator(encodedAsset); System.out.println("Origin Locator Url: " + url); System.out.println("Sample completed!"); } catch (ServiceException se) { System.out.println("ServiceException encountered."); System.out.println(se.toString()); } catch (Exception e) { System.out.println("Exception encountered."); System.out.println(e.toString()); } finally { executorService.shutdown(); } }
Example #16
Source File: AzureKms.java From sfs with Apache License 2.0 | 4 votes |
protected KeyVaultClient createKeyVaultClient(VertxContext<Server> vertxContext) throws Exception { Configuration config = createConfiguration(vertxContext); return create(config); }
Example #17
Source File: AzureComputeService.java From crate with Apache License 2.0 | votes |
Configuration configuration();