Examples of AuthenticationResponse


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

    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

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

      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

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

    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

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

  }

  public void testGroupLookup_only() throws Exception {
    groupSetUp();

    AuthenticationResponse result =
        authentManager.authenticate(new SimpleAuthenticationIdentity(
            DmInitialize.DM_LOGIN_OK1, null));
    assertTrue(result.isValid());
    Collection<?> groups = result.getGroups();
    assertEquals(ImmutableList.of("grp1", "grp2", "grp3", "dm_world"),
        toStrings(groups));
  }
View Full Code Here

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

  }

  public void testGroupLookup_badUser() throws Exception {
    groupSetUp();

    AuthenticationResponse result =
        authentManager.authenticate(new SimpleAuthenticationIdentity(
            DmInitialize.DM_LOGIN_KO, null));
    assertFalse(result.isValid());
  }
View Full Code Here

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

  }

  public void testGroupLookup_authentication() throws Exception {
    groupSetUp();

    AuthenticationResponse result =
        authentManager.authenticate(new SimpleAuthenticationIdentity(
            DmInitialize.DM_LOGIN_OK1, DmInitialize.DM_PWD_OK1));
    assertTrue(result.isValid());
    Collection<?> groups = result.getGroups();
    assertEquals(ImmutableList.of("grp1", "grp2", "grp3", "dm_world"),
        toStrings(groups));
  }
View Full Code Here

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

  }

  public void testGroupLookup_onlyWorld() throws Exception {
    groupSetUp();

    AuthenticationResponse result =
        authentManager.authenticate(new SimpleAuthenticationIdentity(
            DmInitialize.DM_LOGIN_OK2, DmInitialize.DM_PWD_OK2));
    assertTrue(result.isValid());
    Collection<?> groups = result.getGroups();
    assertEquals(ImmutableList.of("dm_world"), toStrings(groups));
  }
View Full Code Here

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

   * Helper method tests group lookup only and verifies that the given
   * groups (along with dm_world) are returned for the user.
   */
  private void testGroupLookup(String user, String domain,
      String... expectedGroups) throws Exception {
    AuthenticationResponse result = authentManager.authenticate(
        new SimpleAuthenticationIdentity(user, null, domain));
    assertTrue(result.isValid());
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    assertEquals(builder.add(expectedGroups).add("dm_world").build(),
        toStrings(result.getGroups()));
  }
View Full Code Here

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

  }

  /** Helper method tests group lookup only and verifies that it fails. */
  private void testGroupLookupFail(String user, String domain)
      throws Exception {
    AuthenticationResponse result = authentManager.authenticate(
        new SimpleAuthenticationIdentity(user, null, domain));
    assertFalse(result.isValid());
  }
View Full Code Here

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

  private void testParentDomainFail(String user, String domain)
      throws Exception {
    insertUser("aceuser", "ldapuser", "LDAP",
        "CN=LDAP User,dc=ace,dc=example,dc=com");

    AuthenticationResponse result = authentManager.authenticate(
        new SimpleAuthenticationIdentity(user, null, domain));
    assertFalse(result.isValid());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.