当前位置: 首页>>代码示例>>Java>>正文


Java OAuth.Parameter方法代码示例

本文整理汇总了Java中net.oauth.OAuth.Parameter方法的典型用法代码示例。如果您正苦于以下问题:Java OAuth.Parameter方法的具体用法?Java OAuth.Parameter怎么用?Java OAuth.Parameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.oauth.OAuth的用法示例。


在下文中一共展示了OAuth.Parameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getParameters

import net.oauth.OAuth; //导入方法依赖的package包/类
public static List<OAuth.Parameter> getParameters(HttpServletRequest request) {
    List<OAuth.Parameter> list = new ArrayList<OAuth.Parameter>();
    for (Enumeration<String> headers = request.getHeaders("Authorization"); headers != null
            && headers.hasMoreElements();) {
        String header = headers.nextElement();
        for (OAuth.Parameter parameter : OAuthMessage
                .decodeAuthorization(header)) {
            if (!"realm".equalsIgnoreCase(parameter.getKey())) {
                list.add(parameter);
            }
        }
    }
    for (Object e : request.getParameterMap().entrySet()) {
        Map.Entry<String, String[]> entry = (Map.Entry<String, String[]>) e;
        String name = entry.getKey();
        for (String value : entry.getValue()) {
            list.add(new OAuth.Parameter(name, value));
        }
    }
    return list;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:HttpRequestMessage.java

示例2: getParameters

import net.oauth.OAuth; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static List<OAuth.Parameter> getParameters(HttpServletRequest request) {
       List<OAuth.Parameter> list = new ArrayList<OAuth.Parameter>();
       for (Enumeration<String> headers = request.getHeaders("Authorization"); headers != null
               && headers.hasMoreElements();) {
           String header = headers.nextElement();
           for (OAuth.Parameter parameter : OAuthMessage
                   .decodeAuthorization(header)) {
               if (!"realm".equalsIgnoreCase(parameter.getKey())) {
                   list.add(parameter);
               }
           }
       }
       for (Object e : request.getParameterMap().entrySet()) {
           Map.Entry<String, String[]> entry = (Map.Entry<String, String[]>) e;
           String name = entry.getKey();
           for (String value : entry.getValue()) {
               list.add(new OAuth.Parameter(name, value));
           }
       }
       return list;
   }
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:23,代码来源:HttpRequestMessage.java

示例3: doGet

import net.oauth.OAuth; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    OAuthConsumer consumer = null;
    try {
        consumer = CookieConsumer.getConsumer(NAME, getServletContext());
        OAuthAccessor accessor = CookieConsumer.getAccessor(request,
                response, consumer);
        List<OAuth.Parameter> parameters = HttpRequestMessage.getParameters(request);
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        out.println(NAME + " said:");
        // Try it twice:
        out.println(echo(accessor, parameters));
        out.println(echo(accessor, parameters));
    } catch (Exception e) {
        CookieConsumer.handleException(e, request, response, consumer);
    }
}
 
开发者ID:aoprisan,项目名称:net.oauth,代码行数:20,代码来源:TermieConsumer.java

示例4: doGet

import net.oauth.OAuth; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    OAuthConsumer consumer = null;
    try {
        consumer = CookieConsumer.getConsumer(NAME, getServletContext());
        OAuthAccessor accessor = CookieConsumer.getAccessor(request,
                response, consumer);
        Collection<OAuth.Parameter> parameters = HttpRequestMessage.getParameters(request);
        if (!OAuth.newMap(parameters).containsKey("echo")) {
            parameters.add(new OAuth.Parameter("echo", "Hello."));
        }
        response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        out.println("Sample Provider said:");
        // Try it twice:
        out.println(invoke(accessor, parameters));
        out.println(invoke(accessor, parameters));
    } catch (Exception e) {
        CookieConsumer.handleException(e, request, response, consumer);
    }
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:23,代码来源:SampleProviderConsumer.java

示例5: prepareRequestMessage

import net.oauth.OAuth; //导入方法依赖的package包/类
private static OAuthMessage prepareRequestMessage(OAuthConsumer consumer,
                                                 String httpMethod,
                                                 URL url,
                                                 String signatureMethod) {
    OAuthMessage message = new OAuthMessage(httpMethod,
                                          url.toString(),
                                          new ArrayList<OAuth.Parameter>());
    message.addParameter(OAuth.OAUTH_SIGNATURE_METHOD, signatureMethod);
    message.addParameter(OAuth.OAUTH_VERSION, OAuth.VERSION_1_0);
    message.addParameter(OAuth.OAUTH_CONSUMER_KEY, consumer.consumerKey );
    long currentTime = System.currentTimeMillis() / 1000l;
    message.addParameter(OAuth.OAUTH_TIMESTAMP,
                         Long.toString(currentTime, 10));
    byte[] nonce = new byte[8];
    random.nextBytes(nonce);
    BigInteger nonceInt = new BigInteger(1, nonce);
    message.addParameter(OAuth.OAUTH_NONCE,
                         nonceInt.toString(10));
    return message;
}
 
