Advertisement
Guest User

Untitled

a guest
Mar 28th, 2013
1,413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. import java.net.URL;
  2. import java.net.URLConnection;
  3. import javax.xml.bind.DatatypeConverter;
  4. import java.io.IOException;
  5. import java.net.MalformedURLException;
  6.  
  7. public class Temp{
  8.  
  9.     public static void main(String[] args){
  10.    
  11.         URL url = null;
  12.         try {
  13.                   url = new URL("http://localhost:15672/api/traces/%2f/my-trace");
  14.         } catch (MalformedURLException e) {
  15.                  System.out.println("MalformedUrlException: " + e.getMessage());
  16.                  e.printStackTrace();
  17.         }
  18.  
  19.     URLConnection uc = null;
  20.     try {
  21.         uc = url.openConnection();
  22.     uc.setRequestProperty("Content-Type", "application/json");
  23.     uc.setRequestProperty("format","json");
  24.     uc.setRequestProperty("pattern","#");
  25.     } catch (IOException e) {
  26.         System.out.println("IOException: " + e.getMessage());
  27.         e.printStackTrace();
  28.     }
  29.    
  30.     String userpass = "guest" + ":" + "guest";
  31.     String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes());
  32.  
  33.     uc.setRequestProperty ("Authorization", basicAuth);    
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement