本文整理汇总了Java中net.oauth.OAuth.newMap方法的典型用法代码示例。如果您正苦于以下问题:Java OAuth.newMap方法的具体用法?Java OAuth.newMap怎么用?Java OAuth.newMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.oauth.OAuth
的用法示例。
在下文中一共展示了OAuth.newMap方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerMessagingService
import net.oauth.OAuth; //导入方法依赖的package包/类
public String registerMessagingService(String consumerKey) throws Exception
{
WebTarget target = ClientBuilder.newClient().target(ConsumerRegistrationURL);
String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
Invocation.Builder builder = target.request();
builder.header("Authorization", "Basic " + base64Credentials);
Entity<Form> formEntity = Entity.form(new Form(OAuth.OAUTH_CONSUMER_KEY, consumerKey));
Response response = null;
try {
response = builder.post(formEntity);
if (HttpResponseCodes.SC_OK != response.getStatus()) {
throw new RuntimeException("Registration failed");
}
// check that we got all tokens
Map<String, String> tokens = OAuth.newMap(OAuth.decodeForm(response.readEntity(String.class)));
String secret = tokens.get("xoauth_consumer_secret");
if (secret == null) {
throw new RuntimeException("No secret available");
}
return secret;
} finally {
response.close();
}
}
示例2: getSharedSecret
import net.oauth.OAuth; //导入方法依赖的package包/类
public String getSharedSecret(String consumerKey) throws Exception
{
WebTarget target = ClientBuilder.newClient().target(ConsumerRegistrationURL);
Invocation.Builder builder = target.request();
Form form = new Form(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
Entity<Form> formEntity = Entity.form(form);
Response response = builder.post(formEntity);
if (HttpResponseCodes.SC_OK != response.getStatus()) {
response.close();
throw new RuntimeException("Registration failed");
}
// check that we got all tokens
Map<String, String> tokens = OAuth.newMap(OAuth.decodeForm(response.readEntity(String.class)));
String secret = tokens.get("xoauth_consumer_secret");
if (secret == null) {
throw new RuntimeException("No secret available");
}
return secret;
}
示例3: registerMessagingService
import net.oauth.OAuth; //导入方法依赖的package包/类
public String registerMessagingService(String consumerKey) throws Exception
{
WebTarget target = ClientBuilder.newClient().target(ConsumerRegistrationURL);
Invocation.Builder builder = target.request();
builder.header("Authorization", "OpenId " + SubscriberOpenIdIdentifier);
//request.formParameter(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
Response response = builder.post(Entity.form(new Form(OAuth.OAUTH_CONSUMER_KEY, consumerKey)));
if (HttpResponseCodes.SC_OK != response.getStatus()) {
throw new RuntimeException("Registration failed");
}
// check that we got all tokens
Map<String, String> tokens = OAuth.newMap(OAuth.decodeForm(response.readEntity(String.class)));
String secret = tokens.get("xoauth_consumer_secret");
if (secret == null) {
throw new RuntimeException("No secret available");
}
return secret;
}
示例4: getSharedSecret
import net.oauth.OAuth; //导入方法依赖的package包/类
public String getSharedSecret(String consumerKey) throws Exception
{
WebTarget target = ClientBuilder.newClient().target(ConsumerRegistrationURL);
Entity<Form> entityForm = Entity.form(new Form(OAuth.OAUTH_CONSUMER_KEY, consumerKey));
Response response = null;
try {
response = target.request().post(entityForm);
if (HttpResponseCodes.SC_OK != response.getStatus()) {
throw new RuntimeException("Registration failed");
}
// check that we got all tokens
Map<String, String> tokens = OAuth.newMap(OAuth.decodeForm(response.readEntity(String.class)));
String secret = tokens.get("xoauth_consumer_secret");
if (secret == null) {
throw new RuntimeException("No secret available");
}
return secret;
} finally {
response.close();
}
// HttpClient client = new HttpClient();
// PostMethod method = new PostMethod(ConsumerRegistrationURL);
// method.addParameter(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
// int status = client.executeMethod(method);
// if (HttpResponseCodes.SC_OK != status) {
// throw new RuntimeException("Registration failed");
// }
// // check that we got all tokens
// Map<String, String> response = OAuth.newMap(OAuth.decodeForm(method.getResponseBodyAsString()));
// String secret = response.get("xoauth_consumer_secret");
// if (secret == null) {
// throw new RuntimeException("No secret available");
// }
// return secret;
}
示例5: getResponse
import net.oauth.OAuth; //导入方法依赖的package包/类
private Map<String, String> getResponse(String response) throws Exception {
return OAuth.newMap(OAuth.decodeForm(response));
}
示例6: getTokens
import net.oauth.OAuth; //导入方法依赖的package包/类
private Map<String, String> getTokens(String response) throws Exception {
return OAuth.newMap(OAuth.decodeForm(response));
}
示例7: getResponse
import net.oauth.OAuth; //导入方法依赖的package包/类
private Map<String, String> getResponse(Response response) throws Exception {
return OAuth.newMap(OAuth.decodeForm(response.readEntity(String.class)));
}