-
Notifications
You must be signed in to change notification settings - Fork 103
Update Communication Common SDK for Teams Phone Extensibility identifier #1918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alexandra142
merged 16 commits into
Azure:main
from
alexandra142:feature/apistrak/AddOPS
Jun 12, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8c0cfee
Add TeamsPhoneExtensionIdentifier, Add isAnonymous and getAssertedId …
c97e372
Merge branch 'main' into feature/apistrak/AddOPS
b9d0065
Set Is Anonymous during instantiation.
69e4a55
Set Is Anonymous during setting a rawId
f0f0f2f
Add test for IsAnonymous when SetRawId method is called.
9394777
Add test for IsAnonymous when SetRawId method is called.
8298fef
Rename StringUtils.java to ValidationUtils.java
a5cf341
Use class parameters for TeamsExtensionIdentifier tests
b7da6b6
Use class parameters for TeamsExtensionIdentifier_rawIdTakesPrecedenc…
c23d164
Use class parameters for TeamsExtensionIdentifier_rawIdTakesPrecedenc…
fcfa405
Set 1.3.0 version
1010140
Revert changes
1637443
Update readme
fee1ea2
Fix Gradle.properties to version 1.3..
6521718
Remove empty rows
b13314d
Merge branch 'main' into feature/apistrak/AddOPS
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=1.2.1 | ||
version=1.3.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
...on/src/main/java/com/azure/android/communication/common/TeamsExtensionUserIdentifier.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.android.communication.common; | ||
|
||
/** | ||
* Communication identifier for Microsoft Teams Phone user who is using a Communication Services resource | ||
* to extend their Teams Phone set up. | ||
*/ | ||
public final class TeamsExtensionUserIdentifier extends CommunicationIdentifier { | ||
|
||
private final String userId; | ||
|
||
private final String tenantId; | ||
|
||
private final String resourceId; | ||
|
||
private CommunicationCloudEnvironment cloudEnvironment; | ||
|
||
/** | ||
* Creates a TeamsExtensionUserIdentifier object with PUBLIC cloud environment. | ||
* | ||
* @param userId ID of the Microsoft Teams Extension user i.e. the Entra ID object id of the user. | ||
* @param tenantId Tenant ID of the Microsoft Teams Extension user. | ||
* @param resourceId The Communication Services resource id. | ||
* @throws IllegalArgumentException if any parameter fail the validation. | ||
*/ | ||
public TeamsExtensionUserIdentifier(String userId, String tenantId, String resourceId) { | ||
this.userId = ValidationUtils.validateNotNullOrEmpty(userId, "userId"); | ||
this.tenantId = ValidationUtils.validateNotNullOrEmpty(tenantId, "tenantId"); | ||
this.resourceId = ValidationUtils.validateNotNullOrEmpty(resourceId, "resourceId"); | ||
this.cloudEnvironment = CommunicationCloudEnvironment.PUBLIC; | ||
|
||
generateRawId(); | ||
} | ||
|
||
/** | ||
* Set full ID of the identifier | ||
* RawId is the encoded format for identifiers to store in databases or as stable keys in general. | ||
* | ||
* @param rawId full ID of the identifier. | ||
* @return TeamsExtensionUserIdentifier object itself. | ||
*/ | ||
@Override | ||
public TeamsExtensionUserIdentifier setRawId(String rawId) { | ||
super.setRawId(rawId); | ||
return this; | ||
} | ||
|
||
/** | ||
* Get Microsoft Teams Extension user | ||
* @return ID of the Microsoft Teams Extension user i.e. the Entra ID object id of the user. | ||
*/ | ||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
/** | ||
* Get Microsoft Teams Extension user Tenant ID | ||
* @return Tenant ID of the Microsoft Teams Extension user. | ||
*/ | ||
public String getTenantId() { | ||
return tenantId; | ||
} | ||
|
||
/** | ||
* Get Communication Services resource id. | ||
* @return the Communication Services resource id. | ||
*/ | ||
public String getResourceId() { | ||
return resourceId; | ||
} | ||
|
||
/** | ||
* Get cloud environment of the Teams Extension User identifier | ||
* @return cloud environment in which this identifier is created | ||
*/ | ||
public CommunicationCloudEnvironment getCloudEnvironment() { | ||
return cloudEnvironment; | ||
} | ||
|
||
/** | ||
* Set cloud environment of the Teams Extension User identifier | ||
* | ||
* @param cloudEnvironment the cloud environment in which this identifier is created | ||
* @return this object | ||
* @throws IllegalArgumentException if cloudEnvironment . | ||
* | ||
*/ | ||
public TeamsExtensionUserIdentifier setCloudEnvironment(CommunicationCloudEnvironment cloudEnvironment) { | ||
this.cloudEnvironment = ValidationUtils.validateNotNull(cloudEnvironment, "cloudEnvironment"); | ||
generateRawId(); | ||
return this; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object that) { | ||
if (this == that) { | ||
return true; | ||
} | ||
|
||
if (!(that instanceof TeamsExtensionUserIdentifier)) { | ||
return false; | ||
} | ||
|
||
return super.equals(that); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return super.hashCode(); | ||
} | ||
|
||
private void generateRawId() { | ||
String identifierBase = this.resourceId + "_" + this.tenantId + "_" + this.userId; | ||
if (cloudEnvironment.equals(CommunicationCloudEnvironment.DOD)) { | ||
super.setRawId(ACS_USER_DOD_CLOUD_PREFIX + identifierBase); | ||
} else if (cloudEnvironment.equals(CommunicationCloudEnvironment.GCCH)) { | ||
super.setRawId(ACS_USER_GCCH_CLOUD_PREFIX + identifierBase); | ||
} else { | ||
super.setRawId(ACS_USER_PREFIX + identifierBase); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...nication-common/src/main/java/com/azure/android/communication/common/ValidationUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.android.communication.common; | ||
|
||
class ValidationUtils { | ||
|
||
/** | ||
* Validate string | ||
* @param value a value to be validated | ||
* @param paramName Parameter name for exceptionMessage | ||
* @return value | ||
* | ||
* @throws IllegalArgumentException when value is null or Empty. | ||
*/ | ||
public static String validateNotNullOrEmpty(String value, String paramName) { | ||
if (value == null || value.trim().isEmpty()) { | ||
String message = "The parameter [" + paramName + "] cannot be null or empty."; | ||
throw new IllegalArgumentException(message); | ||
} | ||
return value; | ||
} | ||
|
||
/** | ||
* Validate string | ||
* @param cloudEnvironment a value to be validated | ||
* @param paramName Parameter name for exceptionMessage | ||
* @return value | ||
* | ||
* @throws IllegalArgumentException when value is null or Empty. | ||
*/ | ||
public static CommunicationCloudEnvironment validateNotNull(CommunicationCloudEnvironment cloudEnvironment, | ||
alexandra142 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
String paramName) { | ||
if (cloudEnvironment == null) { | ||
String message = "The parameter [" + paramName + "] cannot be null."; | ||
throw new IllegalArgumentException(message); | ||
} | ||
return cloudEnvironment; | ||
} | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.