• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Session类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.dropbox.client2.session.Session的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Session类属于com.dropbox.client2.session包,在下文中一共展示了Session类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doLink

import com.dropbox.client2.session.Session; //导入依赖的package包/类
private static void doLink(String[] args)
    throws DropboxException
{
    if (args.length != 1) {
        throw die("ERROR: \"link\" takes no arguments.");
    }

    // Load state.
    State state = State.load(STATE_FILE);

    WebAuthSession was = new WebAuthSession(state.appKey, Session.AccessType.APP_FOLDER);

    // Make the user log in and authorize us.
    WebAuthSession.WebAuthInfo info = was.getAuthInfo();
    System.out.println("1. Go to: " + info.url);
    System.out.println("2. Allow access to this app.");
    System.out.println("3. Press ENTER.");

    try {
        while (System.in.read() != '\n') {}
    }
    catch (IOException ex) {
        throw die("I/O error: " + ex.getMessage());
    }

    // This will fail if the user didn't visit the above URL and hit 'Allow'.
    String uid = was.retrieveWebAccessToken(info.requestTokenPair);
    AccessTokenPair accessToken = was.getAccessTokenPair();
    System.out.println("Link successful.");

    state.links.put(uid, accessToken);
    state.save(STATE_FILE);
}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:34,代码来源:CopyBetweenAccounts.java


示例2: doLink

import com.dropbox.client2.session.Session; //导入依赖的package包/类
private static void doLink(String[] args)
    throws DropboxException
{
    if (args.length != 3) {
        throw die("ERROR: \"link\" takes exactly two arguments.");
    }

    AppKeyPair appKeyPair = new AppKeyPair(args[1], args[2]);
    WebAuthSession was = new WebAuthSession(appKeyPair, Session.AccessType.APP_FOLDER);

    // Make the user log in and authorize us.
    WebAuthSession.WebAuthInfo info = was.getAuthInfo();
    System.out.println("1. Go to: " + info.url);
    System.out.println("2. Allow access to this app.");
    System.out.println("3. Press ENTER.");

    try {
        while (System.in.read() != '\n') {}
    }
    catch (IOException ex) {
        throw die("I/O error: " + ex.getMessage());
    }

    // This will fail if the user didn't visit the above URL and hit 'Allow'.
    was.retrieveWebAccessToken(info.requestTokenPair);
    AccessTokenPair accessToken = was.getAccessTokenPair();
    System.out.println("Link successful.");

    // Save state
    State state = new State(appKeyPair, accessToken, new Content.Folder());
    state.save(STATE_FILE);
}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:33,代码来源:SearchCache.java


示例3: updateClientProxy

import com.dropbox.client2.session.Session; //导入依赖的package包/类
/**
 * 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 {
            proxy = new HttpHost(proxyInfo.host, proxyInfo.port);
        }
        client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
    } else {
        client.getParams().removeParameter(ConnRoutePNames.DEFAULT_PROXY);
    }
}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:18,代码来源:RESTUtility.java


示例4: getSession

import com.dropbox.client2.session.Session; //导入依赖的package包/类
@Override
public Session getSession() {
    return null;
}
 
开发者ID:GoogleCloudPlatform,项目名称:endpoints-codelab-android,代码行数:5,代码来源:DropboxAPIStub.java


示例5: streamRequest

import com.dropbox.client2.session.Session; //导入依赖的package包/类
/**
* Creates and sends a request to the Dropbox API, and returns a
* {@link RequestAndResponse} containing the {@link HttpUriRequest} and
* {@link HttpResponse}.
*
* @param method GET or POST.
* @param host the hostname to use. Should be either api server,
*         content server, or web server.
* @param path the URL path, starting with a '/'.
* @param apiVersion the API version to use. This should almost always be
*         set to {@code DropboxAPI.VERSION}.
* @param params the URL params in an array, with the even numbered
*         elements the parameter names and odd numbered elements the
*         values, e.g. <code>new String[] {"path", "/Public", "locale",
*         "en"}</code>.
* @param session the {@link Session} to use for this request.
*
* @return a parsed JSON object, typically a Map or a JSONArray.
*
* @throws DropboxServerException if the server responds with an error
*         code. See the constants in {@link DropboxServerException} for
*         the meaning of each error code.
* @throws DropboxIOException if any network-related error occurs.
* @throws DropboxUnlinkedException if the user has revoked access.
* @throws DropboxException for any other unknown errors. This is also a
*         superclass of all other Dropbox exceptions, so you may want to
*         only catch this exception which signals that some kind of error
*         occurred.
*/
static public RequestAndResponse streamRequest(RequestMethod method,
        String host, String path, int apiVersion, String params[],
        Session session) throws DropboxException {
    HttpUriRequest req = null;
    String target = null;

    if (method == RequestMethod.GET) {
        target = buildURL(host, apiVersion, path, params);
        req = new HttpGet(target);
    } else {
        target = buildURL(host, apiVersion, path, null);
        HttpPost post = new HttpPost(target);

        if (params != null && params.length >= 2) {
            if (params.length % 2 != 0) {
                throw new IllegalArgumentException("Params must have an even number of elements.");
            }
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();

            for (int i = 0; i < params.length; i += 2) {
                if (params[i + 1] != null) {
                    nvps.add(new BasicNameValuePair(params[i], params[i + 1]));
                }
            }

            try {
                post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
            } catch (UnsupportedEncodingException e) {
                throw new DropboxException(e);
            }
        }

        req = post;
    }

    session.sign(req);
    HttpResponse resp = execute(session, req);

    return new RequestAndResponse(req, resp);
}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:70,代码来源:RESTUtility.java


