gpt4 book ai didi

org.geoserver.security.WorkspaceAccessLimits.isWritable()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 16:33:05 25 4
gpt4 key购买 nike

本文整理了Java中org.geoserver.security.WorkspaceAccessLimits.isWritable()方法的一些代码示例,展示了WorkspaceAccessLimits.isWritable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WorkspaceAccessLimits.isWritable()方法的具体详情如下:
包路径:org.geoserver.security.WorkspaceAccessLimits
类名称:WorkspaceAccessLimits
方法名:isWritable

WorkspaceAccessLimits.isWritable介绍

暂无

代码示例

代码示例来源:origin: geoserver/geoserver

protected WorkspaceAccessLimits intersection(WorkspaceAccessLimits a, WorkspaceAccessLimits b) {
  CatalogMode mode = intersection(a.getMode(), b.getMode());
  return new WorkspaceAccessLimits(
      mode,
      a.isReadable() && b.isReadable(),
      a.isWritable() && b.isWritable(),
      a.isAdminable() && b.isAdminable());
}

代码示例来源:origin: geoserver/geoserver

} else {
  canRead = wl.isReadable();
  canWrite = wl.isWritable();

代码示例来源:origin: org.geoserver.community/gs-geofence

@Test
public void testCiteCannotWriteOnWorkspace() {
  if (!IS_GEOFENCE_AVAILABLE) {
    return;
  }
  configManager.getConfiguration().setGrantWriteToWorkspacesToAuthenticatedUsers(false);
  UsernamePasswordAuthenticationToken user =
      new UsernamePasswordAuthenticationToken(
          "cite",
          "cite",
          Arrays.asList(
              new GrantedAuthority[] {
                new SimpleGrantedAuthority("ROLE_AUTHENTICATED")
              }));
  // check workspace access
  WorkspaceInfo citeWS = catalog.getWorkspaceByName(MockData.CITE_PREFIX);
  WorkspaceAccessLimits wl = accessManager.getAccessLimits(user, citeWS);
  assertTrue(wl.isReadable());
  assertFalse(wl.isWritable());
}

代码示例来源:origin: org.geoserver.extension/gs-geofence

@Test
public void testCiteCannotWriteOnWorkspace() {
  if (!IS_GEOFENCE_AVAILABLE) {
    return;
  }
  configManager.getConfiguration().setGrantWriteToWorkspacesToAuthenticatedUsers(false);
  UsernamePasswordAuthenticationToken user =
      new UsernamePasswordAuthenticationToken(
          "cite",
          "cite",
          Arrays.asList(
              new GrantedAuthority[] {
                new SimpleGrantedAuthority("ROLE_AUTHENTICATED")
              }));
  // check workspace access
  WorkspaceInfo citeWS = catalog.getWorkspaceByName(MockData.CITE_PREFIX);
  WorkspaceAccessLimits wl = accessManager.getAccessLimits(user, citeWS);
  assertTrue(wl.isReadable());
  assertFalse(wl.isWritable());
}

代码示例来源:origin: org.geoserver.security/gs-security-tests

private boolean canAccess(
      ResourceAccessManager manager,
      Authentication user,
      WorkspaceInfo catalogInfo,
      AccessMode mode) {
    WorkspaceAccessLimits limits = manager.getAccessLimits(user, catalogInfo);
    if (limits == null) {
      return true;
    } else if (mode == AccessMode.READ) {
      return limits.isReadable();
    } else if (mode == AccessMode.WRITE) {
      return limits.isWritable();
    } else if (mode == AccessMode.ADMIN) {
      return limits.isAdminable();
    } else {
      throw new RuntimeException("Unknown access mode " + mode);
    }
  }
}

代码示例来源:origin: org.geoserver.extension/gs-geofence

@Test
public void testCiteCanWriteOnWorkspace() {
  if (!IS_GEOFENCE_AVAILABLE) {
    return;
  }
  configManager.getConfiguration().setGrantWriteToWorkspacesToAuthenticatedUsers(true);
  UsernamePasswordAuthenticationToken user =
      new UsernamePasswordAuthenticationToken(
          "cite",
          "cite",
          Arrays.asList(
              new GrantedAuthority[] {
                new SimpleGrantedAuthority("ROLE_AUTHENTICATED")
              }));
  // check workspace access
  WorkspaceInfo citeWS = catalog.getWorkspaceByName(MockData.CITE_PREFIX);
  WorkspaceAccessLimits wl = accessManager.getAccessLimits(user, citeWS);
  assertTrue(wl.isReadable());
  assertTrue(wl.isWritable());
  configManager.getConfiguration().setGrantWriteToWorkspacesToAuthenticatedUsers(false);
}

代码示例来源:origin: org.geoserver.community/gs-geofence

@Test
public void testCiteCanWriteOnWorkspace() {
  if (!IS_GEOFENCE_AVAILABLE) {
    return;
  }
  configManager.getConfiguration().setGrantWriteToWorkspacesToAuthenticatedUsers(true);
  UsernamePasswordAuthenticationToken user =
      new UsernamePasswordAuthenticationToken(
          "cite",
          "cite",
          Arrays.asList(
              new GrantedAuthority[] {
                new SimpleGrantedAuthority("ROLE_AUTHENTICATED")
              }));
  // check workspace access
  WorkspaceInfo citeWS = catalog.getWorkspaceByName(MockData.CITE_PREFIX);
  WorkspaceAccessLimits wl = accessManager.getAccessLimits(user, citeWS);
  assertTrue(wl.isReadable());
  assertTrue(wl.isWritable());
  configManager.getConfiguration().setGrantWriteToWorkspacesToAuthenticatedUsers(false);
}

