Skip to content

Commit

Permalink
Reset changes to the patch version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aigerim Beishenbekova authored and Aigerim Beishenbekova committed Jan 17, 2022
1 parent d804de7 commit 3aae45b
Show file tree
Hide file tree
Showing 80 changed files with 1,095 additions and 2,391 deletions.
10 changes: 7 additions & 3 deletions sdk/communication/azure-communication-identity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Release History

## 1.2.0-beta.1 (2021-10-29)
## 1.1.4 (2021-11-11)

### Features Added
- Added support for Microsoft 365 Teams identities
### Other Changes

#### Dependency Updates

- Upgraded `azure-communication-common` to 1.0.6
- Upgraded `azure-core` to 1.22.0

## 1.1.3 (2021-10-08)

Expand Down
43 changes: 20 additions & 23 deletions sdk/communication/azure-communication-identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ add the direct dependency to your project as follows.
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-identity</artifactId>
<version>1.1.4</version>
<version>1.1.1</version>
</dependency>
```

Expand All @@ -69,7 +69,8 @@ A `DefaultAzureCredential` object must be passed to the `CommunicationIdentityCl
`AZURE_CLIENT_SECRET`, `AZURE_CLIENT_ID` and `AZURE_TENANT_ID` environment variables
are needed to create a DefaultAzureCredential object.

```java readme-sample-createCommunicationIdentityClientWithAAD
<!-- embedme ./src/samples/java/com/azure/communication/identity/ReadmeSamples.java#L55-L61 -->
```java
// You can find your endpoint and access key from your resource in the Azure Portal
String endpoint = "https://<RESOURCE_NAME>.communication.azure.com";

Expand All @@ -83,7 +84,8 @@ CommunicationIdentityClient communicationIdentityClient = new CommunicationIdent
Identity uses HMAC authentication with the resource access key.
The access key can be used to create an AzureKeyCredential and provided to the `CommunicationIdentityClientBuilder` via the credential() function. Endpoint and httpClient must also be set via the endpoint() and httpClient() functions respectively.

```java readme-sample-createCommunicationIdentityClient
<!-- embedme ./src/samples/java/com/azure/communication/identity/ReadmeSamples.java#L21-L28 -->
```java
// You can find your endpoint and access key from your resource in the Azure Portal
String endpoint = "https://<RESOURCE_NAME>.communication.azure.com";
AzureKeyCredential keyCredential = new AzureKeyCredential("<access-key>");
Expand All @@ -96,8 +98,8 @@ CommunicationIdentityClient communicationIdentityClient = new CommunicationIdent

### Connection String Authentication
Alternatively, you can provide the entire connection string using the connectionString() function instead of providing the endpoint and access key.

```java readme-sample-createCommunicationIdentityClientWithConnectionString
<!-- embedme ./src/samples/java/com/azure/communication/identity/ReadmeSamples.java#L39-L44 -->
```java
// You can find your connection string from your resource in the Azure Portal
String connectionString = "<connection_string>";

Expand All @@ -116,18 +118,20 @@ CommunicationIdentityClient communicationIdentityClient = new CommunicationIdent
Use the `createUser` function to create a new user. `user.getId()` gets the
unique ID of the user that was created.

```java readme-sample-createNewUser
<!-- embedme ./src/samples/java/com/azure/communication/identity/ReadmeSamples.java#L73-L74 -->
```java
CommunicationUserIdentifier user = communicationIdentityClient.createUser();
System.out.println("User id: " + user.getId());
```

### Getting a token for an existing user
Use the `getToken` function to get a token for an existing user. The function
also takes in a list of `CommunicationTokenScope`. Scope options include:
also takes in a list of `CommunicationIdentityTokenScope`. Scope options include:
- `chat` (Chat)
- `voip` (Voice over IP)

```java readme-sample-issueUserToken
<!-- embedme ./src/samples/java/com/azure/communication/identity/ReadmeSamples.java#L102-L107 -->
```java
// Define a list of communication token scopes
List<CommunicationTokenScope> scopes = Arrays.asList(CommunicationTokenScope.CHAT);

Expand All @@ -138,8 +142,8 @@ System.out.println("Expires at: " + userToken.getExpiresAt());

### Create a new user and token in a single request
For convenience, use `createUserAndToken` to create a new user and issue a token with one function call. This translates into a single web request as opposed to creating a user first and then issuing a token.

```java readme-sample-createNewUserAndToken
<!-- embedme ./src/samples/java/com/azure/communication/identity/ReadmeSamples.java#L85-L90 -->
```java
// Define a list of communication token scopes
List<CommunicationTokenScope> scopes = Arrays.asList(CommunicationTokenScope.CHAT);

Expand All @@ -151,33 +155,26 @@ System.out.println("User token value: " + result.getUserToken().getToken());
### Revoking all tokens for an existing user
Use the `revokeTokens` function to revoke all the issued tokens of a user.

```java readme-sample-revokeUserToken
<!-- embedme ./src/samples/java/com/azure/communication/identity/ReadmeSamples.java#L120-L121 -->
```java
// revoke tokens issued for the specified user
communicationIdentityClient.revokeTokens(user);
```

