Package com.google.appengine.api.users

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


public class UserEmailTag extends SimpleTagSupport {

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

    if (user == null) {
      throw new JspException("User not logged in to a Google Account");
    }

    getJspContext().getOut().print(user.getNickname());
  }
View Full Code Here


    protected MessageSourceAccessor messages = SpringSecurityMessageSource.getAccessor();

    private UserRegistry userRegistry;

    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        User googleUser = (User) authentication.getPrincipal();

        GaeUser user = userRegistry.findUser(googleUser.getUserId());

        if (user == null) {
            // User not in registry. Needs to register
            user = new GaeUser(googleUser.getUserId(), googleUser.getNickname(), googleUser.getEmail());
        }

        if (!user.isEnabled()) {
            throw new DisabledException("Account is disabled");
        }
View Full Code Here

    private AuthenticationManager authenticationManager;
    private AuthenticationFailureHandler failureHandler = new SimpleUrlAuthenticationFailureHandler();

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        User googleUser = UserServiceFactory.getUserService().getCurrentUser();

        if (authentication != null && !loggedInUserMatchesGaeUser(authentication, googleUser)) {
            SecurityContextHolder.clearContext();
            authentication = null;
            ((HttpServletRequest)request).getSession().invalidate();
View Full Code Here

    // TODO #11: implement login helper methods in service implementation   

    @Override
    public LoginInfo login(final String requestUri) {
        final UserService userService = UserServiceFactory.getUserService();
        final User user = userService.getCurrentUser();
        final LoginInfo loginInfo = new LoginInfo();
        if (user != null) {
            loginInfo.setLoggedIn(true);
            loginInfo.setName(user.getEmail());
            loginInfo.setLogoutUrl(userService.createLogoutURL(requestUri));
        } else {
            loginInfo.setLoggedIn(false);
            loginInfo.setLoginUrl(userService.createLoginURL(requestUri));
        }
View Full Code Here

        SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSSSSS");
        fmt.setTimeZone(new SimpleTimeZone(0, ""));

        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();
        String loginUrl = userService.createLoginURL("/");
        String logoutUrl = userService.createLogoutURL("/");

        Entity userPrefs = null;
        if (user != null) {
            DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
            MemcacheService memcache = MemcacheServiceFactory.getMemcacheService();

            String cacheKey = "UserPrefs:" + user.getUserId();
            userPrefs = (Entity) memcache.get(cacheKey);
            if (userPrefs == null) {
                log.warning("CACHE MISS");

                Key userKey = KeyFactory.createKey("UserPrefs", user.getUserId());
                try {
                    userPrefs = ds.get(userKey);
                    memcache.put(cacheKey, userPrefs);
                } catch (EntityNotFoundException e) {
                    // No user preferences stored.
View Full Code Here

public class PrefsServlet extends HttpServlet {
    public void doPost(HttpServletRequest req,
            HttpServletResponse resp)
          throws IOException {
        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();

        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        Key userKey = KeyFactory.createKey("UserPrefs", user.getUserId());
        Entity userPrefs = new Entity(userKey);

        MemcacheService memcache = MemcacheServiceFactory.getMemcacheService();
        String cacheKey = "UserPrefs:" + user.getUserId();

        try {
            int tzOffset = new Integer(req.getParameter("tz_offset")).intValue();

            userPrefs.setProperty("tz_offset", tzOffset);
View Full Code Here

@SuppressWarnings("serial")
public class Authentification extends HttpServlet {
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
 
     UserService userService = UserServiceFactory.getUserService();
       User user = userService.getCurrentUser();
       OAuthService oauth = OAuthServiceFactory.getOAuthService();
       PersistenceManager pm = PMF.get().getPersistenceManager();
         
       
       if (user != null)
       {
         resp.setContentType("text/html");
            resp.getWriter().println("<body>");
              
            try{
              DAO dao = new DAO();
             UserData userData = dao.findUserByKey(user.getEmail(), pm);
             if(userData == null){
                 dao.createUserRecord(user.getEmail(), pm);
                 dao.incrementer(user.getEmail(), pm);
                 resp.sendRedirect("/mail?objet=Bienvenue&message=Bonjour, vous venez de vous connecter pour la premiere fois.&addrusr="+user.getEmail());
              }else{
                 if(userData.getNumberOfConnections()>=10){ 
                   dao.incrementer(user.getEmail(), pm);
                   resp.sendRedirect(userService.createLogoutURL("/mail?objet="+userData.getNumberOfConnections()+" connexions atteintes&message=Bonjour, vous avez atteint "+userData.getNumberOfConnections()+" connexions.&addrusr="+user.getEmail()));
                 }
                 else
                   dao.incrementer(user.getEmail(), pm);
                
                 }
            
             resp.getWriter().println("<p>Bonjour " + user.getNickname() + ", bienvenue sur ma premi�re application Google App Engine.</p>");
           resp.getWriter().println("<p>Cliquez <a href=\""+ userService.createLogoutURL("/sendchatmessage?message=L'utilisateur \""+ user.getNickname()+"\" s'est d�connect�.")+ "\">ici </a>pour vous d�connecter.</p>");
           
               
             catch(Exception e){
              
             }finally{
View Full Code Here

@SuppressWarnings("serial")
public class Authentification extends HttpServlet {
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
 
     UserService userService = UserServiceFactory.getUserService();
       User user = userService.getCurrentUser();
       OAuthService oauth = OAuthServiceFactory.getOAuthService();
       PersistenceManager pm = PMF.get().getPersistenceManager();
         
       
       if (user != null)
       {
         resp.setContentType("text/html");
            resp.getWriter().println("<body>");
              
            try{
              DAO dao = new DAO();
             UserData userData = dao.findUserByKey(user.getEmail(), pm);
             if(userData == null){
                 dao.createUserRecord(user.getEmail(), pm);
                 dao.incrementer(user.getEmail(), pm);
                 resp.sendRedirect("/mail?objet=Bienvenue&message=Bonjour, vous venez de vous connecter pour la premiere fois.&addrusr="+user.getEmail());
              }else{
                 if(userData.getNumberOfConnections()>=10){ 
                   dao.incrementer(user.getEmail(), pm);
                   resp.sendRedirect(userService.createLogoutURL("/mail?objet="+userData.getNumberOfConnections()+" connexions atteintes&message=Bonjour, vous avez atteint "+userData.getNumberOfConnections()+" connexions.&addrusr="+user.getEmail()));
                 }
                 else
                   dao.incrementer(user.getEmail(), pm);
                
                 }
            
             resp.getWriter().println("<p>Bonjour " + user.getNickname() + ", bienvenue sur ma premi�re application Google App Engine.</p>");
           resp.getWriter().println("<p>Cliquez <a href=\""+ userService.createLogoutURL("/sendchatmessage?message=L'utilisateur \""+ user.getNickname()+"\" s'est d�connect�.")+ "\">ici </a>pour vous d�connecter.</p>");
           
               
             catch(Exception e){
              
             }finally{
View Full Code Here

   
    if (!userService.isUserLoggedIn()) {
      return null;
    }
   
    User user = userService.getCurrentUser();
   
    return user.getUserId();
  }
View Full Code Here

    }
   
    String result = super.getServiceSpecificUserId(notUsed);
   
    if (result == null) {
      User user = userService.getCurrentUser();
   
      result = user.getEmail();
    }
   
    return result;
  }
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.