开发者ID:aoprisan,项目名称:net.oauth,代码行数:21,代码来源:RSA_SHA1SignatureTest.java

示例6: getAuthorizationURL

import net.oauth.OAuth; //导入方法依赖的package包/类
private String getAuthorizationURL(String consumerKey, Token requestToken) throws Exception {
    List<OAuth.Parameter> parameters = new ArrayList<OAuth.Parameter>();
    //parameters.add(new OAuth.Parameter(OAuth.OAUTH_CONSUMER_KEY, consumerKey));
    parameters.add(new OAuth.Parameter(OAuth.OAUTH_TOKEN, requestToken.getToken()));
    
    return OAuth.addParameters(TokenAuthorizationURL, parameters);
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:8,代码来源:ConsumerResource.java

示例7: OAuthResponseMessage

import net.oauth.OAuth; //导入方法依赖的package包/类
OAuthResponseMessage(HttpResponseMessage http) throws IOException
{
    super(http.method, http.url.toExternalForm(), null);
    this.http = http;
    getHeaders().addAll(http.headers);
    for (Map.Entry<String, String> header : http.headers) {
        if ("WWW-Authenticate".equalsIgnoreCase(header.getKey())) {
            for (OAuth.Parameter parameter : decodeAuthorization(header.getValue())) {
                if (!"realm".equalsIgnoreCase(parameter.getKey())) {
                    addParameter(parameter);
                }
            }
        }
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:16,代码来源:OAuthResponseMessage.java

示例8: OAuthResponseMessage

import net.oauth.OAuth; //导入方法依赖的package包/类
OAuthResponseMessage(HttpResponseMessage http) throws IOException {
	super(http.method, http.url.toExternalForm(), null);
	this.http = http;
	getHeaders().addAll(http.headers);
	for (Map.Entry<String, String> header : http.headers) {
		if ("WWW-Authenticate".equalsIgnoreCase(header.getKey())) {
			for (OAuth.Parameter parameter : decodeAuthorization(header
					.getValue())) {
				if (!"realm".equalsIgnoreCase(parameter.getKey())) {
					addParameter(parameter);
				}
			}
		}
	}
}
 
开发者ID:Simbacode,项目名称:mobipayments,代码行数:16,代码来源:OAuthResponseMessage.java

示例9: getAccessToken

import net.oauth.OAuth; //导入方法依赖的package包/类
/**
 * Get a fresh access token from the service provider.
 * @throws IOException 
 * @throws URISyntaxException 
 * 
 * @throws RedirectException
 *             to obtain authorization
 */
private static void getAccessToken(HttpServletRequest request,
        CookieMap cookies, OAuthAccessor accessor)
    throws OAuthException, IOException, URISyntaxException
{
    final String consumerName = (String) accessor.consumer.getProperty("name");
    final String callbackURL = getCallbackURL(request, consumerName);
    List<OAuth.Parameter> parameters = OAuth.newList(OAuth.OAUTH_CALLBACK, callbackURL);
    // Google needs to know what you intend to do with the access token:
    Object scope = accessor.consumer.getProperty("request.scope");
    if (scope != null) {
        parameters.add(new OAuth.Parameter("scope", scope.toString()));
    }
    OAuthMessage response = CLIENT.getRequestTokenResponse(accessor, null, parameters);
    cookies.put(consumerName + ".requestToken", accessor.requestToken);
    cookies.put(consumerName + ".tokenSecret", accessor.tokenSecret);
    String authorizationURL = accessor.consumer.serviceProvider.userAuthorizationURL;
    if (authorizationURL.startsWith("/")) {
        authorizationURL = (new URL(new URL(request.getRequestURL()
                .toString()), request.getContextPath() + authorizationURL))
                .toString();
    }
    authorizationURL = OAuth.addParameters(authorizationURL //
            , OAuth.OAUTH_TOKEN, accessor.requestToken);
    if (response.getParameter(OAuth.OAUTH_CALLBACK_CONFIRMED) == null) {
        authorizationURL = OAuth.addParameters(authorizationURL //
                , OAuth.OAUTH_CALLBACK, callbackURL);
    }
    throw new RedirectException(authorizationURL);
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:38,代码来源:CookieConsumer.java

示例10: doGet

import net.oauth.OAuth; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
{
    OAuthConsumer consumer = null;
    try {
        consumer = CookieConsumer.getConsumer(NAME, getServletContext());
        OAuthAccessor accessor = CookieConsumer.getAccessor(request, response, consumer);
        List<OAuth.Parameter> parameters = HttpRequestMessage.getParameters(request);
        response.setContentType("text/plain");
        final String serviceURL = "http://oauth-sandbox.mediamatic.nl/services/rest/";
        final String objectId = "117";
        // Store some data into the object:
        CookieConsumer.CLIENT.invoke(accessor //
                , OAuthMessage.POST, serviceURL //
                , OAuth.newList("method", "anymeta.predicates.set" //
                        , "id", objectId //
                        , "field", "text.body" //
                        , "value", OAuth.formEncode(parameters) //
                ));
        // Read the data out again:
        OAuthMessage result = CookieConsumer.CLIENT.invoke(accessor //
                , OAuthMessage.GET, serviceURL //
                , OAuth.newList("method", "anymeta.predicates.get" //
                        , "id", objectId //
                        , "field", "text.body" //
                ));
        response.getWriter().println(result.readBodyAsString());
    } catch (Exception e) {
        CookieConsumer.handleException(e, request, response, consumer);
    }
}
 
开发者ID:aoprisan,项目名称:net.oauth,代码行数:33,代码来源:MediamaticConsumer.java

示例11: getQueryParam

import net.oauth.OAuth; //导入方法依赖的package包/类
public String getQueryParam(String name) {
  for (OAuth.Parameter p : getParsedQuery()) {
    if (p.getKey().equals(name)) {
      return p.getValue();
    }
  }
  return null;
}
 
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:9,代码来源:FakeOAuthServiceProvider.java

示例12: echo

import net.oauth.OAuth; //导入方法依赖的package包/类
private static String echo(OAuthAccessor accessor, List<OAuth.Parameter> parameters)
        throws OAuthException, IOException, URISyntaxException {
    OAuthMessage result = CookieConsumer.CLIENT.invoke(accessor,
            "http://term.ie/oauth/example/echo_api.php", parameters);
    String responseBody = result.readBodyAsString();
    return responseBody;
}
 
开发者ID:aoprisan,项目名称:net.oauth,代码行数:8,代码来源:TermieConsumer.java

示例13: testNormalizeParameters

import net.oauth.OAuth; //导入方法依赖的package包/类
public void testNormalizeParameters() throws Exception {
    for (int c = 0; c < NORMALS.length;) {
        String[] normal = NORMALS[c++];
        int n = 0;
        String label = normal[n++];
        List<OAuth.Parameter> parameters = OAuth.decodeForm(normal[n++]);
        String expected = normal[n++];
        String actual = OAuthSignatureMethod
                .normalizeParameters(parameters);
        assertEquals(label, expected, actual);
    }
}
 
开发者ID:aoprisan,项目名称:net.oauth,代码行数:13,代码来源:OAuthSignatureMethodTest.java

示例14: MessageWithBody

import net.oauth.OAuth; //导入方法依赖的package包/类
public MessageWithBody(String method, String URL,
        Collection<OAuth.Parameter> parameters,
        String contentType, byte[] body) {
    super(method, URL, parameters);
    this.body = body;
    Collection<Map.Entry<String, String>> headers = getHeaders();
    headers.add(new OAuth.Parameter(HttpMessage.ACCEPT_ENCODING, HttpMessageDecoder.ACCEPTED));
    if (body != null) {
        headers.add(new OAuth.Parameter(HttpMessage.CONTENT_LENGTH, String.valueOf(body.length)));
    }
    if (contentType != null) {
        headers.add(new OAuth.Parameter(HttpMessage.CONTENT_TYPE, contentType));
    }
}
 
开发者ID:aoprisan,项目名称:net.oauth,代码行数:15,代码来源:OAuthClientTest.java

示例15: sendResponse

import net.oauth.OAuth; //导入方法依赖的package包/类
private void sendResponse(ContextResource contextResource, List<OAuth.Parameter> parameters) throws IOException {
    contextResource.setMediaType(MediaType.TEXT_PLAIN);
    contextResource.append(OAuth.formEncode(parameters));
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:5,代码来源:OAuthResource.java


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