Fix encoding issues of Shibboleth attributes #7
@ -4,6 +4,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.security.authentication.AuthenticationDetailsSource;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@ -28,7 +29,13 @@ public class ShibbolethAuthenticationDetailsSource implements
|
||||
}
|
||||
|
||||
private static String getString(final HttpServletRequest context, final String mail) {
|
||||
return context.getAttribute(mail) instanceof String s ? s : null;
|
||||
if (context.getAttribute(mail) instanceof String s) {
|
||||
// Somewhere in the Shibboleth pipeline, the encoding of the string mixed up.
|
||||
byte[] bytes = s.getBytes(StandardCharsets.ISO_8859_1);
|
||||
return new String(bytes, StandardCharsets.UTF_8);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Collection<GrantedAuthority> getGrantedAuthorities(final HttpServletRequest context) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user