本文整理汇总了Java中net.oauth.OAuth.Parameter类的典型用法代码示例。如果您正苦于以下问题:Java Parameter类的具体用法?Java Parameter怎么用?Java Parameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Parameter类属于net.oauth.OAuth包,在下文中一共展示了Parameter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: toMap
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
/**
* Converts a list of parameters to a map.
*/
private static Map<String, String> toMap(List<Parameter> params) {
Map<String, String> map = Maps.newHashMap();
for (Parameter parameter : params) {
map.put(parameter.getKey(), parameter.getValue());
}
return map;
}
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:11,代码来源:DataApiOAuthServletTest.java
示例2: createRequestToken
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
private void createRequestToken(ContextResource contextResource) throws IOException, OAuthException, URISyntaxException {
OAuthMessage requestMessage = getOAuthMessage(contextResource.getRequest());
String consumerKey = requestMessage.getConsumerKey();
if (consumerKey == null) {
OAuthProblemException e = new OAuthProblemException(OAuth.Problems.PARAMETER_ABSENT);
e.setParameter(OAuth.Problems.OAUTH_PARAMETERS_ABSENT, OAuth.OAUTH_CONSUMER_KEY);
throw e;
}
OAuthConsumer consumer = dataStore.getConsumer(consumerKey);
if (consumer == null) {
throw new OAuthProblemException(OAuth.Problems.CONSUMER_KEY_UNKNOWN);
}
OAuthAccessor accessor = new OAuthAccessor(consumer);
VALIDATOR.validateMessage(requestMessage, accessor);
String callback = requestMessage.getParameter(OAuth.OAUTH_CALLBACK);
if (callback == null) {
// see if the consumer has a callback
callback = consumer.callbackURL;
}
if (callback == null) {
callback = "oob";
}
// generate request_token and secret
OAuthEntry entry = dataStore.generateRequestToken(consumerKey, requestMessage.getParameter(OAuth.OAUTH_VERSION), callback);
List<Parameter> responseParams = OAuth.newList(OAuth.OAUTH_TOKEN, entry.getToken(), OAuth.OAUTH_TOKEN_SECRET, entry.getTokenSecret());
if (callback != null) {
responseParams.add(new Parameter(OAuth.OAUTH_CALLBACK_CONFIRMED, "true"));
}
sendResponse(contextResource, responseParams);
}
开发者ID:devacfr,项目名称:spring-restlet,代码行数:38,代码来源:OAuthResource.java
示例3: checkBodyHash
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
public static boolean checkBodyHash(String header, String signaturemethod, String xml) {
boolean ok = false;
List<Parameter> authParams;
String value = null;
authParams = OAuthMessage.decodeAuthorization(header);
for (Iterator<Parameter> iter = authParams.iterator(); iter.hasNext();) {
Parameter param = iter.next();
if (param.getKey().equals("oauth_body_hash")) {
value = param.getValue();
break;
}
}
if (value != null) {
String algorithm;
if (signaturemethod.equals("HMAC-SHA256")) {
algorithm = "SHA-256";
} else {
algorithm = "SHA-1";
}
ok = value.equals(getHash("", xml, algorithm, false));
}
return ok;
}
开发者ID:ubc,项目名称:enhanced-basiclti-b2,代码行数:28,代码来源:Utils.java
示例4: sendResponse
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
private void sendResponse(HttpServletResponse servletResponse, List<OAuth.Parameter> parameters)
throws IOException {
servletResponse.setContentType("text/plain");
OutputStream out = servletResponse.getOutputStream();
OAuth.formEncode(parameters, out);
out.close();
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:8,代码来源:SampleOAuthServlet.java
示例5: OAuthRequest
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
/**
* @param fetcherConfig configuration options for the fetcher
* @param fetcher fetcher to use for actually making requests
* @param trustedParams additional parameters to include in all outgoing OAuth requests, useful
* for client data that can't be pulled from the security token but is still trustworthy.
*/
public OAuthRequest(OAuthFetcherConfig fetcherConfig, HttpFetcher fetcher,
List<Parameter> trustedParams) {
this.fetcherConfig = fetcherConfig;
this.fetcher = fetcher;
this.trustedParams = trustedParams;
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:13,代码来源:OAuthRequest.java
示例6: addCallback
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
private void addCallback(List<Parameter> requestTokenParams) throws OAuthRequestException {
// This will be either the consumer key callback URL or the global callback URL.
String baseCallback = StringUtils.trimToNull(accessorInfo.getConsumer().getCallbackUrl());
if (baseCallback != null) {
String callbackUrl = fetcherConfig.getOAuthCallbackGenerator().generateCallback(
fetcherConfig, baseCallback, realRequest, responseParams);
if (callbackUrl != null) {
requestTokenParams.add(new Parameter(OAuth.OAUTH_CALLBACK, callbackUrl));
}
}
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:12,代码来源:OAuthRequest.java
示例7: sanitize
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
/**
* Strip out any owner or viewer identity information passed by the client.
*/
private List<Parameter> sanitize(List<Parameter> params) throws OAuthRequestException {
ArrayList<Parameter> list = Lists.newArrayList();
for (Parameter p : params) {
String name = p.getKey();
if (allowParam(name)) {
list.add(p);
} else {
throw responseParams.oauthRequestException(OAuthError.INVALID_REQUEST,
"invalid parameter name " + name +
", applications may not override opensocial or oauth parameters");
}
}
return list;
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:18,代码来源:OAuthRequest.java
示例8: addIdentityParams
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
/**
* Add identity information, such as owner/viewer/gadget.
*/
private void addIdentityParams(List<Parameter> params) {
// If no owner or viewer information is required, don't add any identity params. This lets
// us be compatible with strict OAuth service providers that reject extra parameters on
// requests.
if (!realRequest.getOAuthArguments().getSignOwner() &&
!realRequest.getOAuthArguments().getSignViewer()) {
return;
}
String owner = realRequest.getSecurityToken().getOwnerId();
if (owner != null && realRequest.getOAuthArguments().getSignOwner()) {
params.add(new Parameter(OPENSOCIAL_OWNERID, owner));
}
String viewer = realRequest.getSecurityToken().getViewerId();
if (viewer != null && realRequest.getOAuthArguments().getSignViewer()) {
params.add(new Parameter(OPENSOCIAL_VIEWERID, viewer));
}
String app = realRequest.getSecurityToken().getAppId();
if (app != null) {
params.add(new Parameter(OPENSOCIAL_APPID, app));
}
String appUrl = realRequest.getSecurityToken().getAppUrl();
if (appUrl != null) {
params.add(new Parameter(OPENSOCIAL_APPURL, appUrl));
}
if (trustedParams != null) {
params.addAll(trustedParams);
}
if (realRequest.getOAuthArguments().isProxiedContentRequest()) {
params.add(new Parameter(OPENSOCIAL_PROXIED_CONTENT, "1"));
}
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:41,代码来源:OAuthRequest.java
示例9: addSignatureParams
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
/**
* Add signature type to the message.
*/
private void addSignatureParams(List<Parameter> params) {
if (accessorInfo.getConsumer().getConsumer().consumerKey == null) {
params.add(
new Parameter(OAuth.OAUTH_CONSUMER_KEY, realRequest.getSecurityToken().getDomain()));
}
if (accessorInfo.getConsumer().getKeyName() != null) {
params.add(new Parameter(XOAUTH_PUBLIC_KEY_OLD, accessorInfo.getConsumer().getKeyName()));
params.add(new Parameter(XOAUTH_PUBLIC_KEY_NEW, accessorInfo.getConsumer().getKeyName()));
}
params.add(new Parameter(OAuth.OAUTH_VERSION, OAuth.VERSION_1_0));
params.add(new Parameter(OAuth.OAUTH_TIMESTAMP,
Long.toString(fetcherConfig.getClock().currentTimeMillis() / 1000)));
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:17,代码来源:OAuthRequest.java
示例10: getParsedQuery
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
public List<OAuth.Parameter> getParsedQuery() {
if (decodedQuery == null) {
if (query != null) {
decodedQuery = OAuth.decodeForm(query);
} else {
decodedQuery = Lists.newArrayList();
}
}
return decodedQuery;
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:11,代码来源:FakeOAuthServiceProvider.java
示例11: getQueryParam
import net.oauth.OAuth.Parameter; //导入依赖的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: createRequest
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
private OAuthRequest createRequest() {
HttpFetcher dest = serviceProvider;
if (nextFetcher != null) {
dest = nextFetcher;
}
if (trustedParams != null) {
List<Parameter> trusted = Lists.newArrayList();
for (Entry<String, String> e : trustedParams.entrySet()) {
trusted.add(new Parameter(e.getKey(), e.getValue()));
}
return new OAuthRequest(fetcherConfig, dest, trusted);
}
return new OAuthRequest(fetcherConfig, dest);
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:15,代码来源:MakeRequestClient.java
示例13: testSignedFetchParametersSet
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
@Test
public void testSignedFetchParametersSet() throws Exception {
MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
HttpResponse resp = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
List<Parameter> queryParams = OAuth.decodeForm(resp.getResponseAsString());
assertTrue(contains(queryParams, "opensocial_owner_id", "o"));
assertTrue(contains(queryParams, "opensocial_viewer_id", "v"));
assertTrue(contains(queryParams, "opensocial_app_id", "app"));
assertTrue(contains(queryParams, OAuth.OAUTH_CONSUMER_KEY, "signedfetch"));
assertTrue(contains(queryParams, "xoauth_signature_publickey", "foo"));
assertTrue(contains(queryParams, "xoauth_public_key", "foo"));
assertFalse(contains(queryParams, "opensocial_proxied_content", "1"));
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:14,代码来源:OAuthRequestTest.java
示例14: testSignedFetchParametersSetProxiedContent
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
@Test
public void testSignedFetchParametersSetProxiedContent() throws Exception {
MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
client.getBaseArgs().setProxiedContentRequest(true);
HttpResponse resp = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
List<Parameter> queryParams = OAuth.decodeForm(resp.getResponseAsString());
assertTrue(contains(queryParams, "opensocial_owner_id", "o"));
assertTrue(contains(queryParams, "opensocial_viewer_id", "v"));
assertTrue(contains(queryParams, "opensocial_app_id", "app"));
assertTrue(contains(queryParams, OAuth.OAUTH_CONSUMER_KEY, "signedfetch"));
assertTrue(contains(queryParams, "xoauth_signature_publickey", "foo"));
assertTrue(contains(queryParams, "xoauth_public_key", "foo"));
assertTrue(contains(queryParams, "opensocial_proxied_content", "1"));
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:15,代码来源:OAuthRequestTest.java
示例15: testPostBinaryData
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
@Test
public void testPostBinaryData() throws Exception {
byte[] raw = { 0, 1, 2, 3, 4, 5 };
MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
HttpResponse resp = client.sendRawPost(FakeOAuthServiceProvider.RESOURCE_URL, null, raw);
List<Parameter> queryParams = OAuth.decodeForm(resp.getResponseAsString());
assertTrue(contains(queryParams, "opensocial_owner_id", "o"));
assertTrue(contains(queryParams, OAuth.OAUTH_CONSUMER_KEY, "signedfetch"));
String echoed = resp.getHeader(FakeOAuthServiceProvider.RAW_BODY_ECHO_HEADER);
byte[] echoedBytes = Base64.decodeBase64(CharsetUtil.getUtf8Bytes(echoed));
assertTrue(Arrays.equals(raw, echoedBytes));
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:13,代码来源:OAuthRequestTest.java
示例16: testPostWeirdContentType
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
@Test
public void testPostWeirdContentType() throws Exception {
byte[] raw = { 0, 1, 2, 3, 4, 5 };
MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
HttpResponse resp = client.sendRawPost(FakeOAuthServiceProvider.RESOURCE_URL,
"funky-content", raw);
List<Parameter> queryParams = OAuth.decodeForm(resp.getResponseAsString());
assertTrue(contains(queryParams, "opensocial_owner_id", "o"));
assertTrue(contains(queryParams, OAuth.OAUTH_CONSUMER_KEY, "signedfetch"));
String echoed = resp.getHeader(FakeOAuthServiceProvider.RAW_BODY_ECHO_HEADER);
byte[] echoedBytes = Base64.decodeBase64(CharsetUtil.getUtf8Bytes(echoed));
assertTrue(Arrays.equals(raw, echoedBytes));
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:14,代码来源:OAuthRequestTest.java
示例17: testGetWithRawBody
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
@Test
public void testGetWithRawBody() throws Exception {
MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
HttpResponse resp = client.sendGetWithBody(FakeOAuthServiceProvider.RESOURCE_URL,
"application/json", "war=peace&yes=no".getBytes());
assertEquals("war=peace&yes=no", resp.getHeader(FakeOAuthServiceProvider.BODY_ECHO_HEADER));
List<Parameter> queryParams = OAuth.decodeForm(resp.getResponseAsString());
checkContains(queryParams, "oauth_body_hash", "MfhwxPN6ns5CwQAZN9OcJXu3Jv4=");
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:10,代码来源:OAuthRequestTest.java
示例18: testSignedFetch_unnamedConsumerKey
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
@Test
public void testSignedFetch_unnamedConsumerKey() throws Exception {
BasicOAuthStoreConsumerKeyAndSecret defaultKey = new BasicOAuthStoreConsumerKeyAndSecret(
null, FakeOAuthServiceProvider.PRIVATE_KEY_TEXT, KeyType.RSA_PRIVATE, "foo", null);
base.setDefaultKey(defaultKey);
MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
HttpResponse resp = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
List<Parameter> queryParams = OAuth.decodeForm(resp.getResponseAsString());
assertTrue(contains(queryParams, "opensocial_owner_id", "o"));
assertTrue(contains(queryParams, "opensocial_viewer_id", "v"));
assertTrue(contains(queryParams, "opensocial_app_id", "app"));
assertTrue(contains(queryParams, OAuth.OAUTH_CONSUMER_KEY, "container.com"));
assertTrue(contains(queryParams, "xoauth_signature_publickey", "foo"));
assertTrue(contains(queryParams, "xoauth_public_key", "foo"));
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:16,代码来源:OAuthRequestTest.java
示例19: testSignedFetch_extraQueryParameters
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
@Test
public void testSignedFetch_extraQueryParameters() throws Exception {
MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
HttpResponse resp = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL + "?foo=bar&foo=baz");
List<Parameter> queryParams = OAuth.decodeForm(resp.getResponseAsString());
assertTrue(contains(queryParams, "opensocial_owner_id", "o"));
assertTrue(contains(queryParams, "opensocial_viewer_id", "v"));
assertTrue(contains(queryParams, "opensocial_app_id", "app"));
assertTrue(contains(queryParams, OAuth.OAUTH_CONSUMER_KEY, "signedfetch"));
assertTrue(contains(queryParams, "xoauth_signature_publickey", "foo"));
assertTrue(contains(queryParams, "xoauth_public_key", "foo"));
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:13,代码来源:OAuthRequestTest.java
示例20: testNoSignViewer
import net.oauth.OAuth.Parameter; //导入依赖的package包/类
@Test
public void testNoSignViewer() throws Exception {
MakeRequestClient client = makeSignedFetchClient("o", "v", "http://www.example.com/app");
client.getBaseArgs().setSignViewer(false);
HttpResponse resp = client.sendGet(FakeOAuthServiceProvider.RESOURCE_URL);
List<Parameter> queryParams = OAuth.decodeForm(resp.getResponseAsString());
assertTrue(contains(queryParams, "opensocial_owner_id", "o"));
assertFalse(contains(queryParams, "opensocial_viewer_id", "v"));
}
开发者ID:inevo,项目名称:shindig-1.1-BETA5-incubating,代码行数:10,代码来源:OAuthRequestTest.java
注:本文中的net.oauth.OAuth.Parameter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论