-
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
Updated CryptographyServiceClient
to preserve the HTTP port if provided in a key identifier.
#24539
Conversation
…ed in a key identifier.
API changes have been detected in API changes + public CryptographyAsyncClient getCryptographyAsyncClient(String keyName)
+ public CryptographyAsyncClient getCryptographyAsyncClient(String keyName, String keyVersion)
+ public CryptographyClient getCryptographyClient(String keyName)
+ public CryptographyClient getCryptographyClient(String keyName, String keyVersion) |
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.
🚀 - just one suggestion
@@ -797,6 +797,11 @@ private void unpackAndValidateId(String keyId) { | |||
URL url = new URL(keyId); | |||
String[] tokens = url.getPath().split("/"); | |||
String endpoint = url.getProtocol() + "://" + url.getHost(); | |||
|
|||
if (url.getPort() != -1) { | |||
endpoint += ":" + url.getPort(); |
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.
If supported by versions of Java we support,
have you looked at https://docs.oracle.com/javase/7/docs/api/java/net/URL.html#getAuthority()? It will return both host and port (if port is provided)
String endpoint = url.getProtocol() + "://" + url.getAuthority();
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.
Great suggestion, thank you Maor!
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.
@maorleger Now that I think about it, getAuthority()
also includes username and password information if present on the URL, would we want to include any of that in the key identifier in case somebody actually includes it?
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.
I'll play it safe and use getHost()
and getPort()
for now.
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.
That makes sense! Sorry, was afk
Fixes: #24508.