-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Implement a Service Bus Shared Access Key Credential #21227
Conversation
…202105061716 by LiHong
Thank you for your contribution hongli750210! We will review the pull request and get back to you soon. |
…202105071022 by LiHong
# Conflicts: # sdk/identity/azure-identity/src/main/java/com/azure/identity/ServiceBusSharedKeyCredential.java
…202105071053 by LiHong
sdk/identity/azure-identity/src/main/java/com/azure/identity/ServiceBusSharedKeyCredential.java
Outdated
Show resolved
Hide resolved
@hongli19750210 Please see #16465 (comment) for the updated design to be followed for this task We should re-use the classes |
…202105191031 by LiHong
…202105191131 by LiHong
…202105191145 by LiHong
…s Key Credential 202105210918 by LiHong
...ssaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusClientBuilder.java
Outdated
Show resolved
Hide resolved
…05241146 by LiHong
…l 202105241200 by LiHong
...ssaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusClientBuilder.java
Outdated
Show resolved
Hide resolved
…05250916 by LiHong
…ess Key Credential 202105251509 by LiHong
...ing-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusSenderAsyncClient.java
Outdated
Show resolved
Hide resolved
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.
Looks good aside from the CI build failures.
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.
Could we add test in integration test for receiving or sending message using sas key ?
...ing-servicebus/src/test/java/com/azure/messaging/servicebus/ServiceBusClientBuilderTest.java
Outdated
Show resolved
Hide resolved
… Credential by lihong 202106101502
… Credential by lihong 202106101502
…s Key Credential by lihong 202106111041
This pull request is protected by Check Enforcer. What is Check Enforcer?Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass. Why am I getting this message?You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged. What should I do now?If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows: What if I am onboarding a new service?Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment: |
…s Key Credential by lihong 202106111058
…s Key Credential by lihong 202106111337
…s Key Credential by lihong 202106111442
…s Key Credential by lihong 202106111512
…s Key Credential by lihong 202106111532
…s Key Credential by lihong 202106111557
…s Key Credential by lihong 202106111619
…s Key Credential by lihong 202106111635
…s Key Credential by lihong 202106111803
@conniey / @hemanttanwar - Do you need anything else on this? |
@@ -235,6 +237,55 @@ public ServiceBusClientBuilder credential(String fullyQualifiedNamespace, TokenC | |||
return this; | |||
} | |||
|
|||
/** | |||
* Sets the credential for the Service Bus resource. |
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.
Add more details to javadoc on how to obtain named key credential and sas credential for the next method.
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.
According to your comment, fixed in the new version.
if (CoreUtils.isNullOrEmpty(fullyQualifiedNamespace)) { | ||
throw logger.logExceptionAsError( | ||
new IllegalArgumentException("'fullyQualifiedNamespace' cannot be an empty string.")); | ||
} |
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.
All input validation should happen before performing any operations on the input. Here ServiceBusSharedKeyCredential
should not be created until fullyQualifiedNamespace
param is validated.
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.
According to your comment, fixed in the new version.
"'fullyQualifiedNamespace' cannot be null."); | ||
Objects.requireNonNull(credential, "'credential' cannot be null."); | ||
|
||
this.credentials = new ServiceBusSharedKeyCredential(credential.getSignature()); |
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.
This overwrites the value set in the previous overload. So, the order of calls to credential()
decides which credential is being used. Instead, we should do the validate in build
method and throw exception if both are set.
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.
According to your comment, fixed in the new version.
Fix issue #16465
1). sdk/identity/azure-identity/src/main/java/com/azure/identity/ServiceBusSharedKeyCredential.java
2). sdk/identity/azure-identity/src/main/java/com/azure/identity/ServiceBusSharedKeyCredentialBuilder.java
3). sdk/identity/azure-identity/src/test/java/com/azure/identity/ServiceBusSharedKeyCredentialTest.java
4). sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation/util/ValidationUtil.java
validateForSharedAccessKey
in theValidationUtil
class to cope with the two parameter setting methods when the Shared Access Key Credential is created.a. When
sharedAccessSignature != null
, the specifiedsharedAccessSignature
can be directly used to create Shared Access Key Credential, sosharedAccessPolicy
andshardAccessKey
do not require any verification.b. When
sharedAccessSignature == null
,sharedAccessPolicy
andshardAccessKey
are required for verification.@jongio, @conniey for notification.