代码示例来源:origin: org.geoserver.community/gs-geofence

public void IGNOREtestCiteWorkspaceAccess() {
  if (!IS_GEOFENCE_AVAILABLE) {
    return;
  }
  UsernamePasswordAuthenticationToken user =
      new UsernamePasswordAuthenticationToken("cite", "cite");
  // check workspace access on cite
  WorkspaceInfo citeWS = catalog.getWorkspaceByName(MockData.CITE_PREFIX);
  WorkspaceAccessLimits wl = accessManager.getAccessLimits(user, citeWS);
  assertTrue(wl.isReadable());
  assertTrue(wl.isWritable());
  // check workspace access on any other but not cite and sf (should fail)
  WorkspaceInfo cdfWS = catalog.getWorkspaceByName(MockData.CDF_PREFIX);
  wl = accessManager.getAccessLimits(user, cdfWS);
  assertFalse(wl.isReadable());
  assertFalse(wl.isWritable());
  // check workspace access on sf (should work, we can do at least a getmap)
  WorkspaceInfo sfWS = catalog.getWorkspaceByName(MockData.SF_PREFIX);
  wl = accessManager.getAccessLimits(user, sfWS);
  assertTrue(wl.isReadable());
  assertTrue(wl.isWritable());
}

代码示例来源:origin: org.geoserver.extension/gs-geofence

@Test
public void testCiteWorkspaceAccess() {
  if (!IS_GEOFENCE_AVAILABLE) {
    return;
  }
  UsernamePasswordAuthenticationToken user =
      new UsernamePasswordAuthenticationToken("cite", "cite");
  // check workspace access on cite
  WorkspaceInfo citeWS = catalog.getWorkspaceByName(MockData.CITE_PREFIX);
  WorkspaceAccessLimits wl = accessManager.getAccessLimits(user, citeWS);
  assertTrue(wl.isReadable());
  assertTrue(wl.isWritable());
  // check workspace access on any other but not cite and sf (should fail)
  WorkspaceInfo cdfWS = catalog.getWorkspaceByName(MockData.CDF_PREFIX);
  wl = accessManager.getAccessLimits(user, cdfWS);
  assertFalse(wl.isReadable());
  assertFalse(wl.isWritable());
  // check workspace access on sf (should work, we can do at least a getmap)
  WorkspaceInfo sfWS = catalog.getWorkspaceByName(MockData.SF_PREFIX);
  wl = accessManager.getAccessLimits(user, sfWS);
  assertTrue(wl.isReadable());
  assertTrue(wl.isWritable());
}

代码示例来源:origin: org.geoserver.community/gs-geofence

@Test
public void testAdmin() {
  if (!IS_GEOFENCE_AVAILABLE) {
    return;
  }
  UsernamePasswordAuthenticationToken user =
      new UsernamePasswordAuthenticationToken(
          "admin",
          "geoserver",
          Arrays.asList(
              new GrantedAuthority[] {
                new SimpleGrantedAuthority("ROLE_ADMINISTRATOR")
              }));
  // check workspace access
  WorkspaceInfo citeWS = catalog.getWorkspaceByName(MockData.CITE_PREFIX);
  WorkspaceAccessLimits wl = accessManager.getAccessLimits(user, citeWS);
  assertTrue(wl.isReadable());
  assertTrue(wl.isWritable());
  // check layer access
  LayerInfo layer = catalog.getLayerByName(getLayerId(MockData.BASIC_POLYGONS));
  VectorAccessLimits vl = (VectorAccessLimits) accessManager.getAccessLimits(user, layer);
  assertEquals(Filter.INCLUDE, vl.getReadFilter());
  assertEquals(Filter.INCLUDE, vl.getWriteFilter());
  assertNull(vl.getReadAttributes());
  assertNull(vl.getWriteAttributes());
}

代码示例来源:origin: org.geoserver.extension/gs-geofence

@Test
public void testAdmin() {
  if (!IS_GEOFENCE_AVAILABLE) {
    return;
  }
  assertTrue(geofenceAdminService.getCountAll() > 0);
  RuleFilter ruleFilter = new RuleFilter();
  ShortRule adminRule = geofenceAdminService.getRule(ruleFilter);
  UsernamePasswordAuthenticationToken user =
      new UsernamePasswordAuthenticationToken(
          "admin",
          "geoserver",
          Arrays.asList(
              new GrantedAuthority[] {
                new SimpleGrantedAuthority("ROLE_ADMINISTRATOR")
              }));
  // check workspace access
  WorkspaceInfo citeWS = catalog.getWorkspaceByName(MockData.CITE_PREFIX);
  WorkspaceAccessLimits wl = accessManager.getAccessLimits(user, citeWS);
  assertTrue(wl.isReadable());
  assertTrue(wl.isWritable());
  // check layer access
  LayerInfo layer = catalog.getLayerByName(getLayerId(MockData.BASIC_POLYGONS));
  VectorAccessLimits vl = (VectorAccessLimits) accessManager.getAccessLimits(user, layer);
  assertEquals(Filter.INCLUDE, vl.getReadFilter());
  assertEquals(Filter.INCLUDE, vl.getWriteFilter());
  assertNull(vl.getReadAttributes());
  assertNull(vl.getWriteAttributes());
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com