Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9b35f06
Port changes for RBAC to central repo
JamesBirdsall May 14, 2019
1336e17
Parallel latest dotnet changes from Serkant
JamesBirdsall May 17, 2019
991d710
Better null testing
JamesBirdsall May 18, 2019
5767a80
RBAC in EPH
JamesBirdsall May 22, 2019
9c6a139
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into jbi…
JamesBirdsall May 22, 2019
58cbf7f
Make tests compile
JamesBirdsall May 22, 2019
fb518b7
Remove managed identity
JamesBirdsall May 22, 2019
31ae8c8
Update pom dependencies
JamesBirdsall May 22, 2019
bdc0191
De-public some things, add javadocs.
JamesBirdsall May 22, 2019
c49d052
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into jbi…
JamesBirdsall Jun 3, 2019
3c7d294
Restore ManagedIdentityTokenProvider and MI support in connection string
JamesBirdsall Jun 3, 2019
21a0a84
Fix getting token in getruntime path
JamesBirdsall Jun 11, 2019
7f766f2
First pass at RBAC tests
JamesBirdsall Jun 13, 2019
20538e4
Second pass at RBAC testing
JamesBirdsall Jun 13, 2019
965c5f0
Fix Managed Identity provider
JamesBirdsall Jun 18, 2019
40f3c73
Fix issues with Managed Identity and connection string
JamesBirdsall Jun 18, 2019
caf7260
AAD client tests finished
JamesBirdsall Jun 18, 2019
a113076
Removed common authority and APIs/tests using it
JamesBirdsall Jun 18, 2019
a213dd3
Common authority was also used in EPH, remove
JamesBirdsall Jun 18, 2019
0e8caaf
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into jbi…
JamesBirdsall Jun 28, 2019
54f7fd8
Take StorageCredentials to support Storage AAD for EPH
JamesBirdsall Jun 28, 2019
64519e1
Update version
JamesBirdsall Jun 28, 2019
6065b14
Executor not handled properly during EPH build/init
JamesBirdsall Jun 28, 2019
149665f
EPH AAD test case
JamesBirdsall Jun 29, 2019
2580f9f
Make builder interfaces public
JamesBirdsall Jul 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions eventhubs/data-plane/azure-eventhubs-eph/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
<parent>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs-clients</artifactId>
<version>2.3.1</version>
<version>3.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-eventhubs-eph</artifactId>
<version>2.5.1</version>
<version>3.0.0</version>

<name>Microsoft Azure SDK for Event Hubs Event Processor Host(EPH)</name>
<description>EPH is built on top of the Azure Event Hubs Client and provides a number of features not present in that lower layer</description>
Expand Down Expand Up @@ -45,6 +45,12 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to add new dependencies in parent pom.xml files so that versions are consistent between client libraries. You would add it here:
https://github.com/Azure/azure-sdk-for-java/blob/master/parent/pom.xml

@JonathanGiles Is this the correct place to define new dependencies? I tried to find gson in it, but doesn't look like it is declared there.

<artifactId>msal4j</artifactId>
<version>0.4.0-preview</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.google.gson.Gson;
import com.microsoft.azure.storage.AccessCondition;
import com.microsoft.azure.storage.CloudStorageAccount;
import com.microsoft.azure.storage.StorageCredentials;
import com.microsoft.azure.storage.StorageErrorCodeStrings;
import com.microsoft.azure.storage.StorageException;
import com.microsoft.azure.storage.StorageExtendedErrorInformation;
Expand Down Expand Up @@ -46,6 +47,7 @@ class AzureStorageCheckpointLeaseManager implements ICheckpointManager, ILeaseMa
private static final String METADATA_OWNER_NAME = "OWNINGHOST";

private final String storageConnectionString;
private final StorageCredentials storageCredentials;
private final String storageBlobPrefix;
private final BlobRequestOptions leaseOperationOptions = new BlobRequestOptions();
private final BlobRequestOptions checkpointOperationOptions = new BlobRequestOptions();
Expand All @@ -59,16 +61,30 @@ class AzureStorageCheckpointLeaseManager implements ICheckpointManager, ILeaseMa

private Hashtable<String, Checkpoint> latestCheckpoint = new Hashtable<String, Checkpoint>();

AzureStorageCheckpointLeaseManager(String storageConnectionString, String storageContainerName) {
this(storageConnectionString, storageContainerName, "");
}

