Advertisement
Guest User

Untitled

a guest
May 26th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public void helloAuth() {
  2. WebTarget wt = wsClient.target(AUTHORIZE_URL).queryParam("login", "soso").queryParam("password", "password");
  3. Invocation webServiceCall = wt.request()
  4. .accept("application/json")
  5. .build("POST");
  6. Response response = webServiceCall.invoke();
  7.  
  8. if (response.getStatus() == Response.Status.OK.getStatusCode()) {
  9. System.out.println("Authorized");
  10. response.close();
  11. wt = wsClient.target(HELLO_AUTHORIZE_URL);
  12. webServiceCall = wt.request()
  13. .accept("application/json")
  14. .build("GET");
  15. response = webServiceCall.invoke();
  16.  
  17. if (response.getStatus() == Response.Status.OK.getStatusCode()) {
  18. System.out.println("Authorized resource accessed");
  19. } else {
  20. System.out.println("Authorized resource not accessed");
  21. }
  22.  
  23. } else {
  24. System.out.println("Bad request");
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement