Tabnine Logo
RoleCalculator
Code IndexAdd Tabnine to your IDE (free)

How to use
RoleCalculator
in
org.geoserver.security.impl

Best Java code snippets using org.geoserver.security.impl.RoleCalculator (Showing top 16 results out of 315)

origin: geoserver/geoserver

@Override
public UserDetails loadUserByUsername(String username)
    throws UsernameNotFoundException, DataAccessException {
  GeoServerUser user = null;
  try {
    user = getUserByUsername(username);
    if (user == null) throw new UsernameNotFoundException(userNotFoundMessage(username));
    RoleCalculator calculator =
        new RoleCalculator(this, getSecurityManager().getActiveRoleService());
    user.setAuthorities(calculator.calculateRoles(user));
  } catch (IOException e) {
    throw new UsernameNotFoundException(userNotFoundMessage(username), e);
  }
  return user;
}
origin: geoserver/geoserver

set1.addAll(getRoleService().getRolesForUser(user.getUsername()));
addInheritedRoles(set1);
if (getUserGroupService() != null) {
  for (GeoServerUserGroup group : getUserGroupService().getGroupsForUser(user)) {
    if (group.isEnabled()) set1.addAll(calculateRoles(group));
SortedSet<GeoServerRole> set2 = personalizeRoles(user, set1);
addMappedSystemRoles(set2);
origin: geoserver/geoserver

/**
 * Calculate the {@link GeoServerRole} objects for a group including inherited roles
 *
 * @param group
 * @throws IOException
 */
public SortedSet<GeoServerRole> calculateRoles(GeoServerUserGroup group) throws IOException {
  SortedSet<GeoServerRole> roles = new TreeSet<GeoServerRole>();
  roles.addAll(getRoleService().getRolesForGroup(group.getGroupname()));
  addInheritedRoles(roles);
  return roles;
}
origin: org.geoserver.web/web-sec-core

  @Override
  protected List<GeoServerRole> load() {
    List<GeoServerRole> tmp = new ArrayList<GeoServerRole>();
    List<GeoServerRole> result = new ArrayList<GeoServerRole>();
    try {
      GeoServerUserGroupService ugService = getSecurityManager()
          .loadUserGroupService(ugServiceName);
      GeoServerRoleService gaService = getSecurityManager()
          .getActiveRoleService();
      RoleCalculator calc = new RoleCalculator(ugService, gaService);
      tmp.addAll(rolePalette.getSelectedRoles());
      calc.addInheritedRoles(tmp);
      for (GeoServerUserGroup group : userGroupPalette.getSelectedGroups()) {
        if (group.isEnabled()) {
          tmp.addAll(calc.calculateRoles(group));
        }
      }
      result.addAll(calc.personalizeRoles(user, tmp));
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  
    Collections.sort(result);
    return result;
  }
}
origin: geoserver/geoserver

  /**
   * Implements roles retrieval from the J2EE container.
   *
   * @param request
   * @param principal
   * @throws IOException
   */
  protected Collection<GeoServerRole> getRolesFromJ2EE(
      HttpServletRequest request, String principal) throws IOException {

    Collection<GeoServerRole> roles = new ArrayList<GeoServerRole>();
    boolean useActiveService =
        getRoleServiceName() == null || getRoleServiceName().trim().length() == 0;

    GeoServerRoleService service =
        useActiveService
            ? getSecurityManager().getActiveRoleService()
            : getSecurityManager().loadRoleService(getRoleServiceName());

    for (GeoServerRole role : service.getRoles())
      if (request.isUserInRole(role.getAuthority())) roles.add(role);

    RoleCalculator calc = new RoleCalculator(service);
    calc.addInheritedRoles(roles);
    calc.addMappedSystemRoles(roles);
    return roles;
  }
}
origin: geoserver/geoserver

/**
 * Convenience method for {@link #calculateRoles(GeoServerUser)}
 *
 * @param username
 * @throws IOException
 */
public SortedSet<GeoServerRole> calculateRoles(String username) throws IOException {
  return calculateRoles(new GeoServerUser(username));
}
origin: org.geoserver.web/gs-web-sec-core

  @Override
  protected List<GeoServerRole> load() {
    List<GeoServerRole> tmp = new ArrayList<GeoServerRole>();
    List<GeoServerRole> result = new ArrayList<GeoServerRole>();
    try {
      GeoServerUserGroupService ugService =
          getSecurityManager().loadUserGroupService(ugServiceName);
      GeoServerRoleService gaService = getSecurityManager().getActiveRoleService();
      RoleCalculator calc = new RoleCalculator(ugService, gaService);
      tmp.addAll(rolePalette.getSelectedRoles());
      calc.addInheritedRoles(tmp);
      for (GeoServerUserGroup group : userGroupPalette.getSelectedGroups()) {
        if (group.isEnabled()) {
          tmp.addAll(calc.calculateRoles(group));
        }
      }
      result.addAll(calc.personalizeRoles(user, tmp));
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    Collections.sort(result);
    return result;
  }
}
origin: geoserver/geoserver

/**
 * Calculates roles from a {@link GeoServerRoleService} The default service is {@link
 * GeoServerSecurityManager#getActiveRoleService()}
 *
 * <p>The result contains all inherited roles, but no personalized roles
 *
 * @param request
 * @param principal
 * @throws IOException
 */
protected Collection<GeoServerRole> getRolesFromRoleService(
    HttpServletRequest request, String principal) throws IOException {
  boolean useActiveService =
      getRoleServiceName() == null || getRoleServiceName().trim().length() == 0;
  GeoServerRoleService service =
      useActiveService
          ? getSecurityManager().getActiveRoleService()
          : getSecurityManager().loadRoleService(getRoleServiceName());
  RoleCalculator calc = new RoleCalculator(service);
  return calc.calculateRoles(principal);
}
origin: org.geoserver.web/web-security

  @Override
  protected List<GeoServerRole> load() {
    List<GeoServerRole> tmp = new ArrayList<GeoServerRole>();
    List<GeoServerRole> result = new ArrayList<GeoServerRole>();
    try {
      GeoServerUserGroupService ugService = getSecurityManager()
          .loadUserGroupService(ugServiceName);
      GeoServerRoleService gaService = getSecurityManager()
          .getActiveRoleService();
      RoleCalculator calc = new RoleCalculator(ugService, gaService);
      tmp.addAll(rolePalette.getSelectedRoles());
      calc.addInheritedRoles(tmp);
      for (GeoServerUserGroup group : userGroupPalette.getSelectedGroups()) {
        if (group.isEnabled()) {
          tmp.addAll(calc.calculateRoles(group));
        }
      }
      result.addAll(calc.personalizeRoles(user, tmp));
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  
    Collections.sort(result);
    return result;
  }
}
origin: org.geoserver.security/sec-jdbc

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException,
    DataAccessException {
  GeoServerUser user=null;
  try {
    user = getUserByUsername(username);            
    if (user==null)
      throw new UsernameNotFoundException(userNotFoundMessage(username));
    RoleCalculator calculator = new RoleCalculator(this, 
        getSecurityManager().getActiveRoleService());
    user.setAuthorities(calculator.calculateRoles(user));
  } catch (IOException e) {
    throw new UsernameNotFoundException(userNotFoundMessage(username),e);
  }        
  return user;
}

origin: org.geoserver.security/gs-sec-ldap

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
  GeoServerUser user = null;
  try {
    user = getUserByUsername(username);
    if (user == null) {
      throw new UsernameNotFoundException(userNotFoundMessage(username));
    }
    RoleCalculator calculator =
        new RoleCalculator(this, getSecurityManager().getActiveRoleService());
    user.setAuthorities(calculator.calculateRoles(user));
  } catch (IOException e) {
    throw new UsernameNotFoundException(userNotFoundMessage(username), e);
  }
  return user;
}
origin: org.geoserver.community/gs-sec-oauth2

    new RoleCalculator(getSecurityManager().getActiveRoleService());
if (calc != null) {
  try {
    roles.addAll(calc.calculateRoles(principal));
  } catch (IOException e) {
    LOGGER.log(
origin: org.geoserver.security/gs-sec-ldap

RoleCalculator calc = new RoleCalculator(getSecurityManager().getActiveRoleService());
try {
  roles.addAll(calc.calculateRoles(new GeoServerUser(auth.getName())));
} catch (IOException e) {
  throw new AuthenticationServiceException(e.getLocalizedMessage(), e);
origin: org.geoserver.community/gs-geofence-server

if (getDefaultSecurityService() instanceof GeoServerRoleService) {
  calc =
      new RoleCalculator(
          userGroupService,
          (GeoServerRoleService) getDefaultSecurityService());
      userGroupService.getGroupsForUser(user)) {
    if (group.isEnabled()) {
      for (GeoServerRole role : calc.calculateRoles(group)) {
        stringSet.add(role.getAuthority());
    new RoleCalculator(
        userGroupService, securityManager.getActiveRoleService());
if (calc != null) {
      userGroupService.getGroupsForUser(user)) {
    if (group.isEnabled()) {
      for (GeoServerRole role : calc.calculateRoles(group)) {
        stringSet.add(role.getAuthority());
origin: org.geoserver.security/sec-jdbc

  roles.addAll(details.getAuthorities());                        
} else {        
  RoleCalculator calc = new RoleCalculator(getSecurityManager().getActiveRoleService());
  try {
    roles.addAll(calc.calculateRoles(new GeoServerUser(user)));
  } catch (IOException e) {
    throw new AuthenticationServiceException(e.getLocalizedMessage(),e);
origin: org.geoserver.security/gs-security-tests

ugService.initializeFromConfig(ugconfig);
RoleCalculator calc = new RoleCalculator(ugService, service);
SortedSet<GeoServerRole> roles;
roles = calc.calculateRoles(ugService.createUserObject("user1", "abc", true));
assertTrue(roles.size() == 4);
assertTrue(roles.contains(adminRole));
assertTrue(roles.contains(GeoServerRole.GROUP_ADMIN_ROLE));
roles = calc.calculateRoles(ugService.createUserObject("user2", "abc", true));
assertTrue(roles.size() == 2);
assertTrue(roles.contains(adminRole));
assertTrue(roles.contains(GeoServerRole.ADMIN_ROLE));
roles = calc.calculateRoles(ugService.createUserObject("user3", "abc", true));
assertTrue(roles.size() == 1);
assertTrue(roles.contains(role1));
org.geoserver.security.implRoleCalculator

Javadoc

Helper Object for role calculations

Most used methods

  • <init>
  • calculateRoles
  • addInheritedRoles
  • personalizeRoles
  • addMappedSystemRoles
  • addParentRole
    Collects the ascendents for a GeoServerRole object
  • assertRoleServiceNotNull
    Check if the role service is not null
  • getRoleService
  • getUserGroupService

Popular in Java

  • Reading from database using SQL prepared statement
  • getSharedPreferences (Context)
  • onCreateOptionsMenu (Activity)
  • findViewById (Activity)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now