Package com.dropbox.client2.session.Session

Examples of com.dropbox.client2.session.Session.ProxyInfo


    /**
     * Updates the given client's proxy from the session.
     */
    private static void updateClientProxy(HttpClient client, Session session) {
        ProxyInfo proxyInfo = session.getProxyInfo();
        if (proxyInfo != null && proxyInfo.host != null && !proxyInfo.host.equals("")) {
            HttpHost proxy;
            if (proxyInfo.port < 0) {
                proxy = new HttpHost(proxyInfo.host);
            } else {
View Full Code Here


  private DropboxAPI<?> client;
 
  public DropboxSession(Map<String, String> parameters) {
    AppKeyPair appKeyPair = new AppKeyPair(parameters.get(DropboxConfig.APP_KEY_PARAM), parameters.get(DropboxConfig.APP_SECRET_PARAM));
    WebAuthSession session = new WebAuthSession(appKeyPair, WebAuthSession.AccessType.DROPBOX);
    AccessTokenPair ac = new AccessTokenPair(parameters.get(DropboxConfig.KEY_PARAM), parameters.get(DropboxConfig.SECRET_PARAM));
    session.setAccessTokenPair(ac);
    client = new DropboxAPI<WebAuthSession>(session);
  }
View Full Code Here

  private DropboxAPI<?> client;
 
  public DropboxSession(Map<String, String> parameters) {
    AppKeyPair appKeyPair = new AppKeyPair(parameters.get(DropboxConfig.APP_KEY_PARAM), parameters.get(DropboxConfig.APP_SECRET_PARAM));
    WebAuthSession session = new WebAuthSession(appKeyPair, WebAuthSession.AccessType.DROPBOX);
    AccessTokenPair ac = new AccessTokenPair(parameters.get(DropboxConfig.KEY_PARAM), parameters.get(DropboxConfig.SECRET_PARAM));
    session.setAccessTokenPair(ac);
    client = new DropboxAPI<WebAuthSession>(session);
  }
View Full Code Here

  private DropboxAPI<?> client;
 
  public DropboxSession(String app_key, String app_secret, String key, String secret) {
    AppKeyPair appKeyPair = new AppKeyPair(app_key, app_secret);
    WebAuthSession session = new WebAuthSession(appKeyPair, WebAuthSession.AccessType.DROPBOX);
    AccessTokenPair ac = new AccessTokenPair(key, secret);
    session.setAccessTokenPair(ac);
    client = new DropboxAPI<WebAuthSession>(session);
  }
View Full Code Here

  private DropboxAPI<?> client;
 
  public DropboxSession(String app_key, String app_secret, String key, String secret) {
    AppKeyPair appKeyPair = new AppKeyPair(app_key, app_secret);
    WebAuthSession session = new WebAuthSession(appKeyPair, WebAuthSession.AccessType.DROPBOX);
    AccessTokenPair ac = new AccessTokenPair(key, secret);
    session.setAccessTokenPair(ac);
    client = new DropboxAPI<WebAuthSession>(session);
  }
View Full Code Here

            //      if ((tsNow-ts) > 15*60*1000) dropboxContextList.remove(key);
            //    }
           
            AppKeyPair appKeyPair;
            appKeyPair = new AppKeyPair(appKey, appSecret);
            WebAuthSession was = new WebAuthSession(appKeyPair, Session.AccessType.DROPBOX);
            try {
                WebAuthSession.WebAuthInfo info = was.getAuthInfo(callbackUrl);
               
                DropboxContext dropboxContext = new DropboxContext(appKey + "-" + String.valueOf(tsNow), was, info);
                //dropboxContextList.put(appKey + "-" + String.valueOf(tsNow), dropboxContext);
                dropboxContextList.add(dropboxContext);
               
View Full Code Here

        String timestamp = StringUtils.trimToEmpty(req.getParameter("timestamp")).trim();
       
        String appKey = ServletUtils.getSetting(this, xmlConfig, "dropbox_appkey", "");
        if ("".equals(appKey)) return XmlResponse.buildErrorXml(-1, "Missing parameters");
       
        WebAuthSession was = null;
        WebAuthSession.WebAuthInfo info = null;
       
        ServletContext context=getServletContext();
        DropboxContext dropboxContext = null;
        synchronized(this) {
            @SuppressWarnings("unchecked")
            //HashMap<String,DropboxContext> dropboxContextList = (HashMap<String, DropboxContext>) context.getAttribute("DropboxContext");
            ArrayList<DropboxContext> dropboxContextList = (ArrayList<DropboxContext>) context.getAttribute("DropboxContext");
            if (dropboxContextList == null) return XmlResponse.buildErrorXml(-1, "No Dropbox context");
            dropboxContext = dropboxContextGet(dropboxContextList, 0, appKey+"-"+timestamp);
            if (dropboxContext == null) return XmlResponse.buildErrorXml(-1, "No Dropbox context");
        }
       
       
        //    Iterator<String> iterator = dropboxContextList.keySet().iterator();
        //
        //    while(iterator.hasNext()){  
        //      String key = (String) iterator.next();
        //      if (key.equals(appKey+"-"+timestamp)) {
        //        was = dropboxContextList.get(key).was;
        //        info = dropboxContextList.get(key).info;
        //        break;
        //      }
        //    }
       
       
        was = dropboxContext.was;
        info = dropboxContext.info;
        if (was == null || info == null) return XmlResponse.buildErrorXml(-1, "No Dropbox context");
       
        try {
            String userId = was.retrieveWebAccessToken(info.requestTokenPair);
            System.out.println("User ID: " + userId);
            System.out.println("Access Key: " + was.getAccessTokenPair().key);
            System.out.println("Access Secret " + was.getAccessTokenPair().secret);
            //DropboxAPI<WebAuthSession> api = new DropboxAPI<WebAuthSession>(was);
            //DeltaPage<Entry> deltaPage = api.delta("");
        } catch (DropboxException e) {
            e.printStackTrace();
            return XmlResponse.buildErrorXml(-1, "Dropbox unlinked");
        }
       
        String ret = "<?xml version=\"1.0\" encoding=\"utf-8\"?><result>";
        ret += "<errno>0</errno>";
        ret += "<token_key>" + was.getAccessTokenPair().key + "</token_key>";
        ret += "<token_secret>" + was.getAccessTokenPair().secret + "</token_secret></result>";
        return ret;     
    }
View Full Code Here

        }
       
        String filePath = StringUtils.trimToEmpty(req.getParameter("filepath")).trim();
       
        AppKeyPair appKeyPair = new AppKeyPair(appKey, appSecret);
        WebAuthSession was = new WebAuthSession(appKeyPair, Session.AccessType.DROPBOX);
        AccessTokenPair accessToken = new AccessTokenPair(tokenKey, tokenSecret);
        was.setAccessTokenPair(accessToken);
        DropboxAPI<WebAuthSession> api = new DropboxAPI<WebAuthSession>(was);
       
        try {
            Entry meta = api.metadata(filePath, 1, null, false, null);
            DropboxInputStream streamData = api.getFileStream(filePath, null);
View Full Code Here

TOP

Related Classes of com.dropbox.client2.session.Session.ProxyInfo

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.