Package org.orgama.shared.auth.action

Examples of org.orgama.shared.auth.action.ValidateEmailAddressResult


    AuthInitialization authInit = authInitService.get();

    AuthUser user = userServices.getUserFromEmailAddress(emailAddress);

    ValidateEmailAddressResult result;

    Map<String, IAuthService> authSources =
        authSourceProvider.getAuthServices();

    //If the returned user is null, the given email address is not known,
    //so the result should indicate this and return the list of auth
    //providers
    if (user == null) {

      //Save the email address the user validated against with in the auth
      //initialization.  This must match any imediately subsequent
      //requests for regisration
      authInit.setEmailAddress(a.getEmailAddress());
      authInitService.save(authInit);

      ArrayList<AuthSourceInfo> authSourceInfos =
          new ArrayList<AuthSourceInfo>();

      for (IAuthService authService : authSources.values()) {
        authSourceInfos.add(authService.getInfo());
      }

      result = new ValidateEmailAddressResult(a.getEmailAddress(),
          authSourceInfos);
    } else {

      //else the user needs to be redirected to the registered user's
      //auth service's login url.

      String serviceName = user.getAuthServiceName();
      emailAddress = user.getSanitizedEmailAddress();

      IAuthService authService = authSources.get(serviceName);

      if (authService == null) {
        throw new AuthException("The auth service that user: "
            + emailAddress + " used to "
            + "authenticate, " + serviceName + " "
            + "was not found in the list of auth sources");
      }

      authInit.setAuthServiceName(serviceName);
      authInit.setEmailAddress(emailAddress);
      authInit.setState(AuthInitializationState.authenticating);
      authInit.setServiceSpecificUserId(user.getServiceSpecificUserId());

      authInitService.save(authInit);

      result = new ValidateEmailAddressResult(authService.getSignInUrl());
    }

    return result;
  }
View Full Code Here


   */
  @Test
  public void testValidationFromScratch() throws Exception {
    ValidateEmailAddress action = new ValidateEmailAddress(
        emailAddress);
    ValidateEmailAddressResult result =
        (ValidateEmailAddressResult)dispatch.execute(null, action);
   
    assertNotNull(result);
    assertEquals(emailAddress, result.getEmailAddress());
    assertNotNull(result.getAuthSourceList());
    assertTrue(result.getAuthSourceList().size() > 0);
    assertNull(result.getRedirectUrl());
    assertEquals(ValidateEmailAddressResult.Code.unknownEmailAddress,
        result.getResponseCode());
  }
View Full Code Here

    authInit.setServiceSpecificUserId(env.getEmailAddress());
    AuthUser user = userService.registerNewUser(authInit);
   
    ValidateEmailAddress action =
        new ValidateEmailAddress(env.getEmailAddress());
    ValidateEmailAddressResult result =
        (ValidateEmailAddressResult)dispatch.execute(null, action);
   
    assertNotNull(result);
    assertNotNull(result.getRedirectUrl());
    assertEquals(ValidateEmailAddressResult.Code.redirect,
        result.getResponseCode());
    assertEquals("/_ah/login?continue=http%3A%2F%2F127.0.0.1%3A8888",
        result.getRedirectUrl());
  }
View Full Code Here

TOP

Related Classes of org.orgama.shared.auth.action.ValidateEmailAddressResult

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.