-
Notifications
You must be signed in to change notification settings - Fork 827
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
fix issue 3083: check user_name claim type #3084
Conversation
similar to other attributes
after first comming ClassCastException: class java.util.ArrayList cannot be cast to class java.lang.String (java.util.ArrayList and java.lang.String are in module java.base of loader 'bootstrap') |
@@ -424,7 +424,7 @@ private String getMappedClaim(String externalName, String internalName, Map<Stri | |||
return (String) claimObject; | |||
} | |||
if (claimObject instanceof Collection) { | |||
Set<String> entry = ((Collection<?>) claimObject).stream().map(String.class::cast).collect(Collectors.toSet()); | |||
Set<String> entry = ((Collection<?>) claimObject).stream().filter(String.class::isInstance).map(String.class::cast).collect(Collectors.toSet()); |
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.
Will collection items always going to be a string? Should we consider handle it in more generic way:
Set entry = ((Collection<?>) claimObject).stream()
.map(claim -> String.valueOf(claim))
.collect(Collectors.toSet());
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 think it is not wanted to have such a generic approach, but simple check if the entries inside of the token are strings. With your approach we allow all but then we are incompatible with now. I mean if claims are type of Boolean or int we would allow them now. But that is not wanted
Wanted to solve is that there is a human readable error and not a technical class cast error. The error should show what mapping is wrong, eg. email , first name , user_name etc. |
solve #3083