Examples of AuthenticationResponse


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

      Logger.getLogger(AdGroupsConnectorTest.class.getName());

  private void runUsernameTest(String comment, AuthenticationManager am,
      String username, String domain, String password)
      throws Exception {
    AuthenticationResponse response;

    response = am.authenticate(
        new SimpleAuthenticationIdentity(username));
    assertTrue(comment + ": Username, no domain, no password",
        response.isValid());

    response = am.authenticate(new SimpleAuthenticationIdentity(
        username, null));
    assertTrue(comment + ": Username, no domain, null password",
        response.isValid());

    response = am.authenticate(new SimpleAuthenticationIdentity(
        username, ""));
    assertFalse(comment + ": Username, no domain, empty password",
        response.isValid());

    response = am.authenticate(
        new SimpleAuthenticationIdentity(username, null, domain));
    assertTrue(comment + ": Username, domain, null password",
        response.isValid());

    response = am.authenticate(new SimpleAuthenticationIdentity(
            username, "", domain));
    assertFalse(comment + ": Username, domain, empty password",
        response.isValid());

    response = am.authenticate(new SimpleAuthenticationIdentity(
        username, password, domain));
    assertTrue(comment + ": Username, domain, password",
        response.isValid());

    response = am.authenticate(new SimpleAuthenticationIdentity(
        username, password + "makeinvalid"));
    assertFalse(comment + ": Username, no domain, incorrect password",
        response.isValid());

    response = am.authenticate(new SimpleAuthenticationIdentity(
        username, password + "makeinvalid", domain));
    assertFalse(comment + ": Username, domain, incorrect password",
        response.isValid());
  }
View Full Code Here

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

      con.setDataSource(dbType, TestConfiguration.dbs.get(dbType));
      Session s = con.login();
      s.getTraversalManager().startTraversal();
      AuthenticationManager am = s.getAuthenticationManager();

      AuthenticationResponse response = am.authenticate(
          new SimpleAuthenticationIdentity(
              "non-existing user", "wrong password", "wrong domain"));
      assertFalse("Non existing user fails authn", response.isValid());
      assertNull("No groups resolved for non-existing user",
          response.getGroups());

      String[] principal =
          TestConfiguration.d1principal.split("\\\\");
      String domain = principal[0];
      String username = principal[1];
View Full Code Here

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

      // recrawl the active directory
      s.getTraversalManager().resumeTraversal("");

      // get groups for the created user
      AuthenticationResponse response = s.getAuthenticationManager()
          .authenticate(new SimpleAuthenticationIdentity(user.sAMAccountName));

      @SuppressWarnings("unchecked") Collection<Principal> principals =
          (Collection<Principal>) response.getGroups();
      assertNotNull(principals);
      assertTrue(principals.size() > 0);

      String groupname = ad.getnETBIOSName() + "\\" + group.sAMAccountName;
View Full Code Here

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

