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

Java HttpResponseCodes类代码示例

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

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



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

示例1: testRequestAllParams

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
@Test
public void testRequestAllParams() throws Exception
{
   Client client = ClientBuilder.newClient();
   WebTarget target = client.target(getRequestURL(MyProvider.Consumer1Key, MyProvider.Consumer1Secret));
   Invocation.Builder request = target.request();
   Response response = request.get();
   Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
   Map<String, String> tokens = getResponse(response.readEntity(String.class));
   Assert.assertEquals(tokens.size(), 3);
   Assert.assertTrue(tokens.containsKey(OAuth.OAUTH_TOKEN));
   Assert.assertTrue(tokens.get(OAuth.OAUTH_TOKEN).length() > 0);
   Assert.assertTrue(tokens.containsKey(OAuth.OAUTH_TOKEN_SECRET));
   Assert.assertTrue(tokens.get(OAuth.OAUTH_TOKEN_SECRET).length() > 0);
   Assert.assertTrue(tokens.containsKey(OAuthUtils.OAUTH_CALLBACK_CONFIRMED_PARAM));
   Assert.assertEquals(tokens.get(OAuthUtils.OAUTH_CALLBACK_CONFIRMED_PARAM), "true");
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:18,代码来源:OAuthTest.java


示例2: testAccessAllParams

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
@Test
public void testAccessAllParams() throws Exception
{
   Client client = ClientBuilder.newClient();
   WebTarget target = client.target(getAccessURL(MyProvider.Consumer1Key, MyProvider.Consumer1Secret, MyProvider.Consumer1Request1Key, MyProvider.Consumer1Request1Secret, MyProvider.Consumer1Request1Verifier));
   Invocation.Builder request = target.request();
   Response response = request.get();
   Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
   // check that we got all tokens
   Map<String, String> tokens = getResponse(response.readEntity(String.class));
   Assert.assertEquals(tokens.size(), 2);
   Assert.assertTrue(tokens.containsKey(OAuth.OAUTH_TOKEN));
   Assert.assertTrue(tokens.get(OAuth.OAUTH_TOKEN).length() > 0);
   Assert.assertTrue(tokens.containsKey(OAuth.OAUTH_TOKEN_SECRET));
   Assert.assertTrue(tokens.get(OAuth.OAUTH_TOKEN_SECRET).length() > 0);
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:17,代码来源:OAuthTest.java


示例3: sendMessage

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public void sendMessage(String callbackURI, String messageSenderId, String message) {
    Response response = null;
    try {
      WebTarget target = ClientBuilder.newClient().target(getPushMessageURL(callbackURI, messageSenderId));

      Entity entity = Entity.entity(message, MediaType.TEXT_PLAIN_TYPE);
      response = target.request().post(entity);
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Message can not be delivered to subscribers");
      }
   } catch (Exception ex) 
   {
      throw new RuntimeException("Message can not be delivered to subscribers");
   } finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:18,代码来源:OAuthMessageSender.java


示例4: registerMessagingServiceCallback

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public void registerMessagingServiceCallback(String consumerKey, String callback)
{
   WebTarget target = ClientBuilder.newClient().target(MessagingServiceCallbackRegistrationURL);
   Invocation.Builder builder = target.request();
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   builder.header("Authorization", "Basic " + base64Credentials);
   Form form = new Form("consumer_id", consumerKey);
   form.param("callback_uri", callback);
   Response response = null;
   try {
      response = builder.post(Entity.form(form));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Callback Registration failed");
      }
   }
   catch (Exception ex) {
      throw new RuntimeException("Callback Registration failed");
   }
   finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:23,代码来源:SubscriberReceiver.java


示例5: produceMessages

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public void produceMessages()
{
  WebTarget target = ClientBuilder.newClient().target(MessagingServiceMessagesURL);
  Invocation.Builder builder = target.request();
  String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
  builder.header("Authorization", "Basic " + base64Credentials);
  Response response = null;
  try {
     response = builder.post(Entity.entity("Hello2 !", MediaType.TEXT_PLAIN_TYPE));
     if (HttpResponseCodes.SC_OK != response.getStatus()) {
        throw new RuntimeException("Messages can not be sent");
     }
  }
  catch (Exception ex) {
     throw new RuntimeException("Messages can not be sent");
  }
  finally {
     response.close();
  }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:21,代码来源:SubscriberReceiver.java


示例6: registerMessagingService

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的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


示例7: registerMessagingServiceScopes

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public void registerMessagingServiceScopes(String consumerKey, String scope) throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(ConsumerScopesRegistrationURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   Form form = new Form(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
   form.param("xoauth_scope", scope);
   form.param("xoauth_permission", "sendMessages");
   Response response = null;
   try {
      response = builder.post(Entity.form(form));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Scopes can not be registered");
      }
   } finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:20,代码来源:Subscriber.java


示例8: registerMessagingServiceCallback

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public void registerMessagingServiceCallback(String consumerKey, String consumerSecret, String callback) 
    throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(MessagingServiceCallbackRegistrationURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   Form form = new Form("consumer_id", consumerKey);
   form.param("consumer_secret", consumerSecret);
   form.param("callback_uri", callback);
   Response response = null;
   try {
      response = builder.post(Entity.form(form));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Callback Registration failed");
     }
   } finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:21,代码来源:Subscriber.java


示例9: produceMessages

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public void produceMessages() 
   throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(MessagingServiceMessagesURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   Response response = null;
   try {
      response = builder.post(Entity.entity("Hello", MediaType.TEXT_PLAIN_TYPE));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Messages can not be sent");
      }
   } finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:18,代码来源:Subscriber.java


示例10: getMessages

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public void getMessages() 
    throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(MessageReceiverGetURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   Response response = null;
   try {
      response = builder.get();
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Messages can not be received");
      }
      String message = response.readEntity(String.class);
      if (!"Hello !".equals(message))
      {
         throw new RuntimeException("Wrong Message");
      }
      System.out.println("Success : " + message);
   } finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:24,代码来源:Subscriber.java


示例11: getMessagesFromSubscriberReceiver

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public void getMessagesFromSubscriberReceiver() throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(MessageReceiverSubscriberGetURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   Response response = null;
   try {
      response = builder.get();
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Messages can not be received");
      }
      String message = response.readEntity(String.class);
      if (!"Hello2 !".equals(message))
      {
         throw new RuntimeException("Wrong Message");
      }
      System.out.println("Message from the subscriber-receiver : " + message);
   } finally {
      response.close();
   }
 }
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:23,代码来源:Subscriber.java


示例12: accessEndUserResource

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
private static void accessEndUserResource(String relativeURI) throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(EndUserResourceURL + relativeURI);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   target.request().header("Authorization", "Basic " + base64Credentials);
   Response response = null;
   try
   {
      response = target.request().get();
      if ("/invisible".equals(relativeURI)) {
         if (response.getStatus() != 401) {
            throw new RuntimeException("End user can access the invisible resource");
         } else {
            return;
         }
      }
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("End user can not access its own resources");
     }
     System.out.println("End user resource : " + response.getEntity());
   }
   finally
   {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:27,代码来源:EndUser.java


示例13: getSharedSecret

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的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


示例14: getRequestToken

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public Token getRequestToken(String consumerKey, String consumerSecret, 
                             String callbackURI, String scope, String permission) throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(getRequestURL(consumerKey, consumerSecret, callbackURI, scope, permission));
   Response response = target.request().get();
   if (HttpResponseCodes.SC_OK != response.getStatus()) {
      response.close();
      throw new RuntimeException("Request token can not be obtained");
   }
   // check that we got all tokens
   Map<String, String> tokens = getTokens(response.readEntity(String.class));
   if (tokens.size() != 3
         || !tokens.containsKey(OAuth.OAUTH_TOKEN)
         || !(tokens.get(OAuth.OAUTH_TOKEN).length() > 0)
         || !tokens.containsKey(OAuth.OAUTH_TOKEN_SECRET)
         || !(tokens.get(OAuth.OAUTH_TOKEN_SECRET).length() > 0)
         || !tokens.containsKey(OAuthUtils.OAUTH_CALLBACK_CONFIRMED_PARAM)
         || !tokens.get(OAuthUtils.OAUTH_CALLBACK_CONFIRMED_PARAM).equals("true")) {
      throw new RuntimeException("Wrong request token details");
   }

   return new Token(tokens.get(OAuth.OAUTH_TOKEN), tokens.get(OAuth.OAUTH_TOKEN_SECRET));
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:24,代码来源:ConsumerResource.java


示例15: getAccessToken

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public Token getAccessToken(String consumerKey, String consumerSecret,
        Token requestToken) throws Exception
{
   String url = getAccessURL(consumerKey, consumerSecret, 
                             requestToken.getToken(), requestToken.getSecret(),
                             requestToken.getVerifier());
   WebTarget target = ClientBuilder.newClient().target(url);
   Response response = target.request().get();
   if (HttpResponseCodes.SC_OK != response.getStatus()) {
      response.close();
      throw new RuntimeException("Request token can not be obtained");
   }
   // check that we got all tokens
   Map<String, String> tokens = getTokens(response.readEntity(String.class));
   if (tokens.size() != 2
         || !tokens.containsKey(OAuth.OAUTH_TOKEN)
         || !(tokens.get(OAuth.OAUTH_TOKEN).length() > 0)
         || !tokens.containsKey(OAuth.OAUTH_TOKEN_SECRET)
         || !(tokens.get(OAuth.OAUTH_TOKEN_SECRET).length() > 0)) {
      throw new RuntimeException("Wrong access token details");
   }

   return new Token(tokens.get(OAuth.OAUTH_TOKEN), tokens.get(OAuth.OAUTH_TOKEN_SECRET));
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:25,代码来源:ConsumerResource.java


示例16: sendMessage

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public void sendMessage(String callbackURI, String messageSenderId, String message) {
   Response response = null;
   try
   {
      WebTarget target = ClientBuilder.newClient().target(getPushMessageURL(callbackURI, messageSenderId));
      response = target.request().post(Entity.entity(message, MediaType.TEXT_PLAIN_TYPE));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Message can not be delivered to subscribers");
      }
   } catch (Exception ex) 
   {
       throw new RuntimeException("Message can not be delivered to subscribers");
   } finally
   {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:18,代码来源:OAuthMessageSender.java


示例17: registerMessagingService

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的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


示例18: getMessages

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public void getMessages() 
    throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(MessageReceiverGetURL);
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "OpenId " + SubscriberOpenIdIdentifier);
   Response response = builder.post(null);
   response.close();
   if (HttpResponseCodes.SC_OK != response.getStatus()) {
      throw new RuntimeException("Messages can not be received");
   }
   String message = response.readEntity(String.class);
   if (!"Hello !".equals(message))
   {
      throw new RuntimeException("Wrong Message");
   }
   System.out.println("Success : " + message);
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:19,代码来源:Subscriber.java


示例19: testDeprovisionGivenMultipleOrganizations

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
@Test
public void testDeprovisionGivenMultipleOrganizations() throws Exception {
    String serviceId11 = provisionService(randomUUID(), ORGANIZATION_ID, SPACE_ID);
    provisionService(randomUUID(), ORGANIZATION_ID, SPACE_ID);

    String organizationId2 = randomUUID();
    String spaceId2 = randomUUID();
    String serviceId21 = provisionService(randomUUID(), organizationId2, spaceId2);
    provisionService(randomUUID(), organizationId2, spaceId2);

    Response response = provisioningService.deprovisionService(getSecurityContext(), serviceId21, QUEUE_SERVICE_ID_STRING, QUEUE_PLAN_ID_STRING);
    assertThat(response.getStatus(), is(HttpResponseCodes.SC_OK));
    assertThat(addressSpaceApi.getAddressUuids(), not(hasItem(serviceId21)));

    response = provisioningService.deprovisionService(getSecurityContext(), serviceId11, QUEUE_SERVICE_ID_STRING, QUEUE_PLAN_ID_STRING);
    assertThat(response.getStatus(), is(HttpResponseCodes.SC_OK));
    assertThat(addressSpaceApi.getAddressUuids(), not(hasItem(serviceId11)));
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:19,代码来源:ProvisionServiceTest.java


示例20: getResponseContent

import org.jboss.resteasy.util.HttpResponseCodes; //导入依赖的package包/类
public byte[] getResponseContent(HttpResponse httpResponse) throws IOException {
       if ((httpResponse == null) || (httpResponse.getStatusLine().getStatusCode() != HttpResponseCodes.SC_OK)) {
       	return null;
       }

       HttpEntity entity = httpResponse.getEntity();
	byte[] responseBytes = new byte[0];
	if (entity != null) {
		responseBytes = EntityUtils.toByteArray(entity);
	}

   	// Consume response content
	if (entity != null) {
		EntityUtils.consume(entity);
	}

   	return responseBytes;
}
 
开发者ID:GluuFederation,项目名称:oxAuth,代码行数:19,代码来源:HttpService.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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