Package com.google.appengine.api.users

Examples of com.google.appengine.api.users.User


        filter.setUserService(userService);
        filter.setAuthenticationManager(authenticationManager);
        filter.afterPropertiesSet();

        User user = new User("email", "authDomain", "userId", "federatedIdentity");
        when(authenticationManager.authenticate(isA(GaeUserAuthenticationToken.class))).thenAnswer(new AuthenticationAnswer());
        when(userService.isUserLoggedIn()).thenReturn(true);      // user is logged in
        when(userService.isUserAdmin()).thenReturn(true);         // user is an admin
        when(userService.getCurrentUser()).thenReturn(user);      // this is the logged in user

        GaeUser gaeUser = callDoFilter(filter)// no client roles
        assertEquals(user.getAuthDomain(), gaeUser.getAuthDomain());
        assertEquals(user.getFederatedIdentity(), gaeUser.getFederatedIdentity());
        assertEquals(user.getEmail(), gaeUser.getEmail());
        assertEquals(user.getUserId(), gaeUser.getUserId());
        assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_ANONYMOUS));
        assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_USER));
        assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_ADMIN));
        assertFalse(gaeUser.isAnonymous());
        assertTrue(gaeUser.isAdmin());
View Full Code Here


        filter.setUserService(userService);
        filter.setAuthenticationManager(authenticationManager);
        filter.afterPropertiesSet();

        User user = new User("email", "authDomain", "userId", "federatedIdentity");
        when(authenticationManager.authenticate(isA(GaeUserAuthenticationToken.class))).thenAnswer(new AuthenticationAnswer());
        when(userService.isUserLoggedIn()).thenReturn(true);      // user is logged in
        when(userService.isUserAdmin()).thenReturn(true);         // user is an admin
        when(userService.getCurrentUser()).thenReturn(user);      // this is the logged in user

        GaeUser gaeUser = callDoFilter(filter, "ONE");
        assertEquals(user.getAuthDomain(), gaeUser.getAuthDomain());
        assertEquals(user.getFederatedIdentity(), gaeUser.getFederatedIdentity());
        assertEquals(user.getEmail(), gaeUser.getEmail());
        assertEquals(user.getUserId(), gaeUser.getUserId());
        assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_ANONYMOUS));
        assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_USER));
        assertTrue(gaeUser.getRoles().contains(GaeRole.ROLE_ADMIN));
        assertTrue(gaeUser.getRoles().contains(new GaeRole("ONE")));
        assertFalse(gaeUser.isAnonymous());
View Full Code Here

    @Override
    public Navigation run() throws Exception {
        // check login
        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        if (!userService.isUserLoggedIn()) { // not login
            return redirect(userService.createLoginURL(request.getRequestURI()));
        } else {
            List<Tweet> tweetList = service.getTweetList();
            requestScope("tweetList", tweetList);
            requestScope("myEmail", user.getEmail());
            requestScope("myNickname", user.getNickname());
            requestScope("myIsAdmin", userService.isUserAdmin());
            return forward("index.jsp");
        }
    }
