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


Java OAuth.newMap方法代码示例

本文整理汇总了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();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:26,代码来源:Subscriber.java

示例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;
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:20,代码来源:ConsumerResource.java

示例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;
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:19,代码来源:Subscriber.java

示例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;
   }
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:37,代码来源:ConsumerResource.java

示例5: getResponse

import net.oauth.OAuth; //导入方法依赖的package包/类
private Map<String, String> getResponse(String response) throws Exception {
 return OAuth.newMap(OAuth.decodeForm(response));
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:4,代码来源:OAuthTest.java

示例6: getTokens

import net.oauth.OAuth; //导入方法依赖的package包/类
private Map<String, String> getTokens(String response) throws Exception {
 return OAuth.newMap(OAuth.decodeForm(response));
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:4,代码来源:ConsumerResource.java

示例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)));
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:4,代码来源:ConsumerResource.java


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