Package com.google.enterprise.connector.spi

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


   * @throws RepositoryException
   */
  public void testInvalidUser() throws RepositoryException {
    Session session = connector.login();
    AuthenticationManager manager = session.getAuthenticationManager();
    AuthenticationResponse response = manager.authenticate(
        new SimpleAuthenticationIdentity("not a real username"));
    assertFalse(response.isValid());
  }
View Full Code Here


   * @throws RepositoryException
   */
  public void testValidUser() throws RepositoryException {
    Session session = connector.login();
    AuthenticationManager manager = session.getAuthenticationManager();
    AuthenticationResponse response = manager.authenticate(
        new SimpleAuthenticationIdentity(username, password));
    assertTrue("Failed to authenticate: " + username, response.isValid());
    @SuppressWarnings({ "unchecked", "cast" })
        Collection<Principal> groups = (Collection<Principal>) response.getGroups();
    if (groups != null) {
      String groupPrefix = ((NotesConnectorSession) session)
          .getGsaGroupPrefix();
      for (Principal group : groups) {
        String name = group.getName();
View Full Code Here

   * @throws RepositoryException
   */
  public void testValidUserGroupResolutionOnly() throws RepositoryException {
    Session session = connector.login();
    AuthenticationManager manager = session.getAuthenticationManager();
    AuthenticationResponse response = manager.authenticate(
        new SimpleAuthenticationIdentity(username, null));
    assertTrue("Authenticated: " + username, response.isValid());
    @SuppressWarnings({ "unchecked", "cast" })
        Collection<Principal> groups = (Collection<Principal>) response.getGroups();
    if (groups != null) {
      String groupPrefix = ((NotesConnectorSession) session)
          .getGsaGroupPrefix();
      for (Principal group : groups) {
        String name = group.getName();
View Full Code Here

  public void testAuthenticateKnownUser() throws Exception {
    // Validate the first name in the list
    String user = names[0];
    NotesNameMock nameMock = notesNamesCache.get(user);
    AuthenticationResponse response = authenticationManager.authenticate(
        new SimpleAuthenticationIdentity(nameMock.getShortName(),"password"));
    assertTrue(user + " is valid: ", response.isValid());
    testUserGroups(connectorSession, response, user);
  }
View Full Code Here

      super.tearDown();
    }
  }

  public void testAuthenticateUnknownUser() throws Exception {
    AuthenticationResponse response = authenticationManager
        .authenticate(new SimpleAuthenticationIdentity("foo"));
    assertFalse(response.isValid());
  }
View Full Code Here

        .authenticate(new SimpleAuthenticationIdentity("foo"));
    assertFalse(response.isValid());
  }

  public void testAuthenticateKnownUserNoPassword() throws Exception {
    AuthenticationResponse response = authenticationManager
        .authenticate(new SimpleAuthenticationIdentity("anakin"));
    assertTrue("known user not valid", response.isValid());
    verifyGroups(connectorSession, response);
  }
View Full Code Here

    assertTrue("known user not valid", response.isValid());
    verifyGroups(connectorSession, response);
  }

  public void testAuthenticateKnownUserBadPassword() throws Exception {
    AuthenticationResponse response = authenticationManager
        .authenticate(new SimpleAuthenticationIdentity("anakin", "foo"));
    assertFalse("valid with bad password", response.isValid());
    verifyGroups(connectorSession, response);
  }
View Full Code Here

    assertFalse("valid with bad password", response.isValid());
    verifyGroups(connectorSession, response);
  }

  public void testAuthenticateKnownUser() throws Exception {
    AuthenticationResponse response = authenticationManager.authenticate(
        new SimpleAuthenticationIdentity("anakin", "password"));
    assertTrue("known user not valid", response.isValid());
    verifyGroups(connectorSession, response);
  }
View Full Code Here

      AuthenticationIdentity authenticationIdentity)
      throws RepositoryLoginException, RepositoryException {
    String userLoginName =
        IdentityUtil.getCanonicalUsername(authenticationIdentity);
    if (userLoginName == null) {
      return new AuthenticationResponse(false, "");
    } else {
      String userDomain = IdentityUtil.getDomain(authenticationIdentity);
      String password = authenticationIdentity.getPassword();
      ISessionManager sessionManagerUser;
      boolean authenticate;
      String userName;
      try {
        if (Strings.isNullOrEmpty(password)) {
          sessionManagerUser =
              getSessionManager(connector.getLogin(), connector.getPassword());
          //check for user existence when null password
          userName = getUserName(sessionManagerUser, userLoginName, userDomain);
          authenticate = (userName != null);
        } else {
          // TODO(jlacey): We are using the raw username from the GSA
          // here because we always have and no bugs have been reported.
          sessionManagerUser =
              getSessionManager(authenticationIdentity.getUsername(), password);

          // Use getSession instead of authenticate, so we can get the
          // authenticated user name.
          ISession session = sessionManagerUser.getSession(docbase);
          try {
            userName = session.getLoginUserName();
          } finally {
            sessionManagerUser.release(session);
          }
          authenticate = true;
        }
      } catch (RepositoryLoginException e) {
        LOGGER.finer(e.getMessage());
        return new AuthenticationResponse(false, "");
      }

      if (authenticate) {
        return new AuthenticationResponse(authenticate, "", getAllGroupsForUser(
            sessionManagerUser, userName));
      } else {
        return new AuthenticationResponse(false, "");
      }
    }
  }
View Full Code Here

    addAllowGroupToAcl(aclObj, "dm_world");

    aclList.processAcl(aclObj, aclValues);
    DctmAuthenticationManager authentManager =
        (DctmAuthenticationManager) dctmSession.getAuthenticationManager();
    AuthenticationResponse result =
        authentManager.authenticate(new SimpleAuthenticationIdentity(
            DmInitialize.DM_LOGIN_OK1, null));
    assertTrue(result.isValid());

    Principal expectedPrincipal = new Principal(PrincipalType.UNKNOWN,
        connector.getGoogleLocalNamespace(), "dm_world",
        CaseSensitivityType.EVERYTHING_CASE_SENSITIVE);

    // get dm_world principal from ACL
    Principal aclPrincipal = null;
    List<Value> values = aclValues.get(SpiConstants.PROPNAME_ACLGROUPS);
    for (Value listvalue : values) {
      if (((PrincipalValue) listvalue).getPrincipal().getName()
          .equalsIgnoreCase("dm_world")) {
        aclPrincipal = ((PrincipalValue) listvalue).getPrincipal();
        break;
      }
    }
    assertEquals(expectedPrincipal, aclPrincipal);

    // get dm_world principal from group lookup
    Principal groupLookupPrincipal = null;
    Collection<Principal> groups = (Collection<Principal>) result.getGroups();
    for (Principal groupPrincipal : groups) {
      if (groupPrincipal.getName().equalsIgnoreCase("dm_world")) {
        groupLookupPrincipal = groupPrincipal;
        break;
      }
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.