示例#1
0
  /**
   * Return the header field
   *
   * @param name the name of the header
   * @return the header field.
   * @see java.net.HttpURLConnection#getHeaderField(String)
   * @see
   *     edu.internet2.middleware.grouperClientExt.org.apache.commons.httpclient.HttpMethod#getResponseHeaders()
   */
  public String getHeaderField(String name) {
    LOG.trace("enter HttpURLConnection.getHeaderField(String)");
    // Note: Return the last matching header in the Header[] array, as in
    // the JDK implementation.
    Header[] headers = this.method.getResponseHeaders();
    for (int i = headers.length - 1; i >= 0; i--) {
      if (headers[i].getName().equalsIgnoreCase(name)) {
        return headers[i].getValue();
      }
    }

    return null;
  }
示例#2
0
  /**
   * Return the header field at the specified position
   *
   * @param position The position
   * @return The header field.
   * @see java.net.HttpURLConnection#getHeaderField(int)
   * @see
   *     edu.internet2.middleware.grouperClientExt.org.apache.commons.httpclient.HttpMethod#getResponseHeaders()
   */
  public String getHeaderField(int position) {
    LOG.trace("enter HttpURLConnection.getHeaderField(int)");

    // Note: HttpClient does not consider the returned Status Line as
    // a response header. However, getHeaderField(0) is supposed to
    // return the status line. Hence the special case below ...

    if (position == 0) {
      return this.method.getStatusLine().toString();
    }

    // Note: HttpClient does not currently keep headers in the same order
    // that they are read from the HTTP server.

    Header[] headers = this.method.getResponseHeaders();
    if (position < 0 || position > headers.length) {
      return null;
    }

    return headers[position - 1].getValue();
  }
示例#3
0
  /**
   * Gets the {@link AuthScheme authentication scheme} with the given ID.
   *
   * @param id the {@link AuthScheme authentication scheme} ID
   * @return {@link AuthScheme authentication scheme}
   * @throws IllegalStateException if a scheme with the ID cannot be found
   */
  public static synchronized AuthScheme getAuthScheme(final String id)
      throws IllegalStateException {

    if (id == null) {
      throw new IllegalArgumentException("Id may not be null");
    }
    Class clazz = (Class) SCHEMES.get(id.toLowerCase());
    if (clazz != null) {
      try {
        return (AuthScheme) clazz.newInstance();
      } catch (Exception e) {
        LOG.error("Error initializing authentication scheme: " + id, e);
        throw new IllegalStateException(
            id
                + " authentication scheme implemented by "
                + clazz.getName()
                + " could not be initialized");
      }
    } else {
      throw new IllegalStateException("Unsupported authentication scheme " + id);
    }
  }
示例#4
0
 /**
  * Not available: the data must have already been retrieved.
  *
  * @see java.net.HttpURLConnection#setDoOutput(boolean)
  */
 public void setDoOutput(boolean isOutput) {
   LOG.trace("enter HttpURLConnection.setDoOutput()");
   throw new RuntimeException("This class can only be used with already" + "retrieved data");
 }
示例#5
0
 /** Not yet implemented. */
 public Object getContent(Class[] classes) throws IOException {
   LOG.trace("enter HttpURLConnection.getContent(Class[])");
   throw new RuntimeException("Not implemented yet");
 }
示例#6
0
 /** @see java.net.HttpURLConnection#getOutputStream() */
 public OutputStream getOutputStream() throws IOException {
   LOG.trace("enter HttpURLConnection.getOutputStream()");
   throw new RuntimeException("This class can only be used with already" + "retrieved data");
 }
示例#7
0
 /**
  * Not yet implemented.
  *
  * @see java.net.HttpURLConnection#getRequestProperty(String)
  */
 public String getRequestProperty(String key) {
   LOG.trace("enter HttpURLConnection.getRequestProperty()");
   throw new RuntimeException("Not implemented yet");
 }
示例#8
0
 /**
  * Not yet implemented. Return the error stream.
  *
  * @see java.net.HttpURLConnection#getErrorStream()
  */
 public InputStream getErrorStream() {
   LOG.trace("enter HttpURLConnection.getErrorStream()");
   throw new RuntimeException("Not implemented yet");
 }
示例#9
0
 /**
  * Not yet implemented.
  *
  * @see java.net.HttpURLConnection#getIfModifiedSince()
  */
 public long getIfModifiedSince() {
   LOG.trace("enter HttpURLConnection.getIfmodifiedSince()");
   throw new RuntimeException("Not implemented yet");
 }
示例#10
0
 /**
  * Not available: the data must have already been retrieved.
  *
  * @see java.net.HttpURLConnection#setDefaultUseCaches(boolean)
  */
 public void setDefaultUseCaches(boolean isUsingCaches) {
   LOG.trace("enter HttpURLConnection.setDefaultUseCaches(boolean)");
   throw new RuntimeException("This class can only be used with already" + "retrieved data");
 }
示例#11
0
 /**
  * Not yet implemented.
  *
  * @see java.net.HttpURLConnection#getDoOutput()
  */
 public boolean getDoOutput() {
   LOG.trace("enter HttpURLConnection.getDoOutput()");
   throw new RuntimeException("Not implemented yet");
 }
示例#12
0
 /**
  * Not yet implemented.
  *
  * @see java.net.HttpURLConnection#getAllowUserInteraction()
  */
 public boolean getAllowUserInteraction() {
   LOG.trace("enter HttpURLConnection.getAllowUserInteraction()");
   throw new RuntimeException("Not implemented yet");
 }
示例#13
0
 /**
  * Not yet implemented.
  *
  * @see java.net.HttpURLConnection#disconnect()
  */
 public void disconnect() {
   LOG.trace("enter HttpURLConnection.disconnect()");
   throw new RuntimeException("Not implemented yet");
 }
示例#14
0
 /**
  * Return the response message
  *
  * @return The response message
  * @throws IOException If an IO problem occurs.
  * @see java.net.HttpURLConnection#getResponseMessage()
  * @see
  *     edu.internet2.middleware.grouperClientExt.org.apache.commons.httpclient.HttpMethod#getStatusText()
  */
 public String getResponseMessage() throws IOException {
   LOG.trace("enter HttpURLConnection.getResponseMessage()");
   return this.method.getStatusText();
 }
示例#15
0
 /**
  * Return the response code.
  *
  * @return The response code.
  * @throws IOException If an IO problem occurs.
  * @see java.net.HttpURLConnection#getResponseCode()
  * @see
  *     edu.internet2.middleware.grouperClientExt.org.apache.commons.httpclient.HttpMethod#getStatusCode()
  */
 public int getResponseCode() throws IOException {
   LOG.trace("enter HttpURLConnection.getResponseCode()");
   return this.method.getStatusCode();
 }
示例#16
0
 /**
  * Return the request method.
  *
  * @return The request method.
  * @see java.net.HttpURLConnection#getRequestMethod()
  * @see
  *     edu.internet2.middleware.grouperClientExt.org.apache.commons.httpclient.HttpMethod#getName()
  */
 public String getRequestMethod() {
   LOG.trace("enter HttpURLConnection.getRequestMethod()");
   return this.method.getName();
 }
示例#17
0
 /**
  * Not yet implemented.
  *
  * @return true if we are using a proxy.
  * @see java.net.HttpURLConnection#usingProxy()
  */
 public boolean usingProxy() {
   LOG.trace("enter HttpURLConnection.usingProxy()");
   throw new RuntimeException("Not implemented yet");
 }
示例#18
0
 /**
  * Not available: the data must have already been retrieved.
  *
  * @see java.net.HttpURLConnection#setAllowUserInteraction(boolean)
  */
 public void setAllowUserInteraction(boolean isAllowInteraction) {
   LOG.trace("enter HttpURLConnection.setAllowUserInteraction(boolean)");
   throw new RuntimeException("This class can only be used with already" + "retrieved data");
 }
示例#19
0
 /**
  * Return the URL
  *
  * @return The URL.
  * @see java.net.HttpURLConnection#getURL()
  */
 public URL getURL() {
   LOG.trace("enter HttpURLConnection.getURL()");
   return this.url;
 }
示例#20
0
 /**
  * Not available: the data must have already been retrieved.
  *
  * @see java.net.HttpURLConnection#setIfModifiedSince(long)
  */
 public void setIfModifiedSince(long modificationDate) {
   LOG.trace("enter HttpURLConnection.setIfModifiedSince(long)");
   throw new RuntimeException("This class can only be used with already" + "retrieved data");
 }
示例#21
0
 /** Not available: the data must have already been retrieved. */
 public void setInstanceFollowRedirects(boolean isFollowingRedirects) {
   LOG.trace("enter HttpURLConnection.setInstanceFollowRedirects(boolean)");
   throw new RuntimeException("This class can only be used with already" + "retrieved data");
 }
示例#22
0
 /**
  * Not available: the data must have already been retrieved.
  *
  * @see java.net.HttpURLConnection#getDefaultUseCaches()
  */
 public boolean getDefaultUseCaches() {
   LOG.trace("enter HttpURLConnection.getDefaultUseCaches()");
   throw new RuntimeException("Not implemented yet");
 }
示例#23
0
 /** Not yet implemented. */
 public boolean getInstanceFollowRedirects() {
   LOG.trace("enter HttpURLConnection.getInstanceFollowRedirects()");
   throw new RuntimeException("Not implemented yet");
 }
示例#24
0
 /**
  * Not available: the data must have already been retrieved.
  *
  * @see java.net.HttpURLConnection#setRequestProperty(String,String)
  */
 public void setRequestProperty(String key, String value) {
   LOG.trace("enter HttpURLConnection.setRequestProperty()");
   throw new RuntimeException("This class can only be used with already" + "retrieved data");
 }
示例#25
0
 /**
  * Not available: the data must have already been retrieved.
  *
  * @see java.net.HttpURLConnection#setRequestMethod(String)
  */
 public void setRequestMethod(String method) throws ProtocolException {
   LOG.trace("enter HttpURLConnection.setRequestMethod(String)");
   throw new RuntimeException("This class can only be used with already" + "retrieved data");
 }
示例#26
0
 /**
  * Not yet implemented.
  *
  * @see java.net.HttpURLConnection#getPermission()
  */
 public Permission getPermission() throws IOException {
   LOG.trace("enter HttpURLConnection.getPermission()");
   throw new RuntimeException("Not implemented yet");
 }
示例#27
0
 /**
  * Gets an input stream for the HttpMethod response body.
  *
  * @throws IOException If an IO problem occurs.
  * @return The input stream.
  * @see java.net.HttpURLConnection#getInputStream()
  * @see
  *     edu.internet2.middleware.grouperClientExt.org.apache.commons.httpclient.HttpMethod#getResponseBodyAsStream()
  */
 public InputStream getInputStream() throws IOException {
   LOG.trace("enter HttpURLConnection.getInputStream()");
   return this.method.getResponseBodyAsStream();
 }