-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Event Hubs Java RBAC #3753
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
Closed
Closed
Event Hubs Java RBAC #3753
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 1336e17
Parallel latest dotnet changes from Serkant
JamesBirdsall 991d710
Better null testing
JamesBirdsall 5767a80
RBAC in EPH
JamesBirdsall 9c6a139
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into jbi…
JamesBirdsall 58cbf7f
Make tests compile
JamesBirdsall fb518b7
Remove managed identity
JamesBirdsall 31ae8c8
Update pom dependencies
JamesBirdsall bdc0191
De-public some things, add javadocs.
JamesBirdsall c49d052
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into jbi…
JamesBirdsall 3c7d294
Restore ManagedIdentityTokenProvider and MI support in connection string
JamesBirdsall 21a0a84
Fix getting token in getruntime path
JamesBirdsall 7f766f2
First pass at RBAC tests
JamesBirdsall 20538e4
Second pass at RBAC testing
JamesBirdsall 965c5f0
Fix Managed Identity provider
JamesBirdsall 40f3c73
Fix issues with Managed Identity and connection string
JamesBirdsall caf7260
AAD client tests finished
JamesBirdsall a113076
Removed common authority and APIs/tests using it
JamesBirdsall a213dd3
Common authority was also used in EPH, remove
JamesBirdsall 0e8caaf
Merge branch 'master' of github.com:Azure/azure-sdk-for-java into jbi…
JamesBirdsall 54f7fd8
Take StorageCredentials to support Storage AAD for EPH
JamesBirdsall 64519e1
Update version
JamesBirdsall 6065b14
Executor not handled properly during EPH build/init
JamesBirdsall 149665f
EPH AAD test case
JamesBirdsall 2580f9f
Make builder interfaces public
JamesBirdsall 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
94 changes: 94 additions & 0 deletions
94
...thubs-eph/src/main/java/com/microsoft/azure/eventprocessorhost/EventHubClientFactory.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,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); | ||
| } | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
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.