Package java.net

Examples of java.net.ProtocolException


    }
    else if (sSourceURI.startsWith("ftp://") && sTargetURI.startsWith("ftp://")) {
      bRetVal = moveFTPToFTP(sSourceURI, sTargetURI);
    }
    else {
      throw new ProtocolException("");
    }
    return bRetVal;
  } // move
View Full Code Here


    }

    Object url = _requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);

    if (url == null)
      throw new ProtocolException("No service endpoint address specified");
   
    if (! (url instanceof String))
      throw new IllegalArgumentException("Invalid service endpoint address specified");

    // XXX cache this and the HandlerChainInvoker
View Full Code Here

            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode < HttpStatus.SC_OK) {
                // 1xx intermediate response
                if (statusCode != HttpStatus.SC_CONTINUE) {
                    throw new ProtocolException(
                            "Unexpected response: " + response.getStatusLine());
                }
                if (httpexchange.getRequestState() == MessageState.ACK_EXPECTED) {
                    int timeout = httpexchange.getTimeout();
                    conn.setSocketTimeout(timeout);
View Full Code Here

            InetSocketAddress proxyAddress = (InetSocketAddress) proxy.address();
            proxySocket = makeTunnel(host, port, proxyUsername, proxyPassword, proxyAddress);

            // Handshake with the origin server.
            if(proxySocket ==  null) {
                throw new ProtocolException("Unable to create tunnel through proxy server.");
            }
            Socket socket = factory.createSocket(proxySocket, host, port, true /* auto close */);
            success = true;
            return socket;
        } finally {
View Full Code Here

    @SuppressFBWarnings(value = "VA_FORMAT_STRING_USES_NEWLINE",
            justification = "use <CR><LF> as according to RFC, not platform-linefeed")
    Socket makeTunnel(String host, int port, String proxyUsername,
            String proxyPassword, InetSocketAddress proxyAddress) throws IOException {
        if(host == null || port < 0 || host.isEmpty() || proxyAddress == null){
            throw new ProtocolException("Incorrect parameters to build tunnel.");  
        }
        logger.debug("Creating socket for Proxy : " + proxyAddress.getAddress() + ":" + proxyAddress.getPort());
        Socket socket;
        try {
            ProxyClient client = new ProxyClient();
            client.getParams().setParameter("http.useragent", "java-apns");
            client.getHostConfiguration().setHost(host, port);
            String proxyHost = proxyAddress.getAddress().toString().substring(0, proxyAddress.getAddress().toString().indexOf("/"));
            client.getHostConfiguration().setProxy(proxyHost, proxyAddress.getPort());
           
       
            ProxyClient.ConnectResponse response = client.connect();
            socket = response.getSocket();
            if (socket == null) {
                ConnectMethod method = response.getConnectMethod();
                // Read the proxy's HTTP response.
                if(method.getStatusLine().toString().matches("HTTP/1\\.\\d 407 Proxy Authentication Required")) {
                    // Proxy server returned 407. We will now try to connect with auth Header
                    if(proxyUsername != null && proxyPassword != null) {
                        socket = AuthenticateProxy(method, client,proxyHost, proxyAddress.getPort(),
                                proxyUsername, proxyPassword);
                    } else {
                        throw new ProtocolException("Socket not created: " + method.getStatusLine());
                    }
                }            
            }
           
        } catch (Exception e) {
            throw new ProtocolException("Error occurred while creating proxy socket : " + e.toString());
        }
        if (socket != null) {
            logger.debug("Socket for proxy created successfully : " + socket.getRemoteSocketAddress().toString());
        }
        return socket;
View Full Code Here

        ProxyClient.ConnectResponse response = client.connect();
        Socket socket = response.getSocket();
       
        if (socket == null) {
            method = response.getConnectMethod();
            throw new ProtocolException("Proxy Authentication failed. Socket not created: "
                    + method.getStatusLine());
        }
        return socket;
    }
View Full Code Here

                        conn.receiveResponseEntity(response);
                    }
                    int status = response.getStatusLine().getStatusCode();
                    if (status < 200) {
                        if (status != HttpStatus.SC_CONTINUE) {
                            throw new ProtocolException(
                                    "Unexpected response: " + response.getStatusLine());
                        }
                        // discard 100-continue
                        response = null;
                    } else {
View Full Code Here

                    }
                    int status = response.getStatusLine().getStatusCode();
                    if (status < 200) {
                        //@@@ TODO: is this in line with RFC 2616, 10.1?
                        if (status != HttpStatus.SC_CONTINUE) {
                            throw new ProtocolException(
                                    "Unexpected response: " + response.getStatusLine());
                        }
                        // discard 100-continue
                        response = null;
                    } else {
View Full Code Here

            new URI(req.getConnection().getProtocol(), req.getConnection().getHost(), req.getConnection().getPort(),
               null);
         base = new URI(base, req.getRequestURI());
         URI res = new URI(base, loc);
         if (res.getHost() == null)
            throw new ProtocolException("Malformed URL in Location header: `" + loc + "' - missing host field");
         return res;
      }
      catch (ParseException pe)
      {
         throw new ProtocolException("Malformed URL in Location header: `" + loc + "' - exception was: "
            + pe.getMessage());
      }
   }
View Full Code Here

            }
            catch (IOException ioe)
            {
            }
            if (req.getData() != null)
               throw new ProtocolException("Received status code 411 even" + " though Content-Length was sent");

            if (log.isDebugEnabled())
               log.debug("Handling " + sts + " " + resp.getReasonLine()
                  + " - resending request with 'Content-length: 0'");
View Full Code Here

TOP

Related Classes of java.net.ProtocolException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.