### Deleting a user
Use the `deleteUser` function to delete a user.

```java readme-sample-deleteUser
<!-- embedme ./src/samples/java/com/azure/communication/identity/ReadmeSamples.java#L130-L131 -->
```java
// delete a previously created user
communicationIdentityClient.deleteUser(user);
```

### Exchanging AAD access token of a Teams User for a Communication Identity access token
Use the `getTokenForTeamsUser` function to exchanges an AAD access token of a Teams User for a new Communication Identity access token.

```java readme-sample-getTokenForTeamsUser
AccessToken accessToken = communicationIdentityClient.getTokenForTeamsUser(teamsUserAadToken);
System.out.println("User token value: " + accessToken.getToken());
System.out.println("Expires at: " + accessToken.getExpiresAt());
```

## Troubleshooting

All user token service operations will throw an exception on failure.

```java readme-sample-createUserTroubleshooting
<!-- embedme ./src/samples/java/com/azure/communication/identity/ReadmeSamples.java#L139-L143 -->
```java
try {
CommunicationUserIdentifier user = communicationIdentityClient.createUser();
} catch (RuntimeException ex) {
Expand Down
42 changes: 29 additions & 13 deletions sdk/communication/azure-communication-identity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<groupId>com.azure</groupId>
<artifactId>azure-communication-identity</artifactId>
<packaging>jar</packaging>
<version>1.2.0-beta.1</version> <!-- {x-version-update;com.azure:azure-communication-identity;current} -->
<version>1.1.4</version> <!-- {x-version-update;com.azure:azure-communication-identity;current} -->

<name>Microsoft Azure identity client library for communication</name>
<description>
Expand Down Expand Up @@ -50,8 +50,8 @@
<src.dir>src/main</src.dir>
<test.dir>src/test</test.dir>
<jacoco.min.linecoverage>0.88</jacoco.min.linecoverage>
<jacoco.min.branchcoverage>0.67</jacoco.min.branchcoverage>
<jacoco.skip>false</jacoco.skip>
<jacoco.min.branchcoverage>0.70</jacoco.min.branchcoverage>
<jacoco.skip.coverage.check>false</jacoco.skip.coverage.check>
<!-- Configures the Java 9+ run to perform the required module exports, opens, and reads that are necessary for testing but shouldn't be part of the module-info. -->
<javaModulesSurefireArgLine>
--add-opens com.azure.communication.identity/com.azure.communication.identity=ALL-UNNAMED
Expand All @@ -62,35 +62,35 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.24.1</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
<version>1.22.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-common</artifactId>
<version>1.0.7</version> <!-- {x-version-update;com.azure:azure-communication-common;dependency} -->
<version>1.0.6</version> <!-- {x-version-update;com.azure:azure-communication-common;dependency} -->
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-api;external_dependency} -->
<version>5.7.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-api;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-engine;external_dependency} -->
<version>5.7.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-engine;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.8.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-params;external_dependency} -->
<version>5.7.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-params;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<version>3.4.13</version> <!-- {x-version-update;io.projectreactor:reactor-test;external_dependency} -->
<version>3.4.10</version> <!-- {x-version-update;io.projectreactor:reactor-test;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -102,25 +102,25 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-test</artifactId>
<version>1.7.7</version> <!-- {x-version-update;com.azure:azure-core-test;dependency} -->
<version>1.7.4</version> <!-- {x-version-update;com.azure:azure-core-test;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.0.0</version><!-- {x-version-update;org.mockito:mockito-core;external_dependency} -->
<version>3.12.4</version><!-- {x-version-update;org.mockito:mockito-core;external_dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-okhttp</artifactId>
<version>1.7.8</version> <!-- {x-version-update;com.azure:azure-core-http-okhttp;dependency} -->
<version>1.7.5</version> <!-- {x-version-update;com.azure:azure-core-http-okhttp;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.4.3</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
<version>1.4.1</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -161,6 +161,22 @@
</rules>
</configuration>
</plugin>
<plugin>
<groupId>org.revapi</groupId>
<artifactId>revapi-maven-plugin</artifactId>
<version>0.11.2</version> <!-- {x-version-update;org.revapi:revapi-maven-plugin;external_dependency} -->
<configuration>
<analysisConfiguration>
<revapi.ignore>
<item>
<code>java.method.added</code>
<class>com.azure.core.util.HttpClientOptions</class>
<justification>Transitive from Core. Not our problem</justification>
</item>
</revapi.ignore>
</analysisConfiguration>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

package com.azure.communication.identity;

import com.azure.communication.identity.implementation.CommunicationIdentitiesImpl;
import com.azure.communication.identity.implementation.CommunicationIdentityClientImpl;
import com.azure.communication.identity.implementation.CommunicationIdentityImpl;
import com.azure.communication.identity.implementation.converters.IdentityErrorConverter;
import com.azure.communication.identity.implementation.models.CommunicationErrorResponseException;
import com.azure.communication.identity.implementation.models.CommunicationIdentityAccessToken;
import com.azure.communication.identity.implementation.models.CommunicationIdentityAccessTokenRequest;
import com.azure.communication.identity.implementation.models.CommunicationIdentityAccessTokenResult;
import com.azure.communication.identity.implementation.models.CommunicationIdentityCreateRequest;
import com.azure.communication.identity.implementation.models.CommunicationIdentityAccessToken;
import com.azure.communication.identity.implementation.models.TeamsUserAccessTokenRequest;
import com.azure.communication.identity.models.CommunicationTokenScope;
import com.azure.communication.identity.models.CommunicationUserIdentifierAndToken;
import com.azure.communication.identity.models.IdentityError;
Expand Down Expand Up @@ -41,11 +40,11 @@
@ServiceClient(builder = CommunicationIdentityClientBuilder.class, isAsync = true)
public final class CommunicationIdentityAsyncClient {

private final CommunicationIdentitiesImpl client;
private final CommunicationIdentityImpl client;
private final ClientLogger logger = new ClientLogger(CommunicationIdentityAsyncClient.class);

CommunicationIdentityAsyncClient(CommunicationIdentityClientImpl communicationIdentityServiceClient) {
client = communicationIdentityServiceClient.getCommunicationIdentities();
client = communicationIdentityServiceClient.getCommunicationIdentity();
}

/**
Expand Down Expand Up @@ -282,48 +281,4 @@ private IdentityErrorResponseException translateException(CommunicationErrorResp
}
return new IdentityErrorResponseException(exception.getMessage(), exception.getResponse(), error);
}

/**
* Exchanges an AAD access token of a Teams User for a new Communication Identity access token.
*
* @param teamsUserAadToken AAD access token of a Teams User to acquire Communication Identity access token.
* @return Communication Identity access token.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<AccessToken> getTokenForTeamsUser(String teamsUserAadToken) {
try {
TeamsUserAccessTokenRequest requestBody = new TeamsUserAccessTokenRequest();
requestBody.setToken(teamsUserAadToken);
return client.exchangeTeamsUserAccessTokenAsync(requestBody)
.onErrorMap(CommunicationErrorResponseException.class, e -> translateException(e))
.flatMap((CommunicationIdentityAccessToken rawToken) -> {
return Mono.just(new AccessToken(rawToken.getToken(), rawToken.getExpiresOn()));
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}

/**
* Exchanges an AAD access token of a Teams User for a new Communication Identity access token.
*
* @param teamsUserAadToken AAD access token of a Teams User to acquire Communication Identity access token.
* @return Communication Identity access token with response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<AccessToken>> getTokenForTeamsUserWithResponse(String teamsUserAadToken) {
try {
TeamsUserAccessTokenRequest requestBody = new TeamsUserAccessTokenRequest();
requestBody.setToken(teamsUserAadToken);
return client.exchangeTeamsUserAccessTokenWithResponseAsync(requestBody)
.onErrorMap(CommunicationErrorResponseException.class, e -> translateException(e))
.flatMap((Response<CommunicationIdentityAccessToken> response) -> {
AccessToken token = new AccessToken(response.getValue().getToken(), response.getValue().getExpiresOn());
return Mono.just(new SimpleResponse<AccessToken>(response, token));
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
}

}
Loading

0 comments on commit 3aae45b

Please sign in to comment.