Package org.orgama.server.auth.model

Examples of org.orgama.server.auth.model.AuthInitialization


  public void tearDown() {
  }
 
  @Test
  public void testSuccessfulRegistrationWithFacebook() {
    AuthInitialization authInitialization = new AuthInitialization();
    authInitialization.setAuthServiceName(AuthServiceName.facebook);
    authInitialization.setEmailAddress(env.getEmailAddress());
    authInitialization.setState(AuthInitializationState.registering);
   
    httpSession.setAttribute(constants.getAuthInitializationKey(),
        authInitialization);
   
    ICompleteAuthState completeAuthState = bootstrapper.bootstrap();
View Full Code Here


 
 
  @Test
  public void testSuccessfulAuthenticationWithFacebook() {
   
    AuthInitialization authInitialization = new AuthInitialization();
    authInitialization.setAuthServiceName(AuthServiceName.facebook);
    authInitialization.setEmailAddress(env.getEmailAddress());
    authInitialization.setState(AuthInitializationState.authenticating);
    authInitialization.setServiceSpecificSessionId(
        facebook.getAccessToken());
    authInitialization.setServiceSpecificUserId(facebook.getUserId(
        facebook.getAccessToken()));
   
    //Register the user with the given auth Initialization
    userService.registerNewUser(authInitialization);
   
View Full Code Here

   
  }
 
  @Test
  public void testSignOutOfAppOnly() throws Exception {
    AuthInitialization authInit = new AuthInitialization();
    authInit.setAuthServiceName(AuthServiceName.googleAccounts);
    authInit.setEmailAddress(env.getEmailAddress());
    authInit.setServiceSpecificUserId(env.getEmailAddress());
    AuthUser user = userService.registerNewUser(authInit);
    sessionService.create(user, authInit);
   
    SignOut action = new SignOut();
    action.setAuthServiceName(AuthServiceName.googleAccounts);
View Full Code Here

    assertNull(session);
  }
 
  @Test
  public void testSignOutOfAppAndExternalService() throws Exception {
    AuthInitialization authInit = new AuthInitialization();
    authInit.setAuthServiceName(AuthServiceName.googleAccounts);
    authInit.setEmailAddress(env.getEmailAddress());
    authInit.setServiceSpecificUserId(env.getEmailAddress());
    AuthUser user = userService.registerNewUser(authInit);
    sessionService.create(user, authInit);
   
    SignOut action = new SignOut();
    action.setAuthServiceName(AuthServiceName.googleAccounts);
View Full Code Here

      throw new AlreadyAuthenticatedException();
    }

    AuthInitializationService authInitService = initProviderProvider.get();

    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());
    }
View Full Code Here

    }
   
    AuthInitializationService authInitService =
        this.initProviderProvider.get();
   
    AuthInitialization authInit = authInitService.get();
   
    IAuthService authService =
        authSourceProvider.getAuthServices().get(authResourceName);
   
    if (authService == null) {
      throw new AuthException("No auth service could be found matching: "
          + authResourceName);
    }
   
    HttpServletResponse response = responseProvider.get();
   
    if (response == null) {
      throw new OrgamaCoreException("Failed to get HttpResponse");
    }
   
    String signInUrl = authService.getSignInUrl();
   
    result.setRedirectUrl(signInUrl);
   
    authInit.setEmailAddress(emailAddress);
    authInit.setState(AuthInitializationState.registering);
    authInit.setAuthServiceName(authResourceName);
   
    authInitService.save(authInit);
   
    return result;
  }
View Full Code Here

  public void testGettingDefaultAuthInitialization() {
    //Make sure the http session does not contain an auth initialization;
    assertNull(httpSession.getAttribute(
        constants.getAuthInitializationKey()));
   
    AuthInitialization ai = authInitializationProvider.get();
   
    assertNotNull(ai);
   
    assertEquals(AuthInitializationState.nil, ai.getState());
   
    //Make sure that attempting to get the auth initialization again returns
    //the same pointer to the authinitialization before.
    AuthInitialization ai2 = authInitializationProvider.get();
   
    assertEquals(ai, ai2);
   
    //Make sure the http ssession now contains a copy of the same
    //auth initialization.  This will not be the same pointer
    AuthInitialization ai3 = (AuthInitialization)httpSession.getAttribute(
        constants.getAuthInitializationKey());
   
    assertNotNull(ai3);
    assertNotSame(ai, ai3);
    assertEquals(ai.getState(), ai3.getState());
  }
View Full Code Here

    String emailAddress = "temp@email.address.com";
    String authSource = "nothing-yet";
    AuthInitializationState state = AuthInitializationState.authenticating;
   
    {
      AuthInitialization ai = new AuthInitialization();
      ai.setEmailAddress(emailAddress);
      ai.setAuthServiceName(authSource);
      ai.setState(state);
     
      httpSession.setAttribute(constants.getAuthInitializationKey(), ai);
    }
   
    AuthInitialization ai = authInitializationProvider.get();
       
    assertNotNull(ai);
    assertEquals(state, ai.getState());
    assertEquals(emailAddress, ai.getEmailAddress());
    assertEquals(authSource, ai.getAuthServiceName());
  }
View Full Code Here

  }
 
  @Test
  public void testRequireNewAfterNonNew() {
   
    AuthInitialization authInitialization = new AuthInitialization();
    authInitialization.setAuthServiceName(AuthServiceName.googleAccounts);
    authInitialization.setEmailAddress(env.getEmailAddress());
    authInitialization.setState(AuthInitializationState.authenticating);
    authInitialization.setServiceSpecificUserId(env.getEmailAddress());
   
    httpSession.setAttribute(constants.getAuthInitializationKey(),
        authInitialization);
   
    AuthInitialization authInit = requireNewAuthInitService.get();
   
    assertNotNull(authInit);
    assertEquals(AuthInitializationState.nil, authInit.getState());
  }
View Full Code Here

  public void tearDown() {
  }
 
  @Test
  public void testSuccessfulRegistrationWithGoogleAccounts() {
    AuthInitialization authInitialization = new AuthInitialization();
    authInitialization.setAuthServiceName(AuthServiceName.googleAccounts);
    authInitialization.setEmailAddress(env.getEmailAddress());
    authInitialization.setState(AuthInitializationState.registering);
   
    httpSession.setAttribute(constants.getAuthInitializationKey(),
        authInitialization);
   
    ICompleteAuthState completeAuthState = bootstrapper.bootstrap();
View Full Code Here

TOP

Related Classes of org.orgama.server.auth.model.AuthInitialization

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.