Package com.google.enterprise.connector.spi

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


    SmbAclBuilder builder = new SmbAclBuilder(smbFile, fetcher);
    Acl acl = builder.getShareAcl();
    assertNotNull(acl);
    assertNotNull(acl.getGroups());
    assertFalse(acl.getGroups().isEmpty());
    Principal p = acl.getGroups().iterator().next();
    assertNotNull(p);
    assertEquals("google\\accountants", p.getName());
    assertEquals(GLOBAL_NAMESPACE, p.getNamespace());
    assertEquals(AclFormat.DOMAIN_BACKSLASH_USER.getPrincipalType(),
                 p.getPrincipalType());
    assertEquals(CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE,
        p.getCaseSensitivityType());
    assertTrue(acl.getUsers().isEmpty());
    assertTrue(acl.getDenyUsers().isEmpty());
    assertTrue(acl.getDenyGroups().isEmpty());
    verify(smbFile);
  }
View Full Code Here


    }
    // This call is used only by LegacySmbAclBuilder and the tests, so
    // we don't need to add namespaces or the rest here.
    List<Principal> principals = new ArrayList<Principal>(list.size());
    for (String item : list) {
      principals.add(new Principal(item));
    }
    return principals;
  }
View Full Code Here

      }
    }
    switch (sidType) {
      case SID.SID_TYPE_USER:
        // TODO: I don't think SID supports local users, so assume global.
        users.add(new Principal(userAclFormat.getPrincipalType(),
                globalNamespace, aclEntry,
                CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE));
        break;
      case SID.SID_TYPE_DOM_GRP:
      case SID.SID_TYPE_DOMAIN:
        groups.add(new Principal(groupAclFormat.getPrincipalType(),
                globalNamespace, aclEntry,
                CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE));
        break;
      case SID.SID_TYPE_ALIAS:
      case SID.SID_TYPE_WKN_GRP:
        if (ix < 0 && !Strings.isNullOrEmpty(sid.getDomainName())) {
          aclEntry = AclFormat.formatString(groupAclFormat, aclEntry,
                                            sid.getDomainName());
        }
        groups.add(new Principal(groupAclFormat.getPrincipalType(),
                globalNamespace, aclEntry,
                CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE));
        break;
    }
  }
View Full Code Here

      "    </Success>\n" +
      "  </AuthnResponse>\n" +
      "</CmResponse>\n";

    Collection<Principal> groups = ImmutableList.of(
        new Principal(SpiConstants.PrincipalType.UNKNOWN, "global", "staff"),
        new Principal(SpiConstants.PrincipalType.UNKNOWN, "global", "wheel"),
        new Principal(SpiConstants.PrincipalType.UNQUALIFIED, "local", "wheel"),
        new Principal(SpiConstants.PrincipalType.UNQUALIFIED, "local", "slo"));
    doTest(xmlBody, expectedResult, "connector1", "fooUser", "fooPassword",
           groups);
  }
View Full Code Here

  }

  public void testAclFilterFindPropertyWithPrincipalValue() 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);

    Document output = createFilter(input,
        CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE, null, false);
    Property prop = output.findProperty(SpiConstants.PROPNAME_ACLUSERS);
    Value value = prop.nextValue();

    Principal newPrincipal = ((PrincipalValue) value).getPrincipal();
    assertEquals(principal.getName(), newPrincipal.getName());
    assertEquals(CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE,
        newPrincipal.getCaseSensitivityType());
  }
View Full Code Here

  private static void wrapAclPrincipal(StringBuilder buff, Property property,
      AclScope scope, AclAccess access)
      throws RepositoryException, IOException {
    ValueImpl value;
    while ((value = (ValueImpl) property.nextValue()) != null) {
      Principal principal = (value instanceof PrincipalValue)
          ? ((PrincipalValue) value).getPrincipal()
          : new Principal(value.toString().trim());
      String name = stripRoles(principal.getName(), access);
      if (!Strings.isNullOrEmpty(name)) {
        buff.append("<").append(XML_PRINCIPAL);
        if (principal.getPrincipalType() ==
            SpiConstants.PrincipalType.UNQUALIFIED) {
          // UNQUALIFIED is a special-case on the GSA to allow us to prevent the
          // GSA from mistakeningly finding a domain in the principal name.
          XmlUtils.xmlAppendAttr(ServletUtil.XMLTAG_PRINCIPALTYPE_ATTRIBUTE,
              SpiConstants.PrincipalType.UNQUALIFIED.toString(), buff);
        }
        if (!Strings.isNullOrEmpty(principal.getNamespace())) {
          XmlUtils.xmlAppendAttr(ServletUtil.XMLTAG_NAMESPACE_ATTRIBUTE,
                                 principal.getNamespace(), buff);
        }
        // The GSA's default is EVERYTHING_CASE_SENSITIVE. No need to send the
        // attribute when it is the default.
        if (principal.getCaseSensitivityType()
            != SpiConstants.CaseSensitivityType.EVERYTHING_CASE_SENSITIVE) {
          XmlUtils.xmlAppendAttr(
              ServletUtil.XMLTAG_CASESENSITIVITYTYPE_ATTRIBUTE,
              principal.getCaseSensitivityType().toString(), buff);
        }
        XmlUtils.xmlAppendAttr(XML_SCOPE, scope.toString(), buff);
        XmlUtils.xmlAppendAttr(XML_ACCESS, access.toString(), buff);
        buff.append(">");
        XmlUtils.xmlAppendAttrValue(name, buff);
View Full Code Here

  public void testAclFilterFindPropertyWithSamePrincipalValue()
      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);

    Document output = createFilter(input,
        CaseSensitivityType.EVERYTHING_CASE_SENSITIVE, null, false);
    Property prop = output.findProperty(SpiConstants.PROPNAME_ACLUSERS);
    Value value = prop.nextValue();

    Principal newPrincipal = ((PrincipalValue) value).getPrincipal();
    assertEquals(principal.getName(), newPrincipal.getName());
    assertTrue(newPrincipal.getCaseSensitivityType().equals(
        CaseSensitivityType.EVERYTHING_CASE_SENSITIVE));
  }
View Full Code Here

  public void testAclFilterFindPropertyWithNoPrincipalValue()
      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);

    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(principal.getName(), newPrincipal.getName());
    assertEquals(CaseSensitivityType.EVERYTHING_CASE_SENSITIVE,
        newPrincipal.getCaseSensitivityType());
  }
View Full Code Here

  public void testAclFilterFindPropertyWithAclInheritFrom()
      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);
    props.put(SpiConstants.PROPNAME_ACLINHERITFROM, "parentId");
    Document input = ConnectorTestUtils.createSimpleDocument(props);

    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(principal.getName(), newPrincipal.getName());
    assertEquals(CaseSensitivityType.EVERYTHING_CASE_SENSITIVE,
        newPrincipal.getCaseSensitivityType());

    Property propInheritFrom =
        output.findProperty(SpiConstants.PROPNAME_ACLINHERITFROM);
    Value valueInheritfrom = propInheritFrom.nextValue();
    assertEquals("parentId", valueInheritfrom.toString());
View Full Code Here

        CaseSensitivityType.EVERYTHING_CASE_SENSITIVE, null, false);
    Property prop = output.findProperty(SpiConstants.PROPNAME_ACLUSERS);
    Value value;
    while ((value = prop.nextValue()) != null) {
      if (value instanceof PrincipalValue) {
        Principal newPrincipal = ((PrincipalValue) value).getPrincipal();
        assertEquals(CaseSensitivityType.EVERYTHING_CASE_SENSITIVE,
            newPrincipal.getCaseSensitivityType());
      }
    }
  }
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.