diff --git a/sdk/maps/README.md b/sdk/maps/README.md index 1a28f35ffcd47..ffc462b518e1f 100644 --- a/sdk/maps/README.md +++ b/sdk/maps/README.md @@ -7,9 +7,13 @@ Microsoft Azure Maps provides developers from all industries with powerful geosp ## Getting started To get started with a specific library, see the **README.md** file located in the library's project folder. -- [Azure Maps Search](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/maps/azure-maps-search/README.md) contains Search APIs for querying addresses, nearby locations, geopolygons etc. -- [Azure Maps Route](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/maps/azure-maps-route/README.md) contains Route APIs for calculating matrix of route summaries, returning routes between destinations, etc. +- [Azure Maps Geolocation](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/maps/azure-maps-geolocation/README.md) contains Geolocation APIs for determining the country/region of an IP address, etc. - [Azure Maps Render](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/maps/azure-maps-render/README.md) contains Render APIs to request map tiles, metadata for tilesets, etc. +- [Azure Maps Route](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/maps/azure-maps-route/README.md) contains Route APIs for calculating matrix of route summaries, returning routes between destinations, etc. +- [Azure Maps Search](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/maps/azure-maps-search/README.md) contains Search APIs for querying addresses, nearby locations, geopolygons, etc. +- [Azure Maps Timezone](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/maps/azure-maps-timezone/README.md) contains Timezone APIs for converting between UTC and local times based on geographic locations, etc. +- [Azure Maps Traffic](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/maps/azure-maps-traffic/README.md) contains Traffic APIs for providing traffic flow and incident information to enhance navigation and routing applications, etc. +- [Azure Maps Weather](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/maps/azure-maps-weather/README.md) contains Weather APIs for retrieving current weather conditions, forecasts, and weather alerts, etc. ## Key concepts @@ -20,9 +24,13 @@ For details on contributing to this repository, see the [contributing guide](htt ## Examples For examples of each module please see: -- [Azure Maps Search Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-search/src/samples) -- [Azure Maps Route Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-route/src/samples) +- [Azure Maps Geolocation Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-geolocation/src/samples) - [Azure Maps Render Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-render/src/samples) +- [Azure Maps Route Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-route/src/samples) +- [Azure Maps Search Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-search/src/samples) +- [Azure Maps Timezone Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-timezone/src/samples) +- [Azure Maps Traffic Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-traffic/src/samples) +- [Azure Maps Weather Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-weather/src/samples) ## Troubleshooting When you interact with the Azure Maps Services, errors returned by the Maps service correspond to the same HTTP status codes returned for REST API requests. @@ -32,11 +40,13 @@ For example, if you search with an invalid coordinate, a error is returned, indi ## Next steps Several Azure Maps Java SDK samples are available to you in the SDK's GitHub repository. -- [Azure Maps Search Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-search/src/samples) -- [Azure Maps Route Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-route/src/samples) -) +- [Azure Maps Geolocation Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-geolocation/src/samples) - [Azure Maps Render Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-render/src/samples) -) +- [Azure Maps Route Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-route/src/samples) +- [Azure Maps Search Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-search/src/samples) +- [Azure Maps Timezone Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-timezone/src/samples) +- [Azure Maps Traffic Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-traffic/src/samples) +- [Azure Maps Weather Samples](https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-maps-weather/src/samples) ## Contributing diff --git a/sdk/maps/azure-maps-geolocation/CHANGELOG.md b/sdk/maps/azure-maps-geolocation/CHANGELOG.md index add66ab5a81eb..458bac2a3c896 100644 --- a/sdk/maps/azure-maps-geolocation/CHANGELOG.md +++ b/sdk/maps/azure-maps-geolocation/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.0.0-beta.3 (Unreleased) + +### Features added + +- Integrated support for SAS-based authentication + ## 1.0.0-beta.2 (2024-11-08) ### Other Changes diff --git a/sdk/maps/azure-maps-geolocation/README.md b/sdk/maps/azure-maps-geolocation/README.md index 202b6703f4df6..cafe8bb8f571e 100644 --- a/sdk/maps/azure-maps-geolocation/README.md +++ b/sdk/maps/azure-maps-geolocation/README.md @@ -39,7 +39,9 @@ Azure Management Libraries require a `TokenCredential` implementation for authen ### Authentication -By default, Azure Active Directory token authentication depends on correct configure of following environment variables. +There are 3 ways to authenticate the client: Shared key authentication, Microsoft Entra ID authentication, and shared access signature (SAS) authentication. + +By default, Microsoft Entra ID token authentication depends on correct configure of following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. @@ -61,7 +63,9 @@ GeolocationClient client = new GeolocationClientBuilder() .buildClient(); ``` -TThe sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. +The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. + +For SAS-based authentication, please refer to [AccountsListSasSamples.java][https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-resourcemanager-maps/src/samples/java/com/azure/resourcemanager/maps/generated/AccountsListSasSamples.java]. See [Authentication][authenticate] for more options. diff --git a/sdk/maps/azure-maps-geolocation/src/main/java/com/azure/maps/geolocation/GeolocationClientBuilder.java b/sdk/maps/azure-maps-geolocation/src/main/java/com/azure/maps/geolocation/GeolocationClientBuilder.java index ec599489f18d7..6e349fb8e77a8 100644 --- a/sdk/maps/azure-maps-geolocation/src/main/java/com/azure/maps/geolocation/GeolocationClientBuilder.java +++ b/sdk/maps/azure-maps-geolocation/src/main/java/com/azure/maps/geolocation/GeolocationClientBuilder.java @@ -10,7 +10,9 @@ import com.azure.core.client.traits.EndpointTrait; import com.azure.core.client.traits.HttpTrait; import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.client.traits.AzureSasCredentialTrait; import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.credential.AzureSasCredential; import com.azure.core.credential.TokenCredential; import com.azure.core.http.HttpClient; import com.azure.core.http.HttpHeaderName; @@ -28,6 +30,7 @@ import com.azure.core.http.policy.RetryOptions; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.policy.AzureSasCredentialPolicy; import com.azure.core.util.ClientOptions; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; @@ -58,7 +61,8 @@ * */ @ServiceClientBuilder(serviceClients = { GeolocationClient.class, GeolocationAsyncClient.class }) -public final class GeolocationClientBuilder implements AzureKeyCredentialTrait, +public final class GeolocationClientBuilder + implements AzureKeyCredentialTrait, AzureSasCredentialTrait, TokenCredentialTrait, HttpTrait, ConfigurationTrait, EndpointTrait { @@ -98,6 +102,7 @@ public final class GeolocationClientBuilder implements AzureKeyCredentialTrait */ @ServiceClientBuilder(serviceClients = { MapsRenderClient.class, MapsRenderAsyncClient.class }) -public final class MapsRenderClientBuilder implements AzureKeyCredentialTrait, +public final class MapsRenderClientBuilder + implements AzureKeyCredentialTrait, AzureSasCredentialTrait, TokenCredentialTrait, HttpTrait, ConfigurationTrait, EndpointTrait { @@ -142,6 +146,7 @@ public MapsRenderClientBuilder() { // credentials private AzureKeyCredential keyCredential; private TokenCredential tokenCredential; + private AzureSasCredential sasCredential; /** * Sets the Azure Maps client id for use with Azure AD Authentication. This client id @@ -297,6 +302,19 @@ public MapsRenderClientBuilder credential(AzureKeyCredential keyCredential) { return this; } + /** + * Sets the {@link AzureSasCredential} used to authenticate HTTP requests. + * + * @param sasCredential The {@link AzureSasCredential} used to authenticate HTTP requests. + * @return The updated {@link MapsRenderClientBuilder} object. + * @throws NullPointerException If {@code sasCredential} is null. + */ + @Override + public MapsRenderClientBuilder credential(AzureSasCredential sasCredential) { + this.sasCredential = Objects.requireNonNull(sasCredential, "'sasCredential' cannot be null."); + return this; + } + /** * Builds an instance of RenderClientImpl with the provided parameters. * @@ -361,6 +379,8 @@ private HttpPipeline createHttpPipeline() { policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); } else if (keyCredential != null) { policies.add(new AzureKeyCredentialPolicy(RENDER_SUBSCRIPTION_KEY, keyCredential)); + } else if (sasCredential != null) { + policies.add(new AzureSasCredentialPolicy(sasCredential)); } else { // Throw exception that credential and tokenCredential cannot be null throw LOGGER.logExceptionAsError( diff --git a/sdk/maps/azure-maps-route/CHANGELOG.md b/sdk/maps/azure-maps-route/CHANGELOG.md index 76a574785c98e..80041579dc59e 100644 --- a/sdk/maps/azure-maps-route/CHANGELOG.md +++ b/sdk/maps/azure-maps-route/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.0.0-beta.3 (Unreleased) + +### Features added + +- Integrated support for SAS-based authentication + ## 1.0.0-beta.2 (2024-11-08) ### Other Changes diff --git a/sdk/maps/azure-maps-route/README.md b/sdk/maps/azure-maps-route/README.md index 1388e68c0f664..c0907db67450a 100644 --- a/sdk/maps/azure-maps-route/README.md +++ b/sdk/maps/azure-maps-route/README.md @@ -39,7 +39,9 @@ Azure Maps Libraries require a `TokenCredential` implementation for authenticati ### Authentication -By default, Azure Active Directory token authentication depends on correct configure of following environment variables. +There are 3 ways to authenticate the client: Shared key authentication, Microsoft Entra ID authentication, and shared access signature (SAS) authentication. + +By default, Microsoft Entra ID token authentication depends on correct configure of following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. @@ -66,6 +68,8 @@ MapsRouteAsyncClient client = builder.buildAsyncClient(); The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. +For SAS-based authentication, please refer to [AccountsListSasSamples.java][https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-resourcemanager-maps/src/samples/java/com/azure/resourcemanager/maps/generated/AccountsListSasSamples.java]. + See [Authentication][authenticate] for more options. ## Key concepts diff --git a/sdk/maps/azure-maps-route/src/main/java/com/azure/maps/route/MapsRouteClientBuilder.java b/sdk/maps/azure-maps-route/src/main/java/com/azure/maps/route/MapsRouteClientBuilder.java index 44bc45dcad518..7aa01adf8c9a7 100644 --- a/sdk/maps/azure-maps-route/src/main/java/com/azure/maps/route/MapsRouteClientBuilder.java +++ b/sdk/maps/azure-maps-route/src/main/java/com/azure/maps/route/MapsRouteClientBuilder.java @@ -9,7 +9,9 @@ import com.azure.core.client.traits.EndpointTrait; import com.azure.core.client.traits.HttpTrait; import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.client.traits.AzureSasCredentialTrait; import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.credential.AzureSasCredential; import com.azure.core.credential.TokenCredential; import com.azure.core.http.HttpClient; import com.azure.core.http.HttpHeaderName; @@ -27,6 +29,7 @@ import com.azure.core.http.policy.RetryOptions; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.policy.AzureSasCredentialPolicy; import com.azure.core.util.ClientOptions; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; @@ -76,7 +79,8 @@ * */ @ServiceClientBuilder(serviceClients = { MapsRouteClient.class, MapsRouteAsyncClient.class }) -public final class MapsRouteClientBuilder implements AzureKeyCredentialTrait, +public final class MapsRouteClientBuilder + implements AzureKeyCredentialTrait, AzureSasCredentialTrait, TokenCredentialTrait, HttpTrait, ConfigurationTrait, EndpointTrait { @@ -109,6 +113,7 @@ public final class MapsRouteClientBuilder implements AzureKeyCredentialTrait */ @ServiceClientBuilder(serviceClients = { MapsSearchClient.class, MapsSearchAsyncClient.class }) -public final class MapsSearchClientBuilder implements AzureKeyCredentialTrait, +public final class MapsSearchClientBuilder + implements AzureKeyCredentialTrait, AzureSasCredentialTrait, TokenCredentialTrait, HttpTrait, ConfigurationTrait, EndpointTrait { @@ -94,6 +98,7 @@ public final class MapsSearchClientBuilder implements AzureKeyCredentialTrait - * + * */ @ServiceClientBuilder(serviceClients = { TimeZoneClient.class, TimeZoneAsyncClient.class }) -public final class TimeZoneClientBuilder - implements AzureKeyCredentialTrait, TokenCredentialTrait, +public final class TimeZoneClientBuilder implements AzureKeyCredentialTrait, + AzureSasCredentialTrait, TokenCredentialTrait, HttpTrait, ConfigurationTrait, EndpointTrait { // constants @@ -105,6 +108,7 @@ public final class TimeZoneClientBuilder // credentials private AzureKeyCredential keyCredential; private TokenCredential tokenCredential; + private AzureSasCredential sasCredential; /** Default constructor for the builder class; Create an instance of the TimeZoneClientBuilder. */ public TimeZoneClientBuilder() { @@ -269,6 +273,19 @@ public TimeZoneClientBuilder credential(AzureKeyCredential keyCredential) { return this; } + /** + * Sets the {@link AzureSasCredential} used to authenticate HTTP requests. + * + * @param sasCredential The {@link AzureSasCredential} used to authenticate HTTP requests. + * @return The updated {@link TimeZoneClientBuilder} object. + * @throws NullPointerException If {@code sasCredential} is null. + */ + @Override + public TimeZoneClientBuilder credential(AzureSasCredential sasCredential) { + this.sasCredential = Objects.requireNonNull(sasCredential, "'sasCredential' cannot be null."); + return this; + } + /** * Sets retry options * @param retryOptions the retry options for the client @@ -345,6 +362,8 @@ private HttpPipeline createHttpPipeline() { policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); } else if (keyCredential != null) { policies.add(new AzureKeyCredentialPolicy(MAPS_SUBSCRIPTION_KEY, keyCredential)); + } else if (sasCredential != null) { + policies.add(new AzureSasCredentialPolicy(sasCredential)); } else { // Throw exception that credential and tokenCredential cannot be null throw LOGGER.logExceptionAsError( diff --git a/sdk/maps/azure-maps-weather/CHANGELOG.md b/sdk/maps/azure-maps-weather/CHANGELOG.md index 6aed7fbe108a3..2dc76f0b881dc 100644 --- a/sdk/maps/azure-maps-weather/CHANGELOG.md +++ b/sdk/maps/azure-maps-weather/CHANGELOG.md @@ -4,6 +4,8 @@ ### Features Added +- Integrated support for SAS-based authentication + ### Breaking Changes ### Bugs Fixed diff --git a/sdk/maps/azure-maps-weather/README.md b/sdk/maps/azure-maps-weather/README.md index f04f50c22921d..ec34892e0de8c 100644 --- a/sdk/maps/azure-maps-weather/README.md +++ b/sdk/maps/azure-maps-weather/README.md @@ -39,7 +39,9 @@ Azure Maps Libraries require a `TokenCredential` implementation for authenticati ### Authentication -By default, Azure Active Directory token authentication depends on correct configure of following environment variables. +There are 3 ways to authenticate the client: Shared key authentication, Microsoft Entra ID authentication, and shared access signature (SAS) authentication. + +By default, Microsoft Entra ID token authentication depends on correct configuration of the following environment variables. - `AZURE_CLIENT_ID` for Azure client ID. - `AZURE_TENANT_ID` for Azure tenant ID. @@ -63,6 +65,8 @@ WeatherClient client = new WeatherClientBuilder() The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. +For SAS-based authentication, please refer to [AccountsListSasSamples.java][https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/maps/azure-resourcemanager-maps/src/samples/java/com/azure/resourcemanager/maps/generated/AccountsListSasSamples.java]. + See [Authentication][authenticate] for more options. ## Key concepts diff --git a/sdk/maps/azure-maps-weather/src/main/java/com/azure/maps/weather/WeatherClientBuilder.java b/sdk/maps/azure-maps-weather/src/main/java/com/azure/maps/weather/WeatherClientBuilder.java index 828a85f0916b8..bb2a8196710ff 100644 --- a/sdk/maps/azure-maps-weather/src/main/java/com/azure/maps/weather/WeatherClientBuilder.java +++ b/sdk/maps/azure-maps-weather/src/main/java/com/azure/maps/weather/WeatherClientBuilder.java @@ -9,7 +9,9 @@ import com.azure.core.client.traits.EndpointTrait; import com.azure.core.client.traits.HttpTrait; import com.azure.core.client.traits.TokenCredentialTrait; +import com.azure.core.client.traits.AzureSasCredentialTrait; import com.azure.core.credential.AzureKeyCredential; +import com.azure.core.credential.AzureSasCredential; import com.azure.core.credential.TokenCredential; import com.azure.core.http.HttpClient; import com.azure.core.http.HttpHeaderName; @@ -27,6 +29,7 @@ import com.azure.core.http.policy.RetryOptions; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.http.policy.AzureSasCredentialPolicy; import com.azure.core.util.ClientOptions; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; @@ -50,7 +53,7 @@ * AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); * * // Creates a client - * WeatherClient client = new WeatherClientBuilder() + * WeatherClient client = new WeatherClientBuilder() * .credential(keyCredential) * .weatherClientId(System.getenv("MAPS_CLIENT_ID")) * .buildClient(); @@ -72,8 +75,8 @@ * */ @ServiceClientBuilder(serviceClients = { WeatherClient.class, WeatherAsyncClient.class }) -public final class WeatherClientBuilder - implements AzureKeyCredentialTrait, TokenCredentialTrait, +public final class WeatherClientBuilder implements AzureKeyCredentialTrait, + AzureSasCredentialTrait, TokenCredentialTrait, HttpTrait, ConfigurationTrait, EndpointTrait { // constants @@ -104,6 +107,7 @@ public final class WeatherClientBuilder // credentials private AzureKeyCredential keyCredential; private TokenCredential tokenCredential; + private AzureSasCredential sasCredential; /** * Default constructor for the builder class. @@ -265,6 +269,18 @@ public WeatherClientBuilder credential(AzureKeyCredential keyCredential) { return this; } + /** + * Sets the {@link AzureSasCredential} used to authenticate HTTP requests. + * + * @param sasCredential The {@link AzureSasCredential} used to authenticate HTTP requests. + * @return The updated {@link WeatherClientBuilder} object. + * @throws NullPointerException If {@code sasCredential} is null. + */ + public WeatherClientBuilder credential(AzureSasCredential sasCredential) { + this.sasCredential = Objects.requireNonNull(sasCredential, "'sasCredential' cannot be null."); + return this; + } + /** * Sets retry options * @param retryOptions the retry options for the client @@ -341,6 +357,8 @@ private HttpPipeline createHttpPipeline() { policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES)); } else if (keyCredential != null) { policies.add(new AzureKeyCredentialPolicy(MAPS_SUBSCRIPTION_KEY, keyCredential)); + } else if (sasCredential != null) { + policies.add(new AzureSasCredentialPolicy(sasCredential)); } else { // Throw exception that credential and tokenCredential cannot be null throw LOGGER.logExceptionAsError(