Is there an alternative for com.vaadin.cdi.access.JaasAccessControl in Vaadin FLOW ? The package com.vaadin.cdi.access has disappeared from library “vaadin-cdi-11.0.1” (since 10.x.x).
We need this utility to use the JBOSS security realm (login, logout, getPrincipal). In fact our complete security mechanism is based on this class.
Can anyone help us ?
The class JaasAccessControl is not depending on rest of the add-on, so you can easily just copy paste it to your project. It is relying on VaadinServletService.getCurrentServletRequest() method of the framework, which has not changed since Vaadin 8.
public abstract class AccessControl {
/**
* Returns true if some used has logged in.
*
* @return true if a user is logged in
*/
public abstract boolean isUserSignedIn();
/**
* Checks if the current user has a role.
*
* @param role
* @return true if currently logged in user is in given role
*/
public abstract boolean isUserInRole(String role);
/**
* Returns the principal (user) name of the currently logged in user.
*
* @return name of the user that is currently logged in, if no user is
* logged in null will be returned.
*/
public abstract String getPrincipalName();
/**
* Checks if the user has any of the given roles.
*
* @param roles
* @return true if currently logged in user is in some of given roles
*/
public boolean isUserInSomeRole(String... roles) {
for (String role : roles) {
if (isUserInRole(role)) {
return true;
}
}
return false;
}
}