Created
January 9, 2022 18:02
-
-
Save raupachz/6719948cac2c6e202d1fe1f9cfde3806 to your computer and use it in GitHub Desktop.
Decoding a JWT in a JavaServer Faces backing bean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Named | |
@SessionScoped | |
public class UserBean implements Serializable { | |
private Map<String, Object> claims; | |
@PostConstruct | |
public void postConstruct() { | |
FacesContext facesContext = FacesContext.getCurrentInstance(); | |
HttpServletRequest httpServletRequest = (HttpServletRequest) facesContext.getExternalContext().getRequest(); | |
String jwt = httpServletRequest.getHeader("x-amzn-oidc-data"); | |
claims = JWT.of(jwt); | |
} | |
public String getName() { | |
return (String) claims.get("name"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment