de.ahus1.keycloak.dropwizard.User Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of keycloak-dropwizard Show documentation
Show all versions of keycloak-dropwizard Show documentation
Add this module to integrate your Dropwizard application with
JBoss Keycloak.
The newest version!
package de.ahus1.keycloak.dropwizard;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.ws.rs.ForbiddenException;
import org.keycloak.KeycloakSecurityContext;
/**
* This is a default implementation for a user. Consider extending this class or AbstractUser
* with any needed wrapper around AccessToken and IDToken.
*/
public class User extends AbstractUser {
public User(KeycloakSecurityContext securityContext, HttpServletRequest request,
KeycloakConfiguration keycloakConfiguration) {
super(request, securityContext, keycloakConfiguration);
}
public void checkUserInRole(String role) {
if (!getRoles().contains(role)) {
throw new ForbiddenException();
}
}
@Override
public String getName() {
return securityContext.getToken().getName();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy