Package com.google.enterprise.connector.notes.NotesUserGroupManager

Examples of com.google.enterprise.connector.notes.NotesUserGroupManager.User


    databaseDocument.addItem(new NotesItemMock("name",
            NCCONST.NCITM_DBNOACCESSGROUPS, "type", NotesItem.TEXT,
            "values", "Separatists"));

    // Allowed access by name.
    User user = new User(1L, "cn=anakin skywalker/ou=tests/o=tests", "anakin");
    user.addGroup("foo");
    assertTrue(
        authorizationManager.checkDatabaseAccess(databaseDocument, user));
    user = new User(1L, "cn=yoda/ou=tests", "yoda");
    user.addGroup("foo");
    assertTrue(
        authorizationManager.checkDatabaseAccess(databaseDocument, user));
    // Denied access by name.
    user = new User(1L, "cn=grievous/ou=tests", "g");
    user.addGroup("foo");
    assertFalse(
        authorizationManager.checkDatabaseAccess(databaseDocument, user));
    // Allowed access by group.
    user = new User(1L, "cn=foo/ou=tests", "g");
    user.addGroup("masters");
    assertTrue(
        authorizationManager.checkDatabaseAccess(databaseDocument, user));
    // TODO: Denied access by group.
    //assertTrue(authorizationManager.checkDatabaseAccess(databaseDocument,
    // "foo", Lists.newArrayList("separatists")));
View Full Code Here


    //assertTrue(authorizationManager.checkDatabaseAccess(databaseDocument,
    // "foo", Lists.newArrayList("separatists")));
  }

  public void testCheckDocumentReaders() throws Exception {
    User user = new User(1L, "cn=anakin skywalker/ou=tests/o=tests", "anakin");
    user.addGroup("masters");
    user.addRole("jtmreplicaid0123", "[tacticsexpert]");

    // User in readers list.
    assertTrue(authorizationManager.checkDocumentReaders(user,
            Lists.newArrayList("cn=anakin skywalker/ou=tests/o=tests"),
            "jtmreplicaid0123"));
View Full Code Here

    SimpleTraversalContext context = new SimpleTraversalContext();
    context.setSupportsInheritedAcls(true);
    ((TraversalContextAware) connectorSession.getTraversalManager())
        .setTraversalContext(context);

    User user =
        connectorSession.getUserGroupManager().getUserByGsaName("jsmith");
    assertNotNull(user);

    NotesDocumentMock notesDoc = createNotesDocument("server",
        "testdb_replicaid", "unid0001", ActionType.ADD);
View Full Code Here

    ArrayList<AuthorizationResponse> authorized =
        new ArrayList<AuthorizationResponse>(docIds.size());
    try {
      // Find the user in the connector cache.
      String gsaName = ncs.getUsernameType().getUsername(id);
      User user = ncs.getUserGroupManager().getUserByGsaName(gsaName);
      if (user == null) {
        LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
            "Person not found in connector user database: " + gsaName +
            " using " + ncs.getUsernameType() + " username type");
        for (String docId : docIds) {
          authorized.add(new AuthorizationResponse(false, docId));
        }
      } else {
        LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
            "Authorizing documents for user " + gsaName +
            " using " + ncs.getUsernameType() + " username type");
        ArrayList<String> userGroups = new ArrayList<String>(user.getGroups());
        LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
            "Groups for " + gsaName + " are: " + userGroups);

        NotesSession ns = null;
        try {
View Full Code Here

      LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
          "Authenticating user: " + gsaName + " using " +
          connectorSession.getUsernameType() + " username type");

      // Find the user in the connector cache.
      User user =
          connectorSession.getUserGroupManager().getUserByGsaName(gsaName);
      if (user == null) {
        LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
            gsaName + " user is not authenticated");
        return new AuthenticationResponse(false, null);
      }
      LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
          user.getNotesName() + " user is authenticated");

      // Find the user in Notes.
      NotesSession notesSession = connectorSession.createNotesSession();
      NotesDatabase notesDirectory = null;
      NotesView notesUsersView = null;
      NotesDocument notesUserDoc = null;
      boolean hasValidPassword = false;
      try {
        notesDirectory = notesSession.getDatabase(
            connectorSession.getServer(), connectorSession.getDirectory());
        notesUsersView = notesDirectory.getView(NCCONST.DIRVIEW_USERS);
        notesUserDoc =
            notesUsersView.getDocumentByKey(user.getNotesName(), true);
        if (notesUserDoc == null) {
          LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
              "Username not found in Notes directory");
          return new AuthenticationResponse(false, null);
        }
        if (id.getPassword() != null) {
          String hashedPassword =
              notesUserDoc.getItemValueString("HTTPPassword");
          hasValidPassword =
              notesSession.verifyPassword(id.getPassword(), hashedPassword);
        }
      } finally {
        Util.recycle(notesUserDoc);
        Util.recycle(notesUsersView);
        Util.recycle(notesDirectory);
        connectorSession.closeNotesSession(notesSession);
      }

      Collection<String> groupsAndRoles = user.getGroupsAndRoles();
      Collection<String> prefixedGroups = GsaUtil.getGsaGroups(
          groupsAndRoles, connectorSession.getGsaGroupPrefix());
      Collection<Principal> principalGroups = null;
      if (prefixedGroups.size() != 0) {
        principalGroups = new ArrayList<Principal>(prefixedGroups.size());
        for (String group : prefixedGroups) {
          Principal principal = new Principal(PrincipalType.UNQUALIFIED,
              connectorSession.getConnector().getLocalNamespace(),
              group, CaseSensitivityType.EVERYTHING_CASE_INSENSITIVE);
          principalGroups.add(principal);
        }
      }
      String idLog = getIdentityLog(gsaName, user.getNotesName(),
          groupsAndRoles, prefixedGroups);
      if (id.getPassword() != null) {
        if (hasValidPassword) {
          LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
              "User succesfully authenticated: " + idLog);
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.notes.NotesUserGroupManager.User

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.