View Full Code Here

    @Override
    public FederatedUser getCurrentUser() throws ServiceException {
        if (!this.isUserLoggedIn()) {
            return null;
        } else {
            User user = this.userService.getCurrentUser();
            boolean admin = this.isUserAdmin();
            OpenIdProvider openIdProvider = deriveOpenIdProvider(user.getAuthDomain());

            // Normally, I'd put a User constructor onto CurrentUser.  That won't
            // work, because then CurrentUser has a dependency on code which isn't
            // translated and isn't available to GWT clients.

            FederatedUser currentUser = new FederatedUser();
            currentUser.setAuthenticationDomain(user.getAuthDomain());
            currentUser.setOpenIdProvider(openIdProvider);
            currentUser.setEmailAddress(user.getEmail());
            currentUser.setFederatedIdentity(user.getFederatedIdentity());
            currentUser.setUserId(user.getUserId());
            currentUser.setAdmin(admin);

            // We can't generate a user name until everything else is filled in

            String userName = deriveUserName(currentUser);
View Full Code Here

        assertFalse(service.isUserAdmin());
    }

    /** Test getCurrentUser(). */
    @Test public void testGetCurrentUser() {
        User user = new User("email", "google.com", "userId", "federatedIdentity");
        UserService userService = mock(UserService.class);
        SpringContextService springContextService = mock(SpringContextService.class);
        GaeUserService service = new GaeUserService();
        service.setUserService(userService);
        service.setSpringContextService(springContextService);
        service.afterPropertiesSet();

        when(userService.isUserLoggedIn()).thenReturn(false);
        FederatedUser currentUser = service.getCurrentUser();
        assertNull(currentUser);

        when(userService.isUserLoggedIn()).thenReturn(true);
        when(userService.getCurrentUser()).thenReturn(user);
        when(userService.isUserAdmin()).thenReturn(true);

        currentUser = service.getCurrentUser();
        assertEquals(user.getEmail(), currentUser.getEmailAddress());
        assertEquals(user.getAuthDomain(), currentUser.getAuthenticationDomain());
        assertEquals(OpenIdProvider.GOOGLE, currentUser.getOpenIdProvider())// because auth domain is "google.com"
        assertEquals(user.getUserId(), currentUser.getUserId());
        assertEquals(user.getFederatedIdentity(), currentUser.getFederatedIdentity());
        assertTrue(currentUser.isAdmin());

        when(userService.isUserLoggedIn()).thenReturn(true);
        when(userService.getCurrentUser()).thenReturn(user);
        when(userService.isUserAdmin()).thenReturn(false);

        currentUser = service.getCurrentUser();
        assertEquals(user.getEmail(), currentUser.getEmailAddress());
        assertEquals(user.getAuthDomain(), currentUser.getAuthenticationDomain());
        assertEquals(OpenIdProvider.GOOGLE, currentUser.getOpenIdProvider())// because auth domain is "google.com"
        assertEquals(user.getUserId(), currentUser.getUserId());
        assertEquals(user.getFederatedIdentity(), currentUser.getFederatedIdentity());
        assertFalse(currentUser.isAdmin());
    }
View Full Code Here

    }

    @Override
    public FeatureUser getCurrentUser() {
        SimpleFeatureUser featureUser = null;
        User user = userService.getCurrentUser();
        if (user != null) {
            featureUser = new SimpleFeatureUser(user.getUserId(), userService.isUserAdmin());
            featureUser.setAttribute("email", user.getEmail());
            featureUser.setAttribute("nickname", user.getNickname());
        }
        return featureUser;
    }
View Full Code Here

   * @see com.google.gwt.maeglin89273.game.ashinyballonthecross.shared.PlayerService#getLoginInfo(java.lang.String)
   */
  @Override
  public CheckLoginResponse checkLogin(CheckLoginRequest request) {
    UserService svc=getUserService();
    User user=svc.getCurrentUser();
    LoginInfo loginInfo;
    CheckLoginResponse response;
   
    if(user!=null){
      loginInfo=new LoginInfo(LoginInfo.Status.LOGGED_IN,svc.createLogoutURL(request.getRquestUrl()),new GoogleAccount(user.getEmail(),user.getNickname()));
      DatastoreService datastore=getDatastoreService();
      TransportablePlayer localPlayer=request.getLocalPlayer();
      Key key=KeyFactory.createKey(Player.class.getSimpleName(), user.getEmail());
      String keyString=KeyFactory.keyToString(key);
     
      try{
        Entity player=datastore.get(key);
       
View Full Code Here

    return new CheckLoginResponse(Status.NEW_PLAYER,loginInfo,localPlayer);
  }
 
  @Override
  public PlayerCreatedResponse createNewPlayer(Player player) {
    User user=getUser();
    PlayerCreatedResponse response;
    try{
      checkLoggedIn(user);
    }catch(IllegalStateException e){
      response=new PlayerCreatedResponse(CreateStatus.NOT_LOGGED_IN);
View Full Code Here

  private List<VerifiedAccount> verifiedAccounts = null;

  @Override
  public int doStartTag() throws JspException {
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (user == null) {
      return SKIP_BODY;
    }

    DataManager dataManager = DataManager.getInstance();
View Full Code Here

  private String defaultValue;

  @Override
  public void doTag() throws JspException, IOException {
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();

    if (user == null) {
      getJspContext().getOut().print(getDefaultValue());
    } else {
      getJspContext().getOut().print(user.getNickname());
    }
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.users.User

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.