Package org.fluxtream.core.domain

Examples of org.fluxtream.core.domain.Guest


    }

    @RequestMapping(value = "/mobile/checkIn")
    public ModelAndView mobileCheckIn(HttpServletRequest request,
                                      HttpServletResponse response) throws IOException, NoSuchAlgorithmException, URISyntaxException {
        final Guest guest = AuthHelper.getGuest();
        long guestId = guest.getId();
        checkIn(request, guestId);
        final HttpSessionRequestCache requestCache = new HttpSessionRequestCache();
        SavedRequest savedRequest =
                requestCache.getRequest(request, response);
        if (savedRequest!=null) {
View Full Code Here


  @RequestMapping(value = "/sendResetRequest")
  public ModelAndView sendResetRequest(HttpServletRequest request) throws HttpException,IOException {
    // create a hash for this request
        String email = request.getParameter("recover[email]");
    Guest guest = guestService.getGuestByEmail(email);
    if (guest == null) {
      ModelAndView mav = new ModelAndView("support/lostPassword");
      mav.addObject("error",
          "Sorry, we could not find a user with your email address. Please try again.");
      mav.addObject("release", env.get("release"));
      return mav;
    }
    SimpleMailMessage message = new SimpleMailMessage();
    message.setTo(email);

        // Retrieve postmark properties.  Keys postmarkApiKey and postmarkSendAddress should be set
        // in common.properties
        String postmarkSendAddress = env.get("postmarkSendAddress");
        String postmarkApiKey = env.get("postmarkApiKey");

        // Process postmarkSendAddress
        if(postmarkSendAddress==null) {
            postmarkSendAddress = "support@fluxtream.com";
            logger.warn("component=support_controller action=sendResetRequest" +
                                    " guestId=" + guest.getId() +
                                    " message=\"**** PLEASE SET postmarkSendAddress IN common.properties; defaulting to support@fluxtream.com\"");
        }
    message.setFrom(postmarkSendAddress);

        // Process postmarkApiKey
        if(postmarkApiKey==null) {
            logger.error("component=support_controller action=sendResetRequest" +
                                    " guestId=" + guest.getId() +
                                    " message=\"**** PLEASE SET postmarkApiKey IN common.properties.  Cannot send reset email without it.\"");
            ModelAndView mav = new ModelAndView("support/serverConfigError");
            mav.addObject("release", env.get("release"));
            mav.addObject("userMessage", "We are not able to send email for resetting your password");
            mav.addObject("adminMessage", "Please set up the following keys in common.properties to enable email sending: postmarkApiKey and postmarkSendAddress");
            return mav;
        }
        PostmarkMailSender sender = new PostmarkMailSender(
              env.get("postmarkApiKey"));



    message.setSubject("Fluxtream Reset password request");
    Map<String, String> vars = new HashMap<String, String>();
    ResetPasswordToken pToken = guestService.createToken(guest.getId());
    vars.put("token", pToken.token);
    vars.put("homeBaseUrl", env.get("homeBaseUrl"));
    if (guest.firstname != null && !guest.firstname.equals(""))
      vars.put("username", guest.firstname);
    else
View Full Code Here

  public ModelAndView resetPassword(HttpServletRequest request,
      @RequestParam("token") String token) throws Exception {
    List<String> errors = new ArrayList<String>();

    ResetPasswordToken pToken = guestService.getToken(token);
    Guest guest = null;
    if (pToken == null)
      errors.add("invalidToken");
    else {
      guest = guestService.getGuestById(pToken.guestId);
    }
View Full Code Here

    ResetPasswordToken pToken = guestService.getToken(token);
    long now = System.currentTimeMillis();
    int resetPasswordTokensExpireDelay = Integer.valueOf(env
        .get("resetPasswordTokensExpireDelay"));

    Guest guest = null;
    if (pToken == null)
      errors.add("invalidToken");
    else if ((now - pToken.ts) > resetPasswordTokensExpireDelay) {
      errors.add("tokenExpired");
      guestService.deleteToken(token);
    } else {
      guest = guestService.getGuestById(pToken.guestId);
    }

    if (errors.size() > 0 || required.size() > 0) {
      ModelAndView mav = new ModelAndView("support/resetPassword");

      if (guest != null) {
        if (guest.firstname != null
            && !guest.firstname.equals(""))
          request.setAttribute("username", guest.firstname);
        else
          request.setAttribute("username", guest.username);
      } else
        request.setAttribute("username", "Stranger");

      mav.addObject("errors", errors);
      mav.addObject("required", required);
      mav.addObject("token", pToken == null ? "null" : pToken.token);
      mav.addObject("release", env.get("release"));
      return mav;
    } else {
      guestService.setPassword(guest.getId(), password);
      guestService.deleteToken(pToken.token);
      UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(
          guest.username, password);
      Authentication authentication = authenticationManager
          .authenticate(authToken);
View Full Code Here

        .getAttribute(BODYMEDIA_OAUTH_CONSUMER);
    OAuthProvider provider = (OAuthProvider) request.getSession()
        .getAttribute(BODYMEDIA_OAUTH_PROVIDER);
    String verifier = request.getParameter("oauth_verifier");
    provider.retrieveAccessToken(consumer, verifier);
    Guest guest = AuthHelper.getGuest();

        ApiKey apiKey;
        if (request.getParameter("apiKeyId")!=null) {
            long apiKeyId = Long.valueOf(request.getParameter("apiKeyId"));
            apiKey = guestService.getApiKey(apiKeyId);
        } else
            apiKey = guestService.createApiKey(guest.getId(), connector());

        guestService.setApiKeyAttribute(apiKey, "api_key", env.get("bodymediaConsumerKey"));
    guestService.setApiKeyAttribute(apiKey,
        "accessToken", consumer.getToken());
    guestService.setApiKeyAttribute(apiKey,
View Full Code Here

            return "redirect:/app";
        }

        String sessionKey = LastfmHelper.getSessionKey(jsonResponse);
    String username = LastfmHelper.getUsername(jsonResponse);
    Guest guest = AuthHelper.getGuest();

        final Connector connector = Connector.getConnector("lastfm");
        ApiKey apiKey;
        if (request.getSession().getAttribute(LASTFM_RENEWTOKEN_APIKEYID)!=null) {
            final String apiKeyIdString = (String) request.getSession().getAttribute(LASTFM_RENEWTOKEN_APIKEYID);
            long apiKeyId = Long.valueOf(apiKeyIdString);
            apiKey = guestService.getApiKey(apiKeyId);
        } else
            apiKey = guestService.createApiKey(guest.getId(), connector);

        guestService.populateApiKey(apiKey.getId());
    guestService.setApiKeyAttribute(apiKey, "sessionKey", sessionKey);
    guestService.setApiKeyAttribute(apiKey,  "username", username);
View Full Code Here

        String api_sig = sign(params);
   
    String getTokenUrl = "http://api.flickr.com/services/rest/" +
      "?method=flickr.auth.getToken&api_key=" + api_key + "&frob=" + frob + "&api_sig=" + api_sig;

    Guest guest = AuthHelper.getGuest();

        String authToken = null;
        try {
            authToken = fetch(getTokenUrl);
        }
        catch (Exception e) {
            e.printStackTrace();
            notificationsService.addNamedNotification(AuthHelper.getGuestId(),
                                                      Notification.Type.ERROR, Connector.getConnector("flickr").statusNotificationName(),
                                                      "Oops, we could not link your Flickr account<br>" +
                                                      "Please contact your administrator.");
            return "redirect:/app";
        }

        StringReader stringReader = new StringReader(authToken);
        StringBuilder sb = new StringBuilder();
        final List<String> responseLines = IOUtils.readLines(stringReader);
        sb.append("<root>");
        for (int i=1; i<responseLines.size(); i++)
            sb.append(responseLines.get(i));
        sb.append("</root>");

        SAXReader reader = new SAXReader();
        Document document = reader.read(new StringReader(authToken));

    Element user = (Element) document.selectSingleNode("rsp/auth/user");
   
    String username = user.attributeValue("username");

    String nsid = user.attributeValue("nsid");
    String fullname = user.attributeValue("fullname");
    String token = document.selectSingleNode("rsp/auth/token/text()").getStringValue();
   
    Connector flickrConnector = Connector.getConnector("flickr");

        ApiKey apiKey;
        if (request.getSession().getAttribute(FLICKR_RENEWTOKEN_APIKEYID)!=null) {
            final String apiKeyIdString = (String)request.getSession().getAttribute(FLICKR_RENEWTOKEN_APIKEYID);
            long apiKeyId = Long.valueOf(apiKeyIdString);
            apiKey = guestService.getApiKey(apiKeyId);
        } else
            apiKey = guestService.createApiKey(guest.getId(), flickrConnector);

        guestService.populateApiKey(apiKey.getId());
    guestService.setApiKeyAttribute(apiKey,  "username", username);
    guestService.setApiKeyAttribute(apiKey,  "token", token);
    guestService.setApiKeyAttribute(apiKey,  "nsid", nsid);
View Full Code Here

            final HttpServletResponse response) throws IOException, OAuthSystemException
    {
        // Get the user. If the user's credentials are invalid for whatever
        // reason, an exception will be thrown and the page will echo back the
        // reason.
        Guest guest = AuthHelper.getGuest();

        // Get the authorization code.
        AuthorizationCode authCode = oAuth2MgmtService.getCode(code);

        // If the code is unknown, we cannot redirect back to the third-party
        // because we don't know who they are.
        if (authCode == null) {
            throw new RuntimeException("The authorization code is unknown.");
        }

        // Verify that the code has not yet expired.
        if (System.currentTimeMillis() > authCode.expirationTime) {
            response.sendRedirect(OAuthASResponse.errorResponse(HttpServletResponse.SC_BAD_REQUEST)
                                          .setError(OAuthError.CodeResponse.ACCESS_DENIED)
                                          .setErrorDescription("The code has expired.")
                                          .location(redirectUri).setState(authCode.state).buildQueryMessage()
                                          .getLocationUri()
            );
            return;
        }

        // Get the response if it already exists.
        AuthorizationCodeResponse codeResponse = oAuth2MgmtService.getResponse(code);

        // If the response does not exist, attempt to create a new one and
        // save it.
        if (codeResponse == null) {
            // Create the new code.
            codeResponse = new AuthorizationCodeResponse(authCode, guest.getId(), granted);

            // Store it.
            oAuth2MgmtService.storeVerification(codeResponse);
        }

        // Make sure it is being verified by the same user.
        else if (!guest.getId().equals(codeResponse.guestId)) {

            response.sendRedirect(OAuthASResponse.errorResponse(HttpServletResponse.SC_UNAUTHORIZED)
                                          .setError(OAuthError.CodeResponse.ACCESS_DENIED)
                                          .setErrorDescription("The code has already been verified by another user.")
                                          .location(redirectUri).setState(authCode.state)
View Full Code Here

    @RequestMapping(value = "/addConnector", method = RequestMethod.POST)
    public void addUploadConnector(@RequestParam("connectorName") String connectorName,
                                   HttpServletResponse response) throws IOException {
        final Connector connector = Connector.getConnector(connectorName);
        final Guest guest = AuthHelper.getGuest();

        guestService.createApiKey(guest.getId(), connector);

        notificationsService.addNotification(guest.getId(), Notification.Type.INFO, "You just added an upload-only connector for " + connector.prettyName() + "<br>" +
                                                                              "Please head to <a href=\"javascript:App.manageConnectors()\">Manage Connectors</a>, " +
                                                                              "identify your new connector, and upload your data from there.");

        response.getWriter().write("Successfully added upload-only connector \"" + connectorName + "\"");
    }
View Full Code Here

    @RequestMapping(value = "/callback")
    public String getToken(HttpServletRequest request) throws IOException, UnexpectedHttpResponseCodeException {
        String code = request.getParameter("code");
        String error = request.getParameter("error");

        Guest guest = AuthHelper.getGuest();

        if (StringUtils.isEmpty(error)) {
            String clientId = env.get("singly.client.id");
            String clientSecret = env.get("singly.client.secret");
            Map<String, String> params = new HashMap<String, String>();
            params.put("client_id", clientId);
            params.put("client_secret", clientSecret);
            params.put("code", code);

            final String tokenJSON = HttpUtils.fetch("https://api.singly.com/oauth/access_token", params);
            JSONObject jsonToken = JSONObject.fromObject(tokenJSON);

            String accessToken = jsonToken.getString("access_token");
            String account = jsonToken.getString("account");

            final Connector connector = Connector.getConnector("github");
            final ApiKey apiKey = guestService.createApiKey(guest.getId(), connector);

            guestService.setApiKeyAttribute(apiKey, "accessToken", accessToken);
            guestService.setApiKeyAttribute(apiKey, "account", account);

            getUserLogin(apiKey, accessToken);
View Full Code Here

TOP

Related Classes of org.fluxtream.core.domain.Guest

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.