示例6: updatedHttpClient

import com.dropbox.client2.session.Session; //导入依赖的package包/类
/**
 * Gets the session's client and updates its proxy.
 */
private static synchronized HttpClient updatedHttpClient(Session session) {
    HttpClient client = session.getHttpClient();
    updateClientProxy(client, session);
    return client;
}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:9,代码来源:RESTUtility.java


示例7: ChunkedUploadRequest

import com.dropbox.client2.session.Session; //导入依赖的package包/类
protected ChunkedUploadRequest(HttpUriRequest request, Session session) {
    this.request = request;
    this.session = session;
}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:5,代码来源:DropboxAPI.java


示例8: BasicUploadRequest

import com.dropbox.client2.session.Session; //导入依赖的package包/类
public BasicUploadRequest(HttpUriRequest request, Session session) {
    this.request = request;
    this.session = session;
}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:5,代码来源:DropboxAPI.java


示例9: connect

import com.dropbox.client2.session.Session; //导入依赖的package包/类
private DropboxAPI<?> connect() {
    WebAuthSession session = new WebAuthSession(appKeyPair, Session.AccessType.DROPBOX, accessTokenPair);

    return new DropboxAPI<WebAuthSession>(session);
}
 
开发者ID:avasquez614,项目名称:cloud-raid,代码行数:6,代码来源:DropboxClient.java


示例10: request

import com.dropbox.client2.session.Session; //导入依赖的package包/类
/**
 * Creates and sends a request to the Dropbox API, parses the response as
 * JSON, and returns the result.
 *
 * @param method GET or POST.
 * @param host the hostname to use. Should be either api server,
 *         content server, or web server.
 * @param path the URL path, starting with a '/'.
 * @param apiVersion the API version to use. This should almost always be
 *         set to {@code DropboxAPI.VERSION}.
 * @param params the URL params in an array, with the even numbered
 *         elements the parameter names and odd numbered elements the
 *         values, e.g. <code>new String[] {"path", "/Public", "locale",
 *         "en"}</code>.
 * @param session the {@link Session} to use for this request.
 *
 * @return a parsed JSON object, typically a Map or a JSONArray.
 *
 * @throws DropboxServerException if the server responds with an error
 *         code. See the constants in {@link DropboxServerException} for
 *         the meaning of each error code.
 * @throws DropboxIOException if any network-related error occurs.
 * @throws DropboxUnlinkedException if the user has revoked access.
 * @throws DropboxParseException if a malformed or unknown response was
 *         received from the server.
 * @throws DropboxException for any other unknown errors. This is also a
 *         superclass of all other Dropbox exceptions, so you may want to
 *         only catch this exception which signals that some kind of error
 *         occurred.
 */
static public Object request(RequestMethod method, String host,
        String path, int apiVersion, String[] params, Session session)
        throws DropboxException {
    HttpResponse resp = streamRequest(method, host, path, apiVersion,
            params, session).response;
    return parseAsJSON(resp);
}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:38,代码来源:RESTUtility.java


示例11: execute

import com.dropbox.client2.session.Session; //导入依赖的package包/类
/**
 * Executes an {@link HttpUriRequest} with the given {@link Session} and
 * returns an {@link HttpResponse}.
 *
 * @param session the session to use.
 * @param req the request to execute.
 *
 * @return an {@link HttpResponse}.
 *
 * @throws DropboxServerException if the server responds with an error
 *         code. See the constants in {@link DropboxServerException} for
 *         the meaning of each error code.
 * @throws DropboxIOException if any network-related error occurs.
 * @throws DropboxUnlinkedException if the user has revoked access.
 * @throws DropboxException for any other unknown errors. This is also a
 *         superclass of all other Dropbox exceptions, so you may want to
 *         only catch this exception which signals that some kind of error
 *         occurred.
 */
public static HttpResponse execute(Session session, HttpUriRequest req)
        throws DropboxException {
    return execute(session, req, -1);
}
 
开发者ID:timezra,项目名称:dropbox-java-sdk,代码行数:24,代码来源:RESTUtility.java



注:本文中的com.dropbox.client2.session.Session类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JobHandler类代码示例发布时间:2022-05-23
下一篇:
Java ISaslAwareAuthenticator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap