Package com.google.enterprise.connector.spi

Examples of com.google.enterprise.connector.spi.Principal


  public void testAclFilterFindPropertyNoOverwriteDenyUserDomainValue()
      throws Exception {
    Document input = createDocument(null, "noCompany\\John Doe");
    String newUserDomain = "MyCompany";
    Principal newPrincipal =
        createFilterAndGetPrinicpal(input, null, newUserDomain, false,
            SpiConstants.PROPNAME_ACLDENYUSERS);

    assertEquals(CaseSensitivityType.EVERYTHING_CASE_SENSITIVE,
        newPrincipal.getCaseSensitivityType());
    assertEquals("noCompany\\John Doe", newPrincipal.getName());
    assertFalse(newPrincipal.getName().contains(newUserDomain));
  }
View Full Code Here


  }

  public void testAclFilterUserDomainForPrincipalType() throws Exception {
    Map<String, Object> props = ConnectorTestUtils
        .createSimpleDocumentBasicProperties("testDocId");
    Principal principal = new Principal(
        SpiConstants.PrincipalType.UNQUALIFIED, null, "John Doe",
        SpiConstants.CaseSensitivityType.EVERYTHING_CASE_SENSITIVE);
    props.put(SpiConstants.PROPNAME_ACLUSERS, principal);
    Document input = ConnectorTestUtils.createSimpleDocument(props);

    String newUserDomain = "MyCompany";
    Principal newPrincipal = createFilterAndGetPrinicpal(input,
        CaseSensitivityType.EVERYTHING_CASE_SENSITIVE, newUserDomain, false,
        SpiConstants.PROPNAME_ACLUSERS);

    assertEquals(CaseSensitivityType.EVERYTHING_CASE_SENSITIVE,
        newPrincipal.getCaseSensitivityType());
    assertEquals(principal.getName(), newPrincipal.getName());
    assertFalse(newPrincipal.getName().contains(newUserDomain));
  }
View Full Code Here

    AclPropertyFilter factory = new AclPropertyFilter();
    Document output = factory.newDocumentFilter(input);

    Property prop = output.findProperty(SpiConstants.PROPNAME_ACLUSERS);
    Value value = prop.nextValue();
    Principal newPrincipal = ((PrincipalValue) value).getPrincipal();
    assertEquals(CaseSensitivityType.EVERYTHING_CASE_SENSITIVE,
        newPrincipal.getCaseSensitivityType());
    assertEquals("Jane Doe", newPrincipal.getName());

    Property denyprop =
        output.findProperty(SpiConstants.PROPNAME_ACLDENYUSERS);
    Value denyvalue = denyprop.nextValue();
    Principal denyPrincipal = ((PrincipalValue) denyvalue).getPrincipal();
    assertEquals(CaseSensitivityType.EVERYTHING_CASE_SENSITIVE,
        denyPrincipal.getCaseSensitivityType());
    assertEquals("John Doe", denyPrincipal.getName());
  }
View Full Code Here

    }
  }

  public void addPrincipalToDocument(Map<String, Object> props, String key,
      String name) {
    Principal principal =
        new Principal(SpiConstants.PrincipalType.UNKNOWN, null, name,
            SpiConstants.CaseSensitivityType.EVERYTHING_CASE_SENSITIVE);
    props.put(key, principal);
  }
View Full Code Here

    String newUserDomain = "MyCompany";
    Document output = createFilter(input,
        CaseSensitivityType.EVERYTHING_CASE_SENSITIVE, newUserDomain, true);

    Principal newPrincipal = getPrincipal(output,
        SpiConstants.PROPNAME_ACLUSERS);
    assertValues(newPrincipal, "MyCompany\\John Doe", newUserDomain, true);

    Principal newDenyPrincipal = getPrincipal(output,
        SpiConstants.PROPNAME_ACLDENYUSERS);
    assertValues(newDenyPrincipal, "MyCompany\\Jane Doe", newUserDomain, true);

    Principal newGroupPrincipal = getPrincipal(output,
        SpiConstants.PROPNAME_ACLGROUPS);
    assertValues(newGroupPrincipal, "noCompany\\Sales", newUserDomain, false);

    Principal groupDenyPrincipal = getPrincipal(output,
        SpiConstants.PROPNAME_ACLDENYGROUPS);
    assertValues(groupDenyPrincipal, "anyCompany\\Testing",
        newUserDomain, false);
  }
View Full Code Here

      String aclPropName, String aclRolePrefix) throws RepositoryException {
    LinkedList<Value> acl = new LinkedList<Value>();
    Property scopeProp = document.findProperty(aclPropName);
    Value scopeVal;
    while ((scopeVal = scopeProp.nextValue()) != null) {
      Principal principal = (scopeVal instanceof PrincipalValue)
          ? ((PrincipalValue) scopeVal).getPrincipal()
          : new Principal(scopeVal.toString().trim());
      String aclScope = principal.getName();
      if (Strings.isNullOrEmpty(aclScope)) {
        continue;
      }
      Property scopeRoleProp = document.findProperty(aclRolePrefix + aclScope);
      if (scopeRoleProp != null) {
        // Add ACL Entry (scope=role pair) to the list.
        Value roleVal;
        while ((roleVal = scopeRoleProp.nextValue()) != null) {
          String role = roleVal.toString().trim();
          if (role.length() > 0) {
            acl.add(Value.getPrincipalValue(new Principal(
                principal.getPrincipalType(),
                principal.getNamespace(), aclScope + '=' + role,
                principal.getCaseSensitivityType())));
          } else {
            // XXX: Empty role implies reader?
            acl.add(scopeVal);
          }
        }
View Full Code Here

   * Tests that a principal with minimal attributes is written to the
   * feed correctly.
   */
  public void testMinimalPrincipal() throws Exception {
    testPrincipal(
        new Principal(SpiConstants.PrincipalType.UNKNOWN, null, "John Doe"),
        "<principal"
        + " scope=\"user\" access=\"permit\">John Doe</principal>");
  }
View Full Code Here

  /**
   * Tests that a principal with no domain is written to the feed correctly.
   */
  public void testUnqualifiedPrincipal() throws Exception {
    testPrincipal(new Principal(SpiConstants.PrincipalType.UNQUALIFIED, null,
            "John Doe"),
        "<principal principal-type=\"unqualified\""
        + " scope=\"user\" access=\"permit\">John Doe</principal>");
  }
View Full Code Here

  /**
   * Tests that the principal namespace is written to the feed correctly.
   */
  public void testPrincipalNamespace() throws Exception {
    testPrincipal(
        new Principal(SpiConstants.PrincipalType.UNKNOWN, "Unknown Persons",
            "John Doe"),
        "<principal namespace=\"Unknown Persons\""
        + " scope=\"user\" access=\"permit\">John Doe</principal>");
  }
View Full Code Here

  /**
   * Tests that an empty namespace is ignored.
   */
  public void testPrincipalEmptyNamespace() throws Exception {
    testPrincipal(
        new Principal(SpiConstants.PrincipalType.UNKNOWN, "",
            "John Doe"),
        "<principal"
        + " scope=\"user\" access=\"permit\">John Doe</principal>");
  }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.spi.Principal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.