Examples of org.apache.hadoop.fs.swift.auth.AuthenticationResponse

      if (method.getStatusCode() == SC_BAD_REQUEST) {
        throw new SwiftAuthenticationFailedException(
          authenticationRequest.toString(), "POST", authUri, method);
      }

      final AuthenticationResponse access =
        JSONUtil.toObject(method.getResponseBodyAsString(),
                          AuthenticationWrapper.class).getAccess();
      final List<Catalog> serviceCatalog = access.getServiceCatalog();
      //locate the specific service catalog that defines Swift; variations
      //in the name of this add complexity to the search
      boolean catalogMatch = false;
      StringBuilder catList = new StringBuilder();
      StringBuilder regionList = new StringBuilder();

      //these fields are all set together at the end of the operation
      URI endpointURI = null;
      URI objectLocation;
      Endpoint swiftEndpoint = null;
      AccessToken accessToken;

      for (Catalog catalog : serviceCatalog) {
        String name = catalog.getName();
        String type = catalog.getType();
        String descr = String.format("[%s: %s]; ", name, type);
        catList.append(descr);
        if (LOG.isDebugEnabled()) {
          LOG.debug("Catalog entry " + descr);
        }
        if (name.equals(SERVICE_CATALOG_SWIFT)
            || name.equals(SERVICE_CATALOG_CLOUD_FILES)
            || type.equals(SERVICE_CATALOG_OBJECT_STORE)) {
          //swift is found
          if (LOG.isDebugEnabled()) {
            LOG.debug("Found swift catalog as " + name + " => " + type);
          }
          //now go through the endpoints
          for (Endpoint endpoint : catalog.getEndpoints()) {
            String endpointRegion = endpoint.getRegion();
            URI publicURL = endpoint.getPublicURL();
            URI internalURL = endpoint.getInternalURL();
            descr = String.format("[%s => %s / %s]; ",
                                  endpointRegion,
                                  publicURL,
                                  internalURL);
            regionList.append(descr);
            if (LOG.isDebugEnabled()) {
              LOG.debug("Endpoint " + descr);
            }
            if (region == null || endpointRegion.equals(region)) {
              endpointURI = usePublicURL ? publicURL : internalURL;
              swiftEndpoint = endpoint;
              break;
            }
          }
        }
      }
      if (endpointURI == null) {
        String message = "Could not find swift service from auth URL "
                         + authUri
                         + " and region '" + region + "'. "
                         + "Categories: " + catList
                         + ((regionList.length() > 0) ?
                            ("regions: " + regionList)
                                                      : "No regions");
        throw new SwiftInvalidResponseException(message,
                                                SC_OK,
                                                "authenticating",
                                                authUri);

      }


      accessToken = access.getToken();
      String path = SWIFT_OBJECT_AUTH_ENDPOINT
                    + swiftEndpoint.getTenantId();
      String host = endpointURI.getHost();
      try {
        objectLocation = new URI(endpointURI.getScheme(),
View Full Code Here

Examples of org.apache.openejb.client.AuthenticationResponse

    public Response processRequest(final ObjectInputStream in, final ProtocolMetaData metaData) throws Exception {

        final AuthenticationRequest req = new AuthenticationRequest();
        req.setMetaData(metaData);

        final AuthenticationResponse res = new AuthenticationResponse();
        res.setMetaData(metaData);

        try {
            req.readExternal(in);

            final String securityRealm = req.getRealm();
            final String username = req.getUsername();
            final String password = req.getCredentials();

            final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
            final Object token = securityService.login(securityRealm, username, password);

            final ClientMetaData client = new ClientMetaData();
            client.setMetaData(metaData);
            client.setClientIdentity(token);

            res.setIdentity(client);
            res.setResponseCode(ResponseCodes.AUTH_GRANTED);
        } catch (Throwable t) {
            res.setResponseCode(ResponseCodes.AUTH_DENIED);
            res.setDeniedCause(t);
        } finally {
            if (debug) {
                try {
                    logger.debug("AUTH REQUEST: " + req + " -- RESPONSE: " + res);
                } catch (Exception e) {
View Full Code Here

Examples of org.apache.openejb.client.AuthenticationResponse

    @Override
    public void processResponse(final Response response, final ObjectOutputStream out, final ProtocolMetaData metaData) throws Exception {

        if (AuthenticationResponse.class.isInstance(response)) {

            final AuthenticationResponse res = (AuthenticationResponse) response;
            res.setMetaData(metaData);

            try {
                res.writeExternal(out);
            } catch (Exception e) {
                logger.fatal("Could not write AuthenticationResponse to output stream", e);
            }
        } else {
            logger.error("AuthRequestHandler cannot process an instance of: " + response.getClass().getName());
View Full Code Here

Examples of org.apache.openejb.client.AuthenticationResponse

    public Response processRequest(final ObjectInputStream in, final ProtocolMetaData metaData) throws Exception {

        final AuthenticationRequest req = new AuthenticationRequest();
        req.setMetaData(metaData);

        final AuthenticationResponse res = new AuthenticationResponse();
        res.setMetaData(metaData);

        try {
            req.readExternal(in);

            final String securityRealm = req.getRealm();
            final String username = req.getUsername();
            final String password = req.getCredentials();

            final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
            final Object token = securityService.login(securityRealm, username, password);

            final ClientMetaData client = new ClientMetaData();
            client.setMetaData(metaData);
            client.setClientIdentity(token);

            res.setIdentity(client);
            res.setResponseCode(ResponseCodes.AUTH_GRANTED);
        } catch (final Throwable t) {
            res.setResponseCode(ResponseCodes.AUTH_DENIED);
            res.setDeniedCause(t);
        } finally {
            if (debug) {
                try {
                    logger.debug("AUTH REQUEST: " + req + " -- RESPONSE: " + res);
                } catch (final Exception e) {
View Full Code Here

Examples of org.apache.openejb.client.AuthenticationResponse

    @Override
    public void processResponse(final Response response, final ObjectOutputStream out, final ProtocolMetaData metaData) throws Exception {

        if (AuthenticationResponse.class.isInstance(response)) {

            final AuthenticationResponse res = (AuthenticationResponse) response;
            res.setMetaData(metaData);

            try {
                res.writeExternal(out);
            } catch (final Exception e) {
                logger.fatal("Could not write AuthenticationResponse to output stream", e);
            }
        } else {
            logger.error("AuthRequestHandler cannot process an instance of: " + response.getClass().getName());
View Full Code Here

Examples of org.apache.openejb.client.AuthenticationResponse

    AuthRequestHandler(EjbDaemon daemon) {
    }

    public void processRequest(ObjectInputStream in, ObjectOutputStream out) {
        AuthenticationRequest req = new AuthenticationRequest();
        AuthenticationResponse res = new AuthenticationResponse();

        try {
            req.readExternal(in);

            String securityRealm = req.getRealm();
            String username = req.getUsername();
            String password = req.getCredentials();

            SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class);
            Object token = securityService.login(securityRealm, username, password);

            ClientMetaData client = new ClientMetaData();
            client.setClientIdentity(token);

            res.setIdentity(client);
            res.setResponseCode(ResponseCodes.AUTH_GRANTED);
        } catch (Throwable t) {
            res.setResponseCode(ResponseCodes.AUTH_DENIED);
            res.setDeniedCause(t);
        } finally {
            if (logger.isDebugEnabled()){
                try {
                    logger.debug("AUTH REQUEST: "+req+" -- RESPONSE: " + res);
                } catch (Exception justInCase) {}
            }

            try {
                res.writeExternal(out);
            } catch (java.io.IOException ie) {
                logger.fatal("Couldn't write AuthenticationResponse to output stream", ie);
            }
        }
    }
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.