Package org.fluxtream.core.domain

Examples of org.fluxtream.core.domain.Guest


   
    String fetched = HttpUtils.fetch(swapTokenUrl, params);
   
    JSONObject token = JSONObject.fromObject(fetched);
    Connector scopedApi = Connector.getConnector("foursquare");
    Guest guest = AuthHelper.getGuest();

        final ApiKey apiKey = guestService.createApiKey(guest.getId(), scopedApi);

    guestService.setApiKeyAttribute(apiKey,
        "accessToken", token.getString("access_token"));
   
    return "redirect:/app/from/"+scopedApi.getName();
View Full Code Here


      HttpServletResponse response) throws OAuthException, OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException {
    OAuthConsumer consumer = (OAuthConsumer) request.getSession().getAttribute(FRESHBOOKS_OAUTH_CONSUMER);
    OAuthProvider provider = (OAuthProvider) request.getSession().getAttribute(FRESHBOOKS_OAUTH_PROVIDER);
    String verifier = request.getParameter("oauth_verifier");
    provider.retrieveAccessToken(consumer, verifier);
    Guest guest = AuthHelper.getGuest();

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

    guestService.setApiKeyAttribute(apiKey, "accessToken", consumer.getToken());
    guestService.setApiKeyAttribute(apiKey, "tokenSecret", consumer.getTokenSecret());

    return "redirect:/app/from/"+connector.getName();
View Full Code Here

    String fetched = HttpUtils.fetch(swapTokenUrl, params);

    JSONObject token = JSONObject.fromObject(fetched);
   
//    String scope = (String) request.getSession().getAttribute("oauth2Scope");
    Guest guest = AuthHelper.getGuest();

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

    guestService.setApiKeyAttribute(apiKey,
        "accessToken", token.getString("access_token"));
   
    JSONObject userObject = token.getJSONObject("user");
View Full Code Here

  }

    @RequestMapping(value = "/setToken")
    public String getToken(@RequestParam("token") String token,
                           @RequestParam("username") String username) throws IOException {
        Guest guest = AuthHelper.getGuest();
        final Connector connector = Connector.getConnector("quantifiedmind");
        final ApiKey apiKey = guestService.createApiKey(guest.getId(), connector);
        guestService.setApiKeyAttribute(apiKey,
                                        "token", token);
        guestService.setApiKeyAttribute(apiKey,
                                        "username", username);
View Full Code Here

        Token requestToken = (Token)request.getSession().getAttribute(EVERNOTE_REQUEST_TOKEN);
        Token accessToken = service.getAccessToken(requestToken, verifier);

        final String token = accessToken.getToken();

        Guest guest = AuthHelper.getGuest();

        final Connector connector = Connector.getConnector("evernote");

        ApiKey apiKey;
        if (request.getSession().getAttribute(EVERNOTE_RENEWTOKEN_APIKEYID)!=null) {
            final String apiKeyIdString = (String) request.getSession().getAttribute(EVERNOTE_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, "accessToken", token);

        request.getSession().removeAttribute(EVERNOTE_REQUEST_TOKEN);
View Full Code Here

  public String upgradeToken(HttpServletRequest request) throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException {
    OAuthConsumer consumer = (OAuthConsumer) request.getSession().getAttribute(LINKEDIN_OAUTH_CONSUMER);
    OAuthProvider provider = (OAuthProvider) request.getSession().getAttribute(LINKEDIN_OAUTH_PROVIDER);
    String verifier = request.getParameter("oauth_verifier");
    provider.retrieveAccessToken(consumer, verifier);
    Guest guest = AuthHelper.getGuest();

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

    guestService.setApiKeyAttribute(apiKey, "accessToken", consumer.getToken());
    guestService.setApiKeyAttribute(apiKey, "tokenSecret", consumer.getTokenSecret());

    return "redirect:/app/from/"+connector.getName();
View Full Code Here

      HttpServletResponse response) throws OAuthException, OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException {
    OAuthConsumer consumer = (OAuthConsumer) request.getSession().getAttribute(DROPBOX_OAUTH_CONSUMER);
    OAuthProvider provider = (OAuthProvider) request.getSession().getAttribute(DROPBOX_OAUTH_PROVIDER);
    String verifier = request.getParameter("oauth_verifier");
    provider.retrieveAccessToken(consumer, verifier);
    Guest guest = AuthHelper.getGuest();
        final Connector connector = Connector.getConnector("dropbox");
        final ApiKey apiKey = guestService.createApiKey(guest.getId(), connector);

    guestService.setApiKeyAttribute(apiKey, "accessToken", consumer.getToken());
    guestService.setApiKeyAttribute(apiKey, "tokenSecret", consumer.getTokenSecret());
   
    return "redirect:/app/from/"+connector.getName() ;
View Full Code Here


    @RequestMapping(value = "/swapToken")
    public String swapToken(HttpServletRequest request) throws Exception {
        final String errorMessage = request.getParameter("error");
        final Guest guest = AuthHelper.getGuest();
        Connector connector = Connector.getConnector("up");
        if (errorMessage!=null) {
            notificationsService.addNamedNotification(guest.getId(),
                                                      Notification.Type.ERROR, connector.statusNotificationName(),
                                                      "There was an error while setting you up with the Jawbone UP service: " + errorMessage);
            return "redirect:/app";
        }
        final String code = request.getParameter("code");

        Map<String,String> parameters = new HashMap<String,String>();
        parameters.put("grant_type", "authorization_code");
        parameters.put("code", code);
        parameters.put("client_id", env.get("jawboneUp.client.id"));
        parameters.put("client_secret", env.get("jawboneUp.client.secret"));
        final String json = HttpUtils.fetch("https://jawbone.com/auth/oauth2/token", parameters);

        JSONObject token = JSONObject.fromObject(json);

        if (token.has("error")) {
            String errorCode = token.getString("error");
            notificationsService.addNamedNotification(guest.getId(),
                                                      Notification.Type.ERROR,
                                                      connector.statusNotificationName(),
                                                      errorCode);
            // NOTE: In the future if we implement renew for the UP connector
            // we will potentially need to mark the connector as permanently failed.
            // The way to do this is to get hold of the existing apiKey and do:
            //  guestService.setApiKeyStatus(apiKey.getId(), ApiKey.Status.STATUS_PERMANENT_FAILURE, null);
            return "redirect:/app";
        }

        final String refresh_token = token.getString("refresh_token");

        // Create the entry for this new apiKey in the apiKey table and populate
        // ApiKeyAttributes with all of the keys fro oauth.properties needed for
        // subsequent update of this connector instance.
        ApiKey apiKey;
        final String stateParameter = request.getParameter("state");
        if (stateParameter !=null&&!StringUtils.isEmpty(stateParameter)) {
            long apiKeyId = Long.valueOf(stateParameter);
            apiKey = guestService.getApiKey(apiKeyId);
        } else {
            apiKey = guestService.createApiKey(guest.getId(), Connector.getConnector("up"));
        }

        guestService.populateApiKey(apiKey.getId());
        guestService.setApiKeyAttribute(apiKey,
                                        "accessToken", token.getString("access_token"));
View Full Code Here

                                   @ApiParam(value="Buddy to access username parameter (" + BuddiesService.BUDDY_TO_ACCESS_PARAM + ")", required=false) @QueryParam(BuddiesService.BUDDY_TO_ACCESS_PARAM) String buddyToAccessParameter){
        try{
            CoachingBuddy coachee;
            try { coachee = AuthHelper.getCoachee(buddyToAccessParameter, buddiesService);
            } catch (CoachRevokedException e) {return Response.status(403).entity("Sorry, permission to access this data has been revoked. Please reload your browser window").build();}
            Guest guest = ApiHelper.getBuddyToAccess(guestService, coachee);
            if (guest==null)
                return Response.status(401).entity("You are no longer logged in").build();
            long guestId = guest.getId();
            List<DataUpdate> updates = dataUpdateService.getAllUpdatesSince(guestId, ISODateTimeFormat.dateTime().parseMillis(since));
            return Response.ok(gson.toJson(new DataUpdateDigestModel(updates,guestService,settingsService,ISODateTimeFormat.dateTime().parseMillis(since)))).build();
        }
        catch (Exception e){
            e.printStackTrace();
View Full Code Here

    @GET
    @Produces({ MediaType.APPLICATION_JSON })
    @ApiOperation(value = "Get the user's settings", response = GuestSettingsModel.class)
    public GuestSettingsModel getSettings(){
        final long guestId = AuthHelper.getGuestId();
        final Guest guest = guestService.getGuestById(guestId);
        final GuestSettings settings = settingsService.getSettings(guestId);
        final List<AuthorizationTokenModel> accessTokens = oAuth2MgmtService.getTokens(guestId);
        GuestSettingsModel settingsModel = new GuestSettingsModel(settings, guest.username,
                guest.firstname, guest.lastname, guest.registrationMethod, accessTokens);
        return settingsModel;
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.