Skip to content

Commit 14f5b5e

Browse files
authored
Fix ClassNotFoundException for StringUtils in AAD starter (#47601)
1 parent b4d7e6b commit 14f5b5e

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed

sdk/spring/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Release History
22

3+
## 6.2.0-beta.1 (Unreleased)
4+
5+
### Spring Cloud Azure Autoconfigure
6+
This section includes changes in `spring-cloud-azure-autoconfigure` module.
7+
8+
#### Bugs Fixed
9+
10+
- Fix `ClassNotFoundException: com.nimbusds.oauth2.sdk.util.StringUtils` in Active Directory starter. ([#47600](https://github.com/Azure/azure-sdk-for-java/issues/47600))
11+
312
## 6.1.0 (2025-12-16)
413
- This release is compatible with Spring Boot 3.5.0-3.5.8. (Note: 3.5.x (x>8) should be supported, but they aren't tested with this release.)
514
- This release is compatible with Spring Cloud 2025.0.0. (Note: 2025.0.x (x>0) should be supported, but they aren't tested with this release.)

sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/aad/security/properties/AadAuthorizationServerEndpoints.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
package com.azure.spring.cloud.autoconfigure.implementation.aad.security.properties;
55

6-
import com.nimbusds.oauth2.sdk.util.StringUtils;
6+
import org.springframework.util.StringUtils;
77

88
/**
99
* Used to get endpoints for Microsoft Identity authorization server.
@@ -27,7 +27,7 @@ public class AadAuthorizationServerEndpoints {
2727
* @param tenantId the tenant ID
2828
*/
2929
public AadAuthorizationServerEndpoints(String baseUri, String tenantId) {
30-
if (StringUtils.isBlank(baseUri)) {
30+
if (!StringUtils.hasText(baseUri)) {
3131
baseUri = DEFAULT_BASE_URI;
3232
}
3333
this.baseUri = addSlash(baseUri);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.spring.cloud.autoconfigure.implementation.aad.security.properties;
5+
6+
import org.junit.jupiter.api.Test;
7+
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
9+
10+
class AadAuthorizationServerEndpointsTests {
11+
12+
private static final String DEFAULT_BASE_URI = "https://login.microsoftonline.com/";
13+
private static final String CUSTOM_BASE_URI = "https://custom.endpoint.com/";
14+
private static final String TENANT_ID = "test-tenant-id";
15+
16+
@Test
17+
void constructorWithNullBaseUri() {
18+
AadAuthorizationServerEndpoints endpoints = new AadAuthorizationServerEndpoints(null, TENANT_ID);
19+
assertEquals(DEFAULT_BASE_URI, endpoints.getBaseUri());
20+
}
21+
22+
@Test
23+
void constructorWithEmptyBaseUri() {
24+
AadAuthorizationServerEndpoints endpoints = new AadAuthorizationServerEndpoints("", TENANT_ID);
25+
assertEquals(DEFAULT_BASE_URI, endpoints.getBaseUri());
26+
}
27+
28+
@Test
29+
void constructorWithWhitespaceBaseUri() {
30+
AadAuthorizationServerEndpoints endpoints = new AadAuthorizationServerEndpoints(" ", TENANT_ID);
31+
assertEquals(DEFAULT_BASE_URI, endpoints.getBaseUri());
32+
}
33+
34+
@Test
35+
void constructorWithValidBaseUri() {
36+
AadAuthorizationServerEndpoints endpoints = new AadAuthorizationServerEndpoints(CUSTOM_BASE_URI, TENANT_ID);
37+
assertEquals(CUSTOM_BASE_URI, endpoints.getBaseUri());
38+
}
39+
40+
@Test
41+
void constructorWithBaseUriWithoutTrailingSlash() {
42+
String baseUriWithoutSlash = "https://custom.endpoint.com";
43+
AadAuthorizationServerEndpoints endpoints = new AadAuthorizationServerEndpoints(baseUriWithoutSlash, TENANT_ID);
44+
assertEquals(baseUriWithoutSlash + "/", endpoints.getBaseUri());
45+
}
46+
47+
@Test
48+
void getAuthorizationEndpoint() {
49+
AadAuthorizationServerEndpoints endpoints = new AadAuthorizationServerEndpoints(DEFAULT_BASE_URI, TENANT_ID);
50+
String authEndpoint = endpoints.getAuthorizationEndpoint();
51+
assertEquals(DEFAULT_BASE_URI + TENANT_ID + "/oauth2/v2.0/authorize", authEndpoint);
52+
}
53+
54+
@Test
55+
void getTokenEndpoint() {
56+
AadAuthorizationServerEndpoints endpoints = new AadAuthorizationServerEndpoints(DEFAULT_BASE_URI, TENANT_ID);
57+
String tokenEndpoint = endpoints.getTokenEndpoint();
58+
assertEquals(DEFAULT_BASE_URI + TENANT_ID + "/oauth2/v2.0/token", tokenEndpoint);
59+
}
60+
61+
@Test
62+
void getJwkSetEndpoint() {
63+
AadAuthorizationServerEndpoints endpoints = new AadAuthorizationServerEndpoints(DEFAULT_BASE_URI, TENANT_ID);
64+
String jwkSetEndpoint = endpoints.getJwkSetEndpoint();
65+
assertEquals(DEFAULT_BASE_URI + TENANT_ID + "/discovery/v2.0/keys", jwkSetEndpoint);
66+
}
67+
68+
@Test
69+
void getEndSessionEndpoint() {
70+
AadAuthorizationServerEndpoints endpoints = new AadAuthorizationServerEndpoints(DEFAULT_BASE_URI, TENANT_ID);
71+
String endSessionEndpoint = endpoints.getEndSessionEndpoint();
72+
assertEquals(DEFAULT_BASE_URI + TENANT_ID + "/oauth2/v2.0/logout", endSessionEndpoint);
73+
}
74+
}

0 commit comments

Comments
 (0)