Skip to content
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

fromString on enums #325

Open
fcorneli opened this issue Oct 13, 2023 · 5 comments
Open

fromString on enums #325

fcorneli opened this issue Oct 13, 2023 · 5 comments

Comments

@fcorneli
Copy link

Within my code I have the following in several places:

startAssertionOptionsBuilder.userVerification(UserVerificationRequirement.valueOf(userVerification.toUpperCase()));
...
authenticatorSelectionCriteriaBuilder
                            .residentKey(ResidentKeyRequirement.valueOf(residentKey.toUpperCase()));

while all these enums have a private static fromString. Maybe make these methods public?

@emlun
Copy link
Member

emlun commented Oct 13, 2023

Hi! Please help me understand the use case. Why do you need to create these values like this?

@fcorneli
Copy link
Author

Because my demo allows it:
https://demo.e-contract.be/ejsf-demo/webauthn.xhtml

@emlun
Copy link
Member

emlun commented Oct 17, 2023

I see, thank you.

There are the functions PublicKeyCredentialCreationOptions.fromJson and AssertionRequest.fromJson that can parse those entire data structures from JSON, does that help?

But yeah, I also don't see much issue in making the fromString(String): Optional<(enum)> functions public. There are even a few that are already public, like the ones in COSEAlgorithmIdentifier and KeyProtectionType, so I guess we might as well make them all public.

@fcorneli
Copy link
Author

Well, I guess once an application allows these options to be somehow configurable (via some property file for example), they need such functions anyway.

@emlun
Copy link
Member

emlun commented Nov 9, 2023

This is now released in experimental release 2.6.0-alpha4. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants