Package com.google.enterprise.connector.spi

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


      Session s = con.login();
      s.getTraversalManager().startTraversal();
      AuthenticationManager am = s.getAuthenticationManager();

      for (AdTestEntity user : ad.users) {
        AuthenticationResponse response = am.authenticate(
            new SimpleAuthenticationIdentity(user.sAMAccountName));

        Set<AdTestEntity> groupsCorrect = new HashSet<AdTestEntity>();
        user.getAllGroups(groupsCorrect);

        Set<String> groups = new HashSet<String>();
        @SuppressWarnings("unchecked") Collection<Principal> principals =
            (Collection<Principal>) response.getGroups();
        for (Principal p : principals) {
          groups.add(p.getName());
        }

        for (AdTestEntity e : groupsCorrect) {
View Full Code Here


        t.start();
        threads.add(t);
      }

      String username = TestConfiguration.d1principal.split("\\\\")[1];
      AuthenticationResponse response = am.authenticate(
          new SimpleAuthenticationIdentity(username));
      // we will expect to find exactly the same number of groups during crawl
      int constGroups = response.getGroups().size();
      boolean finished = false;

      // Run Authentication every 200ms and measure if it was faster than 3 sec
      while (!finished) {
        Thread.sleep(200);
        long start = System.currentTimeMillis();
        response = am.authenticate(
          new SimpleAuthenticationIdentity(username));
        long diff = System.currentTimeMillis() - start;
        assertTrue("Less than three seconds [" + diff + "]" , diff < 3000);
        assertTrue("Principal valid: " + TestConfiguration.d1principal,
            response.isValid());
        int groups = response.getGroups().size();
        assertEquals("Group number constant start: [" + constGroups
            + "] now: [" + groups + "]" , constGroups, groups);
        finished = true;
        for (TestThread t : threads) {
          if (t.isAlive()) {
View Full Code Here

      ad.createUser(false, user, ou);

      // recrawl AD
      s.getTraversalManager().resumeTraversal(null);

      AuthenticationResponse response = s.getAuthenticationManager()
          .authenticate(new SimpleAuthenticationIdentity(
              user.sAMAccountName, TestConfiguration.password));

      assertTrue("Authentication must succeed for resurrected user",
          response.isValid());

      assertFalse(
          "New user mustn't belong to the group he belonged to prior deletion",
          response.getGroups().contains(
              new Principal(group.sAMAccountName.toLowerCase())));

      // add new user as member to the group
      ad.initialize();
      group.children.add(user);
      ad.setMembers(false, group);
      s.getTraversalManager().resumeTraversal(null);

      // delete the group, create the same one with different GUID
      ad.deleteEntity(group);
      ad.createGroup(false, group, ou);
      s.getTraversalManager().resumeTraversal(null);

      response = s.getAuthenticationManager().authenticate(
          new SimpleAuthenticationIdentity(
              user.sAMAccountName, TestConfiguration.password));

      assertTrue("User from resurrected group can be authenticated",
          response.isValid());

      assertFalse("User must not belong to resurrected group",
          response.getGroups().contains(new Principal(
              group.sAMAccountName.toLowerCase())));
    }
  }
View Full Code Here

      // verify that each of x members belongs to this group
      String groupName = ad.getnETBIOSName() + AdConstants.BACKSLASH
          + group.sAMAccountName.toLowerCase();
      for (AdTestEntity user : group.children) {
        AuthenticationResponse response = am.authenticate(
            new SimpleAuthenticationIdentity(user.sAMAccountName));
        Set<String> groups = new HashSet<String>();
        @SuppressWarnings("unchecked") Collection<Principal> principals =
            (Collection<Principal>) response.getGroups();
        for (Principal p : principals) {
          groups.add(p.getName());
        }
        assertTrue("Group [" + groupName + "] must be found",
            groups.contains(groupName));
View Full Code Here

            // faster.
            ClientValue serverInfo = client.GetServerInfo();
            if (LOGGER.isLoggable(Level.FINE))
              LOGGER.fine("AUTHENTICATED: " + username + ": " +
                serverInfo.hasValue());
            return new AuthenticationResponse(serverInfo.hasValue(), null);
        } catch (RepositoryException e) {
            LOGGER.warning("Authentication failed for " +
                username + "; " + e.getMessage());
            throw e;
        }
View Full Code Here

    } finally {
      if (userSess != null) {
        userSess.logout();
      }
    }
    AuthenticationResponse result = new AuthenticationResponse(valid, null);
    return result;
  }
View Full Code Here

      // we need to check.
      if (authnManager != null) {
        if (LOGGER.isLoggable(Level.FINE)) {
          LOGGER.fine("AUTHENTICATE: " + identity);
        }
        AuthenticationResponse response = authnManager.authenticate(identity);
        if (LOGGER.isLoggable(Level.FINE)) {
          LOGGER.fine("AUTHENTICATION "
              + (response.isValid() ? "SUCCEEDED" : "FAILED") + ": "
              + identity + ": " + response);
        }
        return response;
      }
    } catch (ConnectorNotFoundException e) {
      LOGGER.log(Level.WARNING, "Connector " + connectorName + " not found", e);
    } catch (RepositoryLoginException e) {
      LOGGER.log(Level.WARNING, "Authentication failed for connector "
                 + connectorName + ": " + identity , e);
    } catch (RepositoryException e) {
      LOGGER.log(Level.WARNING, "Authentication failed for connector "
                 + connectorName + ": " + identity, e);
    } catch (Exception e) {
      LOGGER.log(Level.WARNING, "Authentication failed for connector "
                 + connectorName + ": " + identity, e);
    }
    return new AuthenticationResponse(false, null);
  }
View Full Code Here

    }
  }

  public static class SimpleAuthenticationManager implements AuthenticationManager {
    public AuthenticationResponse authenticate(AuthenticationIdentity id) {
      return new AuthenticationResponse(true, "admin");
    }
View Full Code Here

      // This is used to test some connectors failing, but others passing.
      if ((CONNECTOR1.equals(identity.getDomain()) &&
           !CONNECTOR1.equals(connectorName)) ||
          (CONNECTOR2.equals(identity.getDomain()) &&
           !CONNECTOR2.equals(connectorName))) {
        return new AuthenticationResponse(false, null, null);
      }

      StringBuilder sb = new StringBuilder();
      if (!verifyIdentity(identity, sb)) {
        return new AuthenticationResponse(false, null, null);
      }
    }
    return new AuthenticationResponse(true, null, groups);
  }
View Full Code Here

      }
      NDC.pushAppend(connectorName);
      try {
        AuthenticationIdentity identity =
            new SimpleAuthenticationIdentity(username, password, domain);
        AuthenticationResponse response =
            manager.authenticate(connectorName, identity);
        if (response.isValid()) {
          ServletUtil.writeXMLTagWithAttrs(
              out, 2, ServletUtil.XMLTAG_SUCCESS,
              ServletUtil.XMLTAG_CONNECTOR_NAME + "=\"" + connectorName + "\"",
              false);
          // TODO: Either fix ServletUtil XML code to XML escape attr values and
          // element text bodies, or add the ability to append attributes to
          // XmlUtils.appendStartTag().
          out.append(ServletUtil.indentStr(3));
          XmlUtils.xmlAppendStartTag(ServletUtil.XMLTAG_IDENTITY, out);
          XmlUtils.xmlAppendAttrValue(username, out);
          XmlUtils.xmlAppendEndTag(ServletUtil.XMLTAG_IDENTITY, out);

          // Add any returned groups that the user may belong to.
          if (response.getGroups() != null) {
            for (Object item : response.getGroups()) {
              Principal group = (item instanceof String) ?
                  new Principal((String) item) : (Principal) item;
              out.append(ServletUtil.indentStr(3));
              out.append('<').append(ServletUtil.XMLTAG_GROUP);
              if (group.getPrincipalType() ==
View Full Code Here

TOP

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

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.