AzureStorageCheckpointLeaseManager(String storageConnectionString, String storageContainerName, String storageBlobPrefix) {
if ((storageConnectionString == null) || storageConnectionString.trim().isEmpty()) {
throw new IllegalArgumentException("Provide valid Azure Storage connection string when using Azure Storage");
}
this.storageConnectionString = storageConnectionString;
this.storageCredentials = null;

if ((storageContainerName != null) && storageContainerName.trim().isEmpty()) {
throw new IllegalArgumentException("Azure Storage container name must be a valid container name or null to use the default");
}
this.storageContainerName = storageContainerName;

// Convert all-whitespace prefix to empty string. Convert null prefix to empty string.
// Then the rest of the code only has one case to worry about.
this.storageBlobPrefix = (storageBlobPrefix != null) ? storageBlobPrefix.trim() : "";
}

AzureStorageCheckpointLeaseManager(StorageCredentials storageCredentials, String storageContainerName, String storageBlobPrefix) {
if (storageCredentials == null) {
throw new IllegalArgumentException("Provide valid Azure Storage credentials when using Azure Storage");
}
this.storageConnectionString = null;
this.storageCredentials = storageCredentials;

if ((storageContainerName != null) && storageContainerName.trim().isEmpty()) {
throw new IllegalArgumentException("Azure Storage container name must be a valid container name or null to use the default");
}
Expand Down Expand Up @@ -102,7 +118,13 @@ void initialize(HostContext hostContext) throws InvalidKeyException, URISyntaxEx
+ "Must be from 3 to 63 characters long.");
}

this.storageClient = CloudStorageAccount.parse(this.storageConnectionString).createCloudBlobClient();
CloudStorageAccount storageAccount = null;
if (this.storageConnectionString != null) {
storageAccount = CloudStorageAccount.parse(this.storageConnectionString);
} else {
storageAccount = new CloudStorageAccount(this.storageCredentials);
}
this.storageClient = storageAccount.createCloudBlobClient();

this.eventHubContainer = this.storageClient.getContainerReference(this.storageContainerName);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.microsoft.azure.eventprocessorhost;

import java.io.IOException;
import java.net.URI;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService;

import com.microsoft.azure.eventhubs.AzureActiveDirectoryTokenProvider;
import com.microsoft.azure.eventhubs.EventHubClient;
import com.microsoft.azure.eventhubs.EventHubClientOptions;
import com.microsoft.azure.eventhubs.EventHubException;
import com.microsoft.azure.eventhubs.ITokenProvider;
import com.microsoft.azure.eventhubs.RetryPolicy;

abstract class EventHubClientFactory {
protected ScheduledExecutorService executor;

protected final EventHubClientOptions options;

public EventHubClientFactory(final RetryPolicy retryPolicy) {
this((new EventHubClientOptions()).setRetryPolicy(retryPolicy));
}

public EventHubClientFactory(final EventHubClientOptions options) {
this.options = options;
}

public void setExecutor(ScheduledExecutorService executor) {
this.executor = executor;
}

abstract CompletableFuture<EventHubClient> createEventHubClient() throws EventHubException, IOException;

static class EHCFWithConnectionString extends EventHubClientFactory {
private final String eventHubConnectionString;

public EHCFWithConnectionString(final String eventHubConnectionString,
final RetryPolicy retryPolicy) {
super(retryPolicy);
this.eventHubConnectionString = eventHubConnectionString;
}

public CompletableFuture<EventHubClient> createEventHubClient() throws EventHubException, IOException {
return EventHubClient.createFromConnectionString(this.eventHubConnectionString, this.options.getRetryPolicy(), this.executor);
}
}

static class EHCFWithAuthCallback extends EventHubClientFactory {
private final URI endpoint;
private final String eventHubPath;
private final AzureActiveDirectoryTokenProvider.AuthenticationCallback authCallback;
private final String authority;

public EHCFWithAuthCallback(final URI endpoint,
final String eventHubPath,
final AzureActiveDirectoryTokenProvider.AuthenticationCallback authCallback,
final String authority,
final EventHubClientOptions options) {
super(options);
this.endpoint = endpoint;
this.eventHubPath = eventHubPath;
this.authCallback = authCallback;
this.authority = authority;
}

public CompletableFuture<EventHubClient> createEventHubClient() throws EventHubException, IOException {
return EventHubClient.createWithAzureActiveDirectory(this.endpoint,
this.eventHubPath, this.authCallback, this.authority, this.executor, this.options);
}
}

static class EHCFWithTokenProvider extends EventHubClientFactory {
private final URI endpoint;
private final String eventHubPath;
private final ITokenProvider tokenProvider;

public EHCFWithTokenProvider(final URI endpoint,
final String eventHubPath,
final ITokenProvider tokenProvider,
final EventHubClientOptions options) {
super(options);
this.endpoint = endpoint;
this.eventHubPath = eventHubPath;
this.tokenProvider = tokenProvider;
}

public CompletableFuture<EventHubClient> createEventHubClient() throws EventHubException, IOException {
return EventHubClient.createWithTokenProvider(this.endpoint, this.eventHubPath, this.tokenProvider, this.executor, this.options);
}
}
}
Loading