-
Notifications
You must be signed in to change notification settings - Fork 240
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
feat(keys): add functionality to extract public key to KeyParsers #4360
feat(keys): add functionality to extract public key to KeyParsers #4360
Conversation
a98897a
to
b5269fe
Compare
@@ -48,6 +48,10 @@ | |||
.orElseGet(() -> Result.failure("No public key could be resolved for key-ID '%s'".formatted(id))); | |||
} | |||
|
|||
public Result<Void> addRawKey(String id, String rawKey) { | |||
return parseKey(rawKey).onSuccess((pk) -> cachedKeys.put(id, pk)).mapTo(); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
Result.mapTo
fbc28f7
to
23279e6
Compare
23279e6
to
a885770
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #4360 +/- ##
==========================================
+ Coverage 71.74% 75.22% +3.48%
==========================================
Files 919 1055 +136
Lines 18457 21132 +2675
Branches 1037 1161 +124
==========================================
+ Hits 13242 15897 +2655
+ Misses 4756 4714 -42
- Partials 459 521 +62 ☔ View full report in Codecov by Sentry. |
core/common/lib/keys-lib/src/main/java/org/eclipse/edc/keys/LocalPublicKeyServiceImpl.java
Outdated
Show resolved
Hide resolved
952badf
to
7f56306
Compare
public Result<PublicKey> parsePublic(String encoded) { | ||
return parsers.stream().filter(kp -> kp.canHandle(encoded)) | ||
.findFirst() | ||
.map(kp -> kp.parsePublic(encoded).compose(k -> Result.success((PublicKey) k))) |
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.
the type validation that was in LocalPublicKeyServiceImpl
is missing
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.
as per the contract of the parsePublic
method this can never be something other than a PublicKey
, even though it returns a Key
. This is necessary to be able to have the parsePublic
method as default
in the interface. Not all key parsers support this feature.
What this PR changes/adds
Adds a
parsePublic
method to they keyparsers, that attempt to extract the public key from an encoded string, leaving behind any potential private key parts.Why it does that
LocalPublicKeyServiceImpl should be able to extract a public key from any serialized format
Further notes
List other areas of code that have changed but are not necessarily linked to the main feature. This could be method
signature changes, package declarations, bugs that were encountered and were fixed inline, etc.
Linked Issue(s)
Closes # <-- insert Issue number if